FELIX-4167: added integration test for fragment bundles.



git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1504847 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/deploymentadmin/itest/pom.xml b/deploymentadmin/itest/pom.xml
index 8a08ee5..7b89b57 100644
--- a/deploymentadmin/itest/pom.xml
+++ b/deploymentadmin/itest/pom.xml
@@ -20,57 +20,69 @@
 	</parent>
 	<properties>
 		<osgi.version>4.2.0</osgi.version>
-		<pax.exam.version>2.4.0</pax.exam.version>
-		<pax.exam.plugin.version>1.2.4</pax.exam.plugin.version>
-		<pax.url.aether.version>1.4.0</pax.url.aether.version>
-		<pax.swissbox.version>1.3.1</pax.swissbox.version>
-		<pax.runner.version>1.7.6</pax.runner.version>
+		<pax.exam.version>3.1.0</pax.exam.version>
+		<pax.url.version>1.5.2</pax.url.version>
 	</properties>
 	<name>Apache Felix DeploymentAdmin Integration Tests</name>
 	<version>0.1.1-SNAPSHOT</version>
 	<artifactId>org.apache.felix.deploymentadmin.itest</artifactId>
 	<packaging>jar</packaging>
 	<dependencies>
+
 		<dependency>
-			<groupId>org.osgi</groupId>
-			<artifactId>org.osgi.core</artifactId>
-			<version>${osgi.version}</version>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>org.apache.felix.framework</artifactId>
+			<version>4.2.1</version>
 			<scope>test</scope>
 		</dependency>
+
 		<dependency>
 			<groupId>org.osgi</groupId>
 			<artifactId>org.osgi.compendium</artifactId>
 			<version>${osgi.version}</version>
 			<scope>test</scope>
 		</dependency>
+
+		<dependency>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>org.apache.felix.dependencymanager</artifactId>
+			<version>3.1.0</version>
+			<scope>test</scope>
+		</dependency>
 		<dependency>
 			<groupId>org.apache.felix</groupId>
 			<artifactId>org.apache.felix.deploymentadmin</artifactId>
-			<version>0.9.1-SNAPSHOT</version>
+			<version>0.9.5-SNAPSHOT</version>
 			<scope>test</scope>
 		</dependency>
 		<dependency>
 			<groupId>org.apache.felix</groupId>
 			<artifactId>org.apache.felix.metatype</artifactId>
-			<version>1.0.5-SNAPSHOT</version>
+			<version>1.0.6</version>
 			<scope>test</scope>
 		</dependency>
 		<dependency>
 			<groupId>org.apache.felix</groupId>
 			<artifactId>org.apache.felix.configadmin</artifactId>
-			<version>1.2.8</version>
+			<version>1.6.0</version>
 			<scope>test</scope>
 		</dependency>
 		<dependency>
 			<groupId>org.apache.felix</groupId>
 			<artifactId>org.apache.felix.eventadmin</artifactId>
-			<version>1.2.14</version>
+			<version>1.3.2</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>org.apache.felix.log</artifactId>
+			<version>1.0.1</version>
 			<scope>test</scope>
 		</dependency>
 		<dependency>
 			<groupId>junit</groupId>
 			<artifactId>junit</artifactId>
-			<version>4.10</version>
+			<version>4.11</version>
 			<scope>test</scope>
 		</dependency>
 
@@ -82,19 +94,7 @@
 		</dependency>
 		<dependency>
 			<groupId>org.ops4j.pax.exam</groupId>
-			<artifactId>pax-exam-container-forked</artifactId>
-			<version>${pax.exam.version}</version>
-			<scope>test</scope>
-		</dependency>
-		<dependency>
-			<groupId>org.ops4j.pax.runner</groupId>
-			<artifactId>pax-runner-no-jcl</artifactId>
-			<version>${pax.runner.version}</version>
-			<scope>test</scope>
-		</dependency>
-		<dependency>
-			<groupId>org.ops4j.pax.exam</groupId>
-			<artifactId>pax-exam-link-assembly</artifactId>
+			<artifactId>pax-exam-container-native</artifactId>
 			<version>${pax.exam.version}</version>
 			<scope>test</scope>
 		</dependency>
