karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject git commit: KARAF-2946 Itest for duplicate package exports
Date Tue, 29 Apr 2014 08:53:55 GMT
Repository: karaf
Updated Branches:
  refs/heads/master 7b00418f7 -> b4e2c4394


KARAF-2946 Itest for duplicate package exports


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/b4e2c439
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/b4e2c439
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/b4e2c439

Branch: refs/heads/master
Commit: b4e2c43949928a4cb70844a988477ed208ca94c1
Parents: 7b00418
Author: Christian Schneider <chris@die-schneider.net>
Authored: Tue Apr 29 09:50:21 2014 +0200
Committer: Christian Schneider <chris@die-schneider.net>
Committed: Tue Apr 29 10:53:38 2014 +0200

----------------------------------------------------------------------
 itests/pom.xml                                  |  4 +++
 .../org/apache/karaf/itests/PackageTest.java    | 33 ++++++++++++++++++--
 .../karaf/packages/core/PackageService.java     |  2 +-
 3 files changed, 35 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/b4e2c439/itests/pom.xml
----------------------------------------------------------------------
diff --git a/itests/pom.xml b/itests/pom.xml
index 21178d2..fa60a78 100644
--- a/itests/pom.xml
+++ b/itests/pom.xml
@@ -84,6 +84,10 @@
             <scope>test</scope>
         </dependency>
 
+        <dependency>
+            <groupId>org.apache.karaf.package</groupId>
+            <artifactId>org.apache.karaf.package.core</artifactId>
+        </dependency>
     </dependencies>
 
     <build>

http://git-wip-us.apache.org/repos/asf/karaf/blob/b4e2c439/itests/src/test/java/org/apache/karaf/itests/PackageTest.java
----------------------------------------------------------------------
diff --git a/itests/src/test/java/org/apache/karaf/itests/PackageTest.java b/itests/src/test/java/org/apache/karaf/itests/PackageTest.java
index 198e863..24f1e12 100644
--- a/itests/src/test/java/org/apache/karaf/itests/PackageTest.java
+++ b/itests/src/test/java/org/apache/karaf/itests/PackageTest.java
@@ -16,11 +16,19 @@ package org.apache.karaf.itests;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
+import java.util.HashMap;
+import java.util.Map;
+import java.util.SortedMap;
+
+import javax.inject.Inject;
 import javax.management.MBeanServerConnection;
 import javax.management.ObjectName;
 import javax.management.openmbean.TabularData;
 import javax.management.remote.JMXConnector;
 
+import org.apache.karaf.packages.core.PackageService;
+import org.apache.karaf.packages.core.PackageVersion;
+import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.junit.PaxExam;
@@ -30,6 +38,8 @@ import org.ops4j.pax.exam.spi.reactors.PerClass;
 @RunWith(PaxExam.class)
 @ExamReactorStrategy(PerClass.class)
 public class PackageTest extends KarafTestSupport {
+    @Inject
+    PackageService packageService;
 
     @Test
     public void exportsCommand() throws Exception {
@@ -45,7 +55,7 @@ public class PackageTest extends KarafTestSupport {
             connector = this.getJMXConnector();
             MBeanServerConnection connection = connector.getMBeanServerConnection();
             ObjectName name = new ObjectName("org.apache.karaf:type=package,name=root");
-            TabularData exports = (TabularData) connection.getAttribute(name, "Exports");
+            TabularData exports = (TabularData)connection.getAttribute(name, "Exports");
             assertTrue(exports.size() > 0);
         } finally {
             close(connector);
@@ -66,10 +76,27 @@ public class PackageTest extends KarafTestSupport {
             connector = this.getJMXConnector();
             MBeanServerConnection connection = connector.getMBeanServerConnection();
             ObjectName name = new ObjectName("org.apache.karaf:type=package,name=root");
-            TabularData imports = (TabularData) connection.getAttribute(name, "Imports");
+            TabularData imports = (TabularData)connection.getAttribute(name, "Imports");
             assertTrue(imports.size() > 0);
         } finally {
-        	close(connector);
+            close(connector);
+        }
+    }
+
+    @Test
+    public void duplicatePackageTest() throws Exception {
+        // Leaving out version to make test easier to manage
+        // We currently expect no duplicate package exports
+        Map<String, Integer> expectedDups = new HashMap<String, Integer>();
+        SortedMap<String, PackageVersion> packageVersionMap = packageService.getExports();
+       
+        for (String packageNameVersion : packageVersionMap.keySet()) {
+            PackageVersion pVer = packageVersionMap.get(packageNameVersion);
+            if (pVer.getBundles().size() > 1) {
+                String packageName = packageNameVersion.split(":")[0];
+                int expectedNum = expectedDups.containsKey(packageName) ? expectedDups.get(packageName)
: 0;
+                Assert.assertEquals("Expecting number of duplicates for package " + packageNameVersion,
expectedNum, pVer.getBundles().size());
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/karaf/blob/b4e2c439/package/src/main/java/org/apache/karaf/packages/core/PackageService.java
----------------------------------------------------------------------
diff --git a/package/src/main/java/org/apache/karaf/packages/core/PackageService.java b/package/src/main/java/org/apache/karaf/packages/core/PackageService.java
index d6ccc65..28a065d 100644
--- a/package/src/main/java/org/apache/karaf/packages/core/PackageService.java
+++ b/package/src/main/java/org/apache/karaf/packages/core/PackageService.java
@@ -33,7 +33,7 @@ public interface PackageService {
     List<String> getImports(long bundleId);
 
 	/**
-	 * Gets a map of all exported packages with their version and the bundles that exprot them
+	 * Gets a map of all exported packages with their version and the bundles that export them
 	 * The key is in the form packagename:version.
 	 * 
 	 * @return 


Mime
View raw message