Java Code Examples for org.jboss.shrinkwrap.api.spec.EnterpriseArchive#addAsModule()

The following examples show how to use org.jboss.shrinkwrap.api.spec.EnterpriseArchive#addAsModule() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Deployments.java    From pnc with Apache License 2.0 6 votes vote down vote up
public static EnterpriseArchive testEar() {
    EnterpriseArchive ear = ShrinkWrap.createFromZipFile(EnterpriseArchive.class, getBaseEar());

    WebArchive restWar = prepareRestArchive(ear);
    ear.addAsModule(archiveToTest(restWar));
    // remove the old rest
    ear.delete("rest.war");

    addTestPersistenceXml(ear);
    ear.setApplicationXML("application-new.xml");

    addKeycloakServiceClientMock(ear);

    logger.info("Ear archive listing: {}", ear.toString(true));

    return ear;
}
 
Example 2
Source File: EventStorePersistenceJPATest.java    From JEEventStore with MIT License 6 votes vote down vote up
@Deployment
public static EnterpriseArchive deployment() {
    EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "test.ear");
    DefaultDeployment.addDependencies(ear, "org.jeeventstore:jeeventstore-persistence-jpa", false);
    ear.addAsModule(ShrinkWrap.create(JavaArchive.class, "ejb.jar")
            .addAsManifestResource(new File("src/test/resources/META-INF/beans.xml"))
            .addAsManifestResource(new File("src/test/resources/META-INF/persistence.xml"))
            .addAsManifestResource(new File(
                    "src/test/resources/META-INF/ejb-jar-EventStorePersistenceJPATest.xml"),
                    "ejb-jar.xml")
            .addClass(XMLSerializer.class)
            .addClass(TestUTF8Utils.class)
            .addClass(PersistenceTestHelper.class)
            .addPackage(AbstractPersistenceTest.class.getPackage())
            .addPackage(EventStorePersistenceJPA.class.getPackage())
            );
    return ear;
}
 
Example 3
Source File: EarGenericBuilder.java    From arquillian-suite-extension with Apache License 2.0 5 votes vote down vote up
/**
 * Dodaje główny moduł do archiwum EAR.
 *
 * @param ear archiwum EAR
 * @param type typ głównego modułu
 * @param module główny moduł
 * @param descriptorBuilder deskreptor builder dla EAR'a
 */
private static void addMainModule(EnterpriseArchive ear, ModuleType type, Archive<?> module, EarDescriptorBuilder descriptorBuilder) {
    if (type.isModule()) {
        ear.addAsModule(module);
        if (type == ModuleType.EJB) {
            descriptorBuilder.addEjb(module.getName());
        }
        if (type == ModuleType.WAR) {
            descriptorBuilder.addWeb(module.getName());
        }
    } else {
        ear.addAsLibrary(module);
    }
}
 
Example 4
Source File: ModulesTestBase.java    From appengine-tck with Apache License 2.0 5 votes vote down vote up
protected static EnterpriseArchive toEarDeployment(WebArchive... wars) {
    EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "gae-tck.ear");
    for (WebArchive war : wars) {
        war.addClass(ModulesTestBase.class);
        ear.addAsModule(war);
    }
    return ear;
}
 
Example 5
Source File: EventSerializerGsonTest.java    From JEEventStore with MIT License 5 votes vote down vote up
@Deployment
public static EnterpriseArchive deployment() {
    EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "testear.ear");
    DefaultDeployment.addDependencies(ear, "org.jeeventstore:jeeventstore-serialization-gson", false);
    ear.addAsModule(ShrinkWrap.create(JavaArchive.class, "ejb.jar")
            .addAsManifestResource(new File("src/test/resources/META-INF/beans.xml"))
            .addAsManifestResource(
                new File("src/test/resources/META-INF/ejb-jar-EventSerializerGsonTest.xml"),
                         "ejb-jar.xml")
            .addPackage(EventSerializerGson.class.getPackage())
            );
    return ear;
}
 
Example 6
Source File: Deployments.java    From pnc with Apache License 2.0 4 votes vote down vote up
public static void addBuildExecutorMock(EnterpriseArchive enterpriseArchive) {
    JavaArchive jar = enterpriseArchive.getAsType(JavaArchive.class, EXECUTOR_JAR);

    jar.deleteClass(DefaultBuildExecutor.class);

    jar.addPackage(BuildExecutorMock.class.getPackage());
    jar.addClass(BuildDriverResultMock.class);
    jar.addClass(RepositoryManagerResultMock.class);
    jar.addClass(ArtifactBuilder.class);

    jar.addAsManifestResource("beans-use-mock-remote-clients.xml", "beans.xml");

    logger.info(jar.toString(true));

    enterpriseArchive.addAsModule(jar);

}
 
