@Artifact @IntegrationTest(runLocally = true) @Resources( { @Resource(destination = "WEB-INF/faces-config.xml", source = "faces-config.xml"), @Resource(destination = "JSFTestPage.jsp", source = "JSFTestPage.jsp"), @Resource(destination = "JSPTestPage.jsp", source = "JSPTestPage.jsp")}) @SpecVersion(spec="cdi", version="20091101") @WebXml("web.xml") public class IntegrationWithUnifiedELTest extends AbstractJSR299Test { @Test(groups = {"el" } ) @SpecAssertion(section = "12.4", id = "a") public void testELResolverRegisteredWithJsf() throws Exception { WebClient webclient = new WebClient(); String content = webclient.getPage(getContextPath() + "JSFTestPage.jsf").getWebResponse().getContentAsString(); assert content.contains("Dolly"); } @Test(groups = { "el" } ) @SpecAssertion(section = "12.4", id = "a") public void testELResolverRegisteredWithServletContainer() throws Exception { WebClient webclient = new WebClient(); String content = webclient.getPage(getContextPath() + "JSPTestPage.jsp").getWebResponse().getContentAsString(); assert content.contains("Dolly"); } }
@IntegrationTest(runLocally=true) @Resources({ @Resource(destination="cloud.jspx", source="cloud.jsf"), @Resource(destination="storm.jspx", source="storm.jsf"), @Resource(destination="clouds.jspx", source="clouds.jsf"), @Resource(destination="/WEB-INF/faces-config.xml", source="faces-config.xml") }) @WebXml("web.xml")
/** * @author Nicklas Karlsson */ @Artifact(addCurrentPackage=false) @Classes({Storm.class, ConversationTestPhaseListener.class, ConversationStatusServlet.class, Cloud.class, CloudController.class}) @IntegrationTest(runLocally=true) @Resources({ @Resource(destination="WEB-INF/faces-config.xml", source="faces-config.xml"), @Resource(destination="clouds.jspx", source="clouds.jsf"), @Resource(destination="cloud.jspx", source="cloud.jsf") }) @WebXml("web.xml") @SpecVersion(spec="cdi", version="20091101") public class InvalidatingSessionDestroysConversationTest extends AbstractConversationTest { @Test(groups = { "contexts" }) @SpecAssertion(section = "6.7.4", id = "qa") // TODO this test doesn't precisely probe the boundaries of the service() method public void testInvalidatingSessionDestroysConversation() throws Exception { WebClient webClient = new WebClient(); resetCloud(webClient); webClient.getPage(getPath("clouds.jsf")); assert !isCloudDestroyed(webClient); invalidateSession(webClient); assert isCloudDestroyed(webClient); } }
@Resource(source = "builtin-constraints-override.xml", destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/builtin-constraints-override.xml") @Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
/** * @author Hardy Ferentschik */ @Artifact(artifactType = ArtifactType.JSR303) @Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class }) @ValidationXml(value = "validation-ConfiguredBeanNotInClassPathTest.xml") @Resource(source = "constraints-ConfiguredBeanNotInClassPathTest.xml", destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/constraints-ConfiguredBeanNotInClassPathTest.xml") public class ConfiguredBeanNotInClassPathTest extends AbstractTest { @Test @SpecAssertion(section = "7.1.1", id = "f") public void testExceptionIsThrownForUnknownBeanNameInXml() { try { TestUtil.getValidatorUnderTest(); fail( "Test should have thrown an exception due to wrong class name" ); } catch ( ValidationException e ) { //success } } }
/** * @author Hardy Ferentschik */ @Artifact(artifactType = ArtifactType.JSR303) @Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class }) @ValidationXml(value = "validation-DefaultSequenceDefinedInXmlTest.xml") @Resource(source = "package-constraints-DefaultSequenceDefinedInXmlTest.xml", destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/package-constraints-DefaultSequenceDefinedInXmlTest.xml") public class DefaultSequenceDefinedInXmlTest extends AbstractTest { @Test @SpecAssertion(section = "7.1.1.1", id = "e") public void testDefaultGroupDefinitionDefinedInEntityApplies() { Validator validator = TestUtil.getValidatorUnderTest(); Package p = new Package(); p.setMaxWeight(30); Set<ConstraintViolation<Package>> violations = validator.validate( p, Default.class ); assertCorrectNumberOfViolations( violations, 1 ); assertCorrectConstraintViolationMessages( violations, "The package is too heavy" ); } }
/** * @author Hardy Ferentschik */ @Artifact(artifactType = ArtifactType.JSR303) @Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class }) @ValidationXml(value = "validation-MandatoryNameAttributeTest.xml") @Resource(source = "constraints-MandatoryNameAttributeTest.xml", destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/constraints-MandatoryNameAttributeTest.xml") public class MandatoryNameAttributeTest extends AbstractTest { @Test @SpecAssertion(section = "7.1.1.4", id = "a") public void testNameAttributeIsMandatory() { try { TestUtil.getValidatorUnderTest(); fail(); } catch ( ValidationException e ) { // success } } }
/** * @author Hardy Ferentschik */ @Artifact(artifactType = ArtifactType.JSR303) @Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class }) @ValidationXml(value = "validation-MissingMandatoryElementTest.xml") @Resource(source = "package-constraints-MissingMandatoryElementTest.xml", destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/package-constraints-MissingMandatoryElementTest.xml") public class MissingMandatoryElementTest extends AbstractTest { @Test @SpecAssertion(section = "7.1.1.4", id = "h") public void testMissingMandatoryElementInConstraintDeclaration() { try { TestUtil.getValidatorUnderTest(); fail( "Creating the validator should have failed since the constraint declaration in xml is incomplete." ); } catch ( ValidationException e ) { // success } } }
/** * @author Hardy Ferentschik */ @Artifact(artifactType = ArtifactType.JSR303) @Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class }) @ValidationXml(value = "validation-ExcludePropertyLevelAnnotationsDueToBeanDefaultsTest.xml") @Resource(source = "user-constraints-ExcludePropertyLevelAnnotationsDueToBeanDefaultsTest.xml", destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel/user-constraints-ExcludePropertyLevelAnnotationsDueToBeanDefaultsTest.xml") public class ExcludePropertyLevelAnnotationsDueToBeanDefaultsTest extends AbstractTest { @Test @SpecAssertions({ @SpecAssertion(section = "7.1.1.3", id = "b"), @SpecAssertion(section = "7.1.1.3", id = "c") }) public void testIgnoreAnnotations() { Validator validator = TestUtil.getValidatorUnderTest(); BeanDescriptor beanDescriptor = validator.getConstraintsForClass( User.class ); assertNotNull( beanDescriptor ); PropertyDescriptor propDescriptor = beanDescriptor.getConstraintsForProperty( "firstname" ); assertNull( propDescriptor, "The annotation defined constraints should be ignored." ); } }
/** * @author Hardy Ferentschik */ @Artifact(artifactType = ArtifactType.JSR303) @Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class }) @ValidationXml(value = "validation-ExcludeFieldLevelAnnotationsDueToBeanDefaultsTest.xml") @Resource(source = "user-constraints-ExcludeFieldLevelAnnotationsDueToBeanDefaultsTest.xml", destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/fieldlevel/user-constraints-ExcludeFieldLevelAnnotationsDueToBeanDefaultsTest.xml") public class ExcludeFieldLevelAnnotationsDueToBeanDefaultsTest extends AbstractTest { @Test @SpecAssertions({ @SpecAssertion(section = "7.1.1.2", id = "b"), @SpecAssertion(section = "7.1.1.2", id = "c") }) public void testIgnoreAnnotations() { Validator validator = TestUtil.getValidatorUnderTest(); BeanDescriptor beanDescriptor = validator.getConstraintsForClass( User.class ); assertNotNull( beanDescriptor ); PropertyDescriptor propDescriptor = beanDescriptor.getConstraintsForProperty( "firstname" ); assertNull( propDescriptor, "The annotation defined constraints should be ignored." ); } }
/** * @author Hardy Ferentschik */ @Artifact(artifactType = ArtifactType.JSR303) @Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class, TCKValidationProvider.class, TCKValidationProvider.DummyValidatorFactory.class, TCKValidatorConfiguration.class }) @Resource(source = "javax.validation.spi.ValidationProvider", destination = "WEB-INF/classes/META-INF/services/javax.validation.spi.ValidationProvider") @IntegrationTest public class UnknownProviderBootstrapTest extends AbstractTest { @Test(expectedExceptions = ValidationException.class) @SpecAssertion(section = "4.4.5", id = "f") public void testUnknownProviderThrowsValidationException() { Validation.byDefaultProvider().configure(); //ValidatorFactory factory = configuration.buildValidatorFactory(); } }
/** * @author Hardy Ferentschik */ @Artifact(artifactType = ArtifactType.JSR303) @Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class }) @ValidationXml(value = "validation-WrongFieldNameTest.xml") @Resource(source = "user-constraints-WrongFieldNameTest.xml", destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/fieldlevel/user-constraints-WrongFieldNameTest.xml") public class WrongFieldNameTest extends AbstractTest { @Test @SpecAssertions({ @SpecAssertion(section = "7.1.1.2", id = "f") }) public void testWrongFieldNameThrowsException() { try { Validator validator = TestUtil.getValidatorUnderTest(); validator.getConstraintsForClass( User.class ); } catch ( ValidationException e ) { // success } } }
/** * @author Hardy Ferentschik */ @Artifact(artifactType = ArtifactType.JSR303) @Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class }) @ValidationXml(value = "validation-WrongPropertyNameTest.xml") @Resource(source = "user-constraints-WrongPropertyNameTest.xml", destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel/user-constraints-WrongPropertyNameTest.xml") public class WrongPropertyNameTest extends AbstractTest { @Test @SpecAssertions({ @SpecAssertion(section = "7.1.1.3", id = "f") }) public void testWrongPropertyNameThrowsException() { try { Validator validator = TestUtil.getValidatorUnderTest(); validator.getConstraintsForClass( User.class ); } catch ( ValidationException e ) { // success } } }
@Artifact @ExpectedDeploymentException(DeploymentFailure.class) @Resource(source = "javax.enterprise.inject.spi.Extension", destination = "WEB-INF/classes/META-INF/services/javax.enterprise.inject.spi.Extension") @IntegrationTest @SpecVersion(spec = "cdi", version = "20091101") public class ThrowExceptionInProcessBeanObserverTest extends AbstractJSR299Test { @Test @SpecAssertion(section = "11.5.8", id = "hd") public void testProcessBeanObserverThrowsException() { assert false; } }
/** * @author Hardy Ferentschik */ @Artifact(artifactType = ArtifactType.JSR303) @Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class }) @ValidationXml(value = "validation-IncludePropertyLevelAnnotationsDueToBeanDefaultsTest.xml") @Resource(source = "user-constraints-IncludePropertyLevelAnnotationsDueToBeanDefaultsTest.xml", destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel/user-constraints-IncludePropertyLevelAnnotationsDueToBeanDefaultsTest.xml") public class IncludePropertyLevelAnnotationsDueToBeanDefaultsTest extends AbstractTest { @Test @SpecAssertions({ @SpecAssertion(section = "7.1.1.3", id = "b"), @SpecAssertion(section = "7.1.1.3", id = "d") }) public void testAnnotationsIncluded() { Validator validator = TestUtil.getValidatorUnderTest(); BeanDescriptor beanDescriptor = validator.getConstraintsForClass( User.class ); assertNotNull( beanDescriptor ); PropertyDescriptor propDescriptor = beanDescriptor.getConstraintsForProperty( "firstname" ); assertNotNull( propDescriptor ); Set<ConstraintDescriptor<?>> constraintDescriptors = propDescriptor.getConstraintDescriptors(); assertEquals( constraintDescriptors.size(), 1, "There should be two constraints" ); ConstraintDescriptor<?> descriptor = constraintDescriptors.iterator().next(); assertTrue( descriptor.getAnnotation() instanceof NotNull, "Wrong constraint annotation." ); } }
/** * @author Hardy Ferentschik */ @Artifact(artifactType = ArtifactType.JSR303) @Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class }) @ValidationXml(value = "validation-ConstraintDeclarationTest.xml") @Resource(source = "package-constraints-ConstraintDeclarationTest.xml", destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/package-constraints-ConstraintDeclarationTest.xml") public class ConstraintDeclarationTest extends AbstractTest { @Test @SpecAssertion(section = "7.1.1", id = "d") public void testConstraintAnnotationsArePerDefaultIgnoredForXmlConfiguredEntities() { Validator validator = TestUtil.getValidatorUnderTest(); BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Package.class ); assertFalse( beanDescriptor.isBeanConstrained(), "With xml configuration there should be no constraint." ); Configuration<?> config = TestUtil.getConfigurationUnderTest(); config.ignoreXmlConfiguration(); validator = config.buildValidatorFactory().getValidator(); beanDescriptor = validator.getConstraintsForClass( Package.class ); assertTrue( beanDescriptor.isBeanConstrained(), "If xml configuration is ignored Package should have a single constraint." ); } }
/** * @author Hardy Ferentschik */ @Artifact(artifactType = ArtifactType.JSR303) @Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class }) @ValidationXml(value = "validation-IncludeFieldLevelAnnotationsDueToBeanDefaultsTest.xml") @Resource(source = "user-constraints-IncludeFieldLevelAnnotationsDueToBeanDefaultsTest.xml", destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/fieldlevel/user-constraints-IncludeFieldLevelAnnotationsDueToBeanDefaultsTest.xml") public class IncludeFieldLevelAnnotationsDueToBeanDefaultsTest extends AbstractTest { @Test @SpecAssertions({ @SpecAssertion(section = "7.1.1.2", id = "b"), @SpecAssertion(section = "7.1.1.2", id = "d") }) public void testAnnotationsIncluded() { Validator validator = TestUtil.getValidatorUnderTest(); BeanDescriptor beanDescriptor = validator.getConstraintsForClass( User.class ); assertNotNull( beanDescriptor ); PropertyDescriptor propDescriptor = beanDescriptor.getConstraintsForProperty( "firstname" ); assertNotNull( propDescriptor ); Set<ConstraintDescriptor<?>> constraintDescriptors = propDescriptor.getConstraintDescriptors(); assertEquals( constraintDescriptors.size(), 1, "There should be two constraints" ); ConstraintDescriptor<?> descriptor = constraintDescriptors.iterator().next(); assertTrue( descriptor.getAnnotation() instanceof NotNull, "Wrong constraint annotation." ); } }
/** * @author Hardy Ferentschik */ @Artifact(artifactType = ArtifactType.JSR303) @Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class, TCKValidationProvider.class, TCKValidatorConfiguration.class, TCKValidationProvider.DummyValidatorFactory.class }) @ValidationXml(value = "validation-MissingClassNameOnBeanNodeTest.xml") @Resource(source = "user-constraints-MissingClassNameOnBeanNodeTest.xml", destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-MissingClassNameOnBeanNodeTest.xml") public class MissingClassNameOnBeanNodeTest extends AbstractTest { @Test @SpecAssertion(section = "7.1.1", id = "c") public void testClassNameIsMandatory() { try { TestUtil.getValidatorUnderTest(); fail(); } catch ( ValidationException e ) { // success } } }
@Resource(source="javax.enterprise.inject.spi.Extension", destination="WEB-INF/classes/META-INF/services/javax.enterprise.inject.spi.Extension") }) @IntegrationTest
/** * Test for adding a definition error via the ProcessInjectionTarget event. * * @author David Allen * */ @Artifact @Resources({ @Resource(source="javax.enterprise.inject.spi.Extension", destination="WEB-INF/classes/META-INF/services/javax.enterprise.inject.spi.Extension") }) // Must be an integration test as it needs a resource copied to a folder @IntegrationTest @ExpectedDeploymentException(DeploymentFailure.class) @SpecVersion(spec="cdi", version="20091101") public class InjectionTargetDefinitionErrorTest extends AbstractJSR299Test { @Test @SpecAssertions({ @SpecAssertion(section = "11.5.6", id = "da") }) public void testAddingDefinitionError() { assert false; } }