Added a whole collection of tests to ensure that DeploymentAdmin conforms to the specification and works correctly. Refactored some of the code. Specifically modified the uninstall behavior to make it spec compliant.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1352090 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/deploymentadmin/testbundles/bundle1/bnd.bnd b/deploymentadmin/testbundles/bundle1/bnd.bnd
new file mode 100644
index 0000000..05e274f
--- /dev/null
+++ b/deploymentadmin/testbundles/bundle1/bnd.bnd
@@ -0,0 +1,5 @@
+Bundle-Version: 1.0.0
+Bundle-SymbolicName: testbundles.bundle1
+Bundle-Activator: org.apache.felix.deploymentadmin.test.bundle1.impl.Activator
+Private-Package: org.apache.felix.deploymentadmin.test.bundle1.impl
+Export-Package: org.apache.felix.deploymentadmin.test.bundle1
diff --git a/deploymentadmin/testbundles/bundle1/pom.xml b/deploymentadmin/testbundles/bundle1/pom.xml
new file mode 100644
index 0000000..9e4d6e3
--- /dev/null
+++ b/deploymentadmin/testbundles/bundle1/pom.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 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. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.deploymentadmin.testbundles</artifactId>
+ <version>1</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <name>Apache Felix DeploymentAdmin Test Bundle 1</name>
+ <version>1.0.0</version>
+ <artifactId>org.apache.felix.deploymentadmin.test.bundle1</artifactId>
+ <packaging>bundle</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.3.4</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <_include>bnd.bnd</_include>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/deploymentadmin/testbundles/bundle1/src/main/java/org/apache/felix/deploymentadmin/test/bundle1/TestService.java b/deploymentadmin/testbundles/bundle1/src/main/java/org/apache/felix/deploymentadmin/test/bundle1/TestService.java
new file mode 100644
index 0000000..2effe5a
--- /dev/null
+++ b/deploymentadmin/testbundles/bundle1/src/main/java/org/apache/felix/deploymentadmin/test/bundle1/TestService.java
@@ -0,0 +1,31 @@
+/*
+ * 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.test.bundle1;
+
+/**
+ * Provides a test service.
+ */
+public interface TestService {
+ /**
+ * Does something.
+ *
+ * @return a string result, never <code>null</code>.
+ */
+ String doIt();
+}
diff --git a/deploymentadmin/testbundles/bundle1/src/main/java/org/apache/felix/deploymentadmin/test/bundle1/impl/Activator.java b/deploymentadmin/testbundles/bundle1/src/main/java/org/apache/felix/deploymentadmin/test/bundle1/impl/Activator.java
new file mode 100644
index 0000000..a175823
--- /dev/null
+++ b/deploymentadmin/testbundles/bundle1/src/main/java/org/apache/felix/deploymentadmin/test/bundle1/impl/Activator.java
@@ -0,0 +1,34 @@
+/*
+ * 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.test.bundle1.impl;
+
+import org.apache.felix.deploymentadmin.test.bundle1.TestService;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ public void start(BundleContext context) throws Exception {
+ context.registerService(TestService.class.getName(), new TestServiceImpl(), null);
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ // No-op
+ }
+}
diff --git a/deploymentadmin/testbundles/bundle1/src/main/java/org/apache/felix/deploymentadmin/test/bundle1/impl/TestServiceImpl.java b/deploymentadmin/testbundles/bundle1/src/main/java/org/apache/felix/deploymentadmin/test/bundle1/impl/TestServiceImpl.java
new file mode 100644
index 0000000..581d7dc
--- /dev/null
+++ b/deploymentadmin/testbundles/bundle1/src/main/java/org/apache/felix/deploymentadmin/test/bundle1/impl/TestServiceImpl.java
@@ -0,0 +1,31 @@
+/*
+ * 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.test.bundle1.impl;
+
+import org.apache.felix.deploymentadmin.test.bundle1.TestService;
+
+/**
+ * Provides a default implementation for {@link TestService}.
+ */
+public class TestServiceImpl implements TestService {
+
+ public String doIt() {
+ return "Hello World!";
+ }
+}
diff --git a/deploymentadmin/testbundles/bundle2/bnd.bnd b/deploymentadmin/testbundles/bundle2/bnd.bnd
new file mode 100644
index 0000000..2c82fd2
--- /dev/null
+++ b/deploymentadmin/testbundles/bundle2/bnd.bnd
@@ -0,0 +1,6 @@
+Bundle-Version: 1.0.0
+Bundle-SymbolicName: testbundles.bundle2
+Bundle-Activator: org.apache.felix.deploymentadmin.test.bundle2.impl.Activator
+Private-Package: org.apache.felix.deploymentadmin.test.bundle2.impl
+Import-Package: org.apache.felix.deploymentadmin.test.bundle1, org.osgi.framework, org.osgi.util.tracker, *
+
diff --git a/deploymentadmin/testbundles/bundle2/pom.xml b/deploymentadmin/testbundles/bundle2/pom.xml
new file mode 100644
index 0000000..2ef211b
--- /dev/null
+++ b/deploymentadmin/testbundles/bundle2/pom.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 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. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.deploymentadmin.testbundles</artifactId>
+ <version>1</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <name>Apache Felix DeploymentAdmin Test Bundle 2</name>
+ <version>1.0.0</version>
+ <artifactId>org.apache.felix.deploymentadmin.test.bundle2</artifactId>
+ <packaging>bundle</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>org.apache.felix.deploymentadmin.test.bundle1</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.3.4</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <_include>bnd.bnd</_include>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/deploymentadmin/testbundles/bundle2/src/main/java/org/apache/felix/deploymentadmin/test/bundle2/impl/Activator.java b/deploymentadmin/testbundles/bundle2/src/main/java/org/apache/felix/deploymentadmin/test/bundle2/impl/Activator.java
new file mode 100644
index 0000000..cc17983
--- /dev/null
+++ b/deploymentadmin/testbundles/bundle2/src/main/java/org/apache/felix/deploymentadmin/test/bundle2/impl/Activator.java
@@ -0,0 +1,58 @@
+/*
+ * 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.test.bundle2.impl;
+
+import org.apache.felix.deploymentadmin.test.bundle1.TestService;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
+import org.osgi.util.tracker.ServiceTrackerCustomizer;
+
+public class Activator implements BundleActivator, ServiceTrackerCustomizer {
+
+ ServiceTracker m_tracker;
+ BundleContext m_context;
+
+ public void start(BundleContext context) throws Exception {
+ m_context = context;
+
+ m_tracker = new ServiceTracker(context, TestService.class.getName(), this);
+ m_tracker.open();
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ // Nop
+ m_tracker.close();
+ }
+
+ public Object addingService(ServiceReference reference) {
+ Object service = m_context.getService(reference);
+ System.out.println("Service added: " + service);
+ return service;
+ }
+
+ public void modifiedService(ServiceReference reference, Object service) {
+ System.out.println("Service modified: " + service);
+ }
+
+ public void removedService(ServiceReference reference, Object service) {
+ System.out.println("Service removed: " + service);
+ }
+}
diff --git a/deploymentadmin/testbundles/bundle3/bnd.bnd b/deploymentadmin/testbundles/bundle3/bnd.bnd
new file mode 100644
index 0000000..55d93bc
--- /dev/null
+++ b/deploymentadmin/testbundles/bundle3/bnd.bnd
@@ -0,0 +1,5 @@
+Bundle-Version: 1.0.0
+Bundle-SymbolicName: testbundles.bundle3
+Bundle-Activator: org.apache.felix.deploymentadmin.test.bundle3.impl.Activator
+Private-Package: org.apache.felix.deploymentadmin.test.bundle3.impl
+
diff --git a/deploymentadmin/testbundles/bundle3/pom.xml b/deploymentadmin/testbundles/bundle3/pom.xml
new file mode 100644
index 0000000..6e0e675
--- /dev/null
+++ b/deploymentadmin/testbundles/bundle3/pom.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 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. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.deploymentadmin.testbundles</artifactId>
+ <version>1</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <name>Apache Felix DeploymentAdmin Test Bundle 3</name>
+ <version>1.0.0</version>
+ <artifactId>org.apache.felix.deploymentadmin.test.bundle3</artifactId>
+ <packaging>bundle</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.3.4</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <_include>bnd.bnd</_include>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/deploymentadmin/testbundles/bundle3/src/main/java/org/apache/felix/deploymentadmin/test/bundle3/impl/Activator.java b/deploymentadmin/testbundles/bundle3/src/main/java/org/apache/felix/deploymentadmin/test/bundle3/impl/Activator.java
new file mode 100644
index 0000000..cbc3e80
--- /dev/null
+++ b/deploymentadmin/testbundles/bundle3/src/main/java/org/apache/felix/deploymentadmin/test/bundle3/impl/Activator.java
@@ -0,0 +1,48 @@
+/*
+ * 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.test.bundle3.impl;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * Throws an exception upon start or stop, depending on a system property.
+ */
+public class Activator implements BundleActivator {
+
+ public void start(BundleContext context) throws Exception {
+ checkMethodRuntimeFailure("start");
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ checkMethodRuntimeFailure("stop");
+ }
+
+ private void checkMethodRuntimeFailure(String methodName) {
+ if (shouldFail(methodName)) {
+ throw new RuntimeException(methodName + " fails forcedly!");
+ }
+ }
+
+ private boolean shouldFail(String methodName) {
+ String value = System.getProperty("bundle3", "");
+ return methodName.equals(value);
+ }
+
+}
diff --git a/deploymentadmin/testbundles/pom.xml b/deploymentadmin/testbundles/pom.xml
new file mode 100644
index 0000000..5b0c91e
--- /dev/null
+++ b/deploymentadmin/testbundles/pom.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 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. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>felix-parent</artifactId>
+ <version>1.2.0</version>
+ <relativePath>../../pom/pom.xml</relativePath>
+ </parent>
+ <properties>
+ <osgi.version>4.2.0</osgi.version>
+ </properties>
+ <name>Apache Felix DeploymentAdmin Test Bundles</name>
+ <artifactId>org.apache.felix.deploymentadmin.testbundles</artifactId>
+ <version>1</version>
+ <packaging>pom</packaging>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>${osgi.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <version>${osgi.version}</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+ <modules>
+ <module>bundle1</module>
+ <module>bundle2</module>
+ <module>bundle3</module>
+ <module>rp1</module>
+ <module>rp2</module>
+ </modules>
+</project>
diff --git a/deploymentadmin/testbundles/rp1/bnd.bnd b/deploymentadmin/testbundles/rp1/bnd.bnd
new file mode 100644
index 0000000..ab9642b
--- /dev/null
+++ b/deploymentadmin/testbundles/rp1/bnd.bnd
@@ -0,0 +1,6 @@
+Bundle-Version: 1.0.0
+Bundle-SymbolicName: testbundles.rp1
+Bundle-Activator: org.apache.felix.deploymentadmin.test.rp1.impl.Activator
+Private-Package: org.apache.felix.deploymentadmin.test.rp1.impl
+DeploymentPackage-Customizer: true
+Deployment-ProvidesResourceProcessor: org.apache.felix.deploymentadmin.test.rp1
diff --git a/deploymentadmin/testbundles/rp1/pom.xml b/deploymentadmin/testbundles/rp1/pom.xml
new file mode 100644
index 0000000..6517dcc
--- /dev/null
+++ b/deploymentadmin/testbundles/rp1/pom.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 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. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.deploymentadmin.testbundles</artifactId>
+ <version>1</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <name>Apache Felix DeploymentAdmin Test RP 1</name>
+ <version>1.0.0</version>
+ <artifactId>org.apache.felix.deploymentadmin.test.rp1</artifactId>
+ <packaging>bundle</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.3.4</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <_include>bnd.bnd</_include>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/deploymentadmin/testbundles/rp1/src/main/java/org/apache/felix/deploymentadmin/test/rp1/impl/Activator.java b/deploymentadmin/testbundles/rp1/src/main/java/org/apache/felix/deploymentadmin/test/rp1/impl/Activator.java
new file mode 100644
index 0000000..009b709
--- /dev/null
+++ b/deploymentadmin/testbundles/rp1/src/main/java/org/apache/felix/deploymentadmin/test/rp1/impl/Activator.java
@@ -0,0 +1,97 @@
+/*
+ * 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.test.rp1.impl;
+
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.service.deploymentadmin.spi.DeploymentSession;
+import org.osgi.service.deploymentadmin.spi.ResourceProcessor;
+import org.osgi.service.deploymentadmin.spi.ResourceProcessorException;
+
+/**
+ * Provides a bundle activator for registering the resource processor.
+ */
+public class Activator implements BundleActivator, ResourceProcessor {
+
+ public void start(BundleContext context) throws Exception {
+ checkMethodRuntimeFailure("start");
+
+ Properties props = new Properties();
+ props.put(Constants.SERVICE_PID, "org.apache.felix.deploymentadmin.test.rp1");
+
+ context.registerService(ResourceProcessor.class.getName(), this, props);
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ checkMethodRuntimeFailure("stop");
+ }
+
+ public void begin(DeploymentSession session) {
+ checkMethodRuntimeFailure("begin");
+ }
+
+ public void process(String name, InputStream stream) throws ResourceProcessorException {
+ checkMethodFailure(ResourceProcessorException.CODE_RESOURCE_SHARING_VIOLATION, "process");
+ }
+
+ public void dropped(String resource) throws ResourceProcessorException {
+ checkMethodFailure(ResourceProcessorException.CODE_OTHER_ERROR, "dropped");
+ }
+
+ public void dropAllResources() throws ResourceProcessorException {
+ checkMethodFailure(ResourceProcessorException.CODE_OTHER_ERROR, "dropAllResources");
+ }
+
+ public void prepare() throws ResourceProcessorException {
+ checkMethodFailure(ResourceProcessorException.CODE_PREPARE, "prepare");
+ }
+
+ public void commit() {
+ checkMethodRuntimeFailure("commit");
+ }
+
+ public void rollback() {
+ checkMethodRuntimeFailure("rollback");
+ }
+
+ public void cancel() {
+ checkMethodRuntimeFailure("cancel");
+ }
+
+ private void checkMethodFailure(int code, String methodName) throws ResourceProcessorException {
+ if (shouldFail(methodName)) {
+ throw new ResourceProcessorException(code, methodName + " fails forcedly!");
+ }
+ }
+
+ private void checkMethodRuntimeFailure(String methodName) {
+ if (shouldFail(methodName)) {
+ throw new RuntimeException(methodName + " fails forcedly!");
+ }
+ }
+
+ private boolean shouldFail(String methodName) {
+ String value = System.getProperty("rp1", "");
+ return methodName.equals(value);
+ }
+}
diff --git a/deploymentadmin/testbundles/rp2/bnd.bnd b/deploymentadmin/testbundles/rp2/bnd.bnd
new file mode 100644
index 0000000..a9d03cb
--- /dev/null
+++ b/deploymentadmin/testbundles/rp2/bnd.bnd
@@ -0,0 +1,6 @@
+Bundle-Version: 1.0.0
+Bundle-SymbolicName: testbundles.rp2
+Bundle-Activator: org.apache.felix.deploymentadmin.test.rp2.impl.Activator
+Private-Package: org.apache.felix.deploymentadmin.test.rp2.impl
+DeploymentPackage-Customizer: true
+Deployment-ProvidesResourceProcessor: org.apache.felix.deploymentadmin.test.rp2
diff --git a/deploymentadmin/testbundles/rp2/pom.xml b/deploymentadmin/testbundles/rp2/pom.xml
new file mode 100644
index 0000000..3f07541
--- /dev/null
+++ b/deploymentadmin/testbundles/rp2/pom.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 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. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.deploymentadmin.testbundles</artifactId>
+ <version>1</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <properties>
+ <osgi.version>4.2.0</osgi.version>
+ </properties>
+ <name>Apache Felix DeploymentAdmin Test RP 2</name>
+ <version>1.0.0</version>
+ <artifactId>org.apache.felix.deploymentadmin.test.rp2</artifactId>
+ <packaging>bundle</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.3.4</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <_include>bnd.bnd</_include>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/deploymentadmin/testbundles/rp2/src/main/java/org/apache/felix/deploymentadmin/test/rp2/impl/Activator.java b/deploymentadmin/testbundles/rp2/src/main/java/org/apache/felix/deploymentadmin/test/rp2/impl/Activator.java
new file mode 100644
index 0000000..4ee24ba
--- /dev/null
+++ b/deploymentadmin/testbundles/rp2/src/main/java/org/apache/felix/deploymentadmin/test/rp2/impl/Activator.java
@@ -0,0 +1,100 @@
+/*
+ * 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.test.rp2.impl;
+
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.service.deploymentadmin.spi.DeploymentSession;
+import org.osgi.service.deploymentadmin.spi.ResourceProcessor;
+import org.osgi.service.deploymentadmin.spi.ResourceProcessorException;
+
+/**
+ * Provides a bundle activator and resource processor implementation that can delay methods for a
+ * certain amount of time (defined by system property "rp2.delay", defaults to 2000 milliseconds).
+ */
+public class Activator implements BundleActivator, ResourceProcessor {
+
+ public void start(BundleContext context) throws Exception {
+ Properties props = new Properties();
+ props.put(Constants.SERVICE_PID, "org.apache.felix.deploymentadmin.bundle.rp2");
+
+ context.registerService(ResourceProcessor.class.getName(), this, props);
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ delayMethod("stop");
+ }
+
+ public void begin(DeploymentSession session) {
+ delayMethod("begin");
+ }
+
+ public void process(String name, InputStream stream) throws ResourceProcessorException {
+ delayMethod("process");
+ }
+
+ public void dropped(String resource) throws ResourceProcessorException {
+ delayMethod("dropped");
+ }
+
+ public void dropAllResources() throws ResourceProcessorException {
+ delayMethod("dropAllResources");
+ }
+
+ public void prepare() throws ResourceProcessorException {
+ delayMethod("prepare");
+ }
+
+ public void commit() {
+ delayMethod("commit");
+ }
+
+ public void rollback() {
+ delayMethod("rollback");
+ }
+
+ public void cancel() {
+ delayMethod("cancel");
+ }
+
+ private void delayMethod(String methodName) {
+ try {
+ if (shouldDelayMethod(methodName)) {
+ String value = System.getProperty("rp2.delay", "2000");
+
+ Thread.sleep(Long.parseLong(value));
+ }
+ }
+ catch (NumberFormatException exception) {
+ exception.printStackTrace();
+ }
+ catch (InterruptedException exception) {
+ Thread.currentThread().interrupt();
+ }
+ }
+
+ private boolean shouldDelayMethod(String methodName) {
+ String value = System.getProperty("rp2", "");
+ return methodName.equals(value);
+ }
+}