felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1504847 - in /felix/trunk/deploymentadmin/itest: ./ src/test/java/org/apache/felix/deploymentadmin/itest/ src/test/java/org/apache/felix/deploymentadmin/itest/util/ src/test/resources/
Date Fri, 19 Jul 2013 11:44:46 GMT
Author: jawi
Date: Fri Jul 19 11:44:46 2013
New Revision: 1504847

URL: http://svn.apache.org/r1504847
Log:
FELIX-4167: added integration test for fragment bundles.


Modified:
    felix/trunk/deploymentadmin/itest/   (props changed)
    felix/trunk/deploymentadmin/itest/pom.xml
    felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/BaseIntegrationTest.java
    felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/CustomizerTest.java
    felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/DeploymentAdminTest.java
    felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/InstallDeploymentPackageTest.java
    felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/InstallFixPackageTest.java
    felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/ResourceSharingTest.java
    felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/UninstallDeploymentPackageTest.java
    felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/util/DeploymentPackageBuilder.java
    felix/trunk/deploymentadmin/itest/src/test/resources/logback.xml

Propchange: felix/trunk/deploymentadmin/itest/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Jul 19 11:44:46 2013
@@ -0,0 +1,4 @@
+.project
+.classpath
+.settings
+target

Modified: felix/trunk/deploymentadmin/itest/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/itest/pom.xml?rev=1504847&r1=1504846&r2=1504847&view=diff
==============================================================================
--- felix/trunk/deploymentadmin/itest/pom.xml (original)
+++ felix/trunk/deploymentadmin/itest/pom.xml Fri Jul 19 11:44:46 2013
@@ -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>

Modified: felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/BaseIntegrationTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/BaseIntegrationTest.java?rev=1504847&r1=1504846&r2=1504847&view=diff
==============================================================================
--- felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/BaseIntegrationTest.java
(original)
+++ felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/BaseIntegrationTest.java
Fri Jul 19 11:44:46 2013
@@ -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 javax.inject.Inject;
 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 @@ public abstract class BaseIntegrationTes
     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 @@ public abstract class BaseIntegrationTes
     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"),
+            
+            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(),
-            frameworkStartLevel(START_LEVEL_TEST_BUNDLE),
-            felix());
+            junitBundles()
+        );
     }
 
     @Before
@@ -146,6 +131,12 @@ public abstract class BaseIntegrationTes
             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 @@ public abstract class BaseIntegrationTes
         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 @@ public abstract class BaseIntegrationTes
     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;
+    }
 }

Modified: felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/CustomizerTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/CustomizerTest.java?rev=1504847&r1=1504846&r2=1504847&view=diff
==============================================================================
--- felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/CustomizerTest.java
(original)
+++ felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/CustomizerTest.java
Fri Jul 19 11:44:46 2013
@@ -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 {
 
     /**

Modified: felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/DeploymentAdminTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/DeploymentAdminTest.java?rev=1504847&r1=1504846&r2=1504847&view=diff
==============================================================================
--- felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/DeploymentAdminTest.java
(original)
+++ felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/DeploymentAdminTest.java
Fri Jul 19 11:44:46 2013
@@ -25,14 +25,14 @@ import org.apache.felix.deploymentadmin.
 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

Modified: felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/InstallDeploymentPackageTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/InstallDeploymentPackageTest.java?rev=1504847&r1=1504846&r2=1504847&view=diff
==============================================================================
--- felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/InstallDeploymentPackageTest.java
(original)
+++ felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/InstallDeploymentPackageTest.java
Fri Jul 19 11:44:46 2013
@@ -21,14 +21,14 @@ package org.apache.felix.deploymentadmin
 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 @@ public class InstallDeploymentPackageTes
         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 @@ public class InstallDeploymentPackageTes
         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 @@ public class InstallDeploymentPackageTes
     }
 
     /**
+     * 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 @@ public class InstallDeploymentPackageTes
         assertTrue(isBundleInstalled(dp.getBundle(getSymbolicName("bundle2"))));
     }
 
+
     /**
      * Tests that installing a bundle along with other (non-bundle) artifacts succeeds.
      */
@@ -225,10 +250,10 @@ public class InstallDeploymentPackageTes
     }
 
     /**
-     * Tests that if an exception is thrown during the stop of a bundle, the installation/update
continues and succeeds.
+     * Tests that if an exception is thrown during the uninstall of a bundle, the installation/update
continues and succeeds.
      */
     @Test