Example 7
Source File: EARTest.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Deployment
public static EnterpriseArchive createDeployment() {

    final JavaArchive apiJar = ShrinkWrap.create(JavaArchive.class, "connector-sample-api.jar");
    apiJar.addPackage("org.superbiz.connector.api");
    System.out.println("API JAR:\n" + apiJar.toString(true));

    final JavaArchive implJar = ShrinkWrap.create(JavaArchive.class, "connector-sample-impl.jar");
    implJar.addPackage("org.superbiz.connector.adapter");
    System.out.println("IMPL JAR:\n" + implJar.toString(true));

    final ResourceAdapterArchive rar = ShrinkWrap.create(ResourceAdapterArchive.class,"connector-sample-ra.rar");
    rar.addAsLibraries(implJar);

    final File raXml = Basedir.basedir("../connector-sample-rar/src/main/rar/META-INF/ra.xml");
    rar.setResourceAdapterXML(raXml);
    System.out.println("RAR:\n" + rar.toString(true));

    final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "connector-sample-war.war");
    webArchive.addPackage("org.superbiz.application");

    final WebAppDescriptor webAppDescriptor = Descriptors.create(WebAppDescriptor.class);
    webAppDescriptor.version("3.0");

    final File resourcesXml = Basedir.basedir("../connector-sample-war/src/main/webapp/WEB-INF/resources.xml");
    webArchive.addAsWebInfResource(resourcesXml);
    webArchive.setWebXML(new StringAsset(webAppDescriptor.exportAsString()));
    webArchive.addAsWebInfResource(resourcesXml);
    webArchive.addAsWebInfResource(new StringAsset("<beans/>"), "beans.xml");
    System.out.println("Webapp:\n" + webArchive.toString(true));

    final EnterpriseArchive enterpriseArchive = ShrinkWrap.create(EnterpriseArchive.class, "connector-sample.ear");
    enterpriseArchive.addAsLibraries(apiJar);
    enterpriseArchive.addAsModule(rar);
    enterpriseArchive.addAsModule(webArchive);

    ApplicationDescriptor applicationXml = Descriptors.create(ApplicationDescriptor.class);
    applicationXml.displayName("connector-sample-ear");
    applicationXml.createModule()
            .getOrCreateWeb()
                .webUri("connector-sample-war.war")
                .contextRoot("/sample")
            .up().up()
            .createModule().connector("connector-sample-ra.rar")
            .up().libraryDirectory("lib");

    enterpriseArchive.setApplicationXML(new StringAsset(applicationXml.exportAsString()));
    System.out.println(enterpriseArchive.toString(true));

    return enterpriseArchive;
}
 
Example 8
Source File: DeployInWebAppsDirectoryTest.java    From tomee with Apache License 2.0 4 votes vote down vote up
public static EnterpriseArchive createDeployment() {

        final JavaArchive apiJar = ShrinkWrap.create(JavaArchive.class, "connector-sample-api.jar");
        apiJar.addPackage("org.superbiz.connector.api");
        System.out.println("API JAR:\n" + apiJar.toString(true));

        final JavaArchive implJar = ShrinkWrap.create(JavaArchive.class, "connector-sample-impl.jar");
        implJar.addPackage("org.superbiz.connector.adapter");
        System.out.println("IMPL JAR:\n" + implJar.toString(true));

        final ResourceAdapterArchive rar = ShrinkWrap.create(ResourceAdapterArchive.class,"connector-sample-ra.rar");
        rar.addAsLibraries(implJar);

        final File raXml = Basedir.basedir("../connector-sample-rar/src/main/rar/META-INF/ra.xml");
        rar.setResourceAdapterXML(raXml);
        System.out.println("RAR:\n" + rar.toString(true));

        final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "connector-sample-war.war");
        webArchive.addPackage("org.superbiz.application");

        final WebAppDescriptor webAppDescriptor = Descriptors.create(WebAppDescriptor.class);
        webAppDescriptor.version("3.0");

        final File resourcesXml = Basedir.basedir("../connector-sample-war/src/main/webapp/WEB-INF/resources.xml");
        webArchive.addAsWebInfResource(resourcesXml);
        webArchive.setWebXML(new StringAsset(webAppDescriptor.exportAsString()));
        webArchive.addAsWebInfResource(resourcesXml);
        webArchive.addAsWebInfResource(new StringAsset("<beans/>"), "beans.xml");
        System.out.println("Webapp:\n" + webArchive.toString(true));

        final EnterpriseArchive enterpriseArchive = ShrinkWrap.create(EnterpriseArchive.class, "connector-sample.ear");
        enterpriseArchive.addAsLibraries(apiJar);
        enterpriseArchive.addAsModule(rar);
        enterpriseArchive.addAsModule(webArchive);

        ApplicationDescriptor applicationXml = Descriptors.create(ApplicationDescriptor.class);
        applicationXml.displayName("connector-sample-ear");
        applicationXml.createModule()
                .getOrCreateWeb()
                .webUri("connector-sample-war.war")
                .contextRoot("/sample")
                .up().up()
                .createModule().connector("connector-sample-ra.rar")
                .up().libraryDirectory("lib");

        enterpriseArchive.setApplicationXML(new StringAsset(applicationXml.exportAsString()));
        System.out.println(enterpriseArchive.toString(true));

        return enterpriseArchive;
    }
 
