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;
}
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());
}
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;
}
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);
}
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());
}
Aggregations