Java Code Examples for org.jboss.shrinkwrap.api.spec.JavaArchive#addPackage()

The following examples show how to use org.jboss.shrinkwrap.api.spec.JavaArchive#addPackage() . 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: ExtensionUtils.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static void storePackage(Package pkg, ClassLoader classLoader, JavaArchive archive) throws IOException {
    archive.addPackage(pkg);

    // Store misc files that shrinkwrap apparently doesn't
    String packagePath = pkg.getName().replace('.', '/');
    Enumeration<URL> resources = classLoader.getResources(packagePath);
    while (resources.hasMoreElements()) {
        URL url = resources.nextElement();
        String urlPath = url.getFile();
        int bangIndex = urlPath.indexOf('!');
        if (bangIndex < 0) {
            storeMiscPackageContentsFromDirectory(url, packagePath, classLoader, archive);
        } else {
            String archivePath = urlPath.substring(0, bangIndex);
            storeMiscPackageContentsFromArchive(archivePath, packagePath, classLoader, archive);
        }
    }
}
 
Example 2
Source File: SuspendResumeTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@BeforeClass
public static void deploy() throws Exception {
    //ServerDeploymentHelper helper = new ServerDeploymentHelper(managementClient.getControllerClient());
    JavaArchive war = ShrinkWrap.create(JavaArchive.class, WEB_SUSPEND_JAR);
    war.addPackage(SuspendResumeHandler.class.getPackage());
    war.addAsServiceProvider(ServiceActivator.class, TestSuspendServiceActivator.class);
    war.addAsResource(new StringAsset("Dependencies: org.jboss.dmr, org.jboss.as.controller, io.undertow.core, org.jboss.as.server,org.wildfly.extension.request-controller, org.jboss.as.network\n"), "META-INF/MANIFEST.MF");
    war.addAsManifestResource(PermissionUtils.createPermissionsXmlAsset(
        new RuntimePermission("createXnioWorker"),
        new SocketPermission(TestSuiteEnvironment.getServerAddress() + ":8080", "listen,resolve"),
        new SocketPermission("*", "accept,resolve")
    ), "permissions.xml");
    //helper.deploy(WEB_SUSPEND_JAR, war.as(ZipExporter.class).exportAsInputStream());
    serverController.deploy(war, WEB_SUSPEND_JAR);

}
 
Example 3
Source File: UserManagedTransactionIntegrationTest.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Deployment
public static JavaArchive deployment() {
    JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "camel-jpa-tests.jar");
    archive.addPackage(JpaRouteBuilder.class.getPackage());
    archive.addAsResource("jpa/persistence.xml", "META-INF/persistence.xml");
    archive.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
    return archive;
}
 
Example 4
Source File: ThreadingIntegrationTest.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Deployment
public static JavaArchive createDeployment() throws IOException {
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "camel-thread-tests.jar");
    archive.addPackage(WildFlyCamelThreadPoolFactory.class.getPackage());
    archive.addAsResource("threading/bigfile.csv", "bigfile.csv");
    archive.addAsResource("threading/smallfile.csv", "smallfile.csv");
    archive.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
    return archive;
}
 
Example 5
Source File: CamelAuxiliaryArchiveAppender.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Override
public Archive<?> createAuxiliaryArchive() {
    JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "wildfly-camel-testenricher.jar");
    archive.addAsServiceProvider(RemoteLoadableExtension.class, CamelRemoteLoadableExtension.class);
    archive.addPackage(CamelLoadableExtension.class.getPackage());
    return archive;
}
 
Example 6
Source File: GroovyShellFactoryTest.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Deployment
public static JavaArchive deployment() {
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "script-tests.jar");
    archive.addPackage(CustomGroovyShellFactory.class.getPackage());
    archive.addAsResource("groovy/groovy-transform-camel-context.xml");
    archive.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
    return archive;
}
 
Example 7
Source File: MyTest.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Deployment
public static JavaArchive createDeployment() {
    final JavaArchive  archive = ShrinkWrap.create(JavaArchive.class, "camel-tests.jar");
    archive.addPackage(MyBean.class.getPackage());
    archive.addAsResource(new File("src/main/webapp/META-INF/jboss-camel-context.xml"), "jboss-camel-context.xml");
    return archive;
}
 
Example 8
Source File: TransformerAttachmentAndInspectModelSubsystemTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@BeforeClass
public static void createLegacyJars() throws IOException {
    JavaArchive legacySubsystemArchive = ShrinkWrap.create(JavaArchive.class, "legacy-archive.jar");
    legacySubsystemArchive.addPackage(NewExtension.class.getPackage());
    StreamExporter exporter = legacySubsystemArchive.as(ZipExporter.class);
    Files.deleteIfExists(LEGACY_ARCHIVE);
    exporter.exportTo(LEGACY_ARCHIVE.toFile());
}
 
Example 9
Source File: TransformerSubsystemTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@BeforeClass
public static void createLegacyJars() throws IOException {
    JavaArchive legacySubsystemArchive = ShrinkWrap.create(JavaArchive.class, "legacy-archive-transformers.jar");
    legacySubsystemArchive.addPackage(VersionedExtension2.class.getPackage());
    StreamExporter exporter = legacySubsystemArchive.as(ZipExporter.class);

    Files.deleteIfExists(LEGACY_ARCHIVE);
    exporter.exportTo(LEGACY_ARCHIVE.toFile());
}
 
