@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;
  }
コード例 #2
0
  /**
   * 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;
  }
コード例 #3
0
  @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;
  }
コード例 #4
0
ファイル: AbstractEJB3Test.java プロジェクト: metlos/RHQ-old
  @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;
  }