@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; }
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; }
@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); }
@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 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; }