@@ -107,51 +107,39 @@
 		<dependency>
 			<groupId>org.ops4j.pax.url</groupId>
 			<artifactId>pax-url-aether</artifactId>
-			<version>${pax.url.aether.version}</version>
-			<scope>test</scope>
-		</dependency>
-		<dependency>
-			<groupId>org.ops4j.pax.url</groupId>
-			<artifactId>pax-url-wrap</artifactId>
-			<version>${pax.url.aether.version}</version>
-			<scope>test</scope>
-		</dependency>
-		<dependency>
-			<groupId>javax.inject</groupId>
-			<artifactId>javax.inject</artifactId>
-			<version>1</version>
+			<version>${pax.url.version}</version>
 			<scope>test</scope>
 		</dependency>
 
 		<dependency>
-			<groupId>org.apache.felix</groupId>
-			<artifactId>org.apache.felix.framework</artifactId>
-			<version>4.0.2</version>
+			<groupId>ch.qos.logback</groupId>
+			<artifactId>logback-core</artifactId>
+			<version>0.9.20</version>
 			<scope>test</scope>
 		</dependency>
-
 		<dependency>
-			<groupId>org.slf4j</groupId>
-			<artifactId>slf4j-simple</artifactId>
-			<version>1.6.0</version>
-			<scope>compile</scope>
-		</dependency>
-
-		<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>
+			<groupId>ch.qos.logback</groupId>
+			<artifactId>logback-classic</artifactId>
+			<version>0.9.20</version>
+			<scope>test</scope>
 		</dependency>
 
 	</dependencies>
 	<build>
 		<plugins>
 			<plugin>
+				<groupId>org.apache.servicemix.tooling</groupId>
+				<artifactId>depends-maven-plugin</artifactId>
+				<executions>
+					<execution>
+						<id>generate-depends-file</id>
+						<goals>
+							<goal>generate-depends-file</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+			<plugin>
 				<groupId>org.apache.maven.plugins</groupId>
 				<artifactId>maven-compiler-plugin</artifactId>
 				<configuration>
@@ -160,5 +148,43 @@
 				</configuration>
 			</plugin>
 		</plugins>
+		<pluginManagement>
+			<plugins>
+				<!--This plugin's configuration is used to store Eclipse m2e settings 
+					only. It has no influence on the Maven build itself. -->
+				<plugin>
+					<groupId>org.eclipse.m2e</groupId>
+					<artifactId>lifecycle-mapping</artifactId>
+					<version>1.0.0</version>
+					<configuration>
+						<lifecycleMappingMetadata>
+							<pluginExecutions>
+								<pluginExecution>
+									<pluginExecutionFilter>
+										<groupId>
+											org.apache.servicemix.tooling
+										</groupId>
+										<artifactId>
+											depends-maven-plugin
+										</artifactId>
+										<versionRange>
+											[1.2,)
+										</versionRange>
+										<goals>
+											<goal>
+												generate-depends-file
+											</goal>
+										</goals>
+									</pluginExecutionFilter>
+									<action>
+										<ignore></ignore>
+									</action>
+								</pluginExecution>
+							</pluginExecutions>
+						</lifecycleMappingMetadata>
+					</configuration>
+				</plugin>
+			</plugins>
+		</pluginManagement>
 	</build>
 </project>
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 b44e357..dd25fe2 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
@@ -18,21 +18,18 @@
  */
 package org.apache.felix.deploymentadmin.itest;
 
-import static org.ops4j.pax.exam.Constants.START_LEVEL_SYSTEM_BUNDLES;
-import static org.ops4j.pax.exam.Constants.START_LEVEL_TEST_BUNDLE;
 import static org.ops4j.pax.exam.CoreOptions.bootDelegationPackage;
 import static org.ops4j.pax.exam.CoreOptions.cleanCaches;
