Search in sources :

Example 11 with ByteArrayAsset

use of org.jboss.shrinkwrap.api.asset.ByteArrayAsset in project wildfly by wildfly.

the class EarLibClassPathTransitiveClosureTestCase method deploy.

@Deployment
public static Archive<?> deploy() {
    WebArchive war = ShrinkWrap.create(WebArchive.class);
    JavaArchive libJar = ShrinkWrap.create(JavaArchive.class);
    libJar.addClasses(TestAA.class, EarLibClassPathTransitiveClosureTestCase.class);
    war.addAsLibraries(libJar);
    EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class);
    ear.addAsModule(war);
    JavaArchive earLib = ShrinkWrap.create(JavaArchive.class, "earLib.jar");
    earLib.addAsManifestResource(new ByteArrayAsset("Class-Path: ../cp1.jar\n".getBytes(StandardCharsets.UTF_8)), "MANIFEST.MF");
    ear.addAsLibraries(earLib);
    earLib = ShrinkWrap.create(JavaArchive.class, "cp1.jar");
    earLib.addAsManifestResource(new ByteArrayAsset("Class-Path: cp2.jar\n".getBytes(StandardCharsets.UTF_8)), "MANIFEST.MF");
    ear.addAsModule(earLib);
    earLib = ShrinkWrap.create(JavaArchive.class, "cp2.jar");
    earLib.addClass(TestBB.class);
    ear.addAsModule(earLib);
    return ear;
}
Also used : EnterpriseArchive(org.jboss.shrinkwrap.api.spec.EnterpriseArchive) ByteArrayAsset(org.jboss.shrinkwrap.api.asset.ByteArrayAsset) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 12 with ByteArrayAsset

use of org.jboss.shrinkwrap.api.asset.ByteArrayAsset in project wildfly by wildfly.

the class AbstractConfigTestCase method createLoggingConfiguration.

static Asset createLoggingConfiguration(final String fileName) throws IOException {
    final Properties properties = new Properties();
    // Configure the root logger
    properties.setProperty("logger.level", "INFO");
    properties.setProperty("logger.handlers", fileName);
    // Configure the handler
    properties.setProperty("handler." + fileName, "org.jboss.logmanager.handlers.FileHandler");
    properties.setProperty("handler." + fileName + ".level", "ALL");
    properties.setProperty("handler." + fileName + ".formatter", "json");
    properties.setProperty("handler." + fileName + ".properties", "append,autoFlush,fileName");
    properties.setProperty("handler." + fileName + ".append", "false");
    properties.setProperty("handler." + fileName + ".autoFlush", "true");
    properties.setProperty("handler." + fileName + ".fileName", "${jboss.server.log.dir}" + File.separatorChar + fileName);
    // Add the JSON formatter
    properties.setProperty("formatter.json", "org.jboss.logmanager.formatters.JsonFormatter");
    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    properties.store(new OutputStreamWriter(out, StandardCharsets.UTF_8), null);
    return new ByteArrayAsset(out.toByteArray());
}
Also used : ByteArrayAsset(org.jboss.shrinkwrap.api.asset.ByteArrayAsset) OutputStreamWriter(java.io.OutputStreamWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Properties(java.util.Properties)

Example 13 with ByteArrayAsset

use of org.jboss.shrinkwrap.api.asset.ByteArrayAsset in project wildfly by wildfly.

the class EarModuleDeploymentTestCase method jarArchive.

public static JavaArchive jarArchive(String name, Class<?>... classes) throws Exception {
    JavaArchive javaArchive = ShrinkWrap.create(JavaArchive.class, name).addAsResource(new StringAsset("<ejb-jar version=\"3.0\" metadata-complete=\"true\"></ejb-jar>"), "META-INF/ejb-jar.xml");
    Indexer indexer = new Indexer();
    for (Class<?> aClass : classes) {
        javaArchive.addClass(aClass);
        try (InputStream resource = aClass.getResourceAsStream(aClass.getSimpleName() + ".class")) {
            indexer.index(resource);
        }
    }
    Index index = indexer.complete();
    ByteArrayOutputStream data = new ByteArrayOutputStream();
    IndexWriter writer = new IndexWriter(data);
    writer.write(index);
    javaArchive.addAsManifestResource(new ByteArrayAsset(data.toByteArray()), "jandex.idx");
    return javaArchive;
}
Also used : StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) Indexer(org.jboss.jandex.Indexer) ByteArrayAsset(org.jboss.shrinkwrap.api.asset.ByteArrayAsset) IndexWriter(org.jboss.jandex.IndexWriter) InputStream(java.io.InputStream) Index(org.jboss.jandex.Index) ByteArrayOutputStream(java.io.ByteArrayOutputStream) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive)

Example 14 with ByteArrayAsset

use of org.jboss.shrinkwrap.api.asset.ByteArrayAsset in project wicket by apache.

