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

The following examples show how to use org.jboss.shrinkwrap.api.spec.JavaArchive#addAsResource() . 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: ServiceActivatorDeploymentUtil.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static void createServiceActivatorDeployment(File destination, String objectName, Class mbeanClass) throws IOException {
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class);
    archive.addClass(ServiceActivatorDeployment.class);
    archive.addClass(mbeanClass);
    archive.addAsServiceProvider(ServiceActivator.class, ServiceActivatorDeployment.class);
    StringBuilder sb = new StringBuilder();
    sb.append(ServiceActivatorDeployment.MBEAN_CLASS_NAME);
    sb.append('=');
    sb.append(mbeanClass.getName());
    sb.append("\n");
    sb.append(ServiceActivatorDeployment.MBEAN_OBJECT_NAME);
    sb.append('=');
    sb.append(objectName);
    sb.append("\n");
    archive.addAsManifestResource(PermissionUtils.createPermissionsXmlAsset(
            getMBeanPermission(mbeanClass, objectName, "registerMBean"),
            getMBeanPermission(mbeanClass, objectName, "unregisterMBean"),
            new MBeanTrustPermission("register")),
            "permissions.xml");
    archive.addAsManifestResource(new StringAsset("Dependencies: org.jboss.msc,org.jboss.as.jmx,org.jboss.as.server,org.jboss.as.controller\n"), "MANIFEST.MF");
    archive.addAsResource(new StringAsset(sb.toString()), ServiceActivatorDeployment.PROPERTIES_RESOURCE);
    archive.as(ZipExporter.class).exportTo(destination);
}
 
Example 2
Source File: SpringContextScanTest.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, "context-scan-tests");
    archive.addAsResource("spring/context-scanA-camel-context.xml");
    archive.addClasses(ScannedComponentRouteBuilder.class);
    return archive;
}
 
Example 3
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 4
Source File: JcrIntegrationTest.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Deployment
public static JavaArchive createDeployment() {
    JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "camel-jcr-tests.jar");
    archive.addAsResource("jcr/repository-simple-security.xml");
    archive.addClasses(FileUtils.class, IOUtils.class);
    archive.setManifest(() -> {
        ManifestBuilder builder = new ManifestBuilder();
        builder.addManifestHeader("Dependencies", "org.apache.jackrabbit");
        return builder.openStream();
    });
    return archive;
}
 
Example 5
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 6
Source File: SpringPackageScanTest.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, "package-scan-tests");
    archive.addAsResource("spring/package-scan-camel-context.xml", "package-scan-camel-context.xml");
    archive.addClasses(ScannedComponentRouteBuilder.class);
    return archive;
}
 
Example 7
Source File: XSLTIntegrationTest.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, "camel-xslt-tests");
    archive.addAsResource("xslt/customer-nons.xml", "customer-nons.xml");
    archive.addAsResource("xslt/customer.xml", "customer.xml");
    archive.addAsResource("xslt/transform.xsl", "transform.xsl");
    archive.addClasses(OrderBean.class, TestUtils.class);
    return archive;
}
 
Example 8
Source File: DomainSuspendResumeTestCase.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 9
Source File: JBossAllCamelDisabledWithAnnotationTest.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, "no-camel-with-annotation");
    archive.addAsResource("classloading/jboss-all-no-camel.xml", "META-INF/jboss-all.xml");
    archive.addClass(CdiRouteBuilder.class);
    return archive;
}
 
Example 10
Source File: ProjectWithFailedTransitiveDependenciesBuildTest.java    From pnc with Apache License 2.0 5 votes vote down vote up
@Deployment
public static JavaArchive createDeployment() {
    JavaArchive deployment = BuildCoordinatorDeployments.deployment(
            BuildCoordinatorDeployments.Options.WITH_DATASTORE,
            BuildCoordinatorDeployments.Options.WITH_BPM);
    deployment.addAsResource("pnc-config-one-parallel-only.json");
    System.setProperty(CONFIG_SYSPROP, "pnc-config-one-parallel-only.json");
    return deployment;
}
 