Example 9
Source File: ConnectorWithApplicationResourcesInEarTest.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Deployment
public static EnterpriseArchive createDeployment() {

    final JavaArchive apiJar = ShrinkWrap.create(JavaArchive.class, "connector-sample-api.jar");
    apiJar.addPackage("org.superbiz.connector.api");
    System.out.println("API JAR:\n" + apiJar.toString(true));

    final JavaArchive implJar = ShrinkWrap.create(JavaArchive.class, "connector-sample-impl.jar");
    implJar.addPackage("org.superbiz.connector.adapter");
    System.out.println("IMPL JAR:\n" + implJar.toString(true));

    final ResourceAdapterArchive rar = ShrinkWrap.create(ResourceAdapterArchive.class,"connector-sample-ra.rar");
    rar.addAsLibraries(implJar);

    rar.setResourceAdapterXML(ConnectorWithApplicationResourcesInEarTest.class.getResource("/connector/ra.xml"));
    System.out.println("RAR:\n" + rar.toString(true));

    final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "connector-sample-war.war");
    webArchive.addPackage("org.superbiz.application");

    final WebAppDescriptor webAppDescriptor = Descriptors.create(WebAppDescriptor.class);
    webAppDescriptor.version("3.0");

    webArchive.addAsWebInfResource(ConnectorWithApplicationResourcesInEarTest.class.getResource("/connector/resources.xml"), "resources.xml");
    webArchive.setWebXML(new StringAsset(webAppDescriptor.exportAsString()));
    System.out.println("Webapp:\n" + webArchive.toString(true));

    final EnterpriseArchive enterpriseArchive = ShrinkWrap.create(EnterpriseArchive.class, "connector-sample.ear");
    enterpriseArchive.addAsLibraries(apiJar);
    enterpriseArchive.addAsModule(rar);
    enterpriseArchive.addAsModule(webArchive);

    ApplicationDescriptor applicationXml = Descriptors.create(ApplicationDescriptor.class);
    applicationXml.displayName("connector-sample-ear");
    applicationXml.createModule()
            .getOrCreateWeb()
                .webUri("connector-sample-war.war")
                .contextRoot("/sample")
            .up().up()
            .createModule().connector("connector-sample-ra.rar")
            .up().libraryDirectory("lib");

    enterpriseArchive.setApplicationXML(new StringAsset(applicationXml.exportAsString()));
    System.out.println(enterpriseArchive.toString(true));

    return enterpriseArchive;
}
 
Example 10
Source File: Deployments.java    From pnc with Apache License 2.0 3 votes vote down vote up
private static void addKeycloakServiceClientMock(EnterpriseArchive enterpriseArchive) {
    JavaArchive jar = enterpriseArchive.getAsType(JavaArchive.class, AUTH_JAR);

    jar.deleteClass(DefaultKeycloakServiceClient.class);
    jar.addClass(KeycloakServiceClientMock.class);

    jar.addAsManifestResource("beans-use-mock-remote-clients.xml", "beans.xml");

    logger.info(jar.toString(true));

    enterpriseArchive.addAsModule(jar);
}