Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for the new version of the XML schemas
- Loading branch information
Showing
4 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
...rnate/beanvalidation/tck/tests/xmlconfiguration/versioning/Version30InMappingXmlTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() ); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...te/beanvalidation/tck/tests/xmlconfiguration/versioning/Version30InValidationXmlTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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." | ||
); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...ernate/beanvalidation/tck/tests/xmlconfiguration/versioning/Version30InMappingXmlTest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
19 changes: 19 additions & 0 deletions
19
...idation/tck/tests/xmlconfiguration/versioning/validation-Version30InValidationXmlTest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |