static void addMarker(ManifestContainer<?> manifestContainer, String markerName) { manifestContainer.addAsManifestResource(new StringAsset("marker"), ArchivePaths.create(PATH_MARKERS, markerName)); }
/** * Process manifest resources. * * @param archive */ protected void processManifestResources(ManifestContainer<?> archive) { if (manifestResources != null) { for (ResourceDescriptor resource : manifestResources) { if (resource.getTarget() == null) { archive.addAsManifestResource(resource.getSource()); } else { archive.addAsManifestResource(resource.getSource(), resource.getTarget()); } } } if (serviceProviders != null) { for (ServiceProviderDescriptor descriptor : serviceProviders) { archive.addAsServiceProvider(descriptor.getServiceInterface(), descriptor.getServiceImplementations()); } } }
public ArchiveBuilder setManifest(Asset manifestAsset) { ManifestContainer<?> container = (ManifestContainer<?>) archive; container.setManifest(manifestAsset); return this; }
@Test(expected = IllegalArgumentException.class) @ArchiveType(ManifestContainer.class) public void testAddServiceProviderStringImplementationsValidation() throws Exception { getManifestContainer().addAsServiceProvider("do.not.exist.impl.Dummy1", (String[]) null); }
@Test @ArchiveType(ManifestContainer.class) public void testAddManifestPackages() throws Exception { getManifestContainer().addAsManifestResources(AssetUtil.class.getPackage(), "Test.properties", "Test2.properties"); ArchivePath testPath = new BasicPath(getManifestPath(), NAME_TEST_PROPERTIES); ArchivePath testPath2 = new BasicPath(getManifestPath(), NAME_TEST_PROPERTIES_2); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); Assert.assertTrue("Archive should contain " + testPath2, getArchive().contains(testPath2)); }
@Test(expected = IllegalArgumentException.class) @ArchiveType(ManifestContainer.class) public void testAddServiceProviderStringInterfaceValidation() throws Exception { String[] impls = { "do.not.exist.impl.Dummy1", "do.not.exist.impl.Dummy2", "do.not.exist.impl.Dummy3" }; getManifestContainer().addAsServiceProvider(null, impls); }
static void addMarker(ManifestContainer<?> manifestContainer, String markerName) { manifestContainer.addAsManifestResource(new StringAsset("marker"), ArchivePaths.create(PATH_MARKERS, markerName)); }
@Test @ArchiveType(ManifestContainer.class) public void testSetManifestResourceInPackage() throws Exception { getManifestContainer().setManifest(AssetUtil.class.getPackage(), "Test.properties"); ArchivePath testPath = new BasicPath(getManifestPath(), MANIFEST_FILE); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test(expected = IllegalArgumentException.class) @ArchiveType(ManifestContainer.class) public void testAddServiceProviderStringImplementationsValueValidation() throws Exception { String[] impls = { "do.not.exist.impl.Dummy1", null }; getManifestContainer().addAsServiceProvider("do.not.exist.impl.Dummy", impls); }
manifestContainer.addAsManifestResource(new Asset() { public InputStream openStream() { try {
/** * https://jira.jboss.org/jira/browse/SHRINKWRAP-142 * * @throws Exception */ @Test @ArchiveType(ManifestContainer.class) public void testSetManifestResource() throws Exception { getManifestContainer().setManifest(NAME_TEST_PROPERTIES); ArchivePath testPath = new BasicPath(getManifestPath(), MANIFEST_FILE); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test @ArchiveType(ManifestContainer.class) public void testAddServiceProvider() throws Exception { getManifestContainer().addAsServiceProvider(DummyInterfaceForTest.class, DummyClassForTest.class); ArchivePath testPath = new BasicPath(getManifestPath(), "services/" + DummyInterfaceForTest.class.getName()); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test(expected = IllegalArgumentException.class) @ArchiveType(ManifestContainer.class) public void testAddNonExistentManifestResource() throws Exception { final String nonExistentResourceName = "ejb/security/ejb-jar.xml"; // Since the resource doesn't exist the ManifestContainer implementation throws the expected exception getManifestContainer().addAsManifestResource(nonExistentResourceName); }
/** * https://jira.jboss.org/jira/browse/SHRINKWRAP-142 * * @throws Exception */ @Test @ArchiveType(ManifestContainer.class) public void testSetManifestURL() throws Exception { getManifestContainer().setManifest(getURLForClassResource(NAME_TEST_PROPERTIES)); ArchivePath testPath = new BasicPath(getManifestPath(), MANIFEST_FILE); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test @ArchiveType(ManifestContainer.class) public void testAddServiceProviderString() throws Exception { String[] impls = { "do.not.exist.impl.Dummy1", "do.not.exist.impl.Dummy2", "do.not.exist.impl.Dummy3" }; String serviceInterface = "do.not.exist.api.Dummy"; getManifestContainer().addAsServiceProvider(serviceInterface, impls); ArchivePath testPath = new BasicPath(getManifestPath(), "services/" + serviceInterface); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); assertServiceProviderContent(getArchive().get(testPath), impls); }
@Test @ArchiveType(ManifestContainer.class) public void testAddManifestPackageStringTarget() throws Exception { getManifestContainer().addAsManifestResource(AssetUtil.class.getPackage(), "Test.properties", "Test.txt"); ArchivePath testPath = new BasicPath(getManifestPath(), "Test.txt"); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
/** * https://jira.jboss.org/jira/browse/SHRINKWRAP-142 * * @throws Exception */ @Test @ArchiveType(ManifestContainer.class) public void testSetManifestAsset() throws Exception { getManifestContainer().setManifest(getAssetForClassResource(NAME_TEST_PROPERTIES)); ArchivePath testPath = new BasicPath(getManifestPath(), MANIFEST_FILE); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test @ArchiveType(ManifestContainer.class) public void testAddManifestPackage() throws Exception { getManifestContainer().addAsManifestResource(AssetUtil.class.getPackage(), "Test.properties"); ArchivePath testPath = new BasicPath(getManifestPath(), NAME_TEST_PROPERTIES); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
/** * https://jira.jboss.org/jira/browse/SHRINKWRAP-142 * * @throws Exception */ @Test @ArchiveType(ManifestContainer.class) public void testSetManifestFile() throws Exception { getManifestContainer().setManifest(getFileForClassResource(NAME_TEST_PROPERTIES)); ArchivePath testPath = new BasicPath(getManifestPath(), MANIFEST_FILE); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }
@Test @ArchiveType(ManifestContainer.class) public void testAddManifestPackagePathTarget() throws Exception { ArchivePath targetPath = ArchivePaths.create("Test.txt"); getManifestContainer().addAsManifestResource(AssetUtil.class.getPackage(), "Test.properties", targetPath); ArchivePath testPath = new BasicPath(getManifestPath(), targetPath); Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath)); }