You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2010/08/10 15:38:01 UTC
svn commit: r983998 [2/3] - in /sling/trunk/installer:
jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/
jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/
osgi/installer/src/main/java/org/apache/sling/osgi/installer/ o...
Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java Tue Aug 10 13:37:59 2010
@@ -35,20 +35,15 @@ import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
import java.util.jar.JarInputStream;
import java.util.jar.Manifest;
import org.apache.sling.osgi.installer.InstallableResource;
-import org.apache.sling.osgi.installer.impl.propertyconverter.PropertyConverter;
-import org.apache.sling.osgi.installer.impl.propertyconverter.PropertyValue;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
-/** A resource that's been registered in the OSGi controller.
- * Data can be either an InputStream or a Dictionary, and we store
- * it locally to avoid holding up to classes or data from our
- * clients, in case those disappear while we're installing stuff.
+/**
+ * Implementation of the registered resource
*/
public class RegisteredResourceImpl implements RegisteredResource, Serializable {
private static final long serialVersionUID = 2L;
@@ -64,11 +59,7 @@ public class RegisteredResourceImpl impl
private final long serialNumber;
private static long serialNumberCounter = System.currentTimeMillis();
- private final InstallableResource.Type resourceType;
-
- public static final String ENTITY_JAR_PREFIX = "jar:";
- public static final String ENTITY_BUNDLE_PREFIX = "bundle:";
- public static final String ENTITY_CONFIG_PREFIX = "config:";
+ private final String resourceType;
/** Create a RegisteredResource from given data. If the data's extension
* maps to a configuration and the data provides an input stream, it is
@@ -87,7 +78,7 @@ public class RegisteredResourceImpl impl
throw new IllegalArgumentException("Missing digest: " + input);
}
- if(resourceType == InstallableResource.Type.BUNDLE) {
+ if (resourceType.equals(InstallableResource.TYPE_BUNDLE)) {
final InputStream is = input.getInputStream();
if (is == null) {
throw new IllegalArgumentException("InputStream is required for BUNDLE resource type: " + input);
@@ -95,7 +86,7 @@ public class RegisteredResourceImpl impl
try {
dictionary = null;
final File f = getDataFile(ctx);
- osgiCtx.logDebug("Copying data to local storage " + f.getAbsolutePath());
+ Logger.logDebug("Copying data to local storage " + f.getAbsolutePath());
copyToLocalStorage(input.getInputStream(), f);
hasDataFile = true;
digest = input.getDigest();
@@ -110,7 +101,7 @@ public class RegisteredResourceImpl impl
} finally {
is.close();
}
- } else {
+ } else if ( resourceType.equals(InstallableResource.TYPE_CONFIG)) {
hasDataFile = false;
final ConfigurationPid pid = new ConfigurationPid(input.getUrl());
entity = ENTITY_CONFIG_PREFIX + pid.getCompositePid();
@@ -118,6 +109,8 @@ public class RegisteredResourceImpl impl
// config provided as a Dictionary
dictionary = copy(input.getDictionary());
digest = input.getDigest();
+ } else {
+ throw new IOException("Unknown type " + resourceType);
}
}
@@ -140,7 +133,7 @@ public class RegisteredResourceImpl impl
public void cleanup(OsgiInstallerContext ctx) {
final File dataFile = getDataFile(ctx.getBundleContext());
if(dataFile.exists()) {
- ctx.logDebug("Deleting local storage file "
+ Logger.logDebug("Deleting local storage file "
+ dataFile.getAbsolutePath());
dataFile.delete();
}
@@ -183,21 +176,6 @@ public class RegisteredResourceImpl impl
}
}
- /** Convert InputStream to Dictionary using our extended properties format,
- * which supports multi-value properties
- */
- static Dictionary<String, Object> readDictionary(InputStream is) throws IOException {
- final Dictionary<String, Object> result = new Hashtable<String, Object>();
- final PropertyConverter converter = new PropertyConverter();
- final Properties p = new Properties();
- p.load(is);
- for(Map.Entry<Object, Object> e : p.entrySet()) {
- final PropertyValue v = converter.convert((String)e.getKey(), (String)e.getValue());
- result.put(v.getKey(), v.getValue());
- }
- return result;
- }
-
/** Copy given Dictionary, sorting keys */
static Dictionary<String, Object> copy(Dictionary<String, Object> d) {
final Dictionary<String, Object> result = new Hashtable<String, Object>();
@@ -217,7 +195,7 @@ public class RegisteredResourceImpl impl
return url;
}
- public InstallableResource.Type getResourceType() {
+ public String getResourceType() {
return resourceType;
}
Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallTask.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallTask.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallTask.java Tue Aug 10 13:37:59 2010
@@ -18,7 +18,7 @@
*/
package org.apache.sling.osgi.installer.impl.tasks;
-import org.apache.sling.osgi.installer.OsgiInstaller;
+import org.apache.sling.osgi.installer.OsgiInstallerStatistics;
import org.apache.sling.osgi.installer.impl.OsgiInstallerContext;
import org.apache.sling.osgi.installer.impl.OsgiInstallerTask;
import org.apache.sling.osgi.installer.impl.RegisteredResource;
@@ -31,23 +31,23 @@ import org.osgi.framework.Version;
public class BundleInstallTask extends OsgiInstallerTask {
private final RegisteredResource resource;
-
+
public BundleInstallTask(RegisteredResource r) {
this.resource = r;
}
-
- @Override
+
+ @Override
public String toString() {
return getClass().getSimpleName() + ": " + resource;
}
-
+
public void execute(OsgiInstallerContext ctx) throws Exception {
final Bundle b = ctx.getBundleContext().installBundle(resource.getUrl(), resource.getInputStream(ctx.getBundleContext()));
final Version newVersion = new Version((String)resource.getAttributes().get(Constants.BUNDLE_VERSION));
ctx.saveInstalledBundleInfo(b, resource.getDigest(), newVersion.toString());
- logExecution(ctx);
+ logExecution();
ctx.addTaskToCurrentCycle(new BundleStartTask(b.getBundleId()));
- ctx.incrementCounter(OsgiInstaller.OSGI_TASKS_COUNTER);
+ ctx.incrementCounter(OsgiInstallerStatistics.OSGI_TASKS_COUNTER);
}
@Override
Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleRemoveTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleRemoveTask.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleRemoveTask.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleRemoveTask.java Tue Aug 10 13:37:59 2010
@@ -18,33 +18,33 @@
*/
package org.apache.sling.osgi.installer.impl.tasks;
-import org.apache.sling.osgi.installer.OsgiInstaller;
+import org.apache.sling.osgi.installer.OsgiInstallerStatistics;
import org.apache.sling.osgi.installer.impl.OsgiInstallerContext;
import org.apache.sling.osgi.installer.impl.OsgiInstallerTask;
import org.apache.sling.osgi.installer.impl.RegisteredResource;
import org.osgi.framework.Bundle;
import org.osgi.framework.Constants;
-/** Remove a bundle from a RegisteredResource.
- * Creates a SynchronousRefreshPackagesTask when
+/** Remove a bundle from a RegisteredResource.
+ * Creates a SynchronousRefreshPackagesTask when
* executed.
*/
public class BundleRemoveTask extends OsgiInstallerTask {
private final RegisteredResource resource;
-
+
public BundleRemoveTask(RegisteredResource r) {
this.resource = r;
}
-
- @Override
+
+ @Override
public String toString() {
return getClass().getSimpleName() + ": " + resource;
}
-
+
@Override
public void execute(OsgiInstallerContext ctx) throws Exception {
- logExecution(ctx);
+ logExecution();
final String symbolicName = (String)resource.getAttributes().get(Constants.BUNDLE_SYMBOLICNAME);
final Bundle b = ctx.getMatchingBundle(symbolicName);
if(b == null) {
@@ -56,7 +56,7 @@ public class BundleRemoveTask extends Os
}
b.uninstall();
ctx.addTaskToCurrentCycle(new SynchronousRefreshPackagesTask());
- ctx.incrementCounter(OsgiInstaller.OSGI_TASKS_COUNTER);
+ ctx.incrementCounter(OsgiInstallerStatistics.OSGI_TASKS_COUNTER);
}
@Override
Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleStartTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleStartTask.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleStartTask.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleStartTask.java Tue Aug 10 13:37:59 2010
@@ -20,8 +20,9 @@ package org.apache.sling.osgi.installer.
import java.text.DecimalFormat;
-import org.apache.sling.osgi.installer.OsgiInstaller;
+import org.apache.sling.osgi.installer.OsgiInstallerStatistics;
import org.apache.sling.osgi.installer.impl.Activator;
+import org.apache.sling.osgi.installer.impl.Logger;
import org.apache.sling.osgi.installer.impl.OsgiInstallerContext;
import org.apache.sling.osgi.installer.impl.OsgiInstallerTask;
import org.osgi.framework.Bundle;
@@ -59,26 +60,26 @@ public class BundleStartTask extends Osg
boolean needToRetry = false;
if(bundleId == 0) {
- ctx.logDebug("Bundle 0 is the framework bundle, ignoring request to start it");
+ Logger.logDebug("Bundle 0 is the framework bundle, ignoring request to start it");
return;
}
if(b == null) {
- ctx.logInfo("Cannot start bundle, id not found:" + bundleId);
+ Logger.logInfo("Cannot start bundle, id not found:" + bundleId);
return;
}
try {
if(b.getState() == Bundle.ACTIVE) {
- ctx.logDebug("Bundle already started, no action taken:" + bundleId + "/" + b.getSymbolicName());
+ Logger.logDebug("Bundle already started, no action taken:" + bundleId + "/" + b.getSymbolicName());
} else {
// Try to start bundle, and if that doesn't work we'll need to retry
- logExecution(ctx);
+ logExecution();
try {
b.start();
- ctx.logInfo("Bundle started (retry count=" + retryCount + ", bundle ID=" + bundleId + ") " + b.getSymbolicName());
+ Logger.logInfo("Bundle started (retry count=" + retryCount + ", bundle ID=" + bundleId + ") " + b.getSymbolicName());
} catch(BundleException e) {
- ctx.logInfo("Could not start bundle (retry count=" + retryCount + ", " + e
+ Logger.logInfo("Could not start bundle (retry count=" + retryCount + ", " + e
+ "), will retry: " + bundleId + "/" + b.getSymbolicName());
needToRetry = true;
}
@@ -100,7 +101,7 @@ public class BundleStartTask extends Osg
}
}
retryCount++;
- ctx.incrementCounter(OsgiInstaller.OSGI_TASKS_COUNTER);
+ ctx.incrementCounter(OsgiInstallerStatistics.OSGI_TASKS_COUNTER);
}
/** Do not execute this task if waiting for events */
@@ -108,7 +109,7 @@ public class BundleStartTask extends Osg
final long eventsCount = Activator.getTotalEventsCount();
final boolean result = eventsCount >= eventsCountForRetrying;
if(!result) {
- tctx.logDebug(this + " is not executable at this time, counters=" + eventsCountForRetrying + "/" + eventsCount);
+ Logger.logDebug(this + " is not executable at this time, counters=" + eventsCountForRetrying + "/" + eventsCount);
}
return result;
}
Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java Tue Aug 10 13:37:59 2010
@@ -20,7 +20,8 @@ package org.apache.sling.osgi.installer.
import java.io.InputStream;
-import org.apache.sling.osgi.installer.OsgiInstaller;
+import org.apache.sling.osgi.installer.OsgiInstallerStatistics;
+import org.apache.sling.osgi.installer.impl.Logger;
import org.apache.sling.osgi.installer.impl.OsgiInstallerContext;
import org.apache.sling.osgi.installer.impl.OsgiInstallerTask;
import org.apache.sling.osgi.installer.impl.RegisteredResource;
@@ -64,7 +65,7 @@ public class BundleUpdateTask extends Os
final Version newVersion = new Version((String)resource.getAttributes().get(Constants.BUNDLE_VERSION));
snapshot = ctx.isSnapshot(newVersion);
if(currentVersion.equals(newVersion) && !snapshot) {
- ctx.logDebug("Same version is already installed, and not a snapshot, ignoring update:" + resource);
+ Logger.logDebug("Same version is already installed, and not a snapshot, ignoring update:" + resource);
return;
}
@@ -74,12 +75,12 @@ public class BundleUpdateTask extends Os
if(snapshot) {
final String oldDigest = ctx.getInstalledBundleDigest(b);
if(resource.getDigest().equals(oldDigest)) {
- ctx.logDebug("Snapshot digest did not change, ignoring update:" + resource);
+ Logger.logDebug("Snapshot digest did not change, ignoring update:" + resource);
return;
}
}
- logExecution(ctx);
+ logExecution();
if(b.getState() == Bundle.ACTIVE) {
// bundle was active before the update - restart it once updated, but
// in sequence, not right now
@@ -96,8 +97,8 @@ public class BundleUpdateTask extends Os
b.update(is);
ctx.saveInstalledBundleInfo(b, resource.getDigest(), newVersion.toString());
ctx.addTaskToCurrentCycle(new SynchronousRefreshPackagesTask());
- ctx.logDebug("Bundle updated: " + b.getBundleId() + "/" + b.getSymbolicName());
- ctx.incrementCounter(OsgiInstaller.OSGI_TASKS_COUNTER);
+ Logger.logDebug("Bundle updated: " + b.getBundleId() + "/" + b.getSymbolicName());
+ ctx.incrementCounter(OsgiInstallerStatistics.OSGI_TASKS_COUNTER);
}
@Override
Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallTask.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallTask.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallTask.java Tue Aug 10 13:37:59 2010
@@ -25,6 +25,7 @@ import java.util.HashSet;
import java.util.Set;
import org.apache.sling.osgi.installer.impl.DigestUtil;
+import org.apache.sling.osgi.installer.impl.Logger;
import org.apache.sling.osgi.installer.impl.OsgiInstallerContext;
import org.apache.sling.osgi.installer.impl.RegisteredResource;
import org.osgi.service.cm.Configuration;
@@ -60,7 +61,7 @@ public class ConfigInstallTask extends A
final ConfigurationAdmin ca = ctx.getConfigurationAdmin();
if(ca == null) {
ctx.addTaskToNextCycle(this);
- ctx.logDebug("ConfigurationAdmin not available, task will be retried later: " + this);
+ Logger.logDebug("ConfigurationAdmin not available, task will be retried later: " + this);
return;
}
@@ -88,7 +89,7 @@ public class ConfigInstallTask extends A
config = getConfiguration(ca, pid, true, ctx);
} else {
if(isSameData(config.getProperties(), resource.getDictionary())) {
- ctx.logDebug("Configuration " + config.getPid()
+ Logger.logDebug("Configuration " + config.getPid()
+ " already installed with same data, update request ignored: "
+ resource);
config = null;
@@ -96,12 +97,12 @@ public class ConfigInstallTask extends A
}
if(config != null) {
- logExecution(ctx);
+ logExecution();
if (config.getBundleLocation() != null) {
config.setBundleLocation(null);
}
config.update(dict);
- ctx.logInfo("Configuration " + config.getPid()
+ Logger.logInfo("Configuration " + config.getPid()
+ " " + (created ? "created" : "updated")
+ " from " + resource);
}
Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigRemoveTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigRemoveTask.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigRemoveTask.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigRemoveTask.java Tue Aug 10 13:37:59 2010
@@ -18,6 +18,7 @@
*/
package org.apache.sling.osgi.installer.impl.tasks;
+import org.apache.sling.osgi.installer.impl.Logger;
import org.apache.sling.osgi.installer.impl.OsgiInstallerContext;
import org.apache.sling.osgi.installer.impl.RegisteredResource;
import org.osgi.service.cm.Configuration;
@@ -44,16 +45,16 @@ import org.osgi.service.cm.Configuration
final ConfigurationAdmin ca = ctx.getConfigurationAdmin();
if(ca == null) {
ctx.addTaskToNextCycle(this);
- ctx.logDebug("ConfigurationAdmin not available, task will be retried later: " + this);
+ Logger.logDebug("ConfigurationAdmin not available, task will be retried later: " + this);
return;
}
- logExecution(ctx);
+ logExecution();
final Configuration cfg = getConfiguration(ca, pid, false, ctx);
if(cfg == null) {
- ctx.logDebug("Cannot delete config , pid=" + pid + " not found, ignored (" + resource + ")");
+ Logger.logDebug("Cannot delete config , pid=" + pid + " not found, ignored (" + resource + ")");
} else {
- ctx.logInfo("Deleting config " + pid + " (" + resource + ")");
+ Logger.logInfo("Deleting config " + pid + " (" + resource + ")");
cfg.delete();
}
}
Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/SynchronousRefreshPackagesTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/SynchronousRefreshPackagesTask.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/SynchronousRefreshPackagesTask.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/SynchronousRefreshPackagesTask.java Tue Aug 10 13:37:59 2010
@@ -18,6 +18,7 @@
*/
package org.apache.sling.osgi.installer.impl.tasks;
+import org.apache.sling.osgi.installer.impl.Logger;
import org.apache.sling.osgi.installer.impl.OsgiInstallerContext;
import org.apache.sling.osgi.installer.impl.OsgiInstallerTask;
import org.osgi.framework.Bundle;
@@ -31,7 +32,6 @@ public class SynchronousRefreshPackagesT
public static final int MAX_REFRESH_PACKAGES_WAIT_SECONDS = 30;
private volatile int packageRefreshEventsCount;
- private OsgiInstallerContext ctx;
/**
* Handles the PACKAGES_REFRESHED framework event which is sent after
@@ -42,9 +42,7 @@ public class SynchronousRefreshPackagesT
*/
public void frameworkEvent(FrameworkEvent event) {
if (event.getType() == FrameworkEvent.PACKAGES_REFRESHED) {
- if (ctx!= null) {
- ctx.logDebug("FrameworkEvent.PACKAGES_REFRESHED");
- }
+ Logger.logDebug("FrameworkEvent.PACKAGES_REFRESHED");
packageRefreshEventsCount++;
}
}
@@ -60,8 +58,7 @@ public class SynchronousRefreshPackagesT
}
public void execute(OsgiInstallerContext ctx) throws Exception {
- logExecution(ctx);
- this.ctx = ctx;
+ logExecution();
final int targetEventCount = packageRefreshEventsCount + 1;
final long start = System.currentTimeMillis();
final long timeout = System.currentTimeMillis() + MAX_REFRESH_PACKAGES_WAIT_SECONDS * 1000L;
@@ -73,7 +70,7 @@ public class SynchronousRefreshPackagesT
if(b.getState() == Bundle.ACTIVE) {
final OsgiInstallerTask t = new BundleStartTask(b.getBundleId());
ctx.addTaskToCurrentCycle(t);
- ctx.logDebug("Added " + t + " to restart bundle if needed after refreshing packages");
+ Logger.logDebug("Added " + t + " to restart bundle if needed after refreshing packages");
}
}
@@ -84,14 +81,14 @@ public class SynchronousRefreshPackagesT
ctx.getPackageAdmin().refreshPackages(null);
while(true) {
if(System.currentTimeMillis() > timeout) {
- ctx.logWarn("No FrameworkEvent.PACKAGES_REFRESHED event received within "
+ Logger.logWarn("No FrameworkEvent.PACKAGES_REFRESHED event received within "
+ MAX_REFRESH_PACKAGES_WAIT_SECONDS
+ " seconds after refresh");
break;
}
if(packageRefreshEventsCount >= targetEventCount) {
final long delta = System.currentTimeMillis() - start;
- ctx.logDebug("FrameworkEvent.PACKAGES_REFRESHED received "
+ Logger.logDebug("FrameworkEvent.PACKAGES_REFRESHED received "
+ delta
+ " msec after refreshPackages call");
break;
Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/InstallableResourceTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/InstallableResourceTest.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/InstallableResourceTest.java (original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/InstallableResourceTest.java Tue Aug 10 13:37:59 2010
@@ -21,6 +21,7 @@ package org.apache.sling.osgi.installer.
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import java.io.IOException;
import java.util.Dictionary;
import java.util.Hashtable;
@@ -33,9 +34,9 @@ public class InstallableResourceTest {
private InstallableResourceFactory factory = new InstallableResourceFactoryImpl();
@Test
- public void testDictionaryDigest() {
+ public void testDictionaryDigest() throws IOException {
final Dictionary<String, Object> d = new Hashtable<String, Object>();
- final InstallableResource r = factory.create("x:url", d, null, null, null);
+ final InstallableResource r = factory.create("x:url", null, d, null, null, null);
assertNotNull("Expected InstallableResource to compute its own digest", r.getDigest());
}
@@ -51,8 +52,8 @@ public class InstallableResourceTest {
d2.put(keys[i], keys[i] + "." + keys[i]);
}
- final InstallableResource r1 = factory.create("test:url1", d1, null, null, null);
- final InstallableResource r2 = factory.create("test:url1", d2, null, null, null);
+ final InstallableResource r1 = factory.create("test:url1", null, d1, null, null, null);
+ final InstallableResource r2 = factory.create("test:url1", null, d2, null, null, null);
assertEquals(
"Two InstallableResource (Dictionary) with same values but different key orderings must have the same key",
Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleResource.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleResource.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleResource.java (original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleResource.java Tue Aug 10 13:37:59 2010
@@ -100,8 +100,8 @@ public class MockBundleResource implemen
return null;
}
- public InstallableResource.Type getResourceType() {
- return InstallableResource.Type.BUNDLE;
+ public String getResourceType() {
+ return InstallableResource.TYPE_BUNDLE;
}
public String getUrl() {
Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockOsgiInstallerContext.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockOsgiInstallerContext.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockOsgiInstallerContext.java (original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockOsgiInstallerContext.java Tue Aug 10 13:37:59 2010
@@ -34,7 +34,7 @@ public class MockOsgiInstallerContext im
public MockOsgiInstallerContext() throws IOException {
final File f = File.createTempFile(MockOsgiInstallerContext.class.getSimpleName(), ".data");
f.deleteOnExit();
- persistentBundleInfo = new PersistentBundleInfo(this, f);
+ persistentBundleInfo = new PersistentBundleInfo(f);
}
public void addTaskToCurrentCycle(OsgiInstallerTask t) {
@@ -84,46 +84,4 @@ public class MockOsgiInstallerContext im
public void saveInstalledBundleInfo(String symbolicName, String digest, String version) throws IOException {
persistentBundleInfo.putInfo(symbolicName, digest, version);
}
-
- /**
- * @see org.apache.sling.osgi.installer.impl.OsgiInstallerContext#logDebug(java.lang.String, java.lang.Throwable)
- */
- public void logDebug(String message, Throwable t) {
- // nothing to do - no logging
- }
-
- /**
- * @see org.apache.sling.osgi.installer.impl.OsgiInstallerContext#logDebug(java.lang.String)
- */
- public void logDebug(String message) {
- // nothing to do - no logging
- }
-
- /**
- * @see org.apache.sling.osgi.installer.impl.OsgiInstallerContext#logInfo(java.lang.String, java.lang.Throwable)
- */
- public void logInfo(String message, Throwable t) {
- // nothing to do - no logging
- }
-
- /**
- * @see org.apache.sling.osgi.installer.impl.OsgiInstallerContext#logInfo(java.lang.String)
- */
- public void logInfo(String message) {
- // nothing to do - no logging
- }
-
- /**
- * @see org.apache.sling.osgi.installer.impl.OsgiInstallerContext#logWarn(java.lang.String, java.lang.Throwable)
- */
- public void logWarn(String message, Throwable t) {
- // nothing to do - no logging
- }
-
- /**
- * @see org.apache.sling.osgi.installer.impl.OsgiInstallerContext#logWarn(java.lang.String)
- */
- public void logWarn(String message) {
- // nothing to do - no logging
- }
}
Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/PersistentBundleInfoTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/PersistentBundleInfoTest.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/PersistentBundleInfoTest.java (original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/PersistentBundleInfoTest.java Tue Aug 10 13:37:59 2010
@@ -19,8 +19,8 @@
package org.apache.sling.osgi.installer.impl;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import java.io.File;
import java.io.IOException;
@@ -34,15 +34,15 @@ public class PersistentBundleInfoTest {
private File testFile;
private TreeSet<String> installedBundles;
private static final String NO_VERSION = "";
-
+
@Before
public void setUp() throws Exception {
testFile = File.createTempFile(getClass().getSimpleName(), "properties");
testFile.deleteOnExit();
- storage = new PersistentBundleInfo(new MockOsgiInstallerContext(), testFile);
+ storage = new PersistentBundleInfo(testFile);
installedBundles = new TreeSet<String>();
}
-
+
@Test
public void testCloseAndReopen() throws IOException {
storage.putInfo("foo", "bar", NO_VERSION);
@@ -53,10 +53,10 @@ public class PersistentBundleInfoTest {
storage.putInfo("foo", "wii", NO_VERSION);
assertEquals("After change, expecting wii digest", "wii", storage.getDigest("foo"));
storage = null;
- final PersistentBundleInfo copy = new PersistentBundleInfo(new MockOsgiInstallerContext(), testFile);
+ final PersistentBundleInfo copy = new PersistentBundleInfo(testFile);
assertEquals("In copy saved before change, expecting bar digest", "bar", copy.getDigest("foo"));
}
-
+
@Test
public void testPurge() throws IOException {
for(int i=0; i < 50; i++) {
@@ -66,45 +66,45 @@ public class PersistentBundleInfoTest {
}
}
for(int i=0; i < 50; i++) {
- assertEquals("Before save, expecting digest to match at step " + i, "bar" + i,
+ assertEquals("Before save, expecting digest to match at step " + i, "bar" + i,
storage.getDigest("foo" + i));
- assertEquals("Before save, expecting version to match at step " + i, "1." + i,
+ assertEquals("Before save, expecting version to match at step " + i, "1." + i,
storage.getInstalledVersion("foo" + i));
}
storage.purgeAndSave(installedBundles);
for(int i=0; i < 50; i++) {
if(i % 2 != 0) {
- assertNull("After purge, expecting null digest at step " + i,
+ assertNull("After purge, expecting null digest at step " + i,
storage.getDigest("foo" + i));
- assertNull("After purge, expecting null version at step " + i,
+ assertNull("After purge, expecting null version at step " + i,
storage.getInstalledVersion("foo" + i));
} else {
- assertNotNull("After purge, expecting non-null digest at step " + i,
+ assertNotNull("After purge, expecting non-null digest at step " + i,
storage.getDigest("foo" + i));
- assertEquals("After purge, expecting digest to match at step " + i, "bar" + i,
+ assertEquals("After purge, expecting digest to match at step " + i, "bar" + i,
storage.getDigest("foo" + i));
- assertNotNull("After purge, expecting non-null version at step " + i,
+ assertNotNull("After purge, expecting non-null version at step " + i,
storage.getInstalledVersion("foo" + i));
- assertEquals("After purge, expecting version to match at step " + i, "1." + i,
+ assertEquals("After purge, expecting version to match at step " + i, "1." + i,
storage.getInstalledVersion("foo" + i));
}
}
storage = null;
- final PersistentBundleInfo copy = new PersistentBundleInfo(new MockOsgiInstallerContext(), testFile);
+ final PersistentBundleInfo copy = new PersistentBundleInfo(testFile);
for(int i=0; i < 50; i++) {
if(i % 2 != 0) {
- assertNull("In copy, expecting null digest at step " + i,
+ assertNull("In copy, expecting null digest at step " + i,
copy.getDigest("foo" + i));
- assertNull("In copy, expecting null version at step " + i,
+ assertNull("In copy, expecting null version at step " + i,
copy.getInstalledVersion("foo" + i));
} else {
- assertNotNull("In copy, expecting non-null digest at step " + i,
+ assertNotNull("In copy, expecting non-null digest at step " + i,
copy.getDigest("foo" + i));
- assertEquals("In copy, expecting digest to match at step " + i, "bar" + i,
+ assertEquals("In copy, expecting digest to match at step " + i, "bar" + i,
copy.getDigest("foo" + i));
- assertNotNull("In copy, expecting non-null version at step " + i,
+ assertNotNull("In copy, expecting non-null version at step " + i,
copy.getInstalledVersion("foo" + i));
- assertEquals("In copy, expecting version to match at step " + i, "1." + i,
+ assertEquals("In copy, expecting version to match at step " + i, "1." + i,
copy.getInstalledVersion("foo" + i));
}
}
Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/PersistentResourceListTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/PersistentResourceListTest.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/PersistentResourceListTest.java (original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/PersistentResourceListTest.java Tue Aug 10 13:37:59 2010
@@ -37,14 +37,14 @@ import org.osgi.framework.Version;
public class PersistentResourceListTest {
private final static int TEST_SCALE = 5;
private final static String FAKE = "fakebundle.";
-
+
@Test
public void testFileNotFound() throws IOException {
File f = new File("NONEXISTENT");
- PersistentResourceList p = new PersistentResourceList(new MockOsgiInstallerContext(), f);
+ PersistentResourceList p = new PersistentResourceList(f);
assertNotNull(p.getData());
}
-
+
@Test
public void testBadDataFile() throws IOException {
File f = File.createTempFile(getClass().getSimpleName(), ".ser");
@@ -55,35 +55,35 @@ public class PersistentResourceListTest
} finally {
oos.close();
}
- PersistentResourceList p = new PersistentResourceList(new MockOsgiInstallerContext(), f);
+ PersistentResourceList p = new PersistentResourceList(f);
assertNotNull(p.getData());
assertEquals("Constructor must fail gracefully with invalid data file", 0, p.getData().size());
}
-
+
@Test
public void testTestData() throws IOException {
File f = new File("NONEXISTENT");
- PersistentResourceList p = new PersistentResourceList(new MockOsgiInstallerContext(), f);
+ PersistentResourceList p = new PersistentResourceList(f);
assertNotNull(p.getData());
addTestData(p);
assertTestData(p);
}
-
+
@Test
public void testSaveAndRetrieve() throws IOException {
File f = File.createTempFile(getClass().getSimpleName(), ".ser");
f.deleteOnExit();
{
- PersistentResourceList p = new PersistentResourceList(new MockOsgiInstallerContext(), f);
+ PersistentResourceList p = new PersistentResourceList(f);
addTestData(p);
p.save();
}
{
- PersistentResourceList p = new PersistentResourceList(new MockOsgiInstallerContext(), f);
+ PersistentResourceList p = new PersistentResourceList(f);
assertTestData(p);
}
}
-
+
private void addTestData(PersistentResourceList p) {
for(int i = 0; i < TEST_SCALE; i++) {
final String symbolicName = FAKE + i;
@@ -94,7 +94,7 @@ public class PersistentResourceListTest
p.getData().put(symbolicName, s);
}
}
-
+
private void assertTestData(PersistentResourceList p) {
for(int i = 0; i < TEST_SCALE; i++) {
final String symbolicName = FAKE + i;
@@ -114,7 +114,7 @@ public class PersistentResourceListTest
p.getData().put(symbolicName, s);
}
}
-
+
private String getFakeVersion(int i, int j) {
return j + "." + i + ".0";
}
Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java (original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java Tue Aug 10 13:37:59 2010
@@ -51,7 +51,7 @@ public class RegisteredResourceComparato
data = new Hashtable<String, Object>();
data.put("foo", "bar");
}
- final InstallableResource r = factory.create("test:" + url, data, null, null, priority);
+ final InstallableResource r = factory.create("test:" + url, null, data, null, null, priority);
return new RegisteredResourceImpl(new MockOsgiInstallerContext(), r);
}
Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java (original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java Tue Aug 10 13:37:59 2010
@@ -28,8 +28,6 @@ import static org.junit.Assert.fail;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FilterInputStream;
-import java.io.IOException;
import java.io.InputStream;
import java.util.Dictionary;
import java.util.Hashtable;
@@ -49,37 +47,12 @@ public class RegisteredResourceTest {
"org.apache.sling.osgi.installer-" + System.getProperty("osgi.installer.pom.version") + "-" + name);
}
- @org.junit.Test public void testStreamIsClosed() throws Exception {
- final String data = "some data";
-
- class TestInputStream extends FilterInputStream {
- int closeCount;
-
- TestInputStream(InputStream i) {
- super(i);
- }
-
- @Override
- public void close() throws IOException {
- super.close();
- closeCount++;
- }
-
- }
-
- final TestInputStream t = new TestInputStream(new ByteArrayInputStream(data.getBytes()));
- final InstallableResource ir = factory.create(TEST_URL, t, "somedigest", null, null);
- //assertEquals("TestInputStream must not be closed before test", 0, t.closeCount);
- new LocalFileRegisteredResource(ir);
- assertEquals("TestInputStream must be closed by RegisteredResource", 1, t.closeCount);
- }
-
@org.junit.Test public void testResourceType() throws Exception {
{
final InputStream s = new FileInputStream(getTestBundle("testbundle-1.0.jar"));
- final RegisteredResource r = new LocalFileRegisteredResource(factory.create("test:1.jar", s, "some digest", null, null));
+ final RegisteredResource r = new LocalFileRegisteredResource(factory.create("test:1.jar", s, null, "some digest", null, null));
assertEquals(".jar URL creates a BUNDLE resource",
- InstallableResource.Type.BUNDLE, r.getResourceType());
+ InstallableResource.TYPE_BUNDLE, r.getResourceType());
final InputStream rs = r.getInputStream(null);
assertNotNull("BUNDLE resource provides an InputStream", rs);
rs.close();
@@ -88,25 +61,12 @@ public class RegisteredResourceTest {
}
{
- final InputStream s = new ByteArrayInputStream("foo=bar\nother=2".getBytes());
- final RegisteredResource r = new LocalFileRegisteredResource(factory.create("test:1.properties", s, "digest1", null, null));
- assertEquals(".properties URL creates a CONFIG resource",
- InstallableResource.Type.CONFIG, r.getResourceType());
- final InputStream rs = r.getInputStream(null);
- assertNull("CONFIG resource does not provide an InputStream", rs);
- final Dictionary<String, Object> d = r.getDictionary();
- assertNotNull("CONFIG resource provides a Dictionary", d);
- assertEquals("CONFIG resource dictionary has two properties", 2, d.size());
- assertNotNull("CONFIG resource has a pid attribute", r.getAttributes().get(RegisteredResource.CONFIG_PID_ATTRIBUTE));
- }
-
- {
final Hashtable<String, Object> data = new Hashtable<String, Object>();
data.put("foo", "bar");
data.put("other", 2);
- final RegisteredResource r = new LocalFileRegisteredResource(factory.create("test:1", data, null, null, null));
+ final RegisteredResource r = new LocalFileRegisteredResource(factory.create("test:1", null, data, null, null, null));
assertEquals("No-extension URL with Dictionary creates a CONFIG resource",
- InstallableResource.Type.CONFIG, r.getResourceType());
+ InstallableResource.TYPE_CONFIG, r.getResourceType());
final InputStream rs = r.getInputStream(null);
assertNull("CONFIG resource does not provide an InputStream", rs);
final Dictionary<String, Object> d = r.getDictionary();
@@ -119,7 +79,7 @@ public class RegisteredResourceTest {
@org.junit.Test public void testLocalFileCopy() throws Exception {
final File f = getTestBundle("testbundle-1.0.jar");
final InputStream s = new FileInputStream(f);
- final LocalFileRegisteredResource r = new LocalFileRegisteredResource(factory.create("test:1.jar", s, "somedigest", null, null));
+ final LocalFileRegisteredResource r = new LocalFileRegisteredResource(factory.create("test:1.jar", s, null, "somedigest", null, null));
assertTrue("Local file exists", r.getDataFile(null).exists());
assertEquals("Local file length matches our data", f.length(), r.getDataFile(null).length());
@@ -130,7 +90,7 @@ public class RegisteredResourceTest {
final InputStream in = new ByteArrayInputStream(data.getBytes());
try {
- new LocalFileRegisteredResource(factory.create("test:1.jar", in, null, null, null));
+ new LocalFileRegisteredResource(factory.create("test:1.jar", in, null, null, null, null));
fail("With jar extension, expected an IllegalArgumentException as digest is null");
} catch(IllegalArgumentException asExpected) {
}
@@ -138,14 +98,14 @@ public class RegisteredResourceTest {
@org.junit.Test public void testBundleManifest() throws Exception {
final File f = getTestBundle("testbundle-1.0.jar");
- final InstallableResource i = factory.create("test:" + f.getAbsolutePath(), new FileInputStream(f), f.getName(), null, null);
+ final InstallableResource i = factory.create("test:" + f.getAbsolutePath(), new FileInputStream(f), null, f.getName(), null, null);
final RegisteredResource r = new LocalFileRegisteredResource(i);
assertNotNull("RegisteredResource must have bundle symbolic name", r.getAttributes().get(Constants.BUNDLE_SYMBOLICNAME));
assertEquals("RegisteredResource entity ID must match", "bundle:osgi-installer-testbundle", r.getEntityId());
}
@org.junit.Test public void testConfigEntity() throws Exception {
- final InstallableResource i = factory.create("test:/foo/someconfig", new Hashtable<String, Object>(), null, null, null);
+ final InstallableResource i = factory.create("test:/foo/someconfig", null, new Hashtable<String, Object>(), null, null, null);
final RegisteredResource r = new LocalFileRegisteredResource(i);
assertNull("RegisteredResource must not have bundle symbolic name", r.getAttributes().get(Constants.BUNDLE_SYMBOLICNAME));
assertEquals("RegisteredResource entity ID must match", "config:someconfig", r.getEntityId());
@@ -153,17 +113,14 @@ public class RegisteredResourceTest {
@org.junit.Test public void testConfigDigestIncludesUrl() throws Exception {
final Dictionary<String, Object> data = new Hashtable<String, Object>();
- final InstallableResource rA = factory.create("test:urlA", data, null, null, null);
- final InstallableResource rB = factory.create("test:urlB", data, null, null, null);
+ final InstallableResource rA = factory.create("test:urlA", null, data, null, null, null);
+ final InstallableResource rB = factory.create("test:urlB", null, data, null, null, null);
assertFalse(
"Expecting configs with same data but different URLs to have different digests",
rA.getDigest().equals(rB.getDigest()));
}
@org.junit.Test public void testUrlScheme() throws Exception {
- final ByteArrayInputStream s = new ByteArrayInputStream("foo".getBytes());
-
-
final String [] badOnes = {
"",
":colonTooEarly",
@@ -172,7 +129,7 @@ public class RegisteredResourceTest {
};
for(String url : badOnes) {
try {
- new RegisteredResourceImpl(new MockOsgiInstallerContext(),factory.create(url, s, null, null, null));
+ new RegisteredResourceImpl(new MockOsgiInstallerContext(),factory.create(url, null, new Hashtable<String, Object>(), null, null, null));
fail("Expected bad URL '" + url + "' to throw IllegalArgumentException");
} catch(IllegalArgumentException asExpected) {
}
@@ -187,7 +144,7 @@ public class RegisteredResourceTest {
for(String url : goodOnes) {
final RegisteredResource r = new RegisteredResourceImpl(new MockOsgiInstallerContext(),
- factory.create(url, s, "digest1", null, null));
+ factory.create(url, null, new Hashtable<String, Object>(), "digest1", null, null));
assertEquals("Expected scheme 'foo' for URL " + url, "foo", r.getUrlScheme());
}
}
Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java (original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java Tue Aug 10 13:37:59 2010
@@ -51,7 +51,7 @@ public class TaskOrderingTest {
}
private static RegisteredResource getRegisteredResource(String url) throws IOException {
- return new RegisteredResourceImpl(new MockOsgiInstallerContext(), factory.create(url, new Hashtable<String, Object>(), null, null, null));
+ return new RegisteredResourceImpl(new MockOsgiInstallerContext(), factory.create(url, null, new Hashtable<String, Object>(), null, null, null));
}
private void assertOrder(int testId, Collection<OsgiInstallerTask> actual, OsgiInstallerTask [] expected) {
Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleDependenciesTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleDependenciesTest.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleDependenciesTest.java (original)
+++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleDependenciesTest.java Tue Aug 10 13:37:59 2010
@@ -19,7 +19,7 @@ package org.apache.sling.osgi.installer.
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-import org.apache.sling.osgi.installer.OsgiInstaller;
+import org.apache.sling.osgi.installer.OsgiInstallerStatistics;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -35,39 +35,39 @@ public class BundleDependenciesTest exte
public static Option[] configuration() {
return defaultConfiguration();
}
-
+
@Before
public void setUp() {
setupInstaller();
}
-
+
@After
public void tearDown() {
super.tearDown();
}
-
+
// needsB bundle requires testB, try loading needsB first,
- // then testB, and verify that in the end needsB is started
+ // then testB, and verify that in the end needsB is started
@Test
public void testBundleDependencies() throws Exception {
final String testB = "osgi-installer-testB";
final String needsB = "osgi-installer-needsB";
-
+
assertNull("TestB bundle must not be present at beginning of test", findBundle(testB));
-
+
// without testB, needsB must not start
{
resetCounters();
installer.addResource(getInstallableResource(getTestBundle(BUNDLE_BASE_NAME + "-needsB.jar")));
- waitForInstallerAction(OsgiInstaller.OSGI_TASKS_COUNTER, 2);
+ waitForInstallerAction(OsgiInstallerStatistics.OSGI_TASKS_COUNTER, 2);
assertBundle(needsB + " must not be started, testB not present", needsB, null, Bundle.INSTALLED);
}
-
+
// now install testB -> needsB must start
{
resetCounters();
installer.addResource(getInstallableResource(getTestBundle(BUNDLE_BASE_NAME + "-testB-1.0.jar")));
- waitForInstallerAction(OsgiInstaller.OSGI_TASKS_COUNTER, 2);
+ waitForInstallerAction(OsgiInstallerStatistics.OSGI_TASKS_COUNTER, 2);
assertNotNull(testB + " must be installed", findBundle(testB));
assertBundle(needsB + " must be started now that testB is installed", needsB, null, Bundle.ACTIVE);
}
Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallStressTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallStressTest.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallStressTest.java (original)
+++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallStressTest.java Tue Aug 10 13:37:59 2010
@@ -25,7 +25,7 @@ import java.util.List;
import java.util.Random;
import org.apache.sling.osgi.installer.InstallableResource;
-import org.apache.sling.osgi.installer.OsgiInstaller;
+import org.apache.sling.osgi.installer.OsgiInstallerStatistics;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -37,49 +37,49 @@ import org.osgi.service.log.LogService;
/** Repeatedly install/remove/reinstall semi-random sets
* of bundles, to stress-test the installer and framework.
- *
+ *
* Randomly selects bundles to remove and reinstall in a folder
- * containing from 4 to N bundles - by supplying a folder with many
- * bundles, and increasing the number of cycles executed (via
- * system properties, see pom.xml) the test can be turned into a
- * long-running stress test.
+ * containing from 4 to N bundles - by supplying a folder with many
+ * bundles, and increasing the number of cycles executed (via
+ * system properties, see pom.xml) the test can be turned into a
+ * long-running stress test.
*/
@RunWith(JUnit4TestRunner.class)
public class BundleInstallStressTest extends OsgiInstallerTestBase {
-
- public static final String PROP_BUNDLES_FOLDER = "osgi.installer.BundleInstallStressTest.bundles.folder";
+
+ public static final String PROP_BUNDLES_FOLDER = "osgi.installer.BundleInstallStressTest.bundles.folder";
public static final String PROP_CYCLE_COUNT = "osgi.installer.BundleInstallStressTest.cycle.count";
public static final String PROP_EXPECT_TIMEOUT_SECONDS = "osgi.installer.BundleInstallStressTest.expect.timeout.seconds";
public static final int MIN_TEST_BUNDLES = 4;
-
+
/** Folder where test bundles are found */
private File bundlesFolder;
-
+
/** How many cycles to run */
private int cycleCount;
-
+
/** List of available test bundles */
private List<File> testBundles;
-
+
/** Always use the same random sequence */
private Random random;
-
+
/** Timeout for expectBundles() */
private long expectBundlesTimeoutMsec;
-
+
/** Synchronize (somewhat) with OSGi operations, to be fair */
private EventsDetector eventsDetector;
public static final long MSEC_WITHOUT_EVENTS = 1000L;
-
+
@org.ops4j.pax.exam.junit.Configuration
public static Option[] configuration() {
return defaultConfiguration();
}
-
+
@Before
public void setUp() {
setupInstaller();
-
+
final String bf = System.getProperty(PROP_BUNDLES_FOLDER);
if(bf == null) {
fail("Missing system property: " + PROP_BUNDLES_FOLDER);
@@ -88,24 +88,24 @@ public class BundleInstallStressTest ext
if(!bundlesFolder.isDirectory()) {
fail("Bundles folder '" + bundlesFolder.getAbsolutePath() + "' not found");
}
-
+
final String cc = System.getProperty(PROP_CYCLE_COUNT);
if(cc == null) {
fail("Missing system property:" + PROP_CYCLE_COUNT);
}
cycleCount = Integer.parseInt(cc);
-
+
final String et = System.getProperty(PROP_EXPECT_TIMEOUT_SECONDS);
if(et == null) {
fail("Missing system property:" + PROP_EXPECT_TIMEOUT_SECONDS);
}
expectBundlesTimeoutMsec = Integer.parseInt(et) * 1000L;
-
- log(LogService.LOG_INFO, getClass().getSimpleName()
+
+ log(LogService.LOG_INFO, getClass().getSimpleName()
+ ": cycle count=" + cycleCount
+ ", expect timeout (msec)=" + expectBundlesTimeoutMsec
+ ", test bundles folder=" + bundlesFolder.getAbsolutePath());
-
+
testBundles = new LinkedList<File>();
final String [] files = bundlesFolder.list();
for(String filename : files) {
@@ -113,41 +113,41 @@ public class BundleInstallStressTest ext
testBundles.add(new File(bundlesFolder, filename));
}
}
-
+
if(testBundles.size() < MIN_TEST_BUNDLES) {
- fail("Found only " + testBundles.size()
+ fail("Found only " + testBundles.size()
+ " bundles in test folder, expected at least " + MIN_TEST_BUNDLES
+ " (test folder=" + bundlesFolder.getAbsolutePath() + ")"
);
}
-
+
random = new Random(42 + cycleCount);
eventsDetector = new EventsDetector(bundleContext);
}
-
+
@After
public void tearDown() {
super.tearDown();
eventsDetector.close();
}
-
+
@Test
public void testSemiRandomInstall() throws Exception {
if(cycleCount < 1) {
fail("Cycle count (" + cycleCount + ") should be >= 1");
}
-
+
final int initialBundleCount = bundleContext.getBundles().length;
log(LogService.LOG_INFO,"Initial bundle count=" + initialBundleCount);
logInstalledBundles();
-
+
// Start by installing all bundles
log(LogService.LOG_INFO,"Registering all test bundles, " + testBundles.size() + " resources");
install(testBundles);
- waitForInstallerAction("After registering all bundles", OsgiInstaller.WORKER_THREAD_BECOMES_IDLE_COUNTER,
+ waitForInstallerAction("After registering all bundles", OsgiInstallerStatistics.WORKER_THREAD_BECOMES_IDLE_COUNTER,
1, expectBundlesTimeoutMsec);
expectBundleCount("After installing all test bundles", initialBundleCount + testBundles.size());
-
+
// And run a number of cycles where randomly selected bundles are removed and reinstalled
for(int i=0; i < cycleCount; i++) {
final long start = System.currentTimeMillis();
@@ -155,16 +155,16 @@ public class BundleInstallStressTest ext
final List<File> toInstall = selectRandomBundles();
log(LogService.LOG_INFO,"Re-registering " + toInstall.size() + " randomly selected resources (other test bundles should be uninstalled)");
install(toInstall);
- waitForInstallerAction("At cycle " + i, OsgiInstaller.WORKER_THREAD_BECOMES_IDLE_COUNTER,
+ waitForInstallerAction("At cycle " + i, OsgiInstallerStatistics.WORKER_THREAD_BECOMES_IDLE_COUNTER,
1, expectBundlesTimeoutMsec);
eventsDetector.waitForNoEvents(MSEC_WITHOUT_EVENTS, expectBundlesTimeoutMsec);
expectBundleCount("At cycle " + i, initialBundleCount + toInstall.size());
- log(LogService.LOG_INFO,"Test cycle " + i + " successful, "
- + toInstall.size() + " bundles, "
+ log(LogService.LOG_INFO,"Test cycle " + i + " successful, "
+ + toInstall.size() + " bundles, "
+ (System.currentTimeMillis() - start) + " msec");
}
}
-
+
private void install(List<File> bundles) throws IOException {
final List<InstallableResource> toInstall = new LinkedList<InstallableResource>();
for(File f : bundles) {
@@ -172,7 +172,7 @@ public class BundleInstallStressTest ext
}
installer.registerResources(toInstall, URL_SCHEME);
}
-
+
private void expectBundleCount(String info, final int nBundles) throws Exception {
log(LogService.LOG_INFO,"Expecting " + nBundles + " bundles to be installed");
final Condition c = new Condition() {
@@ -181,26 +181,26 @@ public class BundleInstallStressTest ext
actualCount = bundleContext.getBundles().length;
return actualCount == nBundles;
}
-
+
@Override
String additionalInfo() {
return "Expected " + nBundles + " installed bundles, got " + actualCount;
}
-
+
@Override
void onFailure() {
log(LogService.LOG_INFO, "Failure: " + additionalInfo());
logInstalledBundles();
}
-
+
@Override
- long getMsecBetweenEvaluations() {
- return 1000L;
+ long getMsecBetweenEvaluations() {
+ return 1000L;
}
};
waitForCondition(info, expectBundlesTimeoutMsec, c);
}
-
+
private List<File> selectRandomBundles() {
final List<File> result = new LinkedList<File>();
for(File f : testBundles) {
@@ -209,14 +209,14 @@ public class BundleInstallStressTest ext
result.add(f);
}
}
-
+
if(result.size() == 0) {
result.add(testBundles.get(0));
}
-
+
return result;
}
-
+
private void logInstalledBundles() {
for(Bundle b : bundleContext.getBundles()) {
log(LogService.LOG_INFO, "Installed bundle: " + b.getSymbolicName());
Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallUpgradeDowngradeTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallUpgradeDowngradeTest.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallUpgradeDowngradeTest.java (original)
+++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallUpgradeDowngradeTest.java Tue Aug 10 13:37:59 2010
@@ -19,7 +19,7 @@ package org.apache.sling.osgi.installer.
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
-import org.apache.sling.osgi.installer.OsgiInstaller;
+import org.apache.sling.osgi.installer.OsgiInstallerStatistics;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -60,7 +60,7 @@ public class BundleInstallUpgradeDowngra
resetCounters();
installer.addResource(getInstallableResource(
getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.1.jar")));
- waitForInstallerAction(OsgiInstaller.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
+ waitForInstallerAction(OsgiInstallerStatistics.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
final Bundle b = assertBundle("After installing", symbolicName, "1.1", Bundle.ACTIVE);
bundleId = b.getBundleId();
}
@@ -72,7 +72,7 @@ public class BundleInstallUpgradeDowngra
resetCounters();
installer.addResource(getInstallableResource(
getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.2.jar"), "digestA"));
- waitForInstallerAction(OsgiInstaller.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
+ waitForInstallerAction(OsgiInstallerStatistics.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
final Bundle b = assertBundle("After updating to 1.2", symbolicName, "1.2", Bundle.ACTIVE);
assertEquals("Bundle ID must not change after update", bundleId, b.getBundleId());
}
@@ -86,7 +86,7 @@ public class BundleInstallUpgradeDowngra
getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.0.jar"), "digestA"));
// make sure no updates happen
- waitForInstallerAction(OsgiInstaller.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
+ waitForInstallerAction(OsgiInstallerStatistics.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
final Bundle b = assertBundle("After ignored downgrade", symbolicName, "1.2", Bundle.ACTIVE);
assertEquals("Bundle ID must not change after ignored downgrade", bundleId, b.getBundleId());
}
@@ -94,8 +94,8 @@ public class BundleInstallUpgradeDowngra
assertNoOsgiTasks("After test " + testIndex++);
// Verify number of registered resources and groups
- assertCounter(OsgiInstaller.REGISTERED_RESOURCES_COUNTER, 3);
- assertCounter(OsgiInstaller.REGISTERED_GROUPS_COUNTER, 1);
+ assertCounter(OsgiInstallerStatistics.REGISTERED_RESOURCES_COUNTER, 3);
+ assertCounter(OsgiInstallerStatistics.REGISTERED_GROUPS_COUNTER, 1);
// Update to same version with different digest must be ignored
{
@@ -110,25 +110,25 @@ public class BundleInstallUpgradeDowngra
resetCounters();
installer.removeResource(getNonInstallableResourceUrl(
getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.0.jar")));
- waitForInstallerAction(OsgiInstaller.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
+ waitForInstallerAction(OsgiInstallerStatistics.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
resetCounters();
installer.removeResource(getNonInstallableResourceUrl(
getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.1.jar")));
- waitForInstallerAction(OsgiInstaller.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
+ waitForInstallerAction(OsgiInstallerStatistics.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
resetCounters();
installer.removeResource(getNonInstallableResourceUrl(
getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.2.jar")));
- waitForInstallerAction(OsgiInstaller.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
+ waitForInstallerAction(OsgiInstallerStatistics.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
final Bundle b = findBundle(symbolicName);
assertNull("Testbundle must be gone", b);
}
// No resources must be registered anymore
- assertCounter(OsgiInstaller.REGISTERED_RESOURCES_COUNTER, 0);
- assertCounter(OsgiInstaller.REGISTERED_GROUPS_COUNTER, 0);
+ assertCounter(OsgiInstallerStatistics.REGISTERED_RESOURCES_COUNTER, 0);
+ assertCounter(OsgiInstallerStatistics.REGISTERED_GROUPS_COUNTER, 0);
assertNoOsgiTasks("After test " + testIndex++);
@@ -137,7 +137,7 @@ public class BundleInstallUpgradeDowngra
resetCounters();
installer.addResource(getInstallableResource(
getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.1.jar")));
- waitForInstallerAction(OsgiInstaller.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
+ waitForInstallerAction(OsgiInstallerStatistics.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
assertBundle("After reinstalling 1.1", symbolicName, "1.1", Bundle.ACTIVE);
}
@@ -154,7 +154,7 @@ public class BundleInstallUpgradeDowngra
resetCounters();
installer.addResource(getInstallableResource(
getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.1.jar")));
- waitForInstallerAction(OsgiInstaller.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
+ waitForInstallerAction(OsgiInstallerStatistics.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
assertBundle("After installing", symbolicName, "1.1", Bundle.ACTIVE);
}
@@ -164,7 +164,7 @@ public class BundleInstallUpgradeDowngra
resetCounters();
installer.removeResource(getNonInstallableResourceUrl(
getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.1.jar")));
- waitForInstallerAction(OsgiInstaller.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
+ waitForInstallerAction(OsgiInstallerStatistics.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
assertNull("Test bundle must be gone", findBundle(symbolicName));
}
@@ -174,7 +174,7 @@ public class BundleInstallUpgradeDowngra
resetCounters();
installer.addResource(getInstallableResource(
getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.1.jar")));
- waitForInstallerAction(OsgiInstaller.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
+ waitForInstallerAction(OsgiInstallerStatistics.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
assertBundle("After reinstalling", symbolicName, "1.1", Bundle.ACTIVE);
}
Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundlePrioritiesTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundlePrioritiesTest.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundlePrioritiesTest.java (original)
+++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundlePrioritiesTest.java Tue Aug 10 13:37:59 2010
@@ -21,7 +21,7 @@ import static org.junit.Assert.assertNul
import java.io.IOException;
import org.apache.sling.osgi.installer.InstallableResourceFactory;
-import org.apache.sling.osgi.installer.OsgiInstaller;
+import org.apache.sling.osgi.installer.OsgiInstallerStatistics;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -61,7 +61,7 @@ public class BundlePrioritiesTest extend
resetCounters();
installer.addResource(getInstallableResource(
getTestBundle(BUNDLE_BASE_NAME + "-snap.jar"), "digest1"));
- waitForInstallerAction(OsgiInstaller.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
+ waitForInstallerAction(OsgiInstallerStatistics.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
assertBundle("Initial install", symbolicName, null, Bundle.ACTIVE);
}
@@ -75,7 +75,7 @@ public class BundlePrioritiesTest extend
resetCounters();
installer.addResource(getInstallableResource(
getTestBundle(BUNDLE_BASE_NAME + "-snap.jar"), "digest3", highPriority));
- waitForInstallerAction(OsgiInstaller.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
+ waitForInstallerAction(OsgiInstallerStatistics.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
}
assertNoOsgiTasks("At end of test");
Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleSnapshotUpdateTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleSnapshotUpdateTest.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleSnapshotUpdateTest.java (original)
+++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleSnapshotUpdateTest.java Tue Aug 10 13:37:59 2010
@@ -16,13 +16,13 @@
*/
package org.apache.sling.osgi.installer.it;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertEquals;
import java.io.IOException;
-import org.apache.sling.osgi.installer.OsgiInstaller;
+import org.apache.sling.osgi.installer.OsgiInstallerStatistics;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -39,22 +39,22 @@ import org.osgi.framework.BundleExceptio
*/
@RunWith(JUnit4TestRunner.class)
public class BundleSnapshotUpdateTest extends OsgiInstallerTestBase {
-
+
@org.ops4j.pax.exam.junit.Configuration
public static Option[] configuration() {
return defaultConfiguration();
}
-
+
@Before
public void setUp() {
setupInstaller();
}
-
+
@After
public void tearDown() {
super.tearDown();
}
-
+
@Test
public void testNonSnapshot() throws IOException {
final String symbolicName = "osgi-installer-testbundle";
@@ -63,32 +63,32 @@ public class BundleSnapshotUpdateTest ex
installer.addResource(getInstallableResource(
getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.1.jar"), "digest1"));
// wait for two tasks: install and start
- waitForInstallerAction(OsgiInstaller.OSGI_TASKS_COUNTER, 2);
+ waitForInstallerAction(OsgiInstallerStatistics.OSGI_TASKS_COUNTER, 2);
final Bundle b = findBundle(symbolicName);
assertNotNull("Test bundle 1.1 must be found after waitForInstallerAction", b);
assertNoOsgiTasks("At end of test");
-
+
// Update with same digest must be ignored
- long nOps = installer.getCounters()[OsgiInstaller.OSGI_TASKS_COUNTER];
+ long nOps = statistics.getCounters()[OsgiInstallerStatistics.OSGI_TASKS_COUNTER];
installer.addResource(getInstallableResource(
getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.1.jar"), "digest1"));
- waitForInstallerAction(OsgiInstaller.INSTALLER_CYCLES_COUNTER, 1);
+ waitForInstallerAction(OsgiInstallerStatistics.INSTALLER_CYCLES_COUNTER, 1);
assertEquals("Updating testbundle with same digest must not generate any OSGi tasks",
- nOps, installer.getCounters()[OsgiInstaller.OSGI_TASKS_COUNTER]);
-
+ nOps, statistics.getCounters()[OsgiInstallerStatistics.OSGI_TASKS_COUNTER]);
+
// Update with different digest must be ignored
- nOps = installer.getCounters()[OsgiInstaller.OSGI_TASKS_COUNTER];
+ nOps = statistics.getCounters()[OsgiInstallerStatistics.OSGI_TASKS_COUNTER];
installer.addResource(getInstallableResource(
getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.1.jar"), "digest2"));
- waitForInstallerAction(OsgiInstaller.INSTALLER_CYCLES_COUNTER, 1);
+ waitForInstallerAction(OsgiInstallerStatistics.INSTALLER_CYCLES_COUNTER, 1);
assertEquals("Updating testbundle with different digest must not generate any OSGi tasks",
- nOps, installer.getCounters()[OsgiInstaller.OSGI_TASKS_COUNTER]);
-
+ nOps, statistics.getCounters()[OsgiInstallerStatistics.OSGI_TASKS_COUNTER]);
+
assertNoOsgiTasks("At end of test");
}
-
+
private void testSnapshotPrimitive(boolean restartInstaller) throws IOException, BundleException {
-
+
// Install test bundle
final String symbolicName = "osgi-installer-snapshot-test";
assertNull("Snapshot test bundle must be absent before installing", findBundle(symbolicName));
@@ -96,31 +96,31 @@ public class BundleSnapshotUpdateTest ex
installer.addResource(getInstallableResource(
getTestBundle(BUNDLE_BASE_NAME + "-snap.jar"), "digest1"));
// wait for two tasks: install and start
- waitForInstallerAction(OsgiInstaller.OSGI_TASKS_COUNTER, 2);
+ waitForInstallerAction(OsgiInstallerStatistics.OSGI_TASKS_COUNTER, 2);
final Bundle b = findBundle(symbolicName);
assertNotNull("Snapshot bundle must be found after waitForInstallerAction", b);
if(restartInstaller) {
restartInstaller();
}
-
+
// Update with same digest must be ignored
- final long nOps = installer.getCounters()[OsgiInstaller.OSGI_TASKS_COUNTER];
+ final long nOps = statistics.getCounters()[OsgiInstallerStatistics.OSGI_TASKS_COUNTER];
installer.addResource(getInstallableResource(
getTestBundle(BUNDLE_BASE_NAME + "-snap.jar"), "digest1"));
- waitForInstallerAction(OsgiInstaller.INSTALLER_CYCLES_COUNTER, 3);
+ waitForInstallerAction(OsgiInstallerStatistics.INSTALLER_CYCLES_COUNTER, 3);
assertEquals("Updating snapshot bundle with same digest must not generate any OSGi tasks",
- nOps, installer.getCounters()[OsgiInstaller.OSGI_TASKS_COUNTER]);
-
+ nOps, statistics.getCounters()[OsgiInstallerStatistics.OSGI_TASKS_COUNTER]);
+
// Update with different digest must generate an OSGi update
resetCounters();
installer.addResource(getInstallableResource(
getTestBundle(BUNDLE_BASE_NAME + "-snap.jar"), "digest2"));
// update also generates a start task, as the bundle was started before, and a framework refresh
- waitForInstallerAction(OsgiInstaller.OSGI_TASKS_COUNTER, 3);
-
+ waitForInstallerAction(OsgiInstallerStatistics.OSGI_TASKS_COUNTER, 3);
+
// And no more OSGi tasks after that
- waitForInstallerAction(OsgiInstaller.INSTALLER_CYCLES_COUNTER, 3);
+ waitForInstallerAction(OsgiInstallerStatistics.INSTALLER_CYCLES_COUNTER, 3);
assertNoOsgiTasks("At end of test");
}
@@ -128,7 +128,7 @@ public class BundleSnapshotUpdateTest ex
public void testSnapshot() throws IOException, BundleException {
testSnapshotPrimitive(false);
}
-
+
@Test
public void testSnapshotWithInstallerRestart() throws IOException, BundleException {
testSnapshotPrimitive(true);
Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStartRetriesTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStartRetriesTest.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStartRetriesTest.java (original)
+++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStartRetriesTest.java Tue Aug 10 13:37:59 2010
@@ -3,7 +3,7 @@ package org.apache.sling.osgi.installer.
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
-import org.apache.sling.osgi.installer.OsgiInstaller;
+import org.apache.sling.osgi.installer.OsgiInstallerStatistics;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -19,12 +19,12 @@ public class BundleStartRetriesTest exte
public static Option[] configuration() {
return defaultConfiguration();
}
-
+
@Before
public void setUp() {
setupInstaller();
}
-
+
@After
public void tearDown() {
super.tearDown();
@@ -34,30 +34,30 @@ public class BundleStartRetriesTest exte
public void testBundleStartRetries() throws Exception {
final String testB = "osgi-installer-testB";
final String needsB = "osgi-installer-needsB";
-
+
assertNull("TestB bundle must not be present at beginning of test", findBundle(testB));
-
+
// without testB, needsB must not start
resetCounters();
- final long nOps = installer.getCounters()[OsgiInstaller.OSGI_TASKS_COUNTER];
+ final long nOps = statistics.getCounters()[OsgiInstallerStatistics.OSGI_TASKS_COUNTER];
installer.addResource(getInstallableResource(getTestBundle(BUNDLE_BASE_NAME + "-needsB.jar")));
- waitForInstallerAction(OsgiInstaller.OSGI_TASKS_COUNTER, 2);
+ waitForInstallerAction(OsgiInstallerStatistics.OSGI_TASKS_COUNTER, 2);
assertBundle(needsB + " must not be started, testB not present", needsB, null, Bundle.INSTALLED);
-
+
// the bundle start task must be retried immediately
// (== 3 tasks since last counters reset)
- waitForInstallerAction(OsgiInstaller.OSGI_TASKS_COUNTER, 3);
-
+ waitForInstallerAction(OsgiInstallerStatistics.OSGI_TASKS_COUNTER, 3);
+
// and no more retries must happen before receiving a bundle event
sleep(1000L);
assertEquals("Exactly 3 OSGi tasks must have been executed after a few installer cycles",
- nOps + 3, installer.getCounters()[OsgiInstaller.OSGI_TASKS_COUNTER]);
+ nOps + 3, statistics.getCounters()[OsgiInstallerStatistics.OSGI_TASKS_COUNTER]);
// generate a bundle event -> must trigger one retry
resetCounters();
generateBundleEvent();
- waitForInstallerAction(OsgiInstaller.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
- waitForInstallerAction(OsgiInstaller.OSGI_TASKS_COUNTER, 1);
+ waitForInstallerAction(OsgiInstallerStatistics.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
+ waitForInstallerAction(OsgiInstallerStatistics.OSGI_TASKS_COUNTER, 1);
}
}
Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStatePreservedTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStatePreservedTest.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStatePreservedTest.java (original)
+++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStatePreservedTest.java Tue Aug 10 13:37:59 2010
@@ -19,7 +19,7 @@ package org.apache.sling.osgi.installer.
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-import org.apache.sling.osgi.installer.OsgiInstaller;
+import org.apache.sling.osgi.installer.OsgiInstallerStatistics;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -53,13 +53,13 @@ public class BundleStatePreservedTest ex
resetCounters();
installer.addResource(getInstallableResource(
getTestBundle(BUNDLE_BASE_NAME + "-testA-1.0.jar")));
- waitForInstallerAction(OsgiInstaller.OSGI_TASKS_COUNTER, 2);
+ waitForInstallerAction(OsgiInstallerStatistics.OSGI_TASKS_COUNTER, 2);
}
{
resetCounters();
installer.addResource(getInstallableResource(
getTestBundle(BUNDLE_BASE_NAME + "-testB-1.0.jar")));
- waitForInstallerAction(OsgiInstaller.OSGI_TASKS_COUNTER, 2);
+ waitForInstallerAction(OsgiInstallerStatistics.OSGI_TASKS_COUNTER, 2);
final Bundle b = findBundle("osgi-installer-testB");
assertNotNull("Test bundle B must be found", b);
b.stop();
@@ -73,24 +73,24 @@ public class BundleStatePreservedTest ex
installer.addResource(getInstallableResource(getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.2.jar")));
resetCounters();
installer.addResource(getInstallableResource(getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.1.jar")));
- waitForInstallerAction(OsgiInstaller.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
+ waitForInstallerAction(OsgiInstallerStatistics.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
assertBundle("After installing testbundle", "osgi-installer-testbundle", "1.2", Bundle.ACTIVE);
// Verify number of registered resources and groups
- assertCounter(OsgiInstaller.REGISTERED_RESOURCES_COUNTER, 5);
- assertCounter(OsgiInstaller.REGISTERED_GROUPS_COUNTER, 3);
+ assertCounter(OsgiInstallerStatistics.REGISTERED_RESOURCES_COUNTER, 5);
+ assertCounter(OsgiInstallerStatistics.REGISTERED_GROUPS_COUNTER, 3);
resetCounters();
installer.removeResource(getNonInstallableResourceUrl(getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.0.jar")));
- waitForInstallerAction(OsgiInstaller.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
+ waitForInstallerAction(OsgiInstallerStatistics.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
resetCounters();
installer.removeResource(getNonInstallableResourceUrl(getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.1.jar")));
- waitForInstallerAction(OsgiInstaller.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
+ waitForInstallerAction(OsgiInstallerStatistics.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
resetCounters();
installer.removeResource(getNonInstallableResourceUrl(getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.2.jar")));
- waitForInstallerAction(OsgiInstaller.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
+ waitForInstallerAction(OsgiInstallerStatistics.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
assertNull("testbundle must be gone at end of test", findBundle("osgi-installer-testbundle"));