Example 11
Source File: JCacheMBeansTest.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, "jcache-mbeans-tests");
    archive.addAsResource("jcache/jcache-camel-context.xml", "some-other-name.xml");
    archive.setManifest(new Asset() {
        @Override
        public InputStream openStream() {
            ManifestBuilder builder = new ManifestBuilder();
            builder.addManifestHeader("Dependencies", "org.jboss.as.controller-client");
            return builder.openStream();
        }
    });
    return archive;
}
 
Example 12
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 13
Source File: ShrinkWrapFatJarPackageService.java    From vertx-maven-plugin with Apache License 2.0 5 votes vote down vote up
private void embedFileSet(Log log, MavenProject project, FileSet fs, JavaArchive jar) {
    File directory = new File(fs.getDirectory());
    if (!directory.isAbsolute()) {
        directory = new File(project.getBasedir(), fs.getDirectory());
    }

    if (!directory.isDirectory()) {
        log.warn("File set root directory (" + directory.getAbsolutePath() + ") does not exist " +
            "- skipping");
        return;
    }

    DirectoryScanner scanner = new DirectoryScanner();
    scanner.setBasedir(directory);
    if (fs.getOutputDirectory() == null) {
        fs.setOutputDirectory("/");
    } else if (!fs.getOutputDirectory().startsWith("/")) {
        fs.setOutputDirectory("/" + fs.getOutputDirectory());
    }
    List<String> excludes = fs.getExcludes();
    if (fs.isUseDefaultExcludes()) {
        excludes.addAll(FileUtils.getDefaultExcludesAsList());
    }
    if (!excludes.isEmpty()) {
        scanner.setExcludes(excludes.toArray(new String[0]));
    }
    if (!fs.getIncludes().isEmpty()) {
        scanner.setIncludes(fs.getIncludes().toArray(new String[0]));
    }
    scanner.scan();
    String[] files = scanner.getIncludedFiles();
    for (String path : files) {
        File file = new File(directory, path);
        log.debug("Adding " + fs.getOutputDirectory() + path + " to the archive");
        jar.addAsResource(file, fs.getOutputDirectory() + path);
    }
}
 
Example 14
Source File: SpringBeanTransformTest.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-spring-tests");
    archive.addClasses(HelloBean.class);
    archive.addAsResource("spring/bean-transformB-camel-context.xml", "some-other-name.xml");
    return archive;
}
 
Example 15
Source File: SalesforceSpringIntegrationTest.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Deployment
public static JavaArchive createDeployment() {
    JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "camel-salesforce-spring-tests.jar");
    if (hasSalesforceEnvVars()) archive.addAsResource("salesforce/salesforce-camel-context.xml");
    archive.addPackage(Order.class.getPackage());
    return archive;
}
 
Example 16
Source File: CXFSpringContextTest.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, "cxf-spring-context-tests");
    archive.addClasses(Endpoint.class);
    archive.addAsResource("cxf/spring/cxfws-producer-camel-context.xml");
    return archive;
}
 
Example 17
Source File: AbstractTest.java    From microprofile-config with Apache License 2.0 4 votes vote down vote up
public static void addFile(JavaArchive archive, String originalFile, String targetFile) {
    archive.addAsResource(new UrlAsset(Thread.currentThread().getContextClassLoader().getResource(originalFile)),
            targetFile);
}
 
Example 18
Source File: SpringFileCharsetTest.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-charset-tests.jar");
    archive.addAsResource("spring/charset-camel-context.xml");
    return archive;
}
 
Example 19
Source File: MvelTransformTest.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-mvel-tests");
    archive.addAsResource("mvel/template.mvel", "template.mvel");
    return archive;
}
 
Example 20
Source File: SpringBatchIntegrationTest.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, "spring-batch-tests");
    archive.addAsResource("spring/batch/springbatch-camel-context.xml");
    return archive;
}