private ResourceDescriptor asResourceDescriptor(Resource resource) { return new ResourceDescriptorImpl( resource.destination(), asAbsolutePath( resource.source() ) ); }
@Resources( @Resource(source = DuplicateConfigurationTest.mappingFile1, destination = "WEB-INF/classes" + DuplicateConfigurationTest.packageName + DuplicateConfigurationTest.mappingFile1), @Resource(source = DuplicateConfigurationTest.mappingFile2, destination = "WEB-INF/classes" + DuplicateConfigurationTest.packageName + DuplicateConfigurationTest.mappingFile2), @Resource(source = DuplicateConfigurationTest.mappingFile3, destination = "WEB-INF/classes" + DuplicateConfigurationTest.packageName + DuplicateConfigurationTest.mappingFile3), @Resource(source = DuplicateConfigurationTest.mappingFile4, destination = "WEB-INF/classes" + DuplicateConfigurationTest.packageName + DuplicateConfigurationTest.mappingFile4)
@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class }) @Resources({ @Resource(source = ClassLevelOverridingTest.mappingFile1, destination = "WEB-INF/classes" + ClassLevelOverridingTest.packageName + ClassLevelOverridingTest.mappingFile1), @Resource(source = ClassLevelOverridingTest.mappingFile2, destination = "WEB-INF/classes" + ClassLevelOverridingTest.packageName + ClassLevelOverridingTest.mappingFile2), @Resource(source = ClassLevelOverridingTest.mappingFile3, destination = "WEB-INF/classes" + ClassLevelOverridingTest.packageName + ClassLevelOverridingTest.mappingFile3) })
final URL resource = getResource(clazz, resourceAnn.source()); if (resource != null) { resources.put(resourceAnn.destination().replaceFirst("WEB-INF/classes/", ""), resource); final Resources resourcesAnn = clazz.getAnnotation(Resources.class); for (final Resource resourceAnn : resourcesAnn.value()) { final URL resource = getResource(clazz, resourceAnn.source()); if (resource != null) { resources.put(resourceAnn.destination().replaceFirst("WEB-INF/classes/", ""), resource);
@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"); } }
final URL resource = getResource(clazz, resourceAnn.source()); if (resource != null) { resources.put(resourceAnn.destination().replaceFirst("WEB-INF/classes/", ""), resource); final Resources resourcesAnn = clazz.getAnnotation(Resources.class); for (final Resource resourceAnn : resourcesAnn.value()) { final URL resource = getResource(clazz, resourceAnn.source()); if (resource != null) { resources.put(resourceAnn.destination().replaceFirst("WEB-INF/classes/", ""), resource);
@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")
@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class }) @Resources({ @Resource(source = ReservedElementNameTest.mappingFile1, destination = "WEB-INF/classes" + ReservedElementNameTest.packageName + ReservedElementNameTest.mappingFile1), @Resource(source = ReservedElementNameTest.mappingFile2, destination = "WEB-INF/classes" + ReservedElementNameTest.packageName + ReservedElementNameTest.mappingFile2) })
@IntegrationTest(runLocally=true) @Resources({ @Resource(destination="home.jspx", source="home.jsf"), @Resource(destination="cloud.jspx", source="cloud.jsf"), @Resource(destination="clouds.jspx", source="clouds.jsf"), @Resource(destination="cumulus.jspx", source="cumulus.jsf"), @Resource(destination="builtin.jspx", source="builtin.jsf"), @Resource(destination="error.jspx", source="error.jsf"), @Resource(destination="storm.jspx", source="storm.jsf"), @Resource(destination="/WEB-INF/faces-config.xml", source="faces-config.xml"), @Resource(destination="rain.jspx", source="rain.jsf") }) @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 })
@IntegrationTest(runLocally=true) @Resources({ @Resource(destination="WEB-INF/faces-config.xml", source="faces-config.xml"), @Resource(destination="storm.jspx", source="storm.jsf"), @Resource(destination="thunder.jspx", source="thunder.jsf"), @Resource(destination="lightening.jspx", source="lightening.jsf") }) @WebXml("web.xml")
@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class }) @Resources({ @Resource(source = XmlConfiguredConstraintValidatorTest.mappingFile1, destination = "WEB-INF/classes" + XmlConfiguredConstraintValidatorTest.packageName + XmlConfiguredConstraintValidatorTest.mappingFile1), @Resource(source = XmlConfiguredConstraintValidatorTest.mappingFile2, destination = "WEB-INF/classes" + XmlConfiguredConstraintValidatorTest.packageName + XmlConfiguredConstraintValidatorTest.mappingFile2) })
@Resource(destination = "WEB-INF/faces-config.xml", source = "faces-config.xml"), @Resource(destination = "WEB-INF/TestLibrary.tld", source = "TestLibrary.tld"), @Resource(destination = "TagPage.jsp", source = "TagPage.jsp"), @Resource(destination = "ManagedBeanTestPage.jsp", source = "ManagedBeanTestPage.jsp"), @Resource(source = "javax.enterprise.inject.spi.Extension", destination = "WEB-INF/classes/META-INF/services/javax.enterprise.inject.spi.Extension") }) @IntegrationTest @WebXml("web.xml")
@Artifact @IntegrationTest(runLocally = true) @Resources( { @Resource(destination = "WEB-INF/faces-config.xml", source = "faces-config.xml"), @Resource(destination = "WEB-INF/TestLibrary.tld", source = "TestLibrary.tld"), @Resource(destination = "TagPage.jsp", source = "TagPage.jsp"), @Resource(destination = "ManagedBeanTestPage.jsp", source = "ManagedBeanTestPage.jsp")}) @SpecVersion(spec="cdi", version="20091101") @WebXml("web2.xml")
/** * @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." ); } }