the class AbstractDeploymentTest method deployment.

@Deployment
public static WebArchive deployment() {
    // Create webapp files from src/main/webapp. (WEB AS NORMAL)
    GenericArchive webapp = ShrinkWrap.create(GenericArchive.class).as(ExplodedImporter.class).importDirectory(WEBAPP_SRC).as(GenericArchive.class);
    // Create webapptest files from src/test/webapp. (TEST)
    GenericArchive webappTest = ShrinkWrap.create(GenericArchive.class).as(ExplodedImporter.class).importDirectory(WEBAPP_TEST_SRC).as(GenericArchive.class);
    // Some configurations to create a manifest.mf.
    ByteArrayAsset resource = new ByteArrayAsset("Dependencies: org.jboss.msc".getBytes());
    // Create libs from POM.XML.
    File[] asFile = Maven.configureResolver().workOffline().withMavenCentralRepo(false).loadPomFromFile("./pom.xml").importCompileAndRuntimeDependencies().resolve().withTransitivity().asFile();
    // Create the WAR.
    return ShrinkWrap.create(WebArchive.class, "wicket-servletContext8.war").addPackages(true, TestWicketJavaEEApplication.class.getPackage()).addAsResource("META-INF/persistence.xml").addAsManifestResource(resource, "MANIFEST.MF").merge(webapp, "/", Filters.exclude(".*\\web.xml")).merge(webappTest, "/", Filters.includeAll()).addAsLibraries(asFile);
}
Also used : GenericArchive(org.jboss.shrinkwrap.api.GenericArchive) ByteArrayAsset(org.jboss.shrinkwrap.api.asset.ByteArrayAsset) File(java.io.File) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 15 with ByteArrayAsset

use of org.jboss.shrinkwrap.api.asset.ByteArrayAsset in project camunda-bpm-platform by camunda.

the class TestFoxPlatformClientAsEjbModule_onePaAsLib method onePaAsLib.

/**
 * Deployment layout
 *
 * test-application.ear
 *    |-- lib /
 *        |-- processes.jar
 *          |-- META-INF/processes.xml
 *          |-- org/camunda/bpm/integrationtest/testDeployProcessArchive.bpmn20.xml
 *
 *    |-- fox-platform-client.jar  <<===============================||
 *                                                                  ||  Class-Path reference
 *    |-- test.war (contains the test-class but also processes)     ||
 *        |-- META-INF/MANIFEST.MF =================================||
 *        |-- WEB-INF/beans.xml
 *        |-- + test classes
 */
@Deployment
public static EnterpriseArchive onePaAsLib() {
    JavaArchive processArchiveJar = ShrinkWrap.create(JavaArchive.class, "processes.jar").addAsResource("org/camunda/bpm/integrationtest/testDeployProcessArchive.bpmn20.xml").addAsResource("META-INF/processes.xml", "META-INF/processes.xml");
    JavaArchive foxPlatformClientJar = DeploymentHelper.getEjbClient();
    WebArchive testJar = ShrinkWrap.create(WebArchive.class, "test.war").addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml").setManifest(new ByteArrayAsset(("Class-Path: " + foxPlatformClientJar.getName() + "\n").getBytes())).addClass(AbstractFoxPlatformIntegrationTest.class).addClass(TestFoxPlatformClientAsEjbModule_onePaAsLib.class);
    return ShrinkWrap.create(EnterpriseArchive.class, "onePaAsLib.ear").addAsLibrary(processArchiveJar).addAsModule(foxPlatformClientJar).addAsModule(testJar).addAsLibrary(DeploymentHelper.getEngineCdi());
}
Also used : ByteArrayAsset(org.jboss.shrinkwrap.api.asset.ByteArrayAsset) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) AbstractFoxPlatformIntegrationTest(org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Aggregations

ByteArrayAsset (org.jboss.shrinkwrap.api.asset.ByteArrayAsset)24 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)11 ByteArrayOutputStream (java.io.ByteArrayOutputStream)9 Deployment (org.jboss.arquillian.container.test.api.Deployment)8 WebArchive (org.jboss.shrinkwrap.api.spec.WebArchive)6 EnterpriseArchive (org.jboss.shrinkwrap.api.spec.EnterpriseArchive)5 InputStream (java.io.InputStream)4 Index (org.jboss.jandex.Index)4 IndexWriter (org.jboss.jandex.IndexWriter)4 Indexer (org.jboss.jandex.Indexer)4 StringAsset (org.jboss.shrinkwrap.api.asset.StringAsset)4 File (java.io.File)3 WildFlySwarmManifest (org.wildfly.swarm.bootstrap.env.WildFlySwarmManifest)3 JAXRSArchive (org.wildfly.swarm.jaxrs.JAXRSArchive)3 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 URL (java.net.URL)2 Properties (java.util.Properties)2 Attributes (java.util.jar.Attributes)2 Manifest (java.util.jar.Manifest)2