Example 10
Source File: DomainGracefulShutdownTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static JavaArchive createDeployment() throws Exception {
    JavaArchive jar = ShrinkWrap.create(JavaArchive.class, WEB_SUSPEND_JAR);
    jar.addPackage(SuspendResumeHandler.class.getPackage());
    jar.addAsServiceProvider(ServiceActivator.class, TestSuspendServiceActivator.class);
    jar.addAsResource(new StringAsset("Dependencies: org.jboss.dmr, org.jboss.as.controller, io.undertow.core, org.jboss.as.server,org.wildfly.extension.request-controller, org.jboss.as.network\n"), "META-INF/MANIFEST.MF");
    jar.addAsManifestResource(PermissionUtils.createPermissionsXmlAsset(
            new ReflectPermission("suppressAccessChecks"),
            new RuntimePermission("createXnioWorker"),
            new SocketPermission(TestSuiteEnvironment.getServerAddress() + ":8080", "listen,resolve"),
            new SocketPermission("*", "accept,resolve")
    ), "permissions.xml");
    return jar;
}
 
Example 11
Source File: BeanValidatorXMLIntegrationTest.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Deployment
public static JavaArchive deployment() {
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "bean-validator-xml-tests");
    archive.addPackage(CarWithoutAnnotations.class.getPackage());
    archive.addAsManifestResource("beanvalidator/validation.xml", "validation.xml");
    archive.addAsResource("beanvalidator/constraints-car.xml", "constraints-car.xml");
    return archive;
}
 
Example 12
Source File: ProcessStateListenerTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static StreamExporter createResourceRoot(Package... additionalPackages) {
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class);
    if (additionalPackages != null) {
        for (Package pkg : additionalPackages) {
            archive.addPackage(pkg);
        }
    }
    return archive.as(ZipExporter.class);
}
 
Example 13
Source File: MllpTcpServerConsumerTest.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Deployment
public static JavaArchive createdeployment() {
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "camel-mllp-tests");
    archive.addPackage(MllpClientResource.class.getPackage());
    archive.addClasses(AvailablePortFinder.class);
    return archive;
}
 
Example 14
Source File: ArchiveUtils.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
public static JavaArchive getContextControlForDeployment()
{
    JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "cdi-control.jar")
            .addClass(ContextControl.class);

    if (CdiContainerUnderTest.is("owb"))
    {
        jar.addPackage("org.apache.deltaspike.cdise.owb");
    }
    return jar;
}
 
Example 15
Source File: SuspendOnSoftKillTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void startContainer(int suspendTimeout) throws Exception {

        suspendTimeout = suspendTimeout < 1 ? suspendTimeout : TimeoutUtil.adjust(suspendTimeout);

        jbossArgs = System.getProperty("jboss.args");
        String newArgs = jbossArgs == null ? "" : jbossArgs;
        newArgs += " -D[Standalone] -Dorg.wildfly.sigterm.suspend.timeout=" + suspendTimeout;
        System.setProperty("jboss.args", newArgs);

        if (File.pathSeparatorChar == ':'){
            processUtil = new UnixProcessUtil();
        } else {
            processUtil = new WindowsProcessUtil();
        }

        // Start the server
        serverController.start();

        // If there's already the deployment there from a previous test, remove it
        try {
            serverController.undeploy(WEB_SUSPEND_JAR);
        } catch (Exception ignored) {
            // assume it wasn't deployed. if it was we'll fail below
        }

        JavaArchive war = ShrinkWrap.create(JavaArchive.class, WEB_SUSPEND_JAR);
        war.addPackage(SuspendResumeHandler.class.getPackage());
        war.addAsServiceProvider(ServiceActivator.class, TestSuspendServiceActivator.class);
        war.addAsResource(new StringAsset("Dependencies: org.jboss.dmr, org.jboss.as.controller, io.undertow.core, org.jboss.as.server,org.wildfly.extension.request-controller, org.jboss.as.network\n"), "META-INF/MANIFEST.MF");
        war.addAsManifestResource(PermissionUtils.createPermissionsXmlAsset(
                new RuntimePermission("createXnioWorker"),
                new SocketPermission(TestSuiteEnvironment.getServerAddress() + ":8080", "listen,resolve"),
                new SocketPermission("*", "accept,resolve")
        ), "permissions.xml");
        serverController.deploy(war, WEB_SUSPEND_JAR);
    }
 
Example 16
Source File: MailIntegrationCDITest.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Deployment(order = 2)
public static JavaArchive createDeployment() throws IOException {
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "camel-mail-cdi-tests.jar");
    archive.addPackage(MailSessionProducer.class.getPackage());
    archive.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
    return archive;
}
 
Example 17
Source File: ThriftIntegrationTest.java    From wildfly-camel with Apache License 2.0 4 votes vote down vote up
@Deployment
public static JavaArchive createDeployment() {
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "camel-thrift-test");
    archive.addPackage(Work.class.getPackage());
    return archive;
}
 
Example 18
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 19
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 20
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);

}