-import static org.ops4j.pax.exam.CoreOptions.felix;
-import static org.ops4j.pax.exam.CoreOptions.frameworkStartLevel;
 import static org.ops4j.pax.exam.CoreOptions.junitBundles;
 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
 import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.url;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
 
 import java.io.File;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -44,18 +41,18 @@
 import junit.framework.TestCase;
 
 import org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder;
+import org.junit.After;
 import org.junit.Before;
-import org.ops4j.pax.exam.CoreOptions;
+import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.FrameworkEvent;
 import org.osgi.framework.FrameworkListener;
 import org.osgi.framework.Version;
+import org.osgi.framework.wiring.FrameworkWiring;
 import org.osgi.service.deploymentadmin.DeploymentAdmin;
 import org.osgi.service.deploymentadmin.DeploymentException;
-import org.osgi.service.packageadmin.PackageAdmin;
 import org.osgi.util.tracker.ServiceTracker;
 
 /**
@@ -72,8 +69,6 @@
     protected volatile BundleContext m_context;
     @Inject
     protected volatile DeploymentAdmin m_deploymentAdmin;
-    @Inject
-    protected volatile PackageAdmin m_packageAdmin;
 
     protected volatile AtomicInteger m_gate = new AtomicInteger(0);
     protected volatile String m_testBundleBasePath;
@@ -82,40 +77,30 @@
     private int cnt = 0;        
     
     @Configuration
-    public Option[] config() {
+    public Option[] config() throws Exception {
+        File f = new File("src/test/resources/logback.xml");
+        if (!f.exists()) {
+            throw new RuntimeException("No log configuration...!");
+        }
         return options(
             bootDelegationPackage("sun.*"),
             cleanCaches(),
-            CoreOptions.systemProperty("logback.configurationFile").value("file:src/test/resources/logback.xml"),
-//            CoreOptions.vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8787"),
-
-            mavenBundle("org.slf4j", "slf4j-api").version("1.6.5").startLevel(START_LEVEL_SYSTEM_BUNDLES),
-            mavenBundle("ch.qos.logback", "logback-core").version("1.0.6").startLevel(START_LEVEL_SYSTEM_BUNDLES),
-            mavenBundle("ch.qos.logback", "logback-classic").version("1.0.6").startLevel(START_LEVEL_SYSTEM_BUNDLES),
-
-            url("link:classpath:META-INF/links/org.ops4j.pax.exam.link").startLevel(START_LEVEL_SYSTEM_BUNDLES),
-            url("link:classpath:META-INF/links/org.ops4j.pax.exam.inject.link").startLevel(START_LEVEL_SYSTEM_BUNDLES),
-            url("link:classpath:META-INF/links/org.ops4j.pax.extender.service.link").startLevel(START_LEVEL_SYSTEM_BUNDLES),
-            url("link:classpath:META-INF/links/org.ops4j.base.link").startLevel(START_LEVEL_SYSTEM_BUNDLES),
-            url("link:classpath:META-INF/links/org.ops4j.pax.swissbox.core.link").startLevel(START_LEVEL_SYSTEM_BUNDLES),
-            url("link:classpath:META-INF/links/org.ops4j.pax.swissbox.extender.link").startLevel(START_LEVEL_SYSTEM_BUNDLES),
-            url("link:classpath:META-INF/links/org.ops4j.pax.swissbox.lifecycle.link").startLevel(START_LEVEL_SYSTEM_BUNDLES),
-            url("link:classpath:META-INF/links/org.ops4j.pax.swissbox.framework.link").startLevel(START_LEVEL_SYSTEM_BUNDLES),
-            url("link:classpath:META-INF/links/org.apache.geronimo.specs.atinject.link").startLevel(START_LEVEL_SYSTEM_BUNDLES),
-
-            mavenBundle("org.osgi", "org.osgi.core").version("4.2.0").startLevel(START_LEVEL_SYSTEM_BUNDLES),
-            mavenBundle("org.osgi", "org.osgi.compendium").version("4.2.0").startLevel(START_LEVEL_SYSTEM_BUNDLES),
-            mavenBundle("org.apache.felix", "org.apache.felix.dependencymanager").version("3.0.0").startLevel(START_LEVEL_SYSTEM_BUNDLES),
-            mavenBundle("org.apache.felix", "org.apache.felix.deploymentadmin").version("0.9.1-SNAPSHOT").startLevel(START_LEVEL_SYSTEM_BUNDLES),
-            mavenBundle("org.apache.felix", "org.apache.felix.eventadmin").version("1.2.14").startLevel(START_LEVEL_SYSTEM_BUNDLES),
-            mavenBundle("org.apache.felix", "org.apache.felix.configadmin").version("1.2.8").startLevel(START_LEVEL_SYSTEM_BUNDLES),
-            mavenBundle("org.apache.felix", "org.apache.felix.log").version("1.0.1").startLevel(START_LEVEL_SYSTEM_BUNDLES),
-//            mavenBundle("org.apache.felix", "org.apache.felix.shell").version("1.4.3").startLevel(START_LEVEL_SYSTEM_BUNDLES),
-//            mavenBundle("org.apache.felix", "org.apache.felix.shell.tui").version("1.4.1").startLevel(START_LEVEL_SYSTEM_BUNDLES),
+            systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN"),
             
-            junitBundles(),
-            frameworkStartLevel(START_LEVEL_TEST_BUNDLE),
-            felix());
+            mavenBundle("org.slf4j", "slf4j-api").version("1.7.5"),
+            mavenBundle("ch.qos.logback", "logback-core").version("1.0.13"),
+            mavenBundle("ch.qos.logback", "logback-classic").version("1.0.13"),
+            systemProperty("logback.configurationFile").value(f.toURI().toASCIIString()),
+
+            mavenBundle("org.apache.felix", "org.apache.felix.metatype").versionAsInProject(),
+            mavenBundle("org.apache.felix", "org.apache.felix.dependencymanager").versionAsInProject(),
+            mavenBundle("org.apache.felix", "org.apache.felix.deploymentadmin").versionAsInProject(),
+            mavenBundle("org.apache.felix", "org.apache.felix.eventadmin").versionAsInProject(),
+            mavenBundle("org.apache.felix", "org.apache.felix.configadmin").versionAsInProject(),
+            mavenBundle("org.apache.felix", "org.apache.felix.log").versionAsInProject(),
+            
+            junitBundles()
+        );
     }
 
     @Before
@@ -146,6 +131,12 @@
             versions.add(bundle.getVersion());
         }
     }
+    
+    @After
+    public void tearDown() throws Exception {
+        System.setProperty("rp1", "");
+        System.setProperty("bundle3", "");
+    }
 
     protected void assertBundleExists(String symbolicName, String version) {
         boolean result = isBundleAdded(symbolicName, version);
@@ -228,11 +219,6 @@
         return resource;
     }
 
-    /**
-     * @param baseName
-     * @return
-     * @throws MalformedURLException
-     */
     protected URL getTestBundle(String baseName) throws MalformedURLException {
         File f = new File(m_testBundleBasePath, String.format("%1$s/target/org.apache.felix.deploymentadmin.test.%1$s-1.0.0.jar", baseName));
         assertTrue("No such bundle: " + f, f.exists() && f.isFile());
@@ -276,4 +262,19 @@
     protected boolean isBundleResolved(Bundle bundle) {
         return isBundleInState(bundle, Bundle.RESOLVED);
     }
+
+    protected boolean resolveBundles(Bundle... bundles) throws Exception {
+        Bundle systemBundle = m_context.getBundle(0L);
+
+        FrameworkWiring frameworkWiring = systemBundle.adapt(FrameworkWiring.class);
+        frameworkWiring.resolveBundles(Arrays.asList(bundles));
+        
+        for (Bundle bundle : bundles) {
+            if ((bundle.getState() & Bundle.RESOLVED) == 0) {
+                return false;
+            }
+        }
+        
+        return true;
+    }
 }
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 35cdff9..269b7bf 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
@@ -18,19 +18,24 @@
  */
 package org.apache.felix.deploymentadmin.itest;
 
-import static org.osgi.service.deploymentadmin.DeploymentException.*;
+import static org.osgi.service.deploymentadmin.DeploymentException.CODE_FOREIGN_CUSTOMIZER;
+import static org.osgi.service.deploymentadmin.DeploymentException.CODE_OTHER_ERROR;
+import static org.osgi.service.deploymentadmin.DeploymentException.CODE_PROCESSOR_NOT_FOUND;
 
 import org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
 import org.osgi.service.deploymentadmin.DeploymentException;
 import org.osgi.service.deploymentadmin.DeploymentPackage;
 
 /**
  * Provides test cases on the use of customizers in Deployment Admin. 
  */
-@RunWith(JUnit4TestRunner.class)
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerMethod.class)
 public class CustomizerTest extends BaseIntegrationTest {
 
     /**
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 64c5689..0b31972 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
@@ -25,14 +25,14 @@
 import org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder.JarManifestManipulatingFilter;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.junit.PaxExam;
 import org.osgi.service.deploymentadmin.DeploymentAdmin;
 import org.osgi.service.deploymentadmin.DeploymentException;
 
 /**
  * Generic tests for {@link DeploymentAdmin}.
  */
-@RunWith(JUnit4TestRunner.class)
+@RunWith(PaxExam.class)
 public class DeploymentAdminTest extends BaseIntegrationTest {
 
     @Test
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 5cee51e..ed28e24 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
@@ -21,14 +21,14 @@
 import org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.junit.PaxExam;
 import org.osgi.framework.Bundle;
 import org.osgi.service.deploymentadmin.DeploymentPackage;
 
 /**
  * Provides test cases regarding the use of "normal" deployment packages in DeploymentAdmin.
  */
-@RunWith(JUnit4TestRunner.class)
+@RunWith(PaxExam.class)
 public class InstallDeploymentPackageTest extends BaseIntegrationTest {
 
     /**
@@ -82,7 +82,7 @@
         assertBundleExists(getSymbolicName("bundle2"), "1.0.0");
 
         // We shouldn't be able to resolve the deps for bundle2...
-        assertFalse(m_packageAdmin.resolveBundles(new Bundle[] { dp1.getBundle(getSymbolicName("bundle2")) }));
+        assertFalse(resolveBundles(dp1.getBundle(getSymbolicName("bundle2"))));
 
         assertTrue(isBundleInstalled(dp1.getBundle(getSymbolicName("bundle2"))));
 
@@ -100,7 +100,7 @@
         assertBundleExists(getSymbolicName("bundle2"), "1.0.0");
 
         // Now we should be able to resolve the dependencies for bundle2...
-        assertTrue(m_packageAdmin.resolveBundles(new Bundle[] { dp1.getBundle(getSymbolicName("bundle2")) }));
+        assertTrue(resolveBundles(dp1.getBundle(getSymbolicName("bundle2"))));
 
         assertTrue(isBundleActive(dp2.getBundle(getSymbolicName("bundle1"))));
         assertTrue(isBundleResolved(dp1.getBundle(getSymbolicName("bundle2"))));
@@ -134,6 +134,30 @@
     }
 
     /**
+     * Tests that installing a bundle along with a fragment bundle succeeds (DA should not try to start the fragment, see FELIX-4167).
+     */
+    @Test
+    public void testInstallBundleWithFragmentOk() throws Exception {
+        DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
+        dpBuilder
+            .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")))
+            .add(dpBuilder.createBundleResource().setUrl(getTestBundle("fragment1")));
+
+        DeploymentPackage dp = m_deploymentAdmin.installDeploymentPackage(dpBuilder.generate());
+        assertNotNull("No deployment package returned?!", dp);
+
+        awaitRefreshPackagesEvent();
+
+        assertBundleExists(getSymbolicName("bundle1"), "1.0.0");
+        assertBundleExists(getSymbolicName("fragment1"), "1.0.0");
+
+        assertTrue(isBundleActive(dp.getBundle(getSymbolicName("bundle1"))));
+        assertFalse(isBundleActive(dp.getBundle(getSymbolicName("fragment1"))));
+
+        assertEquals("Expected a single deployment package?!", 1, m_deploymentAdmin.listDeploymentPackages().length);
+    }
+
+    /**
      * Tests that installing a bundle whose dependencies cannot be met, is installed, but not started.
      */
     @Test
@@ -155,6 +179,7 @@
         assertTrue(isBundleInstalled(dp.getBundle(getSymbolicName("bundle2"))));
     }
 
+
     /**
      * Tests that installing a bundle along with other (non-bundle) artifacts succeeds.
      */
@@ -225,6 +250,43 @@
     }
 
     /**
+     * Tests that if an exception is thrown during the uninstall of a bundle, the installation/update continues and succeeds.
+     */
+    @Test
+    public void testUninstallBundleWithExceptionThrownInStopCauseNoRollbackOk() throws Exception {
+        DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
+        dpBuilder
+            .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")))
+            .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle3")));
+
+        DeploymentPackage dp = m_deploymentAdmin.installDeploymentPackage(dpBuilder.generate());
+        assertNotNull("No deployment package returned?!", dp);
+
+        awaitRefreshPackagesEvent();
+
+        assertBundleExists(getSymbolicName("bundle3"), "1.0.0");
+
+        System.setProperty("bundle3", "stop");
+
+        dpBuilder = dpBuilder.create("1.0.1");
+        dpBuilder
+            .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")))
+            .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle2")));
+
+        dp = m_deploymentAdmin.installDeploymentPackage(dpBuilder.generate());
+        assertNotNull("No deployment package returned?!", dp);
+
+        assertBundleExists(getSymbolicName("bundle1"), "1.0.0");
+        assertBundleExists(getSymbolicName("bundle2"), "1.0.0");
+        assertBundleNotExists(getSymbolicName("bundle3"), "1.0.0");
+
+        assertTrue(isBundleActive(dp.getBundle(getSymbolicName("bundle1"))));
+        assertTrue(isBundleActive(dp.getBundle(getSymbolicName("bundle2"))));
+
+        assertEquals("Expected a single deployment package?!", 1, m_deploymentAdmin.listDeploymentPackages().length);
+    }
+
+    /**
      * Tests that if an exception is thrown during the stop of a bundle, the installation/update continues and succeeds.
      */
     @Test
@@ -262,41 +324,4 @@
 
         assertEquals("Expected a single deployment package?!", 1, m_deploymentAdmin.listDeploymentPackages().length);
     }
