FELIX-4491, FELIX-4718, FELIX-4719:
- (large patch due to unexpected downtime of SVN);
- added support for non-processed resources in deployment packages, which
makes the Felix DP a little more compliant to the OSGi specification. This
should fix FELIX-4491 (and FELIX-4516 as well?);
- reviewed and fixed the snapshot creation/restore functionality used for
the data area of bundles that are upgraded. Both pieces of functionality
were broken and in desparate need of fixing. Added several tests to cover
this functionality.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1643202 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/ResourceInfoImpl.java b/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/ResourceInfoImpl.java
index 07ee847..dc43c38 100644
--- a/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/ResourceInfoImpl.java
+++ b/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/ResourceInfoImpl.java
@@ -27,7 +27,7 @@
*/
public class ResourceInfoImpl extends AbstractInfo {
- private String m_resourceProcessor;
+ private final String m_resourceProcessor;
/**
* Create an instance of this class.
@@ -38,7 +38,21 @@
*/
public ResourceInfoImpl(String path, Attributes attributes) throws DeploymentException {
super(path, attributes);
- m_resourceProcessor = attributes.getValue(RESOURCE_PROCESSOR);
+
+ String rp = attributes.getValue(RESOURCE_PROCESSOR);
+ if (rp != null && "".equals(rp.trim())) {
+ rp = null;
+ }
+
+ m_resourceProcessor = rp;
+ }
+
+ /**
+ * @return <code>true</code> if this resource needs to be processed by a customizer/resource processor,
+ * <code>false</code> otherwise.
+ */
+ public boolean isProcessedResource() {
+ return m_resourceProcessor != null;
}
/**
diff --git a/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/spi/DropAllResourcesCommand.java b/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/spi/DropAllResourcesCommand.java
index 95e9273..105faa0 100644
--- a/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/spi/DropAllResourcesCommand.java
+++ b/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/spi/DropAllResourcesCommand.java
@@ -61,18 +61,21 @@
ResourceInfoImpl[] orderedTargetResources = target.getOrderedResourceInfos();
for (int i = orderedTargetResources.length - 1; i >= 0; i--) {
ResourceInfoImpl resourceInfo = orderedTargetResources[i];
+ // FELIX-4491: only resources that need to be processed should be handled...
+ if (!resourceInfo.isProcessedResource()) {
+ session.getLog().log(LogService.LOG_INFO, "Ignoring non-processed resource: " + resourceInfo.getPath());
+ continue;
+ }
String rpName = resourceInfo.getResourceProcessor();
String path = resourceInfo.getPath();
- if (resourceProcessors.contains(rpName)) {
+ // Keep track of which resource processors we've seen already...
+ if (!resourceProcessors.add(rpName)) {
// Already seen this RP; continue on the next one...
continue;
}
- // Keep track of which resource processors we've seen already...
- resourceProcessors.add(rpName);
-
ServiceReference ref = target.getResourceProcessor(path);
if (ref == null) {
log.log(LogService.LOG_ERROR, "Failed to find resource processor for '" + rpName + "'!");
diff --git a/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/spi/DropResourceCommand.java b/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/spi/DropResourceCommand.java
index c33a228..7f86867 100644
--- a/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/spi/DropResourceCommand.java
+++ b/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/spi/DropResourceCommand.java
@@ -56,6 +56,12 @@
ResourceInfoImpl[] orderedTargetResources = target.getOrderedResourceInfos();
for (int i = orderedTargetResources.length - 1; i >= 0; i--) {
ResourceInfoImpl resourceInfo = orderedTargetResources[i];
+ // FELIX-4491: only resources that need to be processed should be handled...
+ if (!resourceInfo.isProcessedResource()) {
+ session.getLog().log(LogService.LOG_INFO, "Ignoring non-processed resource: " + resourceInfo.getPath());
+ continue;
+ }
+
String path = resourceInfo.getPath();
if (source.getResourceInfoByPath(path) == null) {
ServiceReference ref = target.getResourceProcessor(path);
diff --git a/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/spi/ProcessResourceCommand.java b/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/spi/ProcessResourceCommand.java
index 7b89635..9c0674b 100644
--- a/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/spi/ProcessResourceCommand.java
+++ b/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/spi/ProcessResourceCommand.java
@@ -30,6 +30,7 @@
import org.osgi.service.deploymentadmin.DeploymentException;
import org.osgi.service.deploymentadmin.spi.ResourceProcessor;
import org.osgi.service.deploymentadmin.spi.ResourceProcessorException;
+import org.osgi.service.log.LogService;
/**
* Command that processes all the processed resources in the source deployment
@@ -49,7 +50,7 @@
* committed at a later stage in the deployment session.
*
* @param commitCommand The <code>CommitCommand</code> that will commit all
- * resource processors used in this command.
+ * resource processors used in this command.
*/
public ProcessResourceCommand(CommitResourceCommand commitCommand) {
m_commitCommand = commitCommand;
@@ -84,6 +85,11 @@
if (resourceInfo == null) {
throw new DeploymentException(CODE_OTHER_ERROR, "Resource '" + name + "' is not described in the manifest.");
}
+ // FELIX-4491: only resources that need to be processed should be handled...
+ if (!resourceInfo.isProcessedResource()) {
+ session.getLog().log(LogService.LOG_INFO, "Ignoring non-processed resource: " + resourceInfo.getPath());
+ continue;
+ }
ServiceReference ref = source.getResourceProcessor(name);
if (ref == null) {
diff --git a/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/spi/SnapshotCommand.java b/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/spi/SnapshotCommand.java
index 7b25160..987718f 100644
--- a/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/spi/SnapshotCommand.java
+++ b/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/spi/SnapshotCommand.java
@@ -81,48 +81,114 @@
}
}
- private void store(File source, File target) throws IOException {
+ protected static void delete(File root, boolean deleteRoot) {
+ if (root.isDirectory()) {
+ File[] childs = root.listFiles();
+ for (int i = 0; i < childs.length; i++) {
+ delete(childs[i], true);
+ }
+ }
+ if (deleteRoot) {
+ root.delete();
+ }
+ }
+
+ protected static void restore(File archiveFile, File targetDir) throws IOException {
+ ZipInputStream input = null;
+ try {
+ input = new ZipInputStream(new FileInputStream(archiveFile));
+
+ ZipEntry entry;
+ while ((entry = input.getNextEntry()) != null) {
+ File targetEntry = new File(targetDir, entry.getName());
+
+ if (entry.isDirectory()) {
+ if (!targetEntry.mkdirs()) {
+ throw new IOException("Failed to create one or more sub-directories!");
+ }
+ }
+ else {
+ OutputStream output = null;
+ try {
+ output = new FileOutputStream(targetEntry);
+ copy(input, output);
+ }
+ finally {
+ closeSilently(output);
+ }
+ }
+
+ input.closeEntry();
+ }
+ }
+ finally {
+ closeSilently(input);
+ }
+ }
+
+ protected static void store(File sourceDir, File archiveFile) throws IOException {
ZipOutputStream output = null;
try {
- File[] children = source.listFiles();
- output = new ZipOutputStream(new FileOutputStream(target));
- for (int i = 0; i < children.length; i++) {
- storeRecursive(source, new File(children[i].getName()), output);
- }
+ output = new ZipOutputStream(new FileOutputStream(archiveFile));
+ // Traverse source directory recursively, and store all entries...
+ store(output, sourceDir, "");
}
finally {
closeSilently(output);
}
}
- private void storeRecursive(File current, File path, ZipOutputStream output) throws IOException {
- output.putNextEntry(new ZipEntry(path.getPath()));
- if (current.isDirectory()) {
- output.closeEntry();
- File[] childs = current.listFiles();
- for (int i = 0; i < childs.length; i++) {
- storeRecursive(childs[i], new File(path, childs[i].getName()), output);
+ protected static void copy(InputStream is, OutputStream os) throws IOException {
+ byte[] buffer = new byte[8192];
+ int read;
+ try {
+ while ((read = is.read(buffer)) != -1) {
+ os.write(buffer, 0, read);
}
}
- else {
+ finally {
+ os.flush();
+ }
+ }
+
+ private static void store(ZipOutputStream output, File sourceDir, String entryName) throws IOException {
+ File entry = new File(sourceDir, entryName);
+
+ if (entry.isFile()) {
+ ZipEntry zipEntry = new ZipEntry(entryName);
+ zipEntry.setSize(entry.length());
+ zipEntry.setTime(entry.lastModified());
+
+ output.putNextEntry(zipEntry);
+
InputStream input = null;
try {
- input = new FileInputStream(current);
- byte[] buffer = new byte[4096];
- for (int i = input.read(buffer); i != -1; i = input.read(buffer)) {
- output.write(buffer, 0, i);
- }
- output.closeEntry();
+ input = new FileInputStream(entry);
+ copy(input, output);
}
finally {
closeSilently(input);
+ output.closeEntry();
+ }
+ }
+ else if (entry.isDirectory()) {
+ String baseDir = "";
+ if (!"".equals(entryName)) {
+ baseDir = entryName.concat(File.separator);
+
+ output.putNextEntry(new ZipEntry(baseDir));
+ output.closeEntry();
+ }
+
+ String[] entries = entry.list();
+ for (int i = 0; i < entries.length; i++) {
+ store(output, sourceDir, baseDir.concat(entries[i]));
}
}
}
private static class DeleteSnapshotRunnable extends AbstractAction {
private final DeploymentSessionImpl m_session;
-
private final File m_snapshot;
private DeleteSnapshotRunnable(DeploymentSessionImpl session, File snapshot) {
@@ -139,9 +205,7 @@
private static class RestoreSnapshotRunnable extends AbstractAction {
private final DeploymentSessionImpl m_session;
-
private final File m_snapshot;
-
private final File m_root;
private RestoreSnapshotRunnable(DeploymentSessionImpl session, File snapshot, File root) {
@@ -152,8 +216,8 @@
protected void doRun() throws Exception {
try {
- delete(m_root, false);
- unpack(m_snapshot, m_root);
+ delete(m_root, false /* deleteRoot */);
+ restore(m_snapshot, m_root);
}
finally {
m_snapshot.delete();
@@ -163,46 +227,5 @@
protected void onFailure(Exception e) {
m_session.getLog().log(LogService.LOG_WARNING, "Failed to restore snapshot!", e);
}
-
- private void delete(File root, boolean deleteRoot) {
- if (root.isDirectory()) {
- File[] childs = root.listFiles();
- for (int i = 0; i < childs.length; i++) {
- delete(childs[i], true);
- }
- }
- if (deleteRoot) {
- root.delete();
- }
- }
-
- private void unpack(File source, File target) throws IOException {
- ZipInputStream input = null;
- try {
- input = new ZipInputStream(new FileInputStream(source));
- for (ZipEntry entry = input.getNextEntry(); entry != null; entry = input.getNextEntry()) {
- if (entry.isDirectory()) {
- (new File(target, entry.getName())).mkdirs();
- }
- else {
- OutputStream output = null;
- try {
- output = new FileOutputStream(target);
- byte[] buffer = new byte[4096];
- for (int i = input.read(buffer); i > -1; i = input.read(buffer)) {
- output.write(buffer, 0, i);
- }
- }
- finally {
- closeSilently(output);
- }
- }
- input.closeEntry();
- }
- }
- finally {
- closeSilently(input);
- }
- }
}
}
\ No newline at end of file
diff --git a/deploymentadmin/deploymentadmin/src/test/java/org/apache/felix/deploymentadmin/spi/SnapshotCommandTest.java b/deploymentadmin/deploymentadmin/src/test/java/org/apache/felix/deploymentadmin/spi/SnapshotCommandTest.java
new file mode 100644
index 0000000..a9ae539
--- /dev/null
+++ b/deploymentadmin/deploymentadmin/src/test/java/org/apache/felix/deploymentadmin/spi/SnapshotCommandTest.java
@@ -0,0 +1,227 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.deploymentadmin.spi;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Random;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import junit.framework.TestCase;
+
+/**
+ * Test cases for {@link SnapshotCommand}.
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class SnapshotCommandTest extends TestCase {
+ private final List m_cleanup = new ArrayList();
+
+ /**
+ * Tests that an archive can be correctly restored.
+ * <p>
+ * This tests FELIX-4719.
+ * </p>
+ */
+ public void testRestoreArchiveOk() throws Exception {
+ // Set up a file-hierarchy we can archive...
+ File baseDir = createFileHierarchy();
+
+ File archiveFile = new File(baseDir, "../archive.zip");
+ m_cleanup.add(archiveFile.getCanonicalFile());
+
+ SnapshotCommand.store(baseDir, archiveFile);
+ assertTrue("Archive not created?!", archiveFile.exists());
+
+ File targetDir = createTempDir();
+ SnapshotCommand.restore(archiveFile, targetDir);
+
+ verifyDirContents(baseDir, targetDir);
+ }
+
+ /**
+ * Tests that a directory (data-area) is correctly archived, and that the contents of that archive are as expected.
+ * <p>
+ * This tests FELIX-4718.
+ * </p>
+ */
+ public void testStoreDataAreaOk() throws Exception {
+ // Set up a file-hierarchy we can archive...
+ File baseDir = createFileHierarchy();
+
+ File archiveFile = new File(baseDir, "../archive.zip");
+ m_cleanup.add(archiveFile.getCanonicalFile());
+
+ SnapshotCommand.store(baseDir, archiveFile);
+ assertTrue("Archive not created?!", archiveFile.exists());
+
+ verifyArchiveContents(archiveFile, 3 /* dirs */, 6 /* files */);
+ }
+
+ protected void tearDown() throws Exception {
+ Iterator iter = m_cleanup.iterator();
+ while (iter.hasNext()) {
+ File file = (File) iter.next();
+ if (file.isFile()) {
+ file.delete();
+ }
+ else if (file.isDirectory()) {
+ SnapshotCommand.delete(file, true /* deleteRoot */);
+ }
+ iter.remove();
+ }
+ }
+
+ private void close(Closeable resource) throws IOException {
+ if (resource != null) {
+ resource.close();
+ }
+ }
+
+ private void createFile(File file, int size) throws IOException {
+ assertTrue(file.createNewFile());
+ FileOutputStream fos = null;
+ try {
+ fos = new FileOutputStream(file);
+
+ byte[] data = new byte[size];
+ new Random().nextBytes(data);
+
+ fos.write(data);
+ }
+ finally {
+ close(fos);
+ }
+ }
+
+ /**
+ * Creates a simple file hierarchy with a couple of files and directories (6 files and 3 directories).
+ *
+ * @return the base directory where the file hierarchy is stored, never <code>null</code>.
+ */
+ private File createFileHierarchy() throws IOException {
+ File base = createTempDir();
+
+ File dir1 = new File(base, "dir1");
+ assertTrue(dir1.mkdir());
+
+ File dir2 = new File(dir1, "dir1a");
+ assertTrue(dir2.mkdir());
+
+ File dir3 = new File(dir1, "dir1b");
+ assertTrue(dir3.mkdir());
+
+ createFile(new File(base, "file1"), 1024);
+ createFile(new File(dir1, "file2"), 2048);
+ createFile(new File(dir2, "file3"), 4096);
+ createFile(new File(base, "file4"), 8192);
+ createFile(new File(dir2, "file5"), 16384);
+ createFile(new File(dir3, "file6"), 32768);
+
+ return base;
+ }
+
+ private File createTempDir() throws IOException {
+ File dir = File.createTempFile("felix4718-", "");
+ assertTrue(dir.delete());
+ assertTrue(dir.mkdirs());
+ // For test cleanup...
+ m_cleanup.add(dir);
+ return dir;
+ }
+
+ private void verifyArchiveContents(File archive, int expectedDirCount, int expectedFileCount) throws IOException {
+ FileInputStream fis = null;
+ ZipInputStream zis = null;
+
+ try {
+ fis = new FileInputStream(archive);
+ zis = new ZipInputStream(fis);
+
+ int dirCount = 0;
+ int fileCount = 0;
+
+ ZipEntry entry;
+ while ((entry = zis.getNextEntry()) != null) {
+ if (entry.isDirectory()) {
+ dirCount++;
+ }
+ else {
+ fileCount++;
+ }
+ zis.closeEntry();
+ }
+
+ assertEquals("Unexpected number of files", expectedFileCount, fileCount);
+ assertEquals("Unexpected number of directories", expectedDirCount, dirCount);
+ }
+ finally {
+ close(fis);
+ close(zis);
+ }
+ }
+
+ private void verifyDirContents(File expectedBase, File actualBase) throws IOException {
+ String[] expectedFiles = expectedBase.list();
+ for (int i = 0; i < expectedFiles.length; i++) {
+ File expected = new File(expectedBase, expectedFiles[i]);
+ File actual = new File(actualBase, expectedFiles[i]);
+
+ if (expected.isDirectory()) {
+ assertTrue("Directory '" + expectedFiles[i] + "' does not exist in " + actualBase, actual.isDirectory());
+ verifyDirContents(expected, actual);
+ }
+ else if (expected.isFile()) {
+ assertTrue("File '" + expectedFiles[i] + "' does not exist in " + actualBase, actual.isFile());
+ verifyFileContents(expected, actual);
+ }
+ else {
+ fail("Unknown entity: '" + expectedFiles[i] + "'");
+ }
+ }
+ }
+
+ private void verifyFileContents(File expected, File actual) throws IOException {
+ assertEquals("File size mismatch!", expected.length(), actual.length());
+
+ FileInputStream fis1 = null;
+ FileInputStream fis2 = null;
+ try {
+ fis1 = new FileInputStream(expected);
+ fis2 = new FileInputStream(actual);
+
+ int eb;
+ while ((eb = fis1.read()) != -1) {
+ int ab = fis2.read();
+ assertEquals(eb, ab);
+ }
+ }
+ finally {
+ close(fis2);
+ close(fis1);
+ }
+ }
+}
diff --git a/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/BaseIntegrationTest.java b/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/BaseIntegrationTest.java
index 7fac396..d6020ce 100644
--- a/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/BaseIntegrationTest.java
+++ b/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/BaseIntegrationTest.java
@@ -169,7 +169,10 @@
}
protected final DeploymentPackage installDeploymentPackage(DeploymentPackageBuilder dpBuilder) throws Exception {
- InputStream is = dpBuilder.generate();
+ return installDeploymentPackage(dpBuilder.generate());
+ }
+
+ protected final DeploymentPackage installDeploymentPackage(InputStream is) throws Exception {
try {
return m_deploymentAdmin.installDeploymentPackage(is);
} finally {
@@ -227,17 +230,24 @@
return resource;
}
- protected URL getTestBundle(String baseName) throws MalformedURLException {
- return getTestBundle(baseName, "1.0.0");
- }
- protected URL getTestBundle(String baseName, String version) throws MalformedURLException {
- return getTestBundle(baseName, baseName, version);
+ protected Bundle getBundle(String bsn) {
+ for (Bundle b : m_context.getBundles()) {
+ if (bsn.equals(b.getSymbolicName())) {
+ return b;
+ }
+ }
+ return null;
}
- protected URL getTestBundle(String artifactName, String baseName, String version) throws MalformedURLException {
- if (version == null) {
- version = "0.0.0";
- }
+ protected URL getTestBundleURL(String baseName) throws MalformedURLException {
+ return getTestBundleURL(baseName, "1.0.0");
+ }
+ protected URL getTestBundleURL(String baseName, String version) throws MalformedURLException {
+ return getTestBundleURL(baseName, baseName, version);
+ }
+
+ protected URL getTestBundleURL(String artifactName, String baseName, String version) throws MalformedURLException {
+ assertNotNull("Version cannot be null!", version);
File f = new File(m_testBundleBasePath, String.format("%1$s/target/org.apache.felix.deploymentadmin.test.%2$s-%3$s.jar", artifactName, baseName, version));
assertTrue("No such bundle: " + f, f.exists() && f.isFile());
return f.toURI().toURL();
diff --git a/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/CustomizerTest.java b/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/CustomizerTest.java
index 9d35fde..44c94d1 100644
--- a/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/CustomizerTest.java
+++ b/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/CustomizerTest.java
@@ -39,6 +39,37 @@
public class CustomizerTest extends BaseIntegrationTest {
/**
+ * FELIX-4491 - Only resources with a resource processor defined should be processed.
+ */
+ @Test
+ public void testInstallBundleWithNonProcessedResourcesOk() throws Exception {
+ DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
+ dpBuilder
+ .add(dpBuilder.createResource().setNeedResourceProcessor(false).setUrl(getTestResource("LICENSE")))
+ .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundleURL("rp1")))
+ .add(dpBuilder.createResource().setResourceProcessorPID(TEST_FAILING_BUNDLE_RP1).setUrl(getTestResource("test-config1.xml")))
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")));
+
+ DeploymentPackage dp = installDeploymentPackage(dpBuilder);
+ assertNotNull("No deployment package returned?!", dp);
+
+ assertEquals("Expected a single deployment package?!", 1, countDeploymentPackages());
+
+ awaitRefreshPackagesEvent();
+
+ assertBundleExists(getSymbolicName("bundle1"), "1.0.0");
+
+ // Check that only the processed resources are dropped...
+ dp.uninstall();
+
+ assertEquals("Expected no deployment package?!", 0, countDeploymentPackages());
+
+ awaitRefreshPackagesEvent();
+
+ assertBundleNotExists(getSymbolicName("bundle1"), "1.0.0");
+ }
+
+ /**
* Tests that if an exception is thrown during the commit-phase, the installation proceeds and succeeds.
*/
@Test
@@ -47,9 +78,9 @@
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder
- .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundle("rp1")))
+ .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundleURL("rp1")))
.add(dpBuilder.createResource().setResourceProcessorPID(TEST_FAILING_BUNDLE_RP1).setUrl(getTestResource("test-config1.xml")))
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle3")));
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle3")));
DeploymentPackage dp = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp);
@@ -72,7 +103,7 @@
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder
- .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundle("rp1")))
+ .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundleURL("rp1")))
.add(dpBuilder.createResource().setResourceProcessorPID(TEST_FAILING_BUNDLE_RP1).setUrl(getTestResource("test-config1.xml")));
try {
@@ -98,7 +129,7 @@
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder
- .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundle("rp1")))
+ .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundleURL("rp1")))
.add(dpBuilder.createResource().setResourceProcessorPID(TEST_FAILING_BUNDLE_RP1).setUrl(getTestResource("test-config1.xml")));
try {
@@ -124,7 +155,7 @@
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder
- .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundle("rp1")))
+ .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundleURL("rp1")))
.add(dpBuilder.createResource().setResourceProcessorPID(TEST_FAILING_BUNDLE_RP1).setUrl(getTestResource("test-config1.xml")));
DeploymentPackage dp = installDeploymentPackage(dpBuilder);
@@ -146,9 +177,9 @@
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder
- .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundle("rp1")))
+ .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundleURL("rp1")))
.add(dpBuilder.createResource().setResourceProcessorPID(TEST_FAILING_BUNDLE_RP1).setUrl(getTestResource("test-config1.xml")))
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle3")));
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle3")));
try {
installDeploymentPackage(dpBuilder);
@@ -170,7 +201,7 @@
public void testInstallResourceWithForeignCustomizerFail() throws Exception {
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder
- .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundle("rp1")));
+ .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundleURL("rp1")));
installDeploymentPackage(dpBuilder);
diff --git a/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/DeploymentAdminEventTest.java b/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/DeploymentAdminEventTest.java
index 8af682d..d42e184 100644
--- a/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/DeploymentAdminEventTest.java
+++ b/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/DeploymentAdminEventTest.java
@@ -51,8 +51,8 @@
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
// incluse two different versions of the same bundle (with the same BSN), this is *not* allowed per the DA spec...
dpBuilder
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundleapi1", "bundleapi1", "1.0.0")))
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundleapi2", "bundleapi2", "2.0.0")));
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleapi1", "bundleapi1", "1.0.0")))
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleapi2", "bundleapi2", "2.0.0")));
final AtomicReference<Event> completionEventRef = new AtomicReference<Event>();
final AtomicReference<Event> installEventRef = new AtomicReference<Event>();
@@ -114,8 +114,8 @@
{
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundleapi1", "bundleapi1", "1.0.0")))
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundleimpl1", "bundleimpl1", "1.0.0")));
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleapi1", "bundleapi1", "1.0.0")))
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleimpl1", "bundleimpl1", "1.0.0")));
final AtomicReference<Event> completionEventRef = new AtomicReference<Event>();
final AtomicReference<Event> installEventRef = new AtomicReference<Event>();
@@ -173,8 +173,8 @@
{
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundleapi1", "bundleapi1", "1.0.0")))
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundleimpl1", "bundleimpl1", "1.0.0")));
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleapi1", "bundleapi1", "1.0.0")))
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleimpl1", "bundleimpl1", "1.0.0")));
final AtomicReference<Event> completionEventRef = new AtomicReference<Event>();
final AtomicReference<Event> uninstallEventRef = new AtomicReference<Event>();
@@ -237,8 +237,8 @@
{
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")))
- .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundle("rp1")))
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")))
+ .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundleURL("rp1")))
.add(dpBuilder.createResource().setResourceProcessorPID(TEST_FAILING_BUNDLE_RP1).setUrl(getTestResource("test-config1.xml")));
final AtomicReference<Event> completionEventRef = new AtomicReference<Event>();
diff --git a/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/DeploymentAdminTest.java b/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/DeploymentAdminTest.java
index d50aad5..350d299 100644
--- a/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/DeploymentAdminTest.java
+++ b/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/DeploymentAdminTest.java
@@ -38,8 +38,8 @@
* Generic tests for {@link DeploymentAdmin}.
*/
@RunWith(PaxExam.class)
-public class DeploymentAdminTest extends BaseIntegrationTest {
-
+public class DeploymentAdminTest extends BaseIntegrationTest
+{
/**
* Tests that we can update the configuration of {@link DeploymentAdmin} at runtime. Based on the test case for FELIX-4184, see
* {@link org.apache.felix.deploymentadmin.itest.InstallFixPackageTest#testInstallAndUpdateImplementationBundleWithSeparateAPIBundle_FELIX4184()}
@@ -57,21 +57,22 @@
Thread.sleep(100);
// This test case will only work if stopUnaffectedBundle is set to 'false'...
- try {
+ try
+ {
// first, install a deployment package with implementation and api bundles in version 1.0.0
DeploymentPackageBuilder dpBuilder = createDeploymentPackageBuilder("a", "1.0.0");
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundleimpl1", "bundleimpl1", "1.0.0")));
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundleapi1", "bundleapi1", "1.0.0")));
-
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleimpl1", "bundleimpl1", "1.0.0")));
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleapi1", "bundleapi1", "1.0.0")));
+
DeploymentPackage dp1 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp1);
-
+
assertEquals("Expected a single deployment package?!", 1, countDeploymentPackages());
-
+
// then, install a fix package with implementation and api bundles in version 2.0.0
dpBuilder = createDeploymentPackageBuilder("a", "2.0.0").setFixPackage("[1.0.0,2.0.0]");
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundleimpl2", "bundleimpl2", "2.0.0")));
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundleapi2", "bundleapi2", "2.0.0")));
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleimpl2", "bundleimpl2", "2.0.0")));
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleapi2", "bundleapi2", "2.0.0")));
DeploymentPackage dp2 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp2);
@@ -82,94 +83,82 @@
assertBundleExists(getSymbolicName("bundleapi"), "2.0.0");
assertBundleNotExists(getSymbolicName("bundleimpl"), "1.0.0");
assertBundleNotExists(getSymbolicName("bundleapi"), "1.0.0");
- } finally {
+ }
+ finally
+ {
config.delete();
}
}
@Test
- public void testBundleSymbolicNameMustMatchManifestEntry() throws Exception {
+ public void testBundleSymbolicNameMustMatchManifestEntry() throws Exception
+ {
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
- dpBuilder
- .add(dpBuilder.createBundleResource()
- .setUrl(getTestBundle("bundle1"))
- )
- .add(dpBuilder.createBundleResource()
- .setUrl(getTestBundle("bundle2"))
- .setFilter(new JarManifestManipulatingFilter("Bundle-SymbolicName", "foo"))
- );
-
- try {
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1"))).add(
+ dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")).setFilter(new JarManifestManipulatingFilter("Bundle-SymbolicName", "foo")));
+
+ try
+ {
installDeploymentPackage(dpBuilder);
fail("Succeeded into installing a bundle with a fake symbolic name?!");
}
- catch (DeploymentException exception) {
+ catch (DeploymentException exception)
+ {
// Ok; expected...
assertDeploymentException(CODE_BUNDLE_NAME_ERROR, exception);
}
}
@Test
- public void testBundleVersionMustMatchManifestEntry() throws Exception {
+ public void testBundleVersionMustMatchManifestEntry() throws Exception
+ {
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
- dpBuilder
- .add(dpBuilder.createBundleResource()
- .setUrl(getTestBundle("bundle1"))
- )
- .add(dpBuilder.createBundleResource()
- .setUrl(getTestBundle("bundle2"))
- .setFilter(new JarManifestManipulatingFilter("Bundle-Version", "1.1.0"))
- );
-
- try {
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1"))).add(
+ dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")).setFilter(new JarManifestManipulatingFilter("Bundle-Version", "1.1.0")));
+
+ try
+ {
installDeploymentPackage(dpBuilder);
fail("Succeeded into installing a bundle with a fake version?!");
}
- catch (DeploymentException exception) {
+ catch (DeploymentException exception)
+ {
// Ok; expected...
assertDeploymentException(CODE_OTHER_ERROR, exception);
}
}
@Test
- public void testManifestEntryMustMatchBundleSymbolicName() throws Exception {
+ public void testManifestEntryMustMatchBundleSymbolicName() throws Exception
+ {
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
- dpBuilder
- .add(dpBuilder.createBundleResource()
- .setUrl(getTestBundle("bundle1"))
- )
- .add(dpBuilder.createBundleResource()
- .setSymbolicName("foo")
- .setUrl(getTestBundle("bundle2"))
- );
-
- try {
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1"))).add(dpBuilder.createBundleResource().setSymbolicName("foo").setUrl(getTestBundleURL("bundle2")));
+
+ try
+ {
installDeploymentPackage(dpBuilder);
fail("Succeeded into installing a bundle with a fake symbolic name?!");
}
- catch (DeploymentException exception) {
+ catch (DeploymentException exception)
+ {
// Ok; expected...
assertDeploymentException(CODE_BUNDLE_NAME_ERROR, exception);
}
}
@Test
- public void testManifestEntryMustMatchBundleVersion() throws Exception {
+ public void testManifestEntryMustMatchBundleVersion() throws Exception
+ {
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
- dpBuilder
- .add(dpBuilder.createBundleResource()
- .setUrl(getTestBundle("bundle1"))
- )
- .add(dpBuilder.createBundleResource()
- .setVersion("1.1.0")
- .setUrl(getTestBundle("bundle2"))
- );
-
- try {
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1"))).add(dpBuilder.createBundleResource().setVersion("1.1.0").setUrl(getTestBundleURL("bundle2")));
+
+ try
+ {
installDeploymentPackage(dpBuilder);
fail("Succeeded into installing a bundle with a fake version?!");
}
- catch (DeploymentException exception) {
+ catch (DeploymentException exception)
+ {
// Ok; expected...
assertDeploymentException(CODE_OTHER_ERROR, exception);
}
diff --git a/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/InstallDeploymentPackageTest.java b/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/InstallDeploymentPackageTest.java
index 51f1bf0..3651018 100644
--- a/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/InstallDeploymentPackageTest.java
+++ b/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/InstallDeploymentPackageTest.java
@@ -18,7 +18,10 @@
*/
package org.apache.felix.deploymentadmin.itest;
+import java.io.File;
+
import org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder;
+import org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder.JarManifestManipulatingFilter;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.junit.PaxExam;
@@ -42,8 +45,8 @@
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
// incluse two different versions of the same bundle (with the same BSN), this is *not* allowed per the DA spec...
dpBuilder
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundleapi1", "bundleapi1", "1.0.0")))
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundleapi2", "bundleapi2", "2.0.0")));
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleapi1", "bundleapi1", "1.0.0")))
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleapi2", "bundleapi2", "2.0.0")));
try
{
@@ -69,8 +72,8 @@
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
// incluse two different versions of the same bundle (with the same BSN), this is *not* allowed per the DA spec...
dpBuilder
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundleapi1", "bundleapi1", "1.0.0")).setFilename("bundles/bundleapi1.jar"))
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundleimpl1", "bundleimpl1", "1.0.0")).setFilename("bundles/bundleimpl1.jar"));
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleapi1", "bundleapi1", "1.0.0")).setFilename("bundles/bundleapi1.jar"))
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleimpl1", "bundleimpl1", "1.0.0")).setFilename("bundles/bundleimpl1.jar"));
DeploymentPackage dp = installDeploymentPackage(dpBuilder);
assertNotNull(dp);
@@ -91,7 +94,7 @@
{
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
// missing bundle1 as dependency...
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle2")));
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")));
DeploymentPackage dp1 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp1);
@@ -105,8 +108,8 @@
dpBuilder = createDeploymentPackageBuilder(dpBuilder.getSymbolicName(), "1.0.1");
dpBuilder
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle2")))
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")));
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")))
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")));
DeploymentPackage dp2 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp2);
@@ -124,7 +127,7 @@
public void testInstallBundleWithDependencyInSeparatePackageOk() throws Exception
{
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle2")));
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")));
DeploymentPackage dp1 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp1);
@@ -140,7 +143,7 @@
dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
// as missing bundle1...
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")));
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")));
DeploymentPackage dp2 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp2);
@@ -167,8 +170,8 @@
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")))
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle3")));
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")))
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle3")));
DeploymentPackage dp = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp);
@@ -193,8 +196,8 @@
{
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")))
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("fragment1")));
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")))
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("fragment1")));
DeploymentPackage dp = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp);
@@ -217,7 +220,7 @@
public void testInstallBundleWithMissingDependencyOk() throws Exception
{
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle2")));
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")));
DeploymentPackage dp = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp);
@@ -240,9 +243,9 @@
{
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder
- .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundle("rp1")))
+ .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundleURL("rp1")))
.add(dpBuilder.createResource().setResourceProcessorPID(TEST_FAILING_BUNDLE_RP1).setUrl(getTestResource("test-config1.xml")))
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle3")));
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle3")));
DeploymentPackage dp = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp);
@@ -263,7 +266,7 @@
public void testInstallSingleValidBundleOk() throws Exception
{
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")));
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")));
DeploymentPackage dp = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp);
@@ -284,8 +287,8 @@
{
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")))
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle2")));
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")))
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")));
DeploymentPackage dp = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp);
@@ -309,8 +312,8 @@
{
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")))
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle3")));
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")))
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle3")));
DeploymentPackage dp = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp);
@@ -323,8 +326,8 @@
dpBuilder = dpBuilder.create("1.0.1");
dpBuilder
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")))
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle2")));
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")))
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")));
dp = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp);
@@ -347,8 +350,8 @@
{
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")))
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle3")));
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")))
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle3")));
DeploymentPackage dp = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp);
@@ -361,9 +364,9 @@
dpBuilder = createDeploymentPackageBuilder(dpBuilder.getSymbolicName(), "1.0.1");
dpBuilder
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")))
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle2")))
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle3")));
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")))
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")))
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle3")));
dp = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp);
@@ -378,4 +381,207 @@
assertEquals("Expected a single deployment package?!", 1, countDeploymentPackages());
}
+
+ /**
+ * Tests that we can correctly rollback the installation of a deployment package for bundles that have their data area populated.
+ */
+ @Test
+ public void testRollbackWithPopulatedDataAreaOk() throws Exception {
+ // Install a first version, in which we're going to change the data area of a bundle...
+ DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
+ dpBuilder
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")))
+ .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundleURL("rp1")));
+
+ DeploymentPackage dp = installDeploymentPackage(dpBuilder);
+ assertNotNull("No deployment package returned?!", dp);
+
+ awaitRefreshPackagesEvent();
+
+ Bundle bundle1 = getBundle("testbundles.bundle1");
+ assertNotNull("Unable to get installed test bundle?!", bundle1);
+
+ File dataArea = bundle1.getDataFile("");
+ assertNotNull("No data area obtained for test bundle?!", dataArea);
+
+ // Populate the data area...
+ assertTrue("No file created?!", new File(dataArea, "file1").createNewFile());
+ assertTrue("No file created?!", new File(dataArea, "file2").createNewFile());
+ assertTrue("No file created?!", new File(dataArea, "file3").createNewFile());
+
+ // This will cause the new bundle to fail in its stop method...
+ System.setProperty("rp1", "process");
+
+ // Simulate an upgrade for our bundle, which should cause its data area to be retained...
+ dpBuilder = createDeploymentPackageBuilder(dpBuilder.getSymbolicName(), "1.0.1");
+ dpBuilder
+ .add(dpBuilder.createBundleResource().setVersion("1.1.0").setUrl(getTestBundleURL("bundle1")).setFilter(new JarManifestManipulatingFilter("Bundle-Version", "1.1.0")))
+ .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundleURL("rp1")))
+ .add(dpBuilder.createResource().setResourceProcessorPID(TEST_FAILING_BUNDLE_RP1).setUrl(getTestResource("test-config1.xml")));
+
+ try {
+ dp = installDeploymentPackage(dpBuilder); // should fail!
+ fail("Deployment of upgrade package should have failed?!");
+ }
+ catch (DeploymentException e) {
+ // Ok; expected...
+ }
+
+ // We should still have this bundle..
+ bundle1 = getBundle("testbundles.bundle1");
+ assertNotNull("Unable to get installed test bundle?!", bundle1);
+
+ dataArea = bundle1.getDataFile("");
+ assertNotNull("No data area obtained for test bundle?!", dataArea);
+
+ // Data area should be restored exactly as-is...
+ assertTrue("File not restored?!", new File(dataArea, "file1").exists());
+ assertTrue("File not restored?!", new File(dataArea, "file2").exists());
+ assertTrue("File not restored?!", new File(dataArea, "file3").exists());
+ }
+
+ /**
+ * Tests that we can correctly install a deployment package with bundles that have their data area populated.
+ */
+ @Test
+ public void testUpgradeWithPopulatedDataAreaOk() throws Exception {
+ // Install a first version, in which we're going to change the data area of a bundle...
+ DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
+ dpBuilder
+ .add(dpBuilder.createBundleResource().setVersion("1.0.0").setUrl(getTestBundleURL("bundle1")))
+ .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundleURL("rp1")));
+
+ DeploymentPackage dp = installDeploymentPackage(dpBuilder);
+ assertNotNull("No deployment package returned?!", dp);
+
+ awaitRefreshPackagesEvent();
+
+ Bundle bundle1 = getBundle("testbundles.bundle1");
+ assertNotNull("Unable to get installed test bundle?!", bundle1);
+
+ File dataArea = bundle1.getDataFile("");
+ assertNotNull("No data area obtained for test bundle?!", dataArea);
+
+ // Populate the data area...
+ assertTrue("No file created?!", new File(dataArea, "file1").createNewFile());
+ assertTrue("No file created?!", new File(dataArea, "file2").createNewFile());
+ assertTrue("No file created?!", new File(dataArea, "file3").createNewFile());
+
+ dpBuilder = createDeploymentPackageBuilder(dpBuilder.getSymbolicName(), "1.0.1");
+ dpBuilder
+ .add(dpBuilder.createBundleResource().setVersion("1.1.0").setUrl(getTestBundleURL("bundle1")).setFilter(new JarManifestManipulatingFilter("Bundle-Version", "1.1.0")))
+ .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundleURL("rp1")))
+ .add(dpBuilder.createResource().setResourceProcessorPID(TEST_FAILING_BUNDLE_RP1).setUrl(getTestResource("test-config1.xml")));
+
+ dp = installDeploymentPackage(dpBuilder); // should succeed!
+
+ // We should still have this bundle..
+ bundle1 = getBundle("testbundles.bundle1");
+ assertNotNull("Unable to get installed test bundle?!", bundle1);
+
+ dataArea = bundle1.getDataFile("");
+ assertNotNull("No data area obtained for test bundle?!", dataArea);
+
+ // Data area should be restored exactly as-is...
+ assertTrue("File not restored?!", new File(dataArea, "file1").exists());
+ assertTrue("File not restored?!", new File(dataArea, "file2").exists());
+ assertTrue("File not restored?!", new File(dataArea, "file3").exists());
+ }
+
+ /**
+ * Tests that we can correctly install a deployment package with bundles that have their data area populated.
+ */
+ @Test
+ public void testUninstallBundleWithPopulatedDataAreaOk() throws Exception {
+ // Install a first version, in which we're going to change the data area of a bundle...
+ DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
+ dpBuilder
+ .add(dpBuilder.createBundleResource().setVersion("1.0.0").setUrl(getTestBundleURL("bundle1")))
+ .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundleURL("rp1")));
+
+ DeploymentPackage dp = installDeploymentPackage(dpBuilder);
+ assertNotNull("No deployment package returned?!", dp);
+
+ awaitRefreshPackagesEvent();
+
+ Bundle bundle1 = getBundle("testbundles.bundle1");
+ assertNotNull("Unable to get installed test bundle?!", bundle1);
+
+ File dataArea = bundle1.getDataFile("");
+ assertNotNull("No data area obtained for test bundle?!", dataArea);
+
+ // Populate the data area...
+ assertTrue("No file created?!", new File(dataArea, "file1").createNewFile());
+ assertTrue("No file created?!", new File(dataArea, "file2").createNewFile());
+ assertTrue("No file created?!", new File(dataArea, "file3").createNewFile());
+
+ dpBuilder = createDeploymentPackageBuilder(dpBuilder.getSymbolicName(), "1.0.1");
+ dpBuilder
+ .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundleURL("rp1")))
+ .add(dpBuilder.createResource().setResourceProcessorPID(TEST_FAILING_BUNDLE_RP1).setUrl(getTestResource("test-config1.xml")));
+
+ dp = installDeploymentPackage(dpBuilder); // should succeed!
+
+ // We should no longer have this bundle..
+ bundle1 = getBundle("testbundles.bundle1");
+ assertNull("Unable to get installed test bundle?!", bundle1);
+
+ // Data area should be restored exactly as-is...
+ assertFalse("Data area not purged?!", dataArea.exists());
+ }
+ /**
+ * Tests that we can correctly install a deployment package with bundles that have their data area populated.
+ */
+ @Test
+ public void testRollbackUninstallBundleWithPopulatedDataAreaOk() throws Exception {
+ // Install a first version, in which we're going to change the data area of a bundle...
+ DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
+ dpBuilder
+ .add(dpBuilder.createBundleResource().setVersion("1.0.0").setUrl(getTestBundleURL("bundle1")))
+ .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundleURL("rp1")));
+
+ DeploymentPackage dp = installDeploymentPackage(dpBuilder);
+ assertNotNull("No deployment package returned?!", dp);
+
+ awaitRefreshPackagesEvent();
+
+ Bundle bundle1 = getBundle("testbundles.bundle1");
+ assertNotNull("Unable to get installed test bundle?!", bundle1);
+
+ File dataArea = bundle1.getDataFile("");
+ assertNotNull("No data area obtained for test bundle?!", dataArea);
+
+ // Populate the data area...
+ assertTrue("No file created?!", new File(dataArea, "file1").createNewFile());
+ assertTrue("No file created?!", new File(dataArea, "file2").createNewFile());
+ assertTrue("No file created?!", new File(dataArea, "file3").createNewFile());
+
+ // This will cause the new bundle to fail in its stop method...
+ System.setProperty("rp1", "process");
+
+ dpBuilder = createDeploymentPackageBuilder(dpBuilder.getSymbolicName(), "1.0.1");
+ dpBuilder
+ .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundleURL("rp1")))
+ .add(dpBuilder.createResource().setResourceProcessorPID(TEST_FAILING_BUNDLE_RP1).setUrl(getTestResource("test-config1.xml")));
+
+ try {
+ dp = installDeploymentPackage(dpBuilder); // should fail!
+ fail("Deployment of upgrade package should have failed?!");
+ }
+ catch (DeploymentException e) {
+ // Ok; expected...
+ }
+
+ // We should still have this bundle..
+ bundle1 = getBundle("testbundles.bundle1");
+ assertNotNull("Unable to get installed test bundle?!", bundle1);
+
+ dataArea = bundle1.getDataFile("");
+ assertNotNull("No data area obtained for test bundle?!", dataArea);
+
+ // Data area should be restored exactly as-is...
+ assertTrue("File not restored?!", new File(dataArea, "file1").exists());
+ assertTrue("File not restored?!", new File(dataArea, "file2").exists());
+ assertTrue("File not restored?!", new File(dataArea, "file3").exists());
+ }
}
diff --git a/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/InstallFixPackageTest.java b/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/InstallFixPackageTest.java
index 65a9801..d45a1eb 100644
--- a/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/InstallFixPackageTest.java
+++ b/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/InstallFixPackageTest.java
@@ -46,7 +46,7 @@
public void testInstallBundleWithDependencyInFixPackageUpdateOk() throws Exception
{
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle2")));
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")));
DeploymentPackage dp1 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp1);
@@ -59,7 +59,7 @@
assertEquals(Bundle.INSTALLED, bundle.getState());
dpBuilder = createDeploymentPackageBuilder(dpBuilder.getSymbolicName(), "1.0.1");
- dpBuilder.setFixPackage("[1.0,2.0)").add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1"))).add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle2")).setMissing());
+ dpBuilder.setFixPackage("[1.0,2.0)").add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1"))).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")).setMissing());
DeploymentPackage dp2 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp2);
@@ -82,7 +82,7 @@
public void testInstallFixPackageOutsideLowerTargetRangeFail() throws Exception
{
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle2")));
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")));
DeploymentPackage dp1 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp1);
@@ -96,7 +96,7 @@
dpBuilder = createDeploymentPackageBuilder(dpBuilder.getSymbolicName(), "1.0.1");
dpBuilder.setFixPackage("(1.0,2.0)") // should not include version 1.0.0!
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1"))).add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle2")).setMissing());
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1"))).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")).setMissing());
try
{
@@ -117,7 +117,7 @@
public void testInstallFixPackageOutsideUpperTargetRangeFail() throws Exception
{
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle2")));
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")));
DeploymentPackage dp1 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp1);
@@ -131,7 +131,7 @@
dpBuilder = createDeploymentPackageBuilder(dpBuilder.getSymbolicName(), "1.0.1");
dpBuilder.setFixPackage("[0.9,1.0)") // should not include version 1.0.0!
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1"))).add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle2")).setMissing());
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1"))).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")).setMissing());
try
{
@@ -152,7 +152,7 @@
public void testInstallFixPackageWithoutTargetFail() throws Exception
{
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
- dpBuilder.setFixPackage("[1.0,2.0)").add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1"))).add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle2")));
+ dpBuilder.setFixPackage("[1.0,2.0)").add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1"))).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")));
try
{
@@ -173,7 +173,7 @@
public void testInstallFixPackageReplacesOriginalTargetPackageOk() throws Exception
{
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle2")));
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")));
DeploymentPackage dp1 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp1);
@@ -183,7 +183,7 @@
awaitRefreshPackagesEvent();
dpBuilder = createDeploymentPackageBuilder(dpBuilder.getSymbolicName(), "1.0.1");
- dpBuilder.setFixPackage("[1.0,2.0)").add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1"))).add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle2")).setMissing());
+ dpBuilder.setFixPackage("[1.0,2.0)").add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1"))).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")).setMissing());
DeploymentPackage dp2 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp2);
@@ -201,7 +201,7 @@
{
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
// missed valid-bundle1 as dependency...
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")));
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")));
DeploymentPackage dp1 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp1);
@@ -211,7 +211,7 @@
awaitRefreshPackagesEvent();
dpBuilder = createDeploymentPackageBuilder(dpBuilder.getSymbolicName(), "1.0.1");
- dpBuilder.setFixPackage("[1.0,2.0)").add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle3"))).add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle2")).setMissing());
+ dpBuilder.setFixPackage("[1.0,2.0)").add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle3"))).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")).setMissing());
try
{
@@ -231,7 +231,7 @@
public void testInstallFixPackageWithMissingTargetResourceFail() throws Exception
{
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")));
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")));
DeploymentPackage dp1 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp1);
@@ -241,7 +241,7 @@
awaitRefreshPackagesEvent();
dpBuilder = createDeploymentPackageBuilder(dpBuilder.getSymbolicName(), "1.0.1");
- dpBuilder.setFixPackage("[1.0,2.0)").add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundle("rp1"))).add(
+ dpBuilder.setFixPackage("[1.0,2.0)").add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundleURL("rp1"))).add(
dpBuilder.createResource().setResourceProcessorPID(TEST_FAILING_BUNDLE_RP1).setUrl(getTestResource("test-config1.xml")).setMissing());
try
@@ -262,7 +262,7 @@
public void testInstallFixPackageWithMissingTargetResourceProcessorFail() throws Exception
{
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")));
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")));
DeploymentPackage dp1 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp1);
@@ -272,7 +272,7 @@
awaitRefreshPackagesEvent();
dpBuilder = createDeploymentPackageBuilder(dpBuilder.getSymbolicName(), "1.0.1");
- dpBuilder.setFixPackage("[1.0,2.0)").add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundle("rp1")).setMissing()).add(
+ dpBuilder.setFixPackage("[1.0,2.0)").add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundleURL("rp1")).setMissing()).add(
dpBuilder.createResource().setResourceProcessorPID(TEST_FAILING_BUNDLE_RP1).setUrl(getTestResource("test-config1.xml")));
try
@@ -293,7 +293,7 @@
public void testInstallFixPackageWithMissingTargetBundleFromOtherPackageFail() throws Exception
{
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")));
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")));
DeploymentPackage dp1 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp1);
@@ -303,7 +303,7 @@
assertEquals("Expected only a single deployment package?!", 1, countDeploymentPackages());
dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle2")));
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")));
DeploymentPackage dp2 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp2);
@@ -313,7 +313,7 @@
assertEquals("Expected only a single deployment package?!", 2, countDeploymentPackages());
dpBuilder = createDeploymentPackageBuilder(dpBuilder.getSymbolicName(), "1.0.1");
- dpBuilder.setFixPackage("[1.0,2.0)").add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")).setMissing()).add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle3")));
+ dpBuilder.setFixPackage("[1.0,2.0)").add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")).setMissing()).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle3")));
try
{
@@ -333,7 +333,7 @@
public void testMissingBundlesOnlyInFixPackageFail() throws Exception
{
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle2")));
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")));
DeploymentPackage dp1 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp1);
@@ -346,7 +346,7 @@
assertEquals(Bundle.INSTALLED, bundle.getState());
dpBuilder = createDeploymentPackageBuilder(dpBuilder.getSymbolicName(), "1.0.1");
- dpBuilder.disableVerification().add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1"))).add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle2")).setMissing());
+ dpBuilder.disableVerification().add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1"))).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")).setMissing());
try
{
@@ -367,7 +367,7 @@
public void testRemoveBundleInFixPackageUpdateOk() throws Exception
{
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1"))).add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle2")));
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1"))).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")));
DeploymentPackage dp1 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp1);
@@ -381,7 +381,7 @@
// valid-bundle2 is to be removed by this fix package...
dpBuilder = createDeploymentPackageBuilder(dpBuilder.getSymbolicName(), "1.0.1");
- dpBuilder.setFixPackage("[1.0,2.0)").add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")).setMissing());
+ dpBuilder.setFixPackage("[1.0,2.0)").add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")).setMissing());
DeploymentPackage dp2 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp2);
@@ -399,7 +399,7 @@
public void testUninstallBundleAddedInFixPackageOk() throws Exception
{
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle2")));
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")));
DeploymentPackage dp1 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp1);
@@ -408,7 +408,7 @@
// Add valid-bundle1 through fix-package...
dpBuilder = createDeploymentPackageBuilder(dpBuilder.getSymbolicName(), "1.0.1");
- dpBuilder.setFixPackage("[1.0,2.0)").add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1"))).add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle2")).setMissing());
+ dpBuilder.setFixPackage("[1.0,2.0)").add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1"))).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")).setMissing());
DeploymentPackage dp2 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp2);
@@ -439,7 +439,7 @@
public void testUninstallBundleRemovedInFixPackageOk() throws Exception
{
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1"))).add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle2")));
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1"))).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")));
DeploymentPackage dp1 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp1);
@@ -448,7 +448,7 @@
// remove valid-bundle1 through fix package...
dpBuilder = createDeploymentPackageBuilder(dpBuilder.getSymbolicName(), "1.0.1");
- dpBuilder.setFixPackage("[1.0,2.0)").add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")));
+ dpBuilder.setFixPackage("[1.0,2.0)").add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")));
DeploymentPackage dp2 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp2);
@@ -479,7 +479,7 @@
public void testUninstallFixPackageOnlyRemovesOwnArtifactsOk() throws Exception
{
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")));
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")));
DeploymentPackage dp1 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp1);
@@ -487,7 +487,7 @@
assertEquals("Expected a single deployment package?!", 1, countDeploymentPackages());
dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle2")));
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")));
DeploymentPackage dp2 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp2);
@@ -498,7 +498,7 @@
// add bundle2 through fix package...
dpBuilder = createDeploymentPackageBuilder(dpBuilder.getSymbolicName(), "1.0.1");
- dpBuilder.setFixPackage("[1.0,2.0)").add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle3"))).add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle2")).setMissing());
+ dpBuilder.setFixPackage("[1.0,2.0)").add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle3"))).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")).setMissing());
DeploymentPackage dp3 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp3);
@@ -533,8 +533,8 @@
// first, install a deployment package with implementation and api bundles in version 1.0.0
DeploymentPackageBuilder dpBuilder = createDeploymentPackageBuilder("a", "1.0.0");
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundleimpl1", "bundleimpl1", "1.0.0")));
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundleapi1", "bundleapi1", "1.0.0")));
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleimpl1", "bundleimpl1", "1.0.0")));
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleapi1", "bundleapi1", "1.0.0")));
DeploymentPackage dp1 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp1);
@@ -543,8 +543,8 @@
// then, install a fix package with implementation and api bundles in version 2.0.0
dpBuilder = createDeploymentPackageBuilder("a", "2.0.0").setFixPackage("[1.0.0,2.0.0]");
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundleimpl2", "bundleimpl2", "2.0.0")));
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundleapi2", "bundleapi2", "2.0.0")));
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleimpl2", "bundleimpl2", "2.0.0")));
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleapi2", "bundleapi2", "2.0.0")));
DeploymentPackage dp2 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp2);
@@ -569,8 +569,8 @@
public void testUpdateWithDuplicateBundleFail() throws Exception
{
DeploymentPackageBuilder dpBuilder = createDeploymentPackageBuilder("c", "1.0.0");
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundleimpl1", "bundleimpl1", "1.0.0")));
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundleapi1", "bundleapi1", "1.0.0")));
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleimpl1", "bundleimpl1", "1.0.0")));
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleapi1", "bundleapi1", "1.0.0")));
// Should succeed, as the DP is correct...
DeploymentPackage dp1 = installDeploymentPackage(dpBuilder);
@@ -579,9 +579,9 @@
// then, install a fix package with implementation and api bundles in version 2.0.0, but *also* containing the original implementation
// bundle, which is incorrect (no bundles with the same BSN may exist in a DP)...
dpBuilder = createDeploymentPackageBuilder("c", "2.0.0").setFixPackage("[1.0.0,2.0.0]");
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundleapi1", "bundleapi1", "1.0.0")));
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundleimpl2", "bundleimpl2", "2.0.0")));
- dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundleimpl1", "bundleimpl1", "1.0.0")));
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleapi1", "bundleapi1", "1.0.0")));
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleimpl2", "bundleimpl2", "2.0.0")));
+ dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleimpl1", "bundleimpl1", "1.0.0")));
try
{
diff --git a/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/ResourceSharingTest.java b/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/ResourceSharingTest.java
index 68f1612..31d420a 100644
--- a/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/ResourceSharingTest.java
+++ b/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/ResourceSharingTest.java
@@ -39,16 +39,16 @@
DeploymentPackageBuilder dpBuilder1 = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder1
.add(dpBuilder1.createBundleResource()
- .setUrl(getTestBundle("bundle1"))
+ .setUrl(getTestBundleURL("bundle1"))
)
.add(dpBuilder1.createBundleResource()
- .setUrl(getTestBundle("bundle2"))
+ .setUrl(getTestBundleURL("bundle2"))
);
DeploymentPackageBuilder dpBuilder2 = createNewDeploymentPackageBuilder("0.8.0");
dpBuilder2
.add(dpBuilder2.createBundleResource()
- .setUrl(getTestBundle("bundle1"))
+ .setUrl(getTestBundleURL("bundle1"))
);
DeploymentPackage dp1 = installDeploymentPackage(dpBuilder1);
@@ -70,7 +70,7 @@
@Test
public void testBundleCannotBeSharedWithNonDeploymentPackagedBundle() throws Exception {
// Manually install a bundle...
- Bundle result = m_context.installBundle(getTestBundle("bundle1").toExternalForm());
+ Bundle result = m_context.installBundle(getTestBundleURL("bundle1").toExternalForm());
assertNotNull(result);
assertBundleExists(getSymbolicName("bundle1"), "1.0.0");
@@ -78,10 +78,10 @@
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder
.add(dpBuilder.createBundleResource()
- .setUrl(getTestBundle("bundle1"))
+ .setUrl(getTestBundleURL("bundle1"))
)
.add(dpBuilder.createBundleResource()
- .setUrl(getTestBundle("bundle2"))
+ .setUrl(getTestBundleURL("bundle2"))
);
try {
@@ -98,7 +98,7 @@
@Test
public void testForeignBundleCanCoexistWithPackagedBundleIfVersionsDiffer() throws Exception {
// Manually install a bundle...
- Bundle result = m_context.installBundle(getTestBundle("bundle1").toExternalForm());
+ Bundle result = m_context.installBundle(getTestBundleURL("bundle1").toExternalForm());
assertNotNull(result);
long bundleId = result.getBundleId();
@@ -110,11 +110,11 @@
dpBuilder
.add(dpBuilder.createBundleResource()
.setVersion("1.1.0")
- .setUrl(getTestBundle("bundle1"))
+ .setUrl(getTestBundleURL("bundle1"))
.setFilter(new JarManifestManipulatingFilter("Bundle-Version", "1.1.0"))
)
.add(dpBuilder.createBundleResource()
- .setUrl(getTestBundle("bundle2"))
+ .setUrl(getTestBundleURL("bundle2"))
);
// should succeed: valid-bundle1 is installed, but has a different version than the one in our DP...
diff --git a/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/UninstallDeploymentPackageTest.java b/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/UninstallDeploymentPackageTest.java
index d848a98..f10c029 100644
--- a/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/UninstallDeploymentPackageTest.java
+++ b/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/UninstallDeploymentPackageTest.java
@@ -43,8 +43,8 @@
public void testForcedUninstallDeploymentPackageWithMissingResourceProcessorSucceeds() throws Exception {
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")))
- .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundle("rp1")))
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")))
+ .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundleURL("rp1")))
.add(dpBuilder.createResource().setResourceProcessorPID(TEST_FAILING_BUNDLE_RP1).setUrl(getTestResource("test-config1.xml")));
DeploymentPackage dp = installDeploymentPackage(dpBuilder);
@@ -78,8 +78,8 @@
public void testUninstallBundleWithFragmentOk() throws Exception {
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")))
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("fragment1")));
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")))
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("fragment1")));
DeploymentPackage dp = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp);
@@ -109,11 +109,11 @@
public void testUninstallBundleWithOtherArtifactsOk() throws Exception {
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder
- .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundle("rp1")))
+ .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundleURL("rp1")))
.add(
dpBuilder.createResource().setResourceProcessorPID(TEST_FAILING_BUNDLE_RP1)
.setUrl(getTestResource("test-config1.xml")))
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle3")));
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle3")));
DeploymentPackage dp = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp);
@@ -142,8 +142,8 @@
public void testUninstallDeploymentPackageWithExceptionThrowingInCommitCausesNoRollbackOk() throws Exception {
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")))
- .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundle("rp1")))
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")))
+ .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundleURL("rp1")))
.add(dpBuilder.createResource().setResourceProcessorPID(TEST_FAILING_BUNDLE_RP1).setUrl(getTestResource("test-config1.xml")));
DeploymentPackage dp = installDeploymentPackage(dpBuilder);
@@ -171,8 +171,8 @@
public void testUninstallDeploymentPackageWithExceptionThrowingInDropAllResourcesCausesRollbackOk() throws Exception {
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")))
- .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundle("rp1")))
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")))
+ .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundleURL("rp1")))
.add(dpBuilder.createResource().setResourceProcessorPID(TEST_FAILING_BUNDLE_RP1).setUrl(getTestResource("test-config1.xml")));
DeploymentPackage dp = installDeploymentPackage(dpBuilder);
@@ -210,8 +210,8 @@
public void testUninstallDeploymentPackageWithExceptionThrowingInPrepareCausesRollbackOk() throws Exception {
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")))
- .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundle("rp1")))
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")))
+ .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundleURL("rp1")))
.add(dpBuilder.createResource().setResourceProcessorPID(TEST_FAILING_BUNDLE_RP1).setUrl(getTestResource("test-config1.xml")));
DeploymentPackage dp = installDeploymentPackage(dpBuilder);
@@ -246,8 +246,8 @@
public void testUninstallDeploymentPackageWithExceptionThrownInStopCauseNoRollbackOk() throws Exception {
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")))
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle3")));
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")))
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle3")));
DeploymentPackage dp = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp);
@@ -277,8 +277,8 @@
public void testUninstallDeploymentPackageWithMissingResourceProcessorCausesRollback() throws Exception {
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder
- .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")))
- .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundle("rp1")))
+ .add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")))
+ .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundleURL("rp1")))
.add(dpBuilder.createResource().setResourceProcessorPID(TEST_FAILING_BUNDLE_RP1).setUrl(getTestResource("test-config1.xml")));
DeploymentPackage dp = installDeploymentPackage(dpBuilder);
diff --git a/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/util/ArtifactData.java b/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/util/ArtifactData.java
index 518bfca..d3cdd9e 100644
--- a/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/util/ArtifactData.java
+++ b/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/util/ArtifactData.java
@@ -28,6 +28,7 @@
private String m_bundleSymbolicName;
private String m_bundleVersion;
private boolean m_isCustomizer;
+ private boolean m_needRP;
private String m_processorPID;
private boolean m_missing;
private ResourceFilter m_filter;
@@ -72,6 +73,10 @@
public boolean isMissing() {
return m_missing;
}
+
+ public boolean isResourceProcessorNeeded() {
+ return m_needRP;
+ }
void setArtifactResourceProcessor(String processorPID) {
m_processorPID = processorPID;
@@ -91,6 +96,10 @@
m_missing = missing;
}
+ void setNeedResourceProcessor(boolean needRP) {
+ m_needRP = needRP;
+ }
+
void setResourceProcessor(String processorPID) {
m_isCustomizer = true;
m_processorPID = processorPID;
diff --git a/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/util/DeploymentPackageBuilder.java b/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/util/DeploymentPackageBuilder.java
index d193ce7..1d67ddb 100644
--- a/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/util/DeploymentPackageBuilder.java
+++ b/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/util/DeploymentPackageBuilder.java
@@ -69,16 +69,16 @@
return new ByteArrayInputStream(baos.toByteArray());
}
-
+
protected abstract Manifest filterManifest(Manifest manifest);
}
-
+
/**
* Simple manifest JAR manipulator implementation.
*/
public static class JarManifestManipulatingFilter extends JarManifestFilter {
private final String[] m_replacementEntries;
-
+
public JarManifestManipulatingFilter(String... replacementEntries) {
if (replacementEntries == null || ((replacementEntries.length) % 2 != 0)) {
throw new IllegalArgumentException("Entries must be a multiple of two!");
@@ -90,13 +90,13 @@
protected Manifest filterManifest(Manifest manifest) {
for (int i = 0; i < m_replacementEntries.length; i += 2) {
String key = m_replacementEntries[i];
- String value = m_replacementEntries[i+1];
+ String value = m_replacementEntries[i + 1];
manifest.getMainAttributes().putValue(key, value);
}
return manifest;
}
}
-
+
private static final int BUFFER_SIZE = 32 * 1024;
private final String m_symbolicName;
@@ -112,7 +112,7 @@
private DeploymentPackageBuilder(String symbolicName, String version) {
m_symbolicName = symbolicName;
m_version = version;
-
+
m_verification = true;
}
@@ -172,8 +172,9 @@
}
/**
- * Disables the verification of the generated deployment package, potentially causing an erroneous result to be generated.
- *
+ * Disables the verification of the generated deployment package, potentially causing an erroneous result to be
+ * generated.
+ *
* @return this builder.
*/
public DeploymentPackageBuilder disableVerification() {
@@ -209,12 +210,12 @@
artifacts.addAll(m_bundles);
artifacts.addAll(m_processors);
artifacts.addAll(m_artifacts);
-
+
if (m_verification) {
validateProcessedArtifacts();
validateMissingArtifacts(artifacts);
}
-
+
Manifest m = createManifest(artifacts);
writeStream(artifacts, m, output);
}
@@ -284,7 +285,7 @@
a.putValue("Deployment-ProvidesResourceProcessor", file.getProcessorPid());
}
}
- else {
+ else if (file.isResourceProcessorNeeded()) {
a.putValue("Resource-Processor", file.getProcessorPid());
}
@@ -297,19 +298,19 @@
return manifest;
}
-
+
private void validateMissingArtifacts(List<ArtifactData> files) throws Exception {
boolean missing = false;
-
+
Iterator<ArtifactData> artifactIter = files.iterator();
while (artifactIter.hasNext() && !missing) {
ArtifactData data = artifactIter.next();
-
+
if (data.isMissing()) {
missing = true;
}
}
-
+
if (missing && (m_fixPackageVersion == null || "".equals(m_fixPackageVersion))) {
throw new Exception("Artifact cannot be missing without a fix package version!");
}
@@ -320,20 +321,18 @@
while (artifactIter.hasNext()) {
ArtifactData data = artifactIter.next();
String pid = data.getProcessorPid();
- boolean found = false;
+ boolean found = pid == null;
Iterator<ArtifactData> processorIter = m_processors.iterator();
- while (processorIter.hasNext()) {
+ while (!found && processorIter.hasNext()) {
ArtifactData processor = processorIter.next();
if (pid.equals(processor.getProcessorPid())) {
found = true;
- break;
}
}
- if (!found) {
- throw new Exception("No resource processor found for artifact " + data.getURL()
- + " with processor PID " + pid);
+ if (!found && data.isResourceProcessorNeeded()) {
+ throw new Exception("No resource processor found for artifact " + data.getURL() + " with processor PID " + pid);
}
}
}
diff --git a/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/util/ResourceDataBuilder.java b/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/util/ResourceDataBuilder.java
index 7008ac4..50551eb 100644
--- a/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/util/ResourceDataBuilder.java
+++ b/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/util/ResourceDataBuilder.java
@@ -24,11 +24,16 @@
* Provides a resource data builder.
*/
public class ResourceDataBuilder extends ArtifactDataBuilder<ResourceDataBuilder> {
-
+ private boolean m_needRP;
private String m_resourceProcessorPID;
public ResourceDataBuilder() {
- super();
+ m_needRP = true;
+ }
+
+ public ResourceDataBuilder setNeedResourceProcessor(boolean needRP) {
+ m_needRP = needRP;
+ return this;
}
public ResourceDataBuilder setResourceProcessorPID(String resourceProcessorPID) {
@@ -39,6 +44,7 @@
@Override ArtifactData build() {
ArtifactData result = super.build();
result.setArtifactResourceProcessor(m_resourceProcessorPID);
+ result.setNeedResourceProcessor(m_needRP);
return result;
}
@@ -49,7 +55,7 @@
@Override
void validate() throws RuntimeException {
- if (m_resourceProcessorPID == null || "".equals(m_resourceProcessorPID.trim())) {
+ if (m_needRP && ((m_resourceProcessorPID == null || "".equals(m_resourceProcessorPID.trim())))) {
throw new RuntimeException("Artifact resource processor PID is missing!");
}
diff --git a/deploymentadmin/itest/src/test/resources/LICENSE b/deploymentadmin/itest/src/test/resources/LICENSE
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/deploymentadmin/itest/src/test/resources/LICENSE
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/deploymentadmin/itest/src/test/resources/logo.png b/deploymentadmin/itest/src/test/resources/logo.png
new file mode 100644
index 0000000..dccbddc
--- /dev/null
+++ b/deploymentadmin/itest/src/test/resources/logo.png
Binary files differ
diff --git a/deploymentadmin/testbundles/bundleimpl1/pom.xml b/deploymentadmin/testbundles/bundleimpl1/pom.xml
index d01223c..c79e155 100644
--- a/deploymentadmin/testbundles/bundleimpl1/pom.xml
+++ b/deploymentadmin/testbundles/bundleimpl1/pom.xml
@@ -29,7 +29,7 @@
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.deploymentadmin.test.bundleapi</artifactId>
+ <artifactId>org.apache.felix.deploymentadmin.test.bundleapi1</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
diff --git a/deploymentadmin/testbundles/bundleimpl2/pom.xml b/deploymentadmin/testbundles/bundleimpl2/pom.xml
index 226c7b2..bdbd70f 100644
--- a/deploymentadmin/testbundles/bundleimpl2/pom.xml
+++ b/deploymentadmin/testbundles/bundleimpl2/pom.xml
@@ -29,7 +29,7 @@
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.deploymentadmin.test.bundleapi</artifactId>
+ <artifactId>org.apache.felix.deploymentadmin.test.bundleapi2</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>