Skip to content

Commit

Permalink
Add tests for the new version of the XML schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet committed Mar 4, 2020
1 parent baed28b commit 4e82156
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 0 deletions.
@@ -0,0 +1,49 @@
/**
* Jakarta Bean Validation TCK
*
* License: Apache License, Version 2.0
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>.
*/
package org.hibernate.beanvalidation.tck.tests.xmlconfiguration.versioning;

import static org.testng.Assert.assertFalse;

import jakarta.validation.Validator;

import org.hibernate.beanvalidation.tck.beanvalidation.Sections;
import org.hibernate.beanvalidation.tck.tests.AbstractTCKTest;
import org.hibernate.beanvalidation.tck.util.TestUtil;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.test.audit.annotations.SpecAssertion;
import org.jboss.test.audit.annotations.SpecVersion;
import org.testng.annotations.Test;

/**
* @author Guillaume Smet
*/
@SpecVersion(spec = "beanvalidation", version = "2.0.0")
public class Version30InMappingXmlTest extends AbstractTCKTest {

private static final String MAPPING_FILE = "Version30InMappingXmlTest.xml";

@Deployment
public static WebArchive createTestArchive() {
return webArchiveBuilder()
.withTestClass( Version30InMappingXmlTest.class )
.withClass( TestEntity.class )
.withResource( MAPPING_FILE )
.build();
}

@Test
@SpecAssertion(section = Sections.XML_MAPPING_XSD, id = "a")
public void testValidBeanValidation30Mapping() {
Validator validator = TestUtil.getConfigurationUnderTest()
.addMapping( Version30InMappingXmlTest.class.getResourceAsStream( MAPPING_FILE ) )
.buildValidatorFactory()
.getValidator();

assertFalse( validator.getConstraintsForClass( TestEntity.class ).isBeanConstrained() );
}
}
@@ -0,0 +1,47 @@
/**
* Jakarta Bean Validation TCK
*
* License: Apache License, Version 2.0
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>.
*/
package org.hibernate.beanvalidation.tck.tests.xmlconfiguration.versioning;

import static org.testng.Assert.assertEquals;

import jakarta.validation.Configuration;

import org.hibernate.beanvalidation.tck.beanvalidation.Sections;
import org.hibernate.beanvalidation.tck.tests.AbstractTCKTest;
import org.hibernate.beanvalidation.tck.util.TestUtil;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.test.audit.annotations.SpecAssertion;
import org.jboss.test.audit.annotations.SpecVersion;
import org.testng.annotations.Test;

/**
* @author Guillaume Smet
*/
@SpecVersion(spec = "beanvalidation", version = "2.0.0")
public class Version30InValidationXmlTest extends AbstractTCKTest {

@Deployment
public static WebArchive createTestArchive() {
return webArchiveBuilder()
.withTestClass( Version30InValidationXmlTest.class )
.withClass( DummyClockProvider.class )
.withValidationXml( "validation-Version30InValidationXmlTest.xml" )
.build();
}

@Test
@SpecAssertion(section = Sections.XML_CONFIG_XSD, id = "a")
public void testValidationXmlVersion20() {
Configuration<?> config = TestUtil.getConfigurationUnderTest();
assertEquals(
config.getBootstrapConfiguration().getClockProviderClassName(),
"org.hibernate.beanvalidation.tck.tests.xmlconfiguration.versioning.DummyClockProvider",
"Wrong clock provider class name."
);
}
}
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Jakarta Bean Validation TCK
License: Apache License, Version 2.0
See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>.
-->
<constraint-mappings
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://xmlns.jakarta.ee/xml/ns/validation/mapping validation-mapping-3.0.xsd"
xmlns="https://xmlns.jakarta.ee/xml/ns/validation/mapping"
version="3.0">
<bean class="org.hibernate.beanvalidation.tck.tests.xmlconfiguration.versioning.TestEntity"/>
</constraint-mappings>
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Jakarta Bean Validation TCK
License: Apache License, Version 2.0
See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>.
-->
<validation-config
xmlns="https://xmlns.jakarta.ee/xml/ns/validation/configuration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://xmlns.jakarta.ee/xml/ns/validation/configuration
https://xmlns.jakarta.ee/xml/ns/validation/configuration/validation-configuration-3.0.xsd"
version="3.0">
<clock-provider>
org.hibernate.beanvalidation.tck.tests.xmlconfiguration.versioning.DummyClockProvider
</clock-provider>
</validation-config>

0 comments on commit 4e82156

Please sign in to comment.