-    public void testUpdateBundleWithExceptionThrownInStopCauseNoRollbackOk() throws Exception
{
+    public void testUninstallBundleWithExceptionThrownInStopCauseNoRollbackOk() throws Exception
{
         DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
         dpBuilder
             .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")))
@@ -243,31 +268,29 @@ public class InstallDeploymentPackageTes
 
         System.setProperty("bundle3", "stop");
 
-        dpBuilder = createDeploymentPackageBuilder(dpBuilder.getSymbolicName(), "1.0.1");
+        dpBuilder = dpBuilder.create("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(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");
-        assertBundleExists(getSymbolicName("bundle3"), "1.0.0");
+        assertBundleNotExists(getSymbolicName("bundle3"), "1.0.0");
 
         assertTrue(isBundleActive(dp.getBundle(getSymbolicName("bundle1"))));
         assertTrue(isBundleActive(dp.getBundle(getSymbolicName("bundle2"))));
-        assertTrue(isBundleActive(dp.getBundle(getSymbolicName("bundle3"))));
 
         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.
+     * Tests that if an exception is thrown during the stop of a bundle, the installation/update
continues and succeeds.
      */
     @Test
-    public void testUninstallBundleWithExceptionThrownInStopCauseNoRollbackOk() throws Exception
{
+    public void testUpdateBundleWithExceptionThrownInStopCauseNoRollbackOk() throws Exception
{
         DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
         dpBuilder
             .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")))
@@ -282,20 +305,22 @@ public class InstallDeploymentPackageTes
 
         System.setProperty("bundle3", "stop");
 
-        dpBuilder = dpBuilder.create("1.0.1");
+        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("bundle2")))
+            .add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle3")));
 
         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");
+        assertBundleExists(getSymbolicName("bundle3"), "1.0.0");
 
         assertTrue(isBundleActive(dp.getBundle(getSymbolicName("bundle1"))));
         assertTrue(isBundleActive(dp.getBundle(getSymbolicName("bundle2"))));
+        assertTrue(isBundleActive(dp.getBundle(getSymbolicName("bundle3"))));
 
         assertEquals("Expected a single deployment package?!", 1, m_deploymentAdmin.listDeploymentPackages().length);
     }

Modified: felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/InstallFixPackageTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/InstallFixPackageTest.java?rev=1504847&r1=1504846&r2=1504847&view=diff
==============================================================================
--- felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/InstallFixPackageTest.java
(original)
+++ felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/InstallFixPackageTest.java
Fri Jul 19 11:44:46 2013
@@ -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 static org.osgi.service.deploymen
 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 @@ import org.osgi.service.deploymentadmin.
 /**
  * Provides test cases regarding the use of "fix-packages" in DeploymentAdmin.
  */
-@RunWith(JUnit4TestRunner.class)
+@RunWith(PaxExam.class)
 public class InstallFixPackageTest extends BaseIntegrationTest {
 
     /**

Modified: felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/ResourceSharingTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/ResourceSharingTest.java?rev=1504847&r1=1504846&r2=1504847&view=diff
==============================================================================
--- felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/ResourceSharingTest.java
(original)
+++ felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/ResourceSharingTest.java
Fri Jul 19 11:44:46 2013
@@ -22,7 +22,7 @@ import org.apache.felix.deploymentadmin.
 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 @@ import org.osgi.service.deploymentadmin.
 /**
  * Generic tests for {@link DeploymentAdmin}.
  */
-@RunWith(JUnit4TestRunner.class)
+@RunWith(PaxExam.class)
 public class ResourceSharingTest extends BaseIntegrationTest {
 
     @Test

Modified: felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/UninstallDeploymentPackageTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/UninstallDeploymentPackageTest.java?rev=1504847&r1=1504846&r2=1504847&view=diff
==============================================================================
--- felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/UninstallDeploymentPackageTest.java
(original)
+++ felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/UninstallDeploymentPackageTest.java
Fri Jul 19 11:44:46 2013
@@ -25,7 +25,7 @@ import static org.osgi.service.deploymen
 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 @@ import org.osgi.service.deploymentadmin.
 /**
  * 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 @@ public class UninstallDeploymentPackageT
     }
 
     /**
+     * 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 @@ public class UninstallDeploymentPackageT
         
         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);
     }
 }

Modified: felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/util/DeploymentPackageBuilder.java
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/util/DeploymentPackageBuilder.java?rev=1504847&r1=1504846&r2=1504847&view=diff
==============================================================================
--- felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/util/DeploymentPackageBuilder.java
(original)
+++ felix/trunk/deploymentadmin/itest/src/test/java/org/apache/felix/deploymentadmin/itest/util/DeploymentPackageBuilder.java
Fri Jul 19 11:44:46 2013
@@ -65,6 +65,7 @@ public class DeploymentPackageBuilder {
                 jos.closeEntry();
             }
             jos.close();
+            jis.close();
 
             return new ByteArrayInputStream(baos.toByteArray());
         }

Modified: felix/trunk/deploymentadmin/itest/src/test/resources/logback.xml
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/itest/src/test/resources/logback.xml?rev=1504847&r1=1504846&r2=1504847&view=diff
==============================================================================
--- felix/trunk/deploymentadmin/itest/src/test/resources/logback.xml (original)
+++ felix/trunk/deploymentadmin/itest/src/test/resources/logback.xml Fri Jul 19 11:44:46 2013
@@ -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>



Mime
View raw message