You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by gn...@apache.org on 2010/07/16 17:26:49 UTC
svn commit: r964836 - in /karaf/trunk/features/core/src:
main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java
main/java/org/apache/karaf/features/internal/RepositoryImpl.java
test/java/org/apache/karaf/features/FeaturesServiceTest.java
Author: gnodet
Date: Fri Jul 16 15:26:48 2010
New Revision: 964836
URL: http://svn.apache.org/viewvc?rev=964836&view=rev
Log:
fix unit tests
Modified:
karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java
karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/RepositoryImpl.java
karaf/trunk/features/core/src/test/java/org/apache/karaf/features/FeaturesServiceTest.java
Modified: karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java
URL: http://svn.apache.org/viewvc/karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java?rev=964836&r1=964835&r2=964836&view=diff
==============================================================================
--- karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java (original)
+++ karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java Fri Jul 16 15:26:48 2010
@@ -299,11 +299,7 @@ public class FeaturesServiceImpl impleme
// do no start bundles when user request it
Long bundleId = b.getBundleId();
BundleInfo bundleInfo = state.bundleInfos.get(bundleId);
- boolean status = true;
- if (bundleInfo != null) {
- status = bundleInfo.isStart();
- }
- if(status) {
+ if (bundleInfo == null || bundleInfo.isStart()) {
try {
b.start();
} catch (BundleException be) {
Modified: karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/RepositoryImpl.java?rev=964836&r1=964835&r2=964836&view=diff
==============================================================================
--- karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/RepositoryImpl.java (original)
+++ karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/RepositoryImpl.java Fri Jul 16 15:26:48 2010
@@ -161,30 +161,22 @@ public class RepositoryImpl implements R
Element b = (Element) bundleNodes.item(j);
String bStartLevel = b.getAttribute("start-level");
String bStart = b.getAttribute("start");
- boolean bs;
+ boolean bs = true;
+ int bsl = 0;
- // Check if the value of the attribute "start"
- // is parseable
+ // Check the value of the "start" attribute
if (bStart != null && bStart.length() > 0) {
- bs = Boolean.parseBoolean(bStart);
- } else {
- // Assign true when the value is not readable
- bs = true;
+ bs = Boolean.parseBoolean(bStart);
}
-
+ // Check start level
if (bStartLevel != null && bStartLevel.length() > 0) {
-
try {
- int bsl = Integer.parseInt(bStartLevel);
- f.addBundle(new BundleInfoImpl(b.getTextContent(), bsl, bs));
+ bsl = Integer.parseInt(bStartLevel);
} catch (Exception ex) {
LOGGER.error("The start-level is not an int value for the bundle : " + b.getTextContent());
}
-
- } else {
- f.addBundle(new BundleInfoImpl(b.getTextContent(), bs));
}
-
+ f.addBundle(new BundleInfoImpl(b.getTextContent(), bsl, bs));
}
features.add(f);
}
Modified: karaf/trunk/features/core/src/test/java/org/apache/karaf/features/FeaturesServiceTest.java
URL: http://svn.apache.org/viewvc/karaf/trunk/features/core/src/test/java/org/apache/karaf/features/FeaturesServiceTest.java?rev=964836&r1=964835&r2=964836&view=diff
==============================================================================
--- karaf/trunk/features/core/src/test/java/org/apache/karaf/features/FeaturesServiceTest.java (original)
+++ karaf/trunk/features/core/src/test/java/org/apache/karaf/features/FeaturesServiceTest.java Fri Jul 16 15:26:48 2010
@@ -94,6 +94,7 @@ public class FeaturesServiceTest extends
assertNotNull(features[0].getBundles());
assertEquals(1, features[0].getBundles().size());
assertEquals(name, features[0].getBundles().get(0).getLocation());
+ assertTrue(features[0].getBundles().get(0).isStart());
verify(bundleContext, installedBundle);
@@ -103,6 +104,8 @@ public class FeaturesServiceTest extends
expect(bundleContext.installBundle(isA(String.class),
isA(InputStream.class))).andReturn(installedBundle);
expect(installedBundle.getBundleId()).andReturn(12345L);
+ expect(installedBundle.getBundleId()).andReturn(12345L);
+ expect(installedBundle.getBundleId()).andReturn(12345L);
expect(bundleContext.getBundle(12345L)).andReturn(installedBundle);
expect(installedBundle.getHeaders()).andReturn(new Hashtable());
installedBundle.start();
@@ -156,6 +159,8 @@ public class FeaturesServiceTest extends
expect(bundleContext.installBundle(isA(String.class),
isA(InputStream.class))).andReturn(installedBundle);
expect(installedBundle.getBundleId()).andReturn(12345L);
+ expect(installedBundle.getBundleId()).andReturn(12345L);
+ expect(installedBundle.getBundleId()).andReturn(12345L);
expect(bundleContext.getBundle(12345L)).andReturn(installedBundle);
expect(installedBundle.getHeaders()).andReturn(new Hashtable());
installedBundle.start();
@@ -165,6 +170,8 @@ public class FeaturesServiceTest extends
expect(bundleContext.installBundle(isA(String.class),
isA(InputStream.class))).andReturn(installedBundle);
expect(installedBundle.getBundleId()).andReturn(123456L);
+ expect(installedBundle.getBundleId()).andReturn(123456L);
+ expect(installedBundle.getBundleId()).andReturn(123456L);
expect(bundleContext.getBundle(123456L)).andReturn(installedBundle);
expect(installedBundle.getHeaders()).andReturn(new Hashtable());
installedBundle.start();
@@ -272,6 +279,8 @@ public class FeaturesServiceTest extends
expect(bundleContext.installBundle(isA(String.class),
isA(InputStream.class))).andReturn(installedBundle);
expect(installedBundle.getBundleId()).andReturn(12345L);
+ expect(installedBundle.getBundleId()).andReturn(12345L);
+ expect(installedBundle.getBundleId()).andReturn(12345L);
expect(bundleContext.getBundle(12345L)).andReturn(installedBundle);
expect(installedBundle.getHeaders()).andReturn(new Hashtable());
expect(installedBundle.getSymbolicName()).andReturn("bundle");
@@ -283,6 +292,8 @@ public class FeaturesServiceTest extends
expect(bundleContext.installBundle(isA(String.class),
isA(InputStream.class))).andReturn(installedBundle);
expect(installedBundle.getBundleId()).andReturn(123456L);
+ expect(installedBundle.getBundleId()).andReturn(123456L);
+ expect(installedBundle.getBundleId()).andReturn(123456L);
expect(bundleContext.getBundle(123456L)).andReturn(installedBundle);
expect(installedBundle.getHeaders()).andReturn(new Hashtable());
installedBundle.start();
@@ -292,6 +303,8 @@ public class FeaturesServiceTest extends
expect(bundleContext.installBundle(isA(String.class),
isA(InputStream.class))).andReturn(installedBundle);
expect(installedBundle.getBundleId()).andReturn(1234567L);
+ expect(installedBundle.getBundleId()).andReturn(1234567L);
+ expect(installedBundle.getBundleId()).andReturn(1234567L);
expect(bundleContext.getBundle(1234567L)).andReturn(installedBundle);
expect(installedBundle.getHeaders()).andReturn(new Hashtable());
installedBundle.start();
@@ -357,6 +370,8 @@ public class FeaturesServiceTest extends
expect(bundleContext.installBundle(isA(String.class),
isA(InputStream.class))).andReturn(installedBundle);
expect(installedBundle.getBundleId()).andReturn(12345L);
+ expect(installedBundle.getBundleId()).andReturn(12345L);
+ expect(installedBundle.getBundleId()).andReturn(12345L);
expect(bundleContext.getBundle(12345L)).andReturn(installedBundle);
expect(installedBundle.getHeaders()).andReturn(new Hashtable());
installedBundle.start();
@@ -366,6 +381,8 @@ public class FeaturesServiceTest extends
expect(bundleContext.installBundle(isA(String.class),
isA(InputStream.class))).andReturn(installedBundle);
expect(installedBundle.getBundleId()).andReturn(1234L);
+ expect(installedBundle.getBundleId()).andReturn(1234L);
+ expect(installedBundle.getBundleId()).andReturn(1234L);
expect(bundleContext.getBundle(1234L)).andReturn(installedBundle);
expect(installedBundle.getHeaders()).andReturn(new Hashtable()).anyTimes();
installedBundle.start();
@@ -421,10 +438,14 @@ public class FeaturesServiceTest extends
expect(bundleContext.getBundles()).andReturn(new Bundle[0]);
expect(bundleContext.installBundle(eq(bundle1), isA(InputStream.class))).andReturn(installedBundle1);
expect(installedBundle1.getBundleId()).andReturn(12345L);
+ expect(installedBundle1.getBundleId()).andReturn(12345L);
+ expect(installedBundle1.getBundleId()).andReturn(12345L);
expect(bundleContext.getBundles()).andReturn(new Bundle[0]);
expect(bundleContext.installBundle(eq(bundle2), isA(InputStream.class))).andReturn(installedBundle2);
expect(installedBundle2.getBundleId()).andReturn(54321L);
+ expect(installedBundle2.getBundleId()).andReturn(54321L);
+ expect(installedBundle2.getBundleId()).andReturn(54321L);
expect(installedBundle2.getHeaders()).andReturn(new Hashtable()).anyTimes();
installedBundle2.start();
@@ -469,11 +490,15 @@ public class FeaturesServiceTest extends
expect(bundleContext.getBundles()).andReturn(new Bundle[0]);
expect(bundleContext.installBundle(eq(bundle1), isA(InputStream.class))).andReturn(installedBundle1);
expect(installedBundle1.getBundleId()).andReturn(12345L);
+ expect(installedBundle1.getBundleId()).andReturn(12345L);
+ expect(installedBundle1.getBundleId()).andReturn(12345L);
installedBundle1.uninstall();
expect(bundleContext.getBundles()).andReturn(new Bundle[0]);
expect(bundleContext.installBundle(eq(bundle2), isA(InputStream.class))).andReturn(installedBundle2);
expect(installedBundle2.getBundleId()).andReturn(54321L);
+ expect(installedBundle2.getBundleId()).andReturn(54321L);
+ expect(installedBundle2.getBundleId()).andReturn(54321L);
expect(installedBundle2.getHeaders()).andReturn(new Hashtable()).anyTimes();
installedBundle2.start();
@@ -518,10 +543,14 @@ public class FeaturesServiceTest extends
expect(bundleContext.getBundles()).andReturn(new Bundle[0]);
expect(bundleContext.installBundle(eq(bundle1), isA(InputStream.class))).andReturn(installedBundle1);
expect(installedBundle1.getBundleId()).andReturn(12345L);
+ expect(installedBundle1.getBundleId()).andReturn(12345L);
+ expect(installedBundle1.getBundleId()).andReturn(12345L);
expect(bundleContext.getBundles()).andReturn(new Bundle[0]);
expect(bundleContext.installBundle(eq(bundle2), isA(InputStream.class))).andReturn(installedBundle2);
expect(installedBundle2.getBundleId()).andReturn(54321L);
+ expect(installedBundle2.getBundleId()).andReturn(54321L);
+ expect(installedBundle2.getBundleId()).andReturn(54321L);
installedBundle2.start();
expect(bundleContext.getDataFile(EasyMock.<String>anyObject())).andReturn(dataFile).anyTimes();
@@ -571,11 +600,15 @@ public class FeaturesServiceTest extends
expect(bundleContext.getBundles()).andReturn(new Bundle[0]);
expect(bundleContext.installBundle(eq(bundle1), isA(InputStream.class))).andReturn(installedBundle1);
expect(installedBundle1.getBundleId()).andReturn(12345L);
+ expect(installedBundle1.getBundleId()).andReturn(12345L);
+ expect(installedBundle1.getBundleId()).andReturn(12345L);
installedBundle1.uninstall();
expect(bundleContext.getBundles()).andReturn(new Bundle[0]);
expect(bundleContext.installBundle(eq(bundle2), isA(InputStream.class))).andReturn(installedBundle2);
expect(installedBundle2.getBundleId()).andReturn(54321L);
+ expect(installedBundle2.getBundleId()).andReturn(54321L);
+ expect(installedBundle2.getBundleId()).andReturn(54321L);
installedBundle2.uninstall();
expect(bundleContext.getDataFile(EasyMock.<String>anyObject())).andReturn(dataFile).anyTimes();
@@ -627,7 +660,9 @@ public class FeaturesServiceTest extends
Bundle installedBundle2 = EasyMock.createMock(Bundle.class);
// Installs feature f1
- expect(installedBundle1.getBundleId()).andReturn(12345L).anyTimes();
+ expect(installedBundle1.getBundleId()).andReturn(12345L);
+ expect(installedBundle1.getBundleId()).andReturn(12345L);
+ expect(installedBundle1.getBundleId()).andReturn(12345L);
expect(installedBundle1.getSymbolicName()).andReturn(headers.get(Constants.BUNDLE_SYMBOLICNAME)).anyTimes();
expect(installedBundle1.getHeaders()).andReturn(headers).anyTimes();
expect(bundleContext.getBundles()).andReturn(new Bundle[] { installedBundle1 });
@@ -635,6 +670,8 @@ public class FeaturesServiceTest extends
expect(bundleContext.installBundle(eq(bundle2), isA(InputStream.class))).andReturn(installedBundle2);
expect(bundleContext.getBundles()).andReturn(new Bundle[] { installedBundle1, installedBundle2 });
expect(installedBundle2.getBundleId()).andReturn(54321L);
+ expect(installedBundle2.getBundleId()).andReturn(54321L);
+ expect(installedBundle2.getBundleId()).andReturn(54321L);
expect(installedBundle2.getSymbolicName()).andReturn("fragment").anyTimes();
Dictionary d = new Hashtable();
d.put(Constants.FRAGMENT_HOST, headers.get(Constants.BUNDLE_SYMBOLICNAME));