-
-    /**
-     * Tests that if an exception is thrown during the uninstall of a bundle, the installation/update continues and succeeds.
-     */
-    @Test
-    public void testUninstallBundleWithExceptionThrownInStopCauseNoRollbackOk() throws Exception {
-        DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
-        dpBuilder
-            .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")))
-            .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle3")));
-
-        DeploymentPackage dp = m_deploymentAdmin.installDeploymentPackage(dpBuilder.generate());
-        assertNotNull("No deployment package returned?!", dp);
-
-        awaitRefreshPackagesEvent();
-
-        assertBundleExists(getSymbolicName("bundle3"), "1.0.0");
-
-        System.setProperty("bundle3", "stop");
-
-        dpBuilder = dpBuilder.create("1.0.1");
-        dpBuilder
-            .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")))
-            .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle2")));
-
-        dp = m_deploymentAdmin.installDeploymentPackage(dpBuilder.generate());
-        assertNotNull("No deployment package returned?!", dp);
-
-        assertBundleExists(getSymbolicName("bundle1"), "1.0.0");
-        assertBundleExists(getSymbolicName("bundle2"), "1.0.0");
-        assertBundleNotExists(getSymbolicName("bundle3"), "1.0.0");
-
-        assertTrue(isBundleActive(dp.getBundle(getSymbolicName("bundle1"))));
-        assertTrue(isBundleActive(dp.getBundle(getSymbolicName("bundle2"))));
-
-        assertEquals("Expected a single deployment package?!", 1, m_deploymentAdmin.listDeploymentPackages().length);
-    }
 }
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 7d94550..1df2076 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
@@ -18,7 +18,8 @@
  */
 package org.apache.felix.deploymentadmin.itest;
 
