@Override public String getName() { return delegate.getName(); }
private String createJarURL(JavaArchive jar) { return String.format("staging:/%s", jar.getName()); }
.setManifest(new ByteArrayAsset(("Class-Path: " + foxPlatformClientJar.getName()+"\n").getBytes())) .addClass(AbstractFoxPlatformIntegrationTest.class) .addClass(TestFoxPlatformClientAsEjbModule_onePaAsLib.class);
.setManifest(new ByteArrayAsset(("Class-Path: " + foxPlatformClientJar.getName()+"\n").getBytes())) .addClass(AbstractFoxPlatformIntegrationTest.class) .addClass(TestFoxPlatformClientAsEjbModule_twoPasAsLib.class);
@Test public void shouldCreateArchiveWithCorrectExtensionForJavaArchive() throws Exception { JavaArchive javaArchive = ShrinkWrap.create(JavaArchive.class); String archiveExtension = javaArchive.getName().substring(javaArchive.getName().lastIndexOf(".")); Assert.assertEquals("JavaArchive should have proper extension", ".jar", archiveExtension); }
/** * Ensures we can create a new archive under the default {@link Domain} */ @Test public void createNewArchiveUnderDefaultDomain() { final String archiveName = "test.war"; final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, archiveName); // Test Assert.assertNotNull("A archive should have been created", archive); Assert.assertEquals("Should have the same name as given imput", archiveName, archive.getName()); }
@Test public void shouldCreateJavaArchiveWithGivenName() throws Exception { String archiveName = "testArchive"; JavaArchive javaArchive = ShrinkWrap.create(JavaArchive.class, archiveName); Assert.assertEquals("JavaArchive should have given name", archiveName, javaArchive.getName()); }
public Deployment(String archiveName, Package pkg, boolean show) { this.archiveName = archiveName; ArchivePath metaInf = ArchivePaths.create("META-INF"); archive = ShrinkWrap.create(JavaArchive.class, archiveName); archive.addPackage(pkg); File sourceMetaInf = getSourceMetaInfDir(); addFiles(archive, sourceMetaInf, metaInf); System.out.println(archive.toString(show)); realArchive = new File(getOutputDir(), archive.getName()); archive.as(ZipExporter.class).exportTo(realArchive, true); }
@After public void ls() { System.out.println("test@jboss:/$ ls -l " + archive.getName()); System.out.println(archive.toString(true)); }
@Test // SHRINKWRAP-392 public void shouldHaveEmptyDefaultExtension() { ExplodedImporter explodedImporter = ShrinkWrap.create(ExplodedImporter.class); String explodedImporterArchiveName = explodedImporter.as(JavaArchive.class).getName(); Assert.assertFalse(explodedImporterArchiveName.contains(".")); }
@Override public InputStream openStream() { OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance(); builder.addBundleManifestVersion(2); builder.addBundleSymbolicName(archive.getName()); builder.addBundleVersion("1.0.0"); builder.addImportPackages(ServiceLocator.class, FabricService.class); return builder.openStream(); } });
@Override public InputStream openStream() { OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance(); builder.addBundleManifestVersion(2); builder.addBundleSymbolicName(archive.getName()); builder.addBundleVersion("1.0.0"); builder.addImportPackages(ServiceLocator.class, FabricService.class); builder.addImportPackages(ConfigurationAdmin.class, ServiceTracker.class, Logger.class); return builder.openStream(); } });
@Test public void name() { Assert.assertEquals("Name of the file store should be equal to the name of the underlying archive", this.archive.getName(), this.fileStore.name()); }
@Override public InputStream openStream() { OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance(); builder.addBundleManifestVersion(2); builder.addBundleSymbolicName(archive.getName()); builder.addBundleVersion("1.0.0"); builder.addImportPackages(ServiceLocator.class, FabricService.class); builder.addImportPackages(AbstractCommand.class, Action.class); builder.addImportPackage("org.apache.felix.service.command;status=provisional"); builder.addImportPackages(ConfigurationAdmin.class, ServiceTracker.class, Logger.class); return builder.openStream(); } });
@Deployment public static Archive<?> createTestArchive() { JavaArchive ejb = ShrinkWrap .create( JavaArchive.class, "ModuleMemberRegistrationEarArchiveIT.jar" ) .addClasses( ModuleMemberRegistrationEarArchiveIT.class, Member.class, MemberRegistration.class, Resources.class ) .addAsManifestResource( persistenceXml(), "persistence.xml" ) .addAsManifestResource( EmptyAsset.INSTANCE, "beans.xml" ); String applicationXml = Descriptors.create( ApplicationDescriptor.class ).createModule().ejb( ejb.getName() ).up().exportAsString(); EnterpriseArchive ear = ShrinkWrap .create( EnterpriseArchive.class, "ModuleMemberRegistrationEarArchiveIT.ear" ) .addAsManifestResource( "jboss-deployment-structure-hcann.xml", "jboss-deployment-structure.xml" ) .addAsModules( ejb ) .setApplicationXML( new StringAsset( applicationXml ) ); return ear; }
@Deployment public static Archive<?> createTestArchive() { JavaArchive ejb = ShrinkWrap .create( JavaArchive.class, "MemberRegistrationEarArchiveIT.jar" ) .addClasses( MemberRegistrationEarArchiveIT.class, Member.class, MemberRegistration.class, Resources.class ) .addAsManifestResource( persistenceXml(), "persistence.xml" ) .addAsManifestResource( EmptyAsset.INSTANCE, "beans.xml" ); String applicationXml = Descriptors.create( ApplicationDescriptor.class ).createModule().ejb( ejb.getName() ).up().exportAsString(); EnterpriseArchive ear = ShrinkWrap .create( EnterpriseArchive.class, "MemberRegistrationEarArchiveIT.ear" ) .addAsModules( ejb ) .addAsManifestResource( "jboss-deployment-structure-hcann.xml", "/jboss-deployment-structure.xml" ) .addAsLibraries( PackagerHelper.hibernateSearchLibraries() ) .setApplicationXML( new StringAsset( applicationXml ) ); return ear; }
@Test public void testImportArchiveAsTypeFromStringUsingDefaultFormat() throws Exception { String resourcePath = "/test/cl-test.jar"; GenericArchive archive = ShrinkWrap.create(GenericArchive.class).add( new FileAsset(TestIOUtil.createFileFromResourceName("cl-test.jar")), resourcePath); JavaArchive jar = archive.getAsType(JavaArchive.class, resourcePath).add(new StringAsset("test file content"), "test.txt"); Assert.assertEquals("JAR imported with wrong name", resourcePath, jar.getName()); Assert.assertNotNull("Class in JAR not imported", jar.get("test/classloader/DummyClass.class")); Assert.assertNotNull("Inner Class in JAR not imported", jar.get("test/classloader/DummyClass$DummyInnerClass.class")); Assert.assertNotNull("Should contain a new asset", ((ArchiveAsset) archive.get(resourcePath).getAsset()) .getArchive().get("test.txt")); }
@Test public void testImportArchiveAsTypeFromString() throws Exception { String resourcePath = "/test/cl-test.jar"; GenericArchive archive = ShrinkWrap.create(GenericArchive.class).add( new FileAsset(TestIOUtil.createFileFromResourceName("cl-test.jar")), resourcePath); JavaArchive jar = archive.getAsType(JavaArchive.class, resourcePath, ArchiveFormat.ZIP).add( new StringAsset("test file content"), "test.txt"); Assert.assertEquals("JAR imported with wrong name", resourcePath, jar.getName()); Assert.assertNotNull("Class in JAR not imported", jar.get("test/classloader/DummyClass.class")); Assert.assertNotNull("Inner Class in JAR not imported", jar.get("test/classloader/DummyClass$DummyInnerClass.class")); Assert.assertNotNull("Should contain a new asset", ((ArchiveAsset) archive.get(resourcePath).getAsset()) .getArchive().get("test.txt")); }
@Test public void testImportArchiveAsTypeFromArchivePath() throws Exception { String resourcePath = "/test/cl-test.jar"; GenericArchive archive = ShrinkWrap.create(GenericArchive.class).add( new FileAsset(TestIOUtil.createFileFromResourceName("cl-test.jar")), resourcePath); JavaArchive jar = archive.getAsType(JavaArchive.class, ArchivePaths.create(resourcePath), ArchiveFormat.ZIP) .add(new StringAsset("test file content"), "test.txt"); Assert.assertEquals("JAR imported with wrong name", resourcePath, jar.getName()); Assert.assertNotNull("Class in JAR not imported", jar.get("test/classloader/DummyClass.class")); Assert.assertNotNull("Inner Class in JAR not imported", jar.get("test/classloader/DummyClass$DummyInnerClass.class")); Assert.assertNotNull("Should contain an archive asset", ((ArchiveAsset) archive.get(resourcePath).getAsset()) .getArchive().get("test.txt")); }
@Test public void testImportArchiveAsTypeFromArchivePathUsingDefaultFormat() throws Exception { String resourcePath = "/test/cl-test.jar"; GenericArchive archive = ShrinkWrap.create(GenericArchive.class).add( new FileAsset(TestIOUtil.createFileFromResourceName("cl-test.jar")), resourcePath); JavaArchive jar = archive.getAsType(JavaArchive.class, ArchivePaths.create(resourcePath)).add( new StringAsset("test file content"), "test.txt"); Assert.assertEquals("JAR imported with wrong name", resourcePath, jar.getName()); Assert.assertNotNull("Class in JAR not imported", jar.get("test/classloader/DummyClass.class")); Assert.assertNotNull("Inner Class in JAR not imported", jar.get("test/classloader/DummyClass$DummyInnerClass.class")); Assert.assertNotNull("Should contain an archive asset", ((ArchiveAsset) archive.get(resourcePath).getAsset()) .getArchive().get("test.txt")); }