public static Asset getStringAsAssetWithReplacements(String string, String[][] replacements) { for (String[] replacement : replacements) { string = string.replaceAll(replacement[0], replacement[1]); } return new ByteArrayAsset(string.getBytes()); }
protected static Asset modelAsAsset(BpmnModelInstance modelInstance) { ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); Bpmn.writeModelToStream(byteStream, modelInstance); byte[] bytes = byteStream.toByteArray(); return new ByteArrayAsset(bytes); }
protected static Asset modelAsAsset(BpmnModelInstance modelInstance) { ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); Bpmn.writeModelToStream(byteStream, modelInstance); byte[] bytes = byteStream.toByteArray(); return new ByteArrayAsset(bytes); }
private void doTestImport(ClassLoaderFactory factory) throws Exception { Compiler compiler = new Compiler(); List<JavaClassFileObject> files = compiler.compile("foo.A", "package foo;\n public class A {}"); assertEquals(1, files.size()); JavaClassFileObject aFile = files.get(0); JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "crash.jar"); jar.add(new ByteArrayAsset(aFile.getBytes()), "foo/A.class"); jar.setManifest(Thread.currentThread().getContextClassLoader().getResource("META-INF/MANIFEST.MF")); ClassLoader cl = factory.getClassLoader(jar); // compiler = new Compiler(cl); files = compiler.compile("B", "import foo.A;\n" + "public class B implements java.util.concurrent.Callable<A> {\n" + "public A call() {\n" + "return new A();\n" + "}\n" + "}"); assertEquals(1, files.size()); LoadingClassLoader loader = new LoadingClassLoader(cl, files); Class<?> B = loader.findClass("B"); Callable<?> asCallable = (Callable<?>)B.newInstance(); Object ret = asCallable.call(); assertNotNull(ret); Class<?> A = ret.getClass(); assertEquals("foo.A", A.getName()); assertEquals(cl, A.getClassLoader()); }
@Deployment(name = "dummy-client", order = 2) public static WebArchive createDummyClientDeployment() { return initWebArchiveDeployment("pa2.war") .addAsResource(new ByteArrayAsset(serializeJavaObjectValue(new PriorityBean())), PRIORITY_BEAN_INSTANCE_FILE); }
@Deployment(name = "dummy-client", order = 2) public static WebArchive createDummyClientDeployment() { final WebArchive webArchive = initWebArchiveDeployment("paJavaSerialization2.war", "org/camunda/bpm/integrationtest/processes-javaSerializationEnabled-pa2.xml") .addAsResource(new ByteArrayAsset(serializeJavaObjectValue(new PriorityBean())), PRIORITY_BEAN_INSTANCE_FILE); return webArchive; }
.setManifest(new ByteArrayAsset(("Class-Path: " + foxPlatformClientJar.getName()+"\n").getBytes())) .addClass(AbstractFoxPlatformIntegrationTest.class) .addClass(TestFoxPlatformClientAsEjbModule_onePaAsLib.class);
private Asset createAsset(InputStream in) throws IOException { StringBuilder str = new StringBuilder(); try (BufferedReader reader = new BufferedReader(new InputStreamReader(in))) { String line = null; while ((line = reader.readLine()) != null) { str.append(line).append("\n"); } } return new ByteArrayAsset(str.toString().getBytes()); }
.setManifest(new ByteArrayAsset(("Class-Path: " + foxPlatformClientJar.getName()+"\n").getBytes())) .addClass(AbstractFoxPlatformIntegrationTest.class) .addClass(TestFoxPlatformClientAsEjbModule_twoPasAsLib.class);
@Override public void replaceBundleActivatorsFile( Archive archive, String fileName, List<String> bundleActivators) throws IOException { ByteArrayOutputStream bundleActivatorAsOutputStream = _getBundleActivatorAsOutputStream(bundleActivators); ByteArrayAsset byteArrayAsset = new ByteArrayAsset( bundleActivatorAsOutputStream.toByteArray()); archive.delete(fileName); archive.add(byteArrayAsset, fileName); }
@Deployment public static JavaArchive getDeployment() { JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "test.jar") .addPackages(true, Root.class.getPackage()) .addPackages(true, RenderRoot.class.getPackage()) .addPackages(true, SolderRoot.class.getPackage()) .addAsManifestResource(new ByteArrayAsset("<beans/>".getBytes()), ArchivePaths.create("beans.xml")); return archive; }
private JavaArchive persistenceConfigurationSerializedAsProperties() { return ShrinkWrap.create(JavaArchive.class) .addAsResource(new ByteArrayAsset(exportPersistenceConfigurationAsProperties().toByteArray()), configurationInstance.get().getPrefix() + "properties"); }
@Deployment public static WebArchive createTestArchive() { return baseDeployment() .addAsWebInfResource(new ByteArrayAsset(SimpleExtension.class.getName().getBytes()), "classes/META-INF/services/" + Extension.class.getName()) .addClasses(AdditionalBeanDeploymentArchiveTest.class, SimpleExtension.class) .addAsLibraries(ShrinkWrap.create(BeanArchive.class).addClass(Dummy.class), ShrinkWrap.create(JavaArchive.class).addClass(Outsider.class)); }
@Deployment public static JavaArchive createTestArchive() { return ShrinkWrap .create(JavaArchive.class) .addClasses(MessagesAdapter.class, MessagesImpl.class, MockFlashContext.class, MessageFactory.class, TemplateMessageImpl.class, BundleTemplateMessageImpl.class, Bundles.class, PhaseEventBridge.class, MockLogger.class, MockLoggerProducer.class, ApplicationBundles.class, UserLocaleProducer.class, DefaultLocaleProducer.class) .addAsManifestResource(new ByteArrayAsset(new byte[0]), ArchivePaths.create("beans.xml")); }
@Deployment public static Archive<?> createTestArchive() { return ShrinkWrap.create(JavaArchive.class).addClass(FacesContextProducer.class) .addAsManifestResource(new ByteArrayAsset(new byte[0]), ArchivePaths.create("beans.xml")); }
@Deployment public static Archive<?> createTestArchive() { return ShrinkWrap.create(JavaArchive.class).addClass(FacesContextProducer.class) .addClass(ExternalContextProducer.class) .addAsManifestResource(new ByteArrayAsset(new byte[0]), ArchivePaths.create("beans.xml")); }
private JavaArchive dbUnitConfigurationSerializedAsProperties() { final DBUnitConfiguration dbUnitConfigurationPrototype = new DBUnitConfiguration(); final Map<String, String> extensionProperties = extractExtensionProperties(arquillianDescriptorInstance.get(), dbUnitConfigurationPrototype.getQualifier()); final ByteArrayOutputStream properties = new PropertiesSerializer(dbUnitConfigurationPrototype.getPrefix()).serializeToProperties(extensionProperties); return ShrinkWrap.create(JavaArchive.class).addAsResource(new ByteArrayAsset(properties.toByteArray()), new DBUnitConfiguration().getPrefix() + "properties"); }
private JavaArchive scriptingConfigurationSerializedAsProperties() { final ScriptingConfiguration scriptingConfigurationPrototype = new ScriptingConfiguration(); final Map<String, String> extensionProperties = extractExtensionProperties(arquillianDescriptorInstance.get(), scriptingConfigurationPrototype.getQualifier()); final ByteArrayOutputStream properties = new PropertiesSerializer(scriptingConfigurationPrototype.getPrefix()).serializeToProperties(extensionProperties); return ShrinkWrap.create(JavaArchive.class) .addAsResource(new ByteArrayAsset(properties.toByteArray()), new ScriptingConfiguration().getPrefix() + "properties"); }
private JavaArchive jpaCacheEvictionConfigurationSerializedAsProperties() { final JpaCacheEvictionConfiguration config = new JpaCacheEvictionConfiguration(); final Map<String, String> extensionProperties = extractExtensionProperties(arquillianDescriptorInstance.get(), config.getQualifier()); final ByteArrayOutputStream output = new PropertiesSerializer(config.getPrefix()).serializeToProperties(extensionProperties); return ShrinkWrap.create(JavaArchive.class) .addAsResource(new ByteArrayAsset(output.toByteArray()), new JpaCacheEvictionConfiguration().getPrefix() + "properties"); }
private JavaArchive jpaCacheEvictionConfigurationSerializedAsProperties() { final JpaCacheEvictionConfiguration config = new JpaCacheEvictionConfiguration(); final Map<String, String> extensionProperties = extractExtensionProperties(arquillianDescriptorInstance.get(), config.getQualifier()); final ByteArrayOutputStream output = new PropertiesSerializer(config.getPrefix()).serializeToProperties(extensionProperties); return ShrinkWrap.create(JavaArchive.class) .addAsResource(new ByteArrayAsset(output.toByteArray()), new JpaCacheEvictionConfiguration().getPrefix() + "properties"); }