-import static org.osgi.service.deploymentadmin.DeploymentException.*;
+import static org.osgi.service.deploymentadmin.DeploymentException.CODE_BAD_HEADER;
+import static org.osgi.service.deploymentadmin.DeploymentException.CODE_BUNDLE_SHARING_VIOLATION;
 import static org.osgi.service.deploymentadmin.DeploymentException.CODE_MISSING_BUNDLE;
 import static org.osgi.service.deploymentadmin.DeploymentException.CODE_MISSING_FIXPACK_TARGET;
 import static org.osgi.service.deploymentadmin.DeploymentException.CODE_MISSING_RESOURCE;
@@ -26,7 +27,7 @@
 import org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.junit.PaxExam;
 import org.osgi.framework.Bundle;
 import org.osgi.service.deploymentadmin.DeploymentException;
 import org.osgi.service.deploymentadmin.DeploymentPackage;
@@ -34,7 +35,7 @@
 /**
  * Provides test cases regarding the use of "fix-packages" in DeploymentAdmin.
  */
-@RunWith(JUnit4TestRunner.class)
+@RunWith(PaxExam.class)
 public class InstallFixPackageTest extends BaseIntegrationTest {
 
     /**
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 1ccac49..4bcdbfb 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
@@ -22,7 +22,7 @@
 import org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder.JarManifestManipulatingFilter;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.junit.PaxExam;
 import org.osgi.framework.Bundle;
 import org.osgi.service.deploymentadmin.DeploymentAdmin;
 import org.osgi.service.deploymentadmin.DeploymentException;
@@ -31,7 +31,7 @@
 /**
  * Generic tests for {@link DeploymentAdmin}.
  */
-@RunWith(JUnit4TestRunner.class)
+@RunWith(PaxExam.class)
 public class ResourceSharingTest extends BaseIntegrationTest {
 
     @Test
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 21f4266..65a2620 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
@@ -25,7 +25,7 @@
 import org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.junit.PaxExam;
 import org.osgi.framework.Bundle;
 import org.osgi.service.deploymentadmin.DeploymentException;
 import org.osgi.service.deploymentadmin.DeploymentPackage;
@@ -33,7 +33,7 @@
 /**
  * Provides test cases regarding the use of "normal" deployment packages in DeploymentAdmin.
  */
-@RunWith(JUnit4TestRunner.class)
+@RunWith(PaxExam.class)
 public class UninstallDeploymentPackageTest extends BaseIntegrationTest {
 
     /**
@@ -69,6 +69,70 @@
     }
 
     /**
+     * Tests that uninstalling a DP containing a bundle along with a fragment bundle succeeds (DA should not try to stop the fragment, see FELIX-4167).
+     */
+    @Test
+    public void testUninstallBundleWithFragmentOk() throws Exception {
+        DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
+        dpBuilder
+            .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")))
+            .add(dpBuilder.createBundleResource().setUrl(getTestBundle("fragment1")));
+
+        DeploymentPackage dp = m_deploymentAdmin.installDeploymentPackage(dpBuilder.generate());
+        assertNotNull("No deployment package returned?!", dp);
+
+        awaitRefreshPackagesEvent();
+
+        assertBundleExists(getSymbolicName("bundle1"), "1.0.0");
+        assertBundleExists(getSymbolicName("fragment1"), "1.0.0");
+
+        assertTrue(isBundleActive(dp.getBundle(getSymbolicName("bundle1"))));
+        assertFalse(isBundleActive(dp.getBundle(getSymbolicName("fragment1"))));
+
+        // Should succeed...
+        dp.uninstall();
+
+        assertEquals("Expected no deployment package?!", 0, m_deploymentAdmin.listDeploymentPackages().length);
+
+        // Both bundles should be uninstalled...
+        assertBundleNotExists(getSymbolicName("bundle1"), "1.0.0");
+        assertBundleNotExists(getSymbolicName("fragment1"), "1.0.0");
+    }
+
+    /**
+     * Tests that uninstalling a DP with a bundle along with other (non-bundle) artifacts succeeds.
+     */
+    @Test
+    public void testUninstallBundleWithOtherArtifactsOk() throws Exception {
+        DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
+        dpBuilder
+            .add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundle("rp1")))
+            .add(
+                dpBuilder.createResource().setResourceProcessorPID(TEST_FAILING_BUNDLE_RP1)
+                    .setUrl(getTestResource("test-config1.xml")))
+            .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle3")));
+
+        DeploymentPackage dp = m_deploymentAdmin.installDeploymentPackage(dpBuilder.generate());
+        assertNotNull("No deployment package returned?!", dp);
+
+        awaitRefreshPackagesEvent();
+
+        // Though the commit failed; the package should be installed...
+        assertBundleExists(getSymbolicName("rp1"), "1.0.0");
+        assertBundleExists(getSymbolicName("bundle3"), "1.0.0");
+
+        assertEquals("Expected a single deployment package?!", 1, m_deploymentAdmin.listDeploymentPackages().length);
+
+        // Should succeed...
+        dp.uninstall();
+
+        assertEquals("Expected no deployment package?!", 0, m_deploymentAdmin.listDeploymentPackages().length);
+
+        assertBundleNotExists(getSymbolicName("rp1"), "1.0.0");
+        assertBundleNotExists(getSymbolicName("bundle3"), "1.0.0");
+    }
+
+    /**
      * Tests that if an exception is thrown during the commit-phase, the installation is continued normally.
      */
     @Test
@@ -233,6 +297,6 @@
         
         assertTrue("One bundle should be started!", getCurrentBundles().size() == 1);
 
-        assertEquals("Expected no deployment package?!", 1, m_deploymentAdmin.listDeploymentPackages().length);
+        assertEquals("Expected one deployment package?!", 1, m_deploymentAdmin.listDeploymentPackages().length);
     }
 }
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 49e9330..d193ce7 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
@@ -65,6 +65,7 @@
                 jos.closeEntry();
             }
             jos.close();
+            jis.close();
 
             return new ByteArrayInputStream(baos.toByteArray());
         }
diff --git a/deploymentadmin/itest/src/test/resources/logback.xml b/deploymentadmin/itest/src/test/resources/logback.xml
index fa644da..8bf05e4 100644
--- a/deploymentadmin/itest/src/test/resources/logback.xml
+++ b/deploymentadmin/itest/src/test/resources/logback.xml
@@ -2,13 +2,11 @@
 <configuration>
 	<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
 		<encoder>
-			<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+			<pattern>%-5level %logger{36} - %msg%n</pattern>
 		</encoder>
 	</appender>
 
-	<root level="WARN">
+	<root level="warn">
 		<appender-ref ref="STDOUT" />
 	</root>
-
-	<logger name="org.ops4j" level="WARN" />
 </configuration>