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