@Deployment(name = GOOD_FRAGMENT_EAR, managed = false, testable = false) public static EnterpriseArchive getGoodFragmentEar() { final EnterpriseArchive archive = ShrinkWrap.create(EnterpriseArchive.class, GOOD_FRAGMENT_EAR); archive.add(getGoodBundleArchive(), "/", ZipExporter.class); archive.add(getGoodFragmentArchive(), "/", ZipExporter.class); return archive; }
@Deployment public static EnterpriseArchive criaDeployment() { EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class); adicionaDependenciasMaven(ear); JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "test.jar") .addPackage(Entidade.class.getPackage()) .addPackage(EntidadeServiceImpl.class.getPackage()) .addPackage(ClienteTest.class.getPackage()) .addPackage(Cliente.class.getPackage()) .addPackage(Projeto.class.getPackage()) .addPackage(Funcionario.class.getPackage()) .addPackage(Departamento.class.getPackage()) .addPackage(Endereco.class.getPackage()) .addPackage(Dispositivo.class.getPackage()) .addPackage(Vaga.class.getPackage()) .addAsResource("test-persistence.xml", "META-INF/persistence.xml") .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); ear.addAsModule(jar); return ear; }
@ShouldThrowException(DeploymentException.class) @Deployment public static EnterpriseArchive createTestArchive() { EnterpriseArchive enterpriseArchive = new EnterpriseArchiveBuilder() .noDefaultWebModule() .withTestClassDefinition(SpecializationModularity06Test.class) .withBeanLibrary(Handler.class, Charlie.class) .withLibrary(Connector.class) .build(); // WAR 1 enterpriseArchive.addAsModule( new WebArchiveBuilder() .notTestArchive() .withDefaultEjbModuleDependency() .withClasses(UppercaseHandler.class, Alpha.class) .build()); // WAR 2 enterpriseArchive.addAsModule( new WebArchiveBuilder() .notTestArchive() .withDefaultEjbModuleDependency() .withClasses(Bravo.class) .build()); return enterpriseArchive; }
private Archive<?> getEarArchive() { EnterpriseArchive archive = ShrinkWrap.create(EnterpriseArchive.class, "deployment-app.ear"); archive.setApplicationXML("deployment/META-INF/application.xml"); archive.add(getWebArchive(), "/", ZipExporter.class); archive.add(getEjbArchive(), "/", ZipExporter.class); return archive; }
@Deployment public static Archive<?> getDeployment() throws Exception { doSetup(); WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war") .addClasses( WeldBundledLibraryDeploymentEarTestCase.class, AbstractBundledLibraryDeploymentTestCase.class) .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); JavaArchive library = ShrinkWrap.create(JavaArchive.class, "library.jar") .addClasses(InjectedBean.class) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); JavaArchive ejbJar = ShrinkWrap.create(JavaArchive.class, "ejb-archive.jar") .addClasses(InjectedSessionBean.class) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class); ear.addAsModule(war); ear.addAsModule(ejbJar); ear.addAsLibrary(library); ear.setManifest( new StringAsset("Extension-List: weld1\nweld1-Extension-Name: " + EXTENSION_NAME + "\n")); return ear; }
@Deployment(name = SUB_WEBAPP_EAR, testable = false) public static Archive<?> getSimpleEar() { WebArchive war = ShrinkWrap.create(WebArchive.class, SUB_WEBAPP_WAR); war.addClasses(SimpleServlet.class); EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, SUB_WEBAPP_EAR); ear.addAsModule(war); return ear; }
/** * Creates an EJB deployment * * @return */ @Deployment public static Archive<?> createDeployment() { final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, APP_NAME + ".ear"); final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, MODULE_NAME + ".jar"); jar.addPackage(EJBClientAPIUsageTestCase.class.getPackage()); jar.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); ear.addAsModule(jar); return ear; }
@Deployment(name = MANAGED_BEAN_EAR, testable = false) public static Archive<?> getManagedBeanEar() { WebArchive war = ShrinkWrap.create(WebArchive.class, MANAGED_BEAN_WAR); war.addClasses(SimpleBeanServlet.class); JavaArchive jar = ShrinkWrap.create(JavaArchive.class, MANAGED_BEAN_JAR); jar.addClasses(SimpleManagedBean.class); jar.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, MANAGED_BEAN_EAR); ear.addAsModules(jar, war); return ear; }
/** * Creates an EJB deployment * * @return */ @Deployment public static Archive<?> createDeployment() { final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, APP_NAME + ".ear"); final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, MODULE_NAME + ".jar"); jar.addPackage(EJBClientAPIUsageTestCase.class.getPackage()); jar.addClass(AnonymousCallbackHandler.class); ear.addAsModule(jar); return ear; }
@Deployment(name = "jaxws-jbws1822-two-ejb-modules", testable = false, managed = false) public static EnterpriseArchive createDeployment2() { JavaArchive archive3 = ShrinkWrap.create(JavaArchive.class, "jaxws-jbws1822-one-ejb3-inside.jar"); archive3 .addManifest() .addClass(org.jboss.test.ws.jaxws.jbws1822.webservice.EJB3Bean.class) .addClass(org.jboss.test.ws.jaxws.jbws1822.webservice.EJB3RemoteIface.class); // JBossWSTestHelper.writeToFile(archive3); EnterpriseArchive archive = ShrinkWrap.create(EnterpriseArchive.class, "jaxws-jbws1822-two-ejb-modules.ear"); archive.addManifest().addAsModule(archive3).addAsModule(archive1); return archive; }
/** * Create a .ear, containing a web application (without any JSF constructs) and also the xerces * jar in the .ear/lib * * @return */ @Deployment(name = "app-without-jsf", testable = false) public static EnterpriseArchive createDeployment() { final WebArchive war = ShrinkWrap.create(WebArchive.class, WEB_APP_CONTEXT + ".war"); war.addClasses(XercesUsageServlet.class); // add a dummy xml to parse war.addAsResource(XercesUsageServlet.class.getPackage(), "dummy.xml", "dummy.xml"); final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "xerces-usage.ear"); // add the .war ear.addAsModule(war); // add the xerces jar in the .ear/lib ear.addAsLibrary("xerces/xercesImpl.jar", "xercesImpl.jar"); return ear; }
@Deployment public static Archive<?> deploy() { EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "eartest.ear"); JavaArchive ejbJar = ShrinkWrap.create(JavaArchive.class, "ejbmodule.jar"); ejbJar.addClasses(EarManifestDependencyPropagatedTestCase.class); ejbJar.addAsManifestResource(emptyEjbJar(), "ejb-jar.xml"); ear.addAsModule(ejbJar); JavaArchive earLib = ShrinkWrap.create(JavaArchive.class, "libjar.jar"); earLib.addAsManifestResource( new StringAsset("Dependencies: org.jboss.classfilewriter\n"), "MANIFEST.MF"); ear.addAsLibraries(earLib); return ear; }
@Test public void testEar() { EnterpriseArchive archive = ShrinkWrap.create(MavenImporter.class, "test.ear") .loadEffectivePom("../ear-sample/pom.xml") .importBuildOutput() .as(EnterpriseArchive.class); Assert.assertNotNull("Archive is not null", archive); Assert.assertTrue("Archive contains test.xml", archive.contains("test.xml")); Assert.assertTrue( "Archive contains application.xml", archive.contains("META-INF/application.xml")); Assert.assertEquals("Archive contains one library", 1, getLibraries(archive).size()); }
@Deployment(testable = false) public static Archive<?> deploy() { EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, ARCHIVE_NAME + ".ear"); JavaArchive lib = ShrinkWrap.create(JavaArchive.class, "lib.jar"); lib.addClass(SimpleServlet.class); ear.addAsLibrary(lib); JavaArchive module = ShrinkWrap.create(JavaArchive.class, "ejb.jar"); module.addClasses(CrossModuleInjectionTestCase.class, BaseBean.class); ear.addAsModule(module); WebArchive war = ShrinkWrap.create(WebArchive.class, "simple.war"); war.addAsWebInfResource(new StringAsset(WEB_XML), "web.xml"); ear.addAsModule(war); return ear; }
@Deployment public static Archive<?> deploy() { WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war"); war.addClasses(WebInfLibClass.class, EarJbossStructureDepedenciesTestCase.class); EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class); ear.addModule(war); ear.addManifestResource( new StringAsset( "<jboss-deployment-structure><deployment></deployment><sub-deployment name=\"test.war\"><dependencies><module name=\"org.jboss.classfilewriter\" /></dependencies></sub-deployment></jboss-deployment-structure>"), "jboss-deployment-structure.xml"); JavaArchive earLib = ShrinkWrap.create(JavaArchive.class, "earLib.jar"); earLib.addClass(EarLibClass.class); ear.addLibraries(earLib); return ear; }
@Deployment public static Archive<?> deploy() { EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class); JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "otherjar.jar"); jar.addClass(TestAA.class); jar.addAsResource(emptyEjbJar(), "META-INF/ejb-jar.xml"); ear.addAsModule(jar); WebArchive war = ShrinkWrap.create(WebArchive.class, "testwar.war"); war.addClass(WarCanAccessEjbJarTestCase.class); war.addAsResource(new StringAsset("Class-Path: otherjar.jar\n"), "META-INF/MANIFEST.MF"); ear.addAsModule(war); return ear; }
private Archive<?> handleArchive( EnterpriseArchive applicationArchive, Collection<Archive<?>> auxiliaryArchives, JavaArchive protocol, Processor processor) { Map<ArchivePath, Node> applicationArchiveWars = applicationArchive.getContent(Filters.include(".*\\.war")); if (applicationArchiveWars.size() == 1) { ArchivePath warPath = applicationArchiveWars.keySet().iterator().next(); try { handleArchive( applicationArchive.getAsType(WebArchive.class, warPath), new ArrayList< Archive< ?>>(), // reuse the War handling, but Auxiliary Archives should be added to the // EAR, not the WAR protocol, processor); } catch (IllegalArgumentException e) { throw new IllegalArgumentException( "Can not manipulate war's that are not of type " + WebArchive.class, e); } } else if (applicationArchiveWars.size() > 1) { // TODO: fetch the TestDeployment.getArchiveForEnrichment throw new UnsupportedOperationException( "Multiple WebArchives found in " + applicationArchive.getName() + ". Can not determine which to enrich"); } else { // reuse handle(JavaArchive, ..) logic Archive<?> wrappedWar = handleArchive(protocol, new ArrayList<Archive<?>>(), null, processor); applicationArchive.addAsModule(wrappedWar); if (applicationArchive.contains(APPLICATION_XML_PATH)) { ApplicationDescriptor applicationXml = Descriptors.importAs(ApplicationDescriptor.class) .from(applicationArchive.get(APPLICATION_XML_PATH).getAsset().openStream()); applicationXml.webModule(wrappedWar.getName(), wrappedWar.getName()); // SHRINKWRAP-187, to eager on not allowing overrides, delete it first applicationArchive.delete(APPLICATION_XML_PATH); applicationArchive.setApplicationXML(new StringAsset(applicationXml.exportAsString())); } } applicationArchive.addAsLibraries(auxiliaryArchives.toArray(new Archive<?>[0])); return applicationArchive; }
@Deployment(name = "b", testable = false, managed = true) public static Archive<?> deployB() { EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, APP_B + ".ear"); JavaArchive jarB = ShrinkWrap.create(JavaArchive.class, MOD_B + ".jar"); jarB.addClasses(BEJB.class, BEJBBean.class); JavaArchive jarBshared = ShrinkWrap.create(JavaArchive.class, MOD_B_SHARED + ".jar"); jarBshared.addClasses(Shared.class, SharedBean.class); jarBshared.addAsManifestResource( SharedBeanInEarsUnitTestCase.class.getPackage(), "ejb-jar-b.xml", "ejb-jar.xml"); ear.addAsModule(jarB); ear.addAsModule(jarBshared); ear.addAsManifestResource( SharedBeanInEarsUnitTestCase.class.getPackage(), "application-b.xml", "application.xml"); log.info(ear.toString(true)); return ear; }
@BeforeClass public static void before() throws Exception { CLITestSuite.createSupport(UndeployWildcardDomainTestCase.class.getSimpleName()); String tempDir = System.getProperty("java.io.tmpdir"); // deployment1 WebArchive war = ShrinkWrap.create(WebArchive.class, "cli-test-app1.war"); war.addAsWebResource(new StringAsset("Version0"), "page.html"); cliTestApp1War = new File(tempDir + File.separator + war.getName()); new ZipExporterImpl(war).exportTo(cliTestApp1War, true); // deployment2 war = ShrinkWrap.create(WebArchive.class, "cli-test-app2.war"); war.addAsWebResource(new StringAsset("Version1"), "page.html"); cliTestApp2War = new File(tempDir + File.separator + war.getName()); new ZipExporterImpl(war).exportTo(cliTestApp2War, true); // deployment3 war = ShrinkWrap.create(WebArchive.class, "cli-test-another.war"); war.addAsWebResource(new StringAsset("Version2"), "page.html"); cliTestAnotherWar = new File(tempDir + File.separator + war.getName()); new ZipExporterImpl(war).exportTo(cliTestAnotherWar, true); // deployment4 war = ShrinkWrap.create(WebArchive.class, "cli-test-app3.war"); war.addAsWebResource(new StringAsset("Version3"), "page.html"); final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "cli-test-app.ear"); ear.add(war, new BasicPath("/"), ZipExporter.class); cliTestAppEar = new File(tempDir + File.separator + ear.getName()); new ZipExporterImpl(ear).exportTo(cliTestAppEar, true); final Iterator<String> sgI = CLITestSuite.serverGroups.keySet().iterator(); if (!sgI.hasNext()) { fail("Server groups aren't available."); } sgOne = sgI.next(); if (!sgI.hasNext()) { fail("Second server groups isn't available."); } sgTwo = sgI.next(); }
@Deployment public static EnterpriseArchive createTestArchive() { EnterpriseArchive enterpriseArchive = new EnterpriseArchiveBuilder() .noDefaultWebModule() .withTestClassDefinition(EnabledManagedBeanInjectionAvailabilityTest.class) .withClasses(ManagedFoo.class) .withBeanLibrary(Foo.class, Bar.class) .build(); enterpriseArchive.addAsModule( new WebArchiveBuilder() .notTestArchive() .withDefaultEjbModuleDependency() .withClasses(EnabledManagedBeanInjectionAvailabilityTest.class, WebBar.class) .build()); return enterpriseArchive; }
protected static void adicionaDependenciasMaven(EnterpriseArchive ear) { MavenStrategyStage mavenStrategyStage = Maven.configureResolver() .fromFile(System.getenv("M2_HOME") + "/conf/settings.xml") .loadPomFromFile("pom.xml") .importCompileAndRuntimeDependencies() .resolve(); MavenFormatStage mavenFormatStage = mavenStrategyStage.withTransitivity(); ear.addAsLibraries(mavenFormatStage.asFile()); }
@Deployment public static Archive<?> deploy() { EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class); JavaArchive earLib = ShrinkWrap.create(JavaArchive.class); earLib.addClasses(EarResourceListingTestCase.class, ResourceListingUtils.class); earLib.addAsManifestResource(EmptyAsset.INSTANCE, "emptyJarLibResource.properties"); earLib.addAsManifestResource(EmptyAsset.INSTANCE, "properties/nestedJarLib.properties"); ear.addAsLibraries(earLib); WebArchive war = ShrinkWrap.create(WebArchive.class, INNER_WAR_ARCHIVE_NAME); war.addClass(TestA.class); war.add(EmptyAsset.INSTANCE, "META-INF/example.txt"); war.add(EmptyAsset.INSTANCE, "META-INF/properties/nested.properties"); war.add(EmptyAsset.INSTANCE, "example2.txt"); war.addAsResource( EarResourceListingTestCase.class.getPackage(), "TextFile1.txt", "TextFile1.txt"); war.addAsWebInfResource(EarResourceListingTestCase.class.getPackage(), "web.xml", "web.xml"); JavaArchive libJar = ShrinkWrap.create(JavaArchive.class, INNER_JAR_ARCHIVE_NAME); libJar.addClass(WebInfLibClass.class); war.addAsLibraries(libJar); ear.addAsModules(libJar, war); ear.addAsManifestResource(EmptyAsset.INSTANCE, "MANIFEST.MF"); ear.addAsResource(EmptyAsset.INSTANCE, "emptyEarResource"); ear.addAsManifestResource( EarResourceListingTestCase.class.getPackage(), "application.xml", "application.xml"); return ear; }
public void testEarScan() throws Exception { File ear = File.createTempFile("helloworld", ".ear"); JavaArchive jarArchive = ShrinkWrap.create(JavaArchive.class, "my-lib-1.0.jar") .addClass(FunAnnotatedClientClass2.class); WebArchive warArchive = ShrinkWrap.create(WebArchive.class, "helloworld.war") .addClasses(FunAnnotatedClientClass.class) .addAsLibrary(jarArchive); EnterpriseArchive earArchive = ShrinkWrap.create(EnterpriseArchive.class).addAsModule(warArchive); earArchive.as(ZipExporter.class).exportTo(ear, true); URL earUrl = new URL(ear.toURI() + "/helloworld.war!/WEB-INF/classes"); URL libUrl = new URL(ear.toURI() + "/helloworld.war!/WEB-INF/lib/my-lib-1.0.jar"); List<URL> urlList = new ArrayList<URL>(); urlList.add(earUrl); urlList.add(libUrl); MetaDataScanner scanner = createScanner(urlList); // nested in ear/war/WEB-INF/classes assertTrue( "Didn't find @Local annotated class FunAnnotatedClientClass in ear-war nesting", scanner .getStore() .getTypesAnnotatedWith(Local.class.getName()) .contains("org.jboss.errai.bus.client.tests.support.FunAnnotatedClientClass")); // nested in ear/war/WEB-INF/lib assertTrue( "Didn't find @Service annotated class FunAnnotatedClientClass2 in ear-war-jar nesting", scanner .getStore() .getTypesAnnotatedWith(Service.class.getName()) .contains("org.jboss.errai.bus.client.tests.support.FunAnnotatedClientClass2")); }
@Deployment public static Archive<?> deploy() throws Exception { EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, ARCHIVE_NAME + ".ear"); // add required jars as manifest dependencies ear.addAsManifestResource( new StringAsset("Dependencies: org.hibernate.envers export,org.hibernate, org.javassist\n"), "MANIFEST.MF"); JavaArchive lib = ShrinkWrap.create(JavaArchive.class, "beans.jar"); lib.addClasses(SFSBHibernateEnversSessionFactory.class); ear.addAsModule(lib); lib = ShrinkWrap.create(JavaArchive.class, "entities.jar"); lib.addClasses(StudentAudited.class); lib.addAsResource(new StringAsset(testmapping), "testmapping.hbm.xml"); lib.addAsResource(new StringAsset(hibernate_cfg), "hibernate.cfg.xml"); ear.addAsLibraries(lib); final WebArchive main = ShrinkWrap.create(WebArchive.class, "main.war"); main.addClasses(Hibernate4NativeAPIEnversTestCase.class); ear.addAsModule(main); // add application dependency on H2 JDBC driver, so that the Hibernate classloader (same as app // classloader) // will see the H2 JDBC driver. // equivalent hack for use of shared Hiberante module, would be to add the H2 dependency // directly to the // shared Hibernate module. // also add dependency on org.slf4j ear.addAsManifestResource( new StringAsset( "<jboss-deployment-structure>" + " <deployment>" + " <dependencies>" + " <module name=\"com.h2database.h2\" />" + " <module name=\"org.slf4j\"/>" + " </dependencies>" + " </deployment>" + "</jboss-deployment-structure>"), "jboss-deployment-structure.xml"); return ear; }
@BeforeClass public static void before() throws Exception { String tempDir = System.getProperty("java.io.tmpdir"); WebArchive[] wars = new WebArchive[3]; // deployment1 wars[0] = ShrinkWrap.create(WebArchive.class, "deployment0.war"); wars[0].addClass(SimpleServlet.class); wars[0].addAsWebResource(new StringAsset("Version0"), "page.html"); // deployment2 wars[1] = ShrinkWrap.create(WebArchive.class, "deployment1.war"); wars[1].addClass(SimpleServlet.class); wars[1].addAsWebResource(new StringAsset("Version1"), "page.html"); // deployment3 is included but not deployed wars[2] = ShrinkWrap.create(WebArchive.class, "deployment2.war"); wars[2].addClass(SimpleServlet.class); wars[2].addAsWebResource(new StringAsset("Version2"), "page.html"); // build cli archive EnterpriseArchive cliArchive = ShrinkWrap.create(EnterpriseArchive.class, "archive.cli"); String deploy = "deploy deployment0.war\ndeploy deployment1.war"; String undeploy = "undeploy deployment0.war\nundeploy deployment1.war"; cliArchive.add(new StringAsset(deploy), new BasicPath("/", "install.scr")); // add the default script which shouldn't be picked up cliArchive.add( new StringAsset("deploy deployment0.war\ndeploy deployment1.war\ndeploy deployment2.war"), new BasicPath("/", "deploy.scr")); cliArchive.add(new StringAsset(undeploy), new BasicPath("/", "uninstall.scr")); cliArchive.add( new StringAsset( "undeploy deployment0.war\nundeploy deployment1.war\nundeploy deployment2.war"), new BasicPath("/", "undeploy.scr")); for (WebArchive war : wars) { cliArchive.add(war, new BasicPath("/"), ZipExporter.class); } cliArchiveFile = new File(tempDir + File.separator + "archive.cli"); new ZipExporterImpl(cliArchive).exportTo(cliArchiveFile, true); }
private Archive<?> handleArchive( EnterpriseArchive applicationArchive, Collection<Archive<?>> auxiliaryArchives, WebArchive protocol, Processor processor, TestDeployment testDeployment) { Map<ArchivePath, Node> applicationArchiveWars = applicationArchive.getContent(Filters.include(".*\\.war")); if (applicationArchiveWars.size() == 1) { ArchivePath warPath = applicationArchiveWars.keySet().iterator().next(); try { handleArchive( applicationArchive.getAsType(WebArchive.class, warPath), new ArrayList< Archive< ?>>(), // reuse the War handling, but Auxiliary Archives should be added to the // EAR, not the WAR protocol, processor); } catch (IllegalArgumentException e) { throw new IllegalArgumentException( "Can not manipulate war's that are not of type " + WebArchive.class, e); } } else if (applicationArchiveWars.size() > 1) { Archive<?> archiveToTest = testDeployment.getArchiveForEnrichment(); if (archiveToTest == null) { throw new UnsupportedOperationException( "Multiple WebArchives found in " + applicationArchive.getName() + ". Can not determine which to enrich"); } else if (!archiveToTest.getName().endsWith(".war")) { // TODO: Removed throwing an exception when EJB modules are supported as well throw new UnsupportedOperationException("Archive to test is not a WebArchive!"); } else { handleArchive( archiveToTest.as(WebArchive.class), new ArrayList< Archive< ?>>(), // reuse the War handling, but Auxiliary Archives should be added to the // EAR, not the WAR protocol, processor); } } else { // SHRINKWRAP-187, to eager on not allowing overrides, delete it first protocol.delete(WEB_XML_PATH); applicationArchive.addAsModule( protocol.setWebXML(new StringAsset(WebUtils.createNewDescriptor().exportAsString()))); if (applicationArchive.contains(APPLICATION_XML_PATH)) { ApplicationDescriptor applicationXml = Descriptors.importAs(ApplicationDescriptor.class) .from(applicationArchive.get(APPLICATION_XML_PATH).getAsset().openStream()); applicationXml.webModule( protocol.getName(), ServletUtil.calculateContextRoot(protocol.getName())); // SHRINKWRAP-187, to eager on not allowing overrides, delete it first applicationArchive.delete(APPLICATION_XML_PATH); applicationArchive.setApplicationXML(new StringAsset(applicationXml.exportAsString())); } processor.process(protocol); } applicationArchive.addAsLibraries(auxiliaryArchives.toArray(new Archive<?>[0])); return applicationArchive; }
@Deployment protected static EnterpriseArchive getBaseDeployment() { // deploy the test classes in their own jar, under /lib JavaArchive testClassesJar = ShrinkWrap.create(JavaArchive.class, "test-classes.jar"); testClassesJar = addClasses(testClassesJar, new File("target/test-classes/org"), null); // add non itests-2 RHQ classes used by the test classes, as well as needed resources testClassesJar.addClass(ThrowableUtil.class); testClassesJar.addClass(MessageDigestGenerator.class); testClassesJar.addClass(StreamUtil.class); testClassesJar.addClass(AssertUtils.class); testClassesJar.addClass(ResourceBuilder.class); testClassesJar.addClass(ResourceTypeBuilder.class); testClassesJar.addClass(BuilderException.class); testClassesJar.addClasses( PropertyMatcher.class, MatchResult.class, PropertyMatchException.class); testClassesJar.addAsManifestResource( EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml")); // add CDI injection (needed by arquillian injection); // TOD0 (jshaughn): Once we have identified all of the necessary test resource files, see if we // can just add the // entire /resources dir in one statement testClassesJar.addAsResource("binary-blob-sample.jar"); testClassesJar.addAsResource("test-alert-sender-serverplugin.xml"); testClassesJar.addAsResource("test-assist-color-number.txt"); testClassesJar.addAsResource("test-ldap.properties"); testClassesJar.addAsResource("test-scheduler.properties"); testClassesJar.addAsResource( "org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v1.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v2.xml"); testClassesJar.addAsResource("org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.xml"); testClassesJar.addAsResource("org/rhq/enterprise/server/resource/metadata/MetadataTest.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/AlertMetadataManagerBeanTest/plugin_v1.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/AlertMetadataManagerBeanTest/plugin_v2.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/ContentMetadataManagerBeanTest/plugin_v1.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/ContentMetadataManagerBeanTest/plugin_v2.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/EventMetadataManagerBeanTest/plugin_v1.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/EventMetadataManagerBeanTest/plugin_v2.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/MeasurementMetadataManagerBeanTest/plugin_v1.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/MeasurementMetadataManagerBeanTest/plugin_v2.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/MultiplePluginExtensionMetadataTest/child1_plugin_v1.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/MultiplePluginExtensionMetadataTest/child2_plugin_v1.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/MultiplePluginExtensionMetadataTest/parent_plugin_v1.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/MultiplePluginExtensionMetadataTest/parent_plugin_v2.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/MultiplePluginExtensionSinglePluginDescriptorMetadataTest/child_plugin_v1.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/MultiplePluginExtensionSinglePluginDescriptorMetadataTest/parent_plugin_v1.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/MultiplePluginExtensionSinglePluginDescriptorMetadataTest/parent_plugin_v2.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/OperationMetadataManagerBeanTest/plugin_v1.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/OperationMetadataManagerBeanTest/plugin_v2.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/PluginExtensionMetadataTest/child_plugin_v1.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/PluginExtensionMetadataTest/parent_plugin_v1.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/PluginExtensionMetadataTest/parent_plugin_v2.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/PluginManagerBeanTest/plugin_1.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/PluginManagerBeanTest/plugin_2.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/PluginManagerBeanTest/plugin_3.1.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/PluginManagerBeanTest/plugin_3.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/PluginScanningExtensionMetadataTest/child1_plugin_v1.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/PluginScanningExtensionMetadataTest/child2_plugin_v1.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/PluginScanningExtensionMetadataTest/parent_plugin_v1.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/PluginScanningExtensionMetadataTest/parent_plugin_v2.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest/dup_drift.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest/parent_resource_type-plugin.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest/plugin_v1.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest/plugin_v2.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest/remove_bundle_drift_config_v1.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest/remove_bundle_drift_config_v2.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest/remove_types_v1.xml"); testClassesJar.addAsResource( "org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest/remove_types_v2.xml"); testClassesJar.addAsResource("perftest/AvailabilityInsertPurgeTest-testOne-data.xml.zip"); testClassesJar.addAsResource("serverplugins/simple-generic-serverplugin.xml"); testClassesJar.addAsResource("test/deployment/1.0-feb-2.xml"); testClassesJar.addAsResource("test/deployment/1.0-feb.xml"); testClassesJar.addAsResource("test/deployment/1.0-june.xml"); testClassesJar.addAsResource("test/deployment/1.1-feb.xml"); testClassesJar.addAsResource("test/deployment/1.1-june.xml"); testClassesJar.addAsResource("test/metadata/content-source-update-v1.xml"); testClassesJar.addAsResource("test/metadata/content-source-update-v2.xml"); testClassesJar.addAsResource("test/metadata/noTypes.xml"); testClassesJar.addAsResource("test/metadata/alerts/type-with-metric.xml"); testClassesJar.addAsResource("test/metadata/configuration/addDeleteTemplate1.xml"); testClassesJar.addAsResource("test/metadata/configuration/addDeleteTemplate2.xml"); testClassesJar.addAsResource("test/metadata/configuration/addDeleteTemplate3.xml"); testClassesJar.addAsResource("test/metadata/configuration/constraint.xml"); testClassesJar.addAsResource("test/metadata/configuration/constraintMinMax.xml"); testClassesJar.addAsResource("test/metadata/configuration/propertyChanging-v1.xml"); testClassesJar.addAsResource("test/metadata/configuration/propertyChanging-v2.xml"); testClassesJar.addAsResource("test/metadata/configuration/propertyList-v1.xml"); testClassesJar.addAsResource("test/metadata/configuration/propertyList-v2.xml"); testClassesJar.addAsResource("test/metadata/configuration/propertyList-simple.xml"); testClassesJar.addAsResource("test/metadata/configuration/propertyMap-v1.xml"); testClassesJar.addAsResource("test/metadata/configuration/propertyMap-v2.xml"); testClassesJar.addAsResource("test/metadata/configuration/groupDeleted-v1.xml"); testClassesJar.addAsResource("test/metadata/configuration/groupDeleted-v2.xml"); testClassesJar.addAsResource("test/metadata/configuration/groupPropDeleted-v1.xml"); testClassesJar.addAsResource("test/metadata/configuration/groupPropDeleted-v2.xml"); testClassesJar.addAsResource("test/metadata/configuration/groupPropDeleted-v3.xml"); testClassesJar.addAsResource("test/metadata/configuration/groupPropDeleted-v4.xml"); testClassesJar.addAsResource("test/metadata/configuration/groupPropMoved-v1.xml"); testClassesJar.addAsResource("test/metadata/configuration/groupPropMoved-v2.xml"); testClassesJar.addAsResource("test/metadata/configuration/update5-v1_0.xml"); testClassesJar.addAsResource("test/metadata/configuration/update5-v2_0.xml"); testClassesJar.addAsResource("test/metadata/configuration/updateDefaultTemplate1.xml"); testClassesJar.addAsResource("test/metadata/configuration/updateDefaultTemplate2.xml"); testClassesJar.addAsResource("test/metadata/events/event1-1.xml"); testClassesJar.addAsResource("test/metadata/events/event1-2.xml"); testClassesJar.addAsResource("test/metadata/measurement/measurementDeletion-v1_0.xml"); testClassesJar.addAsResource("test/metadata/measurement/measurementDeletion-v2_0.xml"); testClassesJar.addAsResource("test/metadata/measurement/update-v1_0.xml"); testClassesJar.addAsResource("test/metadata/measurement/update-v2_0.xml"); testClassesJar.addAsResource("test/metadata/measurement/update6-1.xml"); testClassesJar.addAsResource("test/metadata/measurement/update6-2.xml"); testClassesJar.addAsResource("test/metadata/measurement/update7-1.xml"); testClassesJar.addAsResource("test/metadata/measurement/update7-2.xml"); testClassesJar.addAsResource("test/metadata/natives/update5-v1_0.xml"); testClassesJar.addAsResource("test/metadata/natives/update5-v2_0.xml"); testClassesJar.addAsResource("test/metadata/operation/operation1-1.xml"); testClassesJar.addAsResource("test/metadata/operation/operation1-2.xml"); testClassesJar.addAsResource("test/metadata/operation/operation2-1.xml"); testClassesJar.addAsResource("test/metadata/operation/operation2-2.xml"); testClassesJar.addAsResource("test/metadata/operation/operation3-1.xml"); testClassesJar.addAsResource("test/metadata/operation/operation3-2.xml"); testClassesJar.addAsResource("test/metadata/operation/update3-v1_0.xml"); testClassesJar.addAsResource("test/metadata/operation/update3-v2_0.xml"); testClassesJar.addAsResource("test/metadata/resource/illegal-subcat-1.xml"); testClassesJar.addAsResource("test/metadata/resource/nested-subcat-2children.xml"); testClassesJar.addAsResource("test/metadata/resource/nested-subcat-grandchild.xml"); testClassesJar.addAsResource("test/metadata/resource/nested-subcat-services-v1_0.xml"); testClassesJar.addAsResource("test/metadata/resource/nested-subcat-services-v2_0.xml"); testClassesJar.addAsResource("test/metadata/resource/nested-subcat-v1_0.xml"); testClassesJar.addAsResource("test/metadata/resource/nested-subcat-v1_1.xml"); testClassesJar.addAsResource("test/metadata/resource/nested-subcat-v2_0.xml"); testClassesJar.addAsResource("test/metadata/resource/no-subcat.xml"); testClassesJar.addAsResource("test/metadata/resource/one-subcat-v1_0.xml"); testClassesJar.addAsResource("test/metadata/resource/one-subcat-v1_1.xml"); testClassesJar.addAsResource("test/metadata/resource/one-subcat-v2_0.xml"); testClassesJar.addAsResource("test/metadata/resource/one-subcat-v3_0.xml"); testClassesJar.addAsResource("test/metadata/resource/services-v1_0.xml"); testClassesJar.addAsResource("test/metadata/resource/services-v2_0.xml"); testClassesJar.addAsResource("test/metadata/resource/test-subcategories.xml"); testClassesJar.addAsResource("test/metadata/resource/test-subcategories2.xml"); testClassesJar.addAsResource("test/metadata/resource/test-subcategories3.xml"); testClassesJar.addAsResource("test/metadata/resource/two-subcat.xml"); testClassesJar.addAsResource("test/metadata/resource/undefined-child-subcat-1.xml"); testClassesJar.addAsResource("test/metadata/resource-type/duplicateResourceType.xml"); testClassesJar.addAsResource("test/metadata/resource-type/update2-v1_0.xml"); testClassesJar.addAsResource("test/metadata/resource-type/update2-v2_0.xml"); testClassesJar.addAsResource("test/metadata/resource-type/update4-v1_0.xml"); testClassesJar.addAsResource("test/metadata/resource-type/update4-v2_0.xml"); testClassesJar.addAsResource( "test/metadata/resource-type/updateResourceTypeBundleTarget-v1.xml"); testClassesJar.addAsResource( "test/metadata/resource-type/updateResourceTypeBundleTarget-v2.xml"); // create test ear by starting with rhq.ear and thinning it MavenDependencyResolver earResolver = DependencyResolvers.use(MavenDependencyResolver.class); // this must be named rhq.ear because the "rhq" portion is used in the jndi names EnterpriseArchive testEar = ShrinkWrap.create(EnterpriseArchive.class, "rhq.ear"); EnterpriseArchive rhqEar = earResolver .artifact("org.rhq:rhq-enterprise-server-ear:ear:4.6.0-SNAPSHOT") .resolveAs(EnterpriseArchive.class) .iterator() .next(); // merge rhq.ear into testEar but include only the EJB jars and the supporting libraries. Note // that we // don't include the services sar because tests are responsible for prepare/unprepare of all // required services, // we don't want the production services performig any unexpected work. testEar = testEar.merge(rhqEar, Filters.include("/lib.*|/rhq.*ejb3\\.jar.*")); // remove startup beans and shutdown listeners, we don't want this to be a full server // deployment. The tests // start/stop what they need, typically with test services or mocks. testEar.delete( ArchivePaths.create( "/rhq-enterprise-server-ejb3.jar/org/rhq/enterprise/server/core/StartupBean.class")); testEar.delete( ArchivePaths.create( "/rhq-enterprise-server-ejb3.jar/org/rhq/enterprise/server/core/StartupBean$1.class")); testEar.delete( ArchivePaths.create( "/rhq-enterprise-server-ejb3.jar/org/rhq/enterprise/server/core/StartupBeanPreparation.class")); testEar.delete( ArchivePaths.create( "/rhq-enterprise-server-ejb3.jar/org/rhq/enterprise/server/core/ShutdownListener.class")); // replace the above startup beans with stripped down versions testEar.add( new ClassAsset(StrippedDownStartupBean.class), ArchivePaths.create( "/rhq-enterprise-server-ejb3.jar/org/rhq/enterprise/server/test/StrippedDownStartupBean.class")); testEar.add( new ClassAsset(StrippedDownStartupBeanPreparation.class), ArchivePaths.create( "/rhq-enterprise-server-ejb3.jar/org/rhq/enterprise/server/test/" + "StrippedDownStartupBeanPreparation.class")); // add the test classes to the deployment testEar.addAsLibrary(testClassesJar); // add the necessary AS7 dependency modules testEar.addAsManifestResource("jboss-deployment-structure.xml"); // add the application xml declaring the ejb jars testEar.setApplicationXML("application.xml"); // add additional 3rd party dependent jars needed to support test classes MavenDependencyResolver resolver = DependencyResolvers.use(MavenDependencyResolver.class); resolver.loadMetadataFromPom("pom.xml"); Collection<JavaArchive> dependencies = new HashSet<JavaArchive>(); dependencies.addAll( resolver.artifact("org.powermock:powermock-api-mockito").resolveAs(JavaArchive.class)); dependencies.addAll( resolver.artifact("org.liquibase:liquibase-core").resolveAs(JavaArchive.class)); dependencies.addAll(resolver.artifact("joda-time:joda-time").resolveAs(JavaArchive.class)); dependencies.addAll( resolver .artifact("org.jboss.shrinkwrap:shrinkwrap-impl-base") .resolveAs(JavaArchive.class)); dependencies.addAll( resolver.artifact("org.rhq:rhq-core-client-api:jar:tests").resolveAs(JavaArchive.class)); dependencies.addAll(resolver.artifact("org.rhq:test-utils").resolveAs(JavaArchive.class)); dependencies.addAll( resolver.artifact("org.rhq.helpers:perftest-support").resolveAs(JavaArchive.class)); // If we're running oracle we need to include the OJDBC driver because dbunit needs it. Note // that we need // add it explicitly even though it is a provided module used by the datasource. if (!Boolean.valueOf(System.getProperty("rhq.skip.oracle"))) { // in proxy situations (like Jenkins) shrinkwrap won't be able to find repositories defined in // settings.xml profiles. We know at this point the driver is in the local repo, try going // offline // at this point to force local repo resolution since the oracle driver is not in public // repos. // see // http://stackoverflow.com/questions/6291146/arquillian-shrinkwrap-mavendependencyresolver-behind-proxy resolver.goOffline(); dependencies.addAll( resolver .artifact("com.oracle:ojdbc6:jar:" + System.getProperty("rhq.ojdbc.version")) .resolveAs(JavaArchive.class)); } // Transitive deps required by the above and for some reason not sucked in. Note that // these require an explicit version. TODO (jshaughn): Can we make these transitive or // avoid the explicit version? // dep required byt rhq-core-client-api test-jar dependencies.addAll( resolver.artifact("commons-jxpath:commons-jxpath:1.3").resolveAs(JavaArchive.class)); // exclude any transitive deps we don't want String[] excludeFilters = {"testng.*jdk", "rhq-core-domain.*jar"}; dependencies = exclude(dependencies, excludeFilters); testEar.addAsLibraries(dependencies); // Print out the test EAR structure // System.out.println("** The Deployment EAR: " + testEar.toString(true) + "\n"); // Save the test EAR to a zip file for inspection (set file explicitly) // exportZip(testEar, new File("/home/jshaughn/temp/test-ear.ear")); return testEar; }