Author: bdelacretaz
Date: Fri Aug 14 14:28:27 2009
New Revision: 804237

URL: http://svn.apache.org/viewvc?rev=804237&view=rev
Log:
SLING-1078 - starting to rewrite integration tests, work in progress

Added:
    
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java
      - copied, changed from r804107, 
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerContext.java
    
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerTask.java
      - copied, changed from r804107, 
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerTask.java
Removed:
    
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerContext.java
    
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerTask.java
Modified:
    
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java
    
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java
    
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Storage.java
    
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveTask.java
    
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleStartTask.java
    
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallRemoveTask.java
    
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/InstallRemoveTask.java
    
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/SynchronousRefreshPackagesTask.java
    
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/TaskUtilities.java
    
sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockOsgiControllerContext.java
    
sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java
    
sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/StorageTest.java
    
sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java
    
sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveIgnoreTest.java
    
sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallTest.java
    
sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java

Copied: 
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java
 (from r804107, 
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerContext.java)
URL: 
http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java?p2=sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java&p1=sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerContext.java&r1=804107&r2=804237&rev=804237&view=diff
==============================================================================
--- 
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerContext.java
 (original)
+++ 
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java
 Fri Aug 14 14:28:27 2009
@@ -23,19 +23,20 @@
 import org.osgi.service.log.LogService;
 import org.osgi.service.packageadmin.PackageAdmin;
 
-/** Context for OsgiControllerTask */
-public interface OsgiControllerContext {
+/** Installer context, gives access to selected methods of the {...@link 
OsgiInstallerImpl} */
+public interface OsgiInstallerContext {
        Storage getStorage();
        BundleContext getBundleContext();
        PackageAdmin getPackageAdmin();
        ConfigurationAdmin getConfigurationAdmin();
        LogService getLogService();
+       void incrementCounter(int index);
        
        /** Schedule a task for execution in the current OsgiController cycle */
-       void addTaskToCurrentCycle(OsgiControllerTask t);
+       void addTaskToCurrentCycle(OsgiInstallerTask t);
        
        /** Schedule a task for execution in the next OsgiController cycle, 
         *      usually to indicate that a task must be retried 
         */
-       void addTaskToNextCycle(OsgiControllerTask t);
+       void addTaskToNextCycle(OsgiInstallerTask t);
 }

Modified: 
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java?rev=804237&r1=804236&r2=804237&view=diff
==============================================================================
--- 
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java
 (original)
+++ 
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java
 Fri Aug 14 14:28:27 2009
@@ -31,11 +31,12 @@
 import org.osgi.util.tracker.ServiceTracker;
 
 /** OsgiInstaller service implementation */
-public class OsgiInstallerImpl implements OsgiInstaller, OsgiControllerContext 
{
+public class OsgiInstallerImpl implements OsgiInstaller, OsgiInstallerContext {
 
        private final BundleContext bundleContext;
     private final PackageAdmin packageAdmin;
     private final ServiceTracker logServiceTracker;
+    private final OsgiInstallerThread installerThread;
     private long [] counters = new long[COUNTERS_SIZE];
 
     public OsgiInstallerImpl(final BundleContext bc,
@@ -45,6 +46,10 @@
         this.bundleContext = bc;
         this.packageAdmin = pa;
         this.logServiceTracker = logServiceTracker;
+        
+        installerThread = new OsgiInstallerThread(this);
+        installerThread.setDaemon(true);
+        installerThread.start();
     }
 
     public void deactivate() {
@@ -71,15 +76,11 @@
                return (LogService)logServiceTracker.getService();
        }
 
-       public void addTaskToCurrentCycle(OsgiControllerTask t) {
-               if(getLogService() != null) {
-                       getLogService().log(LogService.LOG_DEBUG, "adding task 
to current cycle:" + t);
-               }
-               // TODO
-               //tasksForThisCycle.add(t);
+       public void addTaskToCurrentCycle(OsgiInstallerTask t) {
+               installerThread.addTaskToCurrentCycle(t);
        }
 
-       public void addTaskToNextCycle(OsgiControllerTask t) {
+       public void addTaskToNextCycle(OsgiInstallerTask t) {
                if(getLogService() != null) {
                        getLogService().log(LogService.LOG_DEBUG, "adding task 
to next cycle:" + t);
                }
@@ -99,8 +100,9 @@
                return counters;
        }
 
-       public void addResource(InstallableResource d) throws IOException {
-               // TODO
+       public void addResource(InstallableResource r) throws IOException {
+           // TODO do not add if we already have it, based on digest
+           installerThread.addResource(new RegisteredResource(bundleContext, 
r));
        }
 
        public void registerResources(Collection<InstallableResource> data,
@@ -116,4 +118,8 @@
                // TODO
                return null;
        }
+       
+       public void incrementCounter(int index) {
+           counters[index]++;
+       }
 }
\ No newline at end of file

Copied: 
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerTask.java
 (from r804107, 
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerTask.java)
URL: 
http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerTask.java?p2=sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerTask.java&p1=sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerTask.java&r1=804107&r2=804237&rev=804237&view=diff
==============================================================================
--- 
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerTask.java
 (original)
+++ 
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerTask.java
 Fri Aug 14 14:28:27 2009
@@ -18,28 +18,28 @@
  */
 package org.apache.sling.osgi.installer.impl;
 
-/** Base class for tasks that can be executed by the OsgiController */ 
-public abstract class OsgiControllerTask implements 
Comparable<OsgiControllerTask> {
+/** Base class for tasks that can be executed by the {...@link 
OsgiInstallerImpl} */ 
+public abstract class OsgiInstallerTask implements 
Comparable<OsgiInstallerTask> {
        /** Execute this task */
-       public abstract void execute(OsgiControllerContext ctx) throws 
Exception;
+       public abstract void execute(OsgiInstallerContext ctx) throws Exception;
        
        /** Tasks are sorted according to this key */
        public abstract String getSortKey();
 
        /** All comparisons are based on getSortKey() */
-       public final int compareTo(OsgiControllerTask o) {
+       public final int compareTo(OsgiInstallerTask o) {
                return getSortKey().compareTo(o.getSortKey());
        }
        
        /** Is it worth executing this task now? */
-       public boolean isExecutable(OsgiControllerContext ctx) throws Exception 
{
+       public boolean isExecutable(OsgiInstallerContext ctx) throws Exception {
            return true;
        }
 
        @Override
        public final boolean equals(Object o) {
-               if(o instanceof OsgiControllerTask) {
-                       return 
getSortKey().equals(((OsgiControllerTask)o).getSortKey());
+               if(o instanceof OsgiInstallerTask) {
+                       return 
getSortKey().equals(((OsgiInstallerTask)o).getSortKey());
                }
                return false;
        }

Modified: 
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java?rev=804237&r1=804236&r2=804237&view=diff
==============================================================================
--- 
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java
 (original)
+++ 
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java
 Fri Aug 14 14:28:27 2009
@@ -57,36 +57,61 @@
        private final Dictionary<String, Object> dictionary;
        private static long fileNumber;
        
+       static enum State {
+           NEW,
+           ACTIVE,
+        INSTALLED,
+           IGNORED,
+           REMOVED,
+       }
+    private State desiredState = State.ACTIVE;
+    private State actualState = State.NEW;
+    
+    static enum ResourceType {
+        BUNDLE,
+        CONFIG
+    }
+    
+    private final ResourceType resourceType;
+       
        public static final String DIGEST_TYPE = "MD5";
        
+       /** Create a RegisteredResource from given data. If the data's extension
+        *  maps to a configuration and the data provides an input stream, it is
+        *  converted to a Dictionary 
+        */
        public RegisteredResource(BundleContext ctx, InstallableResource input) 
throws IOException {
-               url = input.getUrl();
-               
-               // TODO if input.url ends with a "config" extension, convert to 
dictionary
-               
-               try {
-                       if(input.getDictionary() == null) {
-                               dictionary = null;
-                               if(input.getInputStream() == null) {
-                                       throw new 
IllegalArgumentException("input provides no Dictionary and no InputStream:" + 
input);
-                               } else {
-                                       dataFile = getDataFile(ctx);
-                                       
copyToLocalStorage(input.getInputStream(), dataFile);
-                                       digest = input.getDigest();
-                                       if(digest == null || digest.length() == 
0) {
-                                           throw new IllegalArgumentException(
-                                                   "Digest must be supplied 
for an InstallableResource that wraps an InputStream");
-                                       }
-                               }
-                       } else {
-                               dataFile = null;
-                               dictionary = copy(input.getDictionary());
-                               digest = computeDigest(dictionary);
-                       }
-                       
-       } catch(NoSuchAlgorithmException nse) {
-               throw new IOException("NoSuchAlgorithmException:" + 
DIGEST_TYPE);
+           
+           try {
+               url = input.getUrl();
+               resourceType = computeResourceType(input.getExtension());
                
+               if(resourceType == ResourceType.BUNDLE) {
+                if(input.getInputStream() == null) {
+                    throw new IllegalArgumentException("InputStream is 
required for BUNDLE resource type: " + input);
+                }
+                dictionary = null;
+                dataFile = getDataFile(ctx);
+                copyToLocalStorage(input.getInputStream(), dataFile);
+                digest = input.getDigest();
+                if(digest == null || digest.length() == 0) {
+                    throw new IllegalArgumentException(
+                            "Digest must be supplied for BUNDLE resource type: 
" + input);
+                }
+               } else {
+                dataFile = null;
+                if(input.getInputStream() == null) {
+                    // config provided as a Dictionary
+                    dictionary = copy(input.getDictionary());
+                } else {
+                    dictionary = readDictionary(input.getInputStream()); 
+                }
+                try {
+                    digest = computeDigest(dictionary);
+                } catch(NoSuchAlgorithmException nse) {
+                    throw new IOException("NoSuchAlgorithmException:" + 
DIGEST_TYPE);
+                }
+               }
        } finally {
                if(input.getInputStream() != null) {
                        input.getInputStream().close();
@@ -146,7 +171,7 @@
     }
     
     /** Copy data to local storage */
-       private void copyToLocalStorage(InputStream data, File f) throws 
IOException, NoSuchAlgorithmException {
+       private void copyToLocalStorage(InputStream data, File f) throws 
IOException {
                final OutputStream os = new BufferedOutputStream(new 
FileOutputStream(f));
                try {
                        final byte[] buffer = new byte[16384];
@@ -191,4 +216,36 @@
            }
            return result;
        }
+       
+       public String getUrl() {
+           return url;
+       }
+
+    public State getDesiredState() {
+        return desiredState;
+    }
+
+    public void setDesiredState(State desiredState) {
+        this.desiredState = desiredState;
+    }
+
+    public State getActualState() {
+        return actualState;
+    }
+
+    public void setActualState(State actualState) {
+        this.actualState = actualState;
+    }
+    
+    public ResourceType getResourceType() {
+        return resourceType;
+    }
+    
+    static ResourceType computeResourceType(String extension) {
+        if(extension.equals("jar")) {
+            return ResourceType.BUNDLE;
+        } else {
+            return ResourceType.CONFIG;
+        }
+    }
 }

Modified: 
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Storage.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Storage.java?rev=804237&r1=804236&r2=804237&view=diff
==============================================================================
--- 
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Storage.java
 (original)
+++ 
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Storage.java
 Fri Aug 14 14:28:27 2009
@@ -45,7 +45,7 @@
     /** Create Storage that uses dataFile for persistence, and
      *  read the current status from that file */
     @SuppressWarnings("unchecked")
-    Storage(File dataFile, OsgiControllerContext ocs) throws IOException {
+    Storage(File dataFile, OsgiInstallerContext ocs) throws IOException {
         this.dataFile = dataFile;
         ObjectInputStream ois = null;
         Map<String, Map<String, Object>> loadedData = null;

Modified: 
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveTask.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveTask.java?rev=804237&r1=804236&r2=804237&view=diff
==============================================================================
--- 
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveTask.java
 (original)
+++ 
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveTask.java
 Fri Aug 14 14:28:27 2009
@@ -23,27 +23,26 @@
 import java.util.Map;
 import java.util.jar.Manifest;
 
-import org.apache.sling.osgi.installer.impl.OsgiControllerContext;
-import org.apache.sling.osgi.installer.impl.OsgiInstallerImpl;
+import org.apache.sling.osgi.installer.impl.OsgiInstallerContext;
 import org.apache.sling.osgi.installer.impl.RegisteredResource;
 import org.apache.sling.osgi.installer.impl.Storage;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
 import org.osgi.framework.Constants;
 import org.osgi.framework.Version;
 import org.osgi.service.log.LogService;
 
-/** Install/remove task for bundles */
+/** Install/remove task for bundles 
+ *  TODO unusued? remove? */
 public class BundleInstallRemoveTask extends InstallRemoveTask {
 
        private final BundleContext bundleContext;
        
     public static final String MAVEN_SNAPSHOT_MARKER = "SNAPSHOT";
 
-    public BundleInstallRemoveTask(String uri, RegisteredResource data, 
BundleContext ctx, OsgiControllerContext ocs) {
+    public BundleInstallRemoveTask(String uri, RegisteredResource data, 
OsgiInstallerContext ocs) {
        super(uri, data, ocs);
-       this.bundleContext = ctx;
+       this.bundleContext = ocs.getBundleContext();
     }
     
        @Override
@@ -56,7 +55,7 @@
        }
 
        @Override
-       protected void doUninstall(OsgiControllerContext tctx, Map<String, 
Object> attributes) throws Exception {
+       protected void doUninstall(OsgiInstallerContext tctx, Map<String, 
Object> attributes) throws Exception {
         final Long longId = (Long) attributes.get(Storage.KEY_BUNDLE_ID);
         if (longId == null) {
                if(ocs.getLogService() != null) {
@@ -80,7 +79,7 @@
        }
 
        @Override
-       protected boolean doInstallOrUpdate(OsgiControllerContext tctx, 
Map<String, Object> attributes) throws Exception {
+       protected boolean doInstallOrUpdate(OsgiInstallerContext tctx, 
Map<String, Object> attributes) throws Exception {
 
        // Check that we have bundle data and manifest
        InputStream is = data.getInputStream();
@@ -95,7 +94,7 @@
 
         // Update if we already have a bundle id, else install
                Bundle b;
-               boolean updated;
+               boolean updated = false;
                try {
                        b = null;
                        updated = false;

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=804237&r1=804236&r2=804237&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
 Fri Aug 14 14:28:27 2009
@@ -20,15 +20,16 @@
 
 import java.text.DecimalFormat;
 
+import org.apache.sling.osgi.installer.OsgiInstaller;
 import org.apache.sling.osgi.installer.impl.Activator;
-import org.apache.sling.osgi.installer.impl.OsgiControllerTask;
-import org.apache.sling.osgi.installer.impl.OsgiControllerContext;
+import org.apache.sling.osgi.installer.impl.OsgiInstallerTask;
+import org.apache.sling.osgi.installer.impl.OsgiInstallerContext;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleException;
 import org.osgi.service.log.LogService;
 
 /** Task that starts a bundle */
-public class BundleStartTask extends OsgiControllerTask {
+public class BundleStartTask extends OsgiInstallerTask {
 
        private final long bundleId;
        private final String sortKey;
@@ -50,7 +51,7 @@
                return getClass().getSimpleName() + " (bundle " + bundleId + 
")";
        }
 
-       public void execute(OsgiControllerContext tctx) throws Exception {
+       public void execute(OsgiInstallerContext tctx) throws Exception {
                final Bundle b = tctx.getBundleContext().getBundle(bundleId);
                final LogService log = tctx.getLogService();
                boolean needToRetry = false;
@@ -101,10 +102,11 @@
                }
                }
                retryCount++;
+               tctx.incrementCounter(OsgiInstaller.OSGI_TASKS_COUNTER);
        }
        
        /** Do not execute this task if waiting for events */
-    public boolean isExecutable(OsgiControllerContext tctx) {
+    public boolean isExecutable(OsgiInstallerContext tctx) {
         final long eventsCount = Activator.getTotalEventsCount(); 
         final boolean result = eventsCount >= eventsCountForRetrying; 
         if(!result) {

Modified: 
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallRemoveTask.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallRemoveTask.java?rev=804237&r1=804236&r2=804237&view=diff
==============================================================================
--- 
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallRemoveTask.java
 (original)
+++ 
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallRemoveTask.java
 Fri Aug 14 14:28:27 2009
@@ -21,7 +21,7 @@
 import java.util.Dictionary;
 import java.util.Map;
 
-import org.apache.sling.osgi.installer.impl.OsgiControllerContext;
+import org.apache.sling.osgi.installer.impl.OsgiInstallerContext;
 import org.apache.sling.osgi.installer.impl.RegisteredResource;
 import org.osgi.service.cm.Configuration;
 import org.osgi.service.log.LogService;
@@ -33,7 +33,7 @@
     static final String CONFIG_PATH_KEY = "_jcr_config_path";
     static final String [] CONFIG_EXTENSIONS = { ".cfg", ".properties" };
     
-       public ConfigInstallRemoveTask(String uri, RegisteredResource data, 
OsgiControllerContext ocs) {
+       public ConfigInstallRemoveTask(String uri, RegisteredResource data, 
OsgiInstallerContext ocs) {
                super(uri, data, ocs);
        }
        
@@ -47,7 +47,7 @@
        }
 
        @Override
-       protected boolean doInstallOrUpdate(OsgiControllerContext tctx, 
Map<String, Object> attributes) throws Exception {
+       protected boolean doInstallOrUpdate(OsgiInstallerContext tctx, 
Map<String, Object> attributes) throws Exception {
        // Convert data to a configuration Dictionary
        Dictionary dict = data.getDictionary();
 
@@ -88,7 +88,7 @@
        }
 
        @Override
-       protected void doUninstall(OsgiControllerContext tctx, Map<String, 
Object> attributes) throws Exception {
+       protected void doUninstall(OsgiInstallerContext tctx, Map<String, 
Object> attributes) throws Exception {
         final ConfigurationPid pid = new ConfigurationPid(uri);
         final Configuration cfg = TaskUtilities.getConfiguration(pid, false, 
ocs);
         // TODO defer delete if ConfigAdmin not available?

Modified: 
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/InstallRemoveTask.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/InstallRemoveTask.java?rev=804237&r1=804236&r2=804237&view=diff
==============================================================================
--- 
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/InstallRemoveTask.java
 (original)
+++ 
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/InstallRemoveTask.java
 Fri Aug 14 14:28:27 2009
@@ -20,20 +20,20 @@
 
 import java.util.Map;
 
-import org.apache.sling.osgi.installer.impl.OsgiControllerContext;
-import org.apache.sling.osgi.installer.impl.OsgiControllerTask;
+import org.apache.sling.osgi.installer.impl.OsgiInstallerContext;
+import org.apache.sling.osgi.installer.impl.OsgiInstallerTask;
 import org.apache.sling.osgi.installer.impl.RegisteredResource;
 
 /** Base class for OsgiControllerTasks that install or
  *     remove OSGi bundles or configs (or deployment packages, etc.)
  */
-abstract class InstallRemoveTask extends OsgiControllerTask {
+abstract class InstallRemoveTask extends OsgiInstallerTask {
 
        protected final String uri;
        protected final RegisteredResource data;
-       protected final OsgiControllerContext ocs;
+       protected final OsgiInstallerContext ocs;
 
-    protected InstallRemoveTask(String uri, RegisteredResource data, 
OsgiControllerContext ocs) {
+    protected InstallRemoveTask(String uri, RegisteredResource data, 
OsgiInstallerContext ocs) {
        this.uri = uri;
        this.data = data;
        this.ocs = ocs;
@@ -51,7 +51,7 @@
        }
 
        /** {...@inheritdoc} */
-       public void execute(OsgiControllerContext context) throws Exception {
+       public void execute(OsgiInstallerContext context) throws Exception {
                // TODO cleanup stored data? (previously 
RegisteredResourceWrapper)
        }
        
@@ -61,8 +61,8 @@
        }
        
        /** Do the actual uninstall */
-       protected abstract void doUninstall(OsgiControllerContext ctx, 
Map<String, Object> attributes) throws Exception;
+       protected abstract void doUninstall(OsgiInstallerContext ctx, 
Map<String, Object> attributes) throws Exception;
        
        /** Do the actual install or update */
-       protected abstract boolean doInstallOrUpdate(OsgiControllerContext ctx, 
Map<String, Object> attributes) throws Exception;
+       protected abstract boolean doInstallOrUpdate(OsgiInstallerContext ctx, 
Map<String, Object> attributes) throws Exception;
 }

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=804237&r1=804236&r2=804237&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
 Fri Aug 14 14:28:27 2009
@@ -18,21 +18,21 @@
  */
 package org.apache.sling.osgi.installer.impl.tasks;
 
-import org.apache.sling.osgi.installer.impl.OsgiControllerContext;
-import org.apache.sling.osgi.installer.impl.OsgiControllerTask;
+import org.apache.sling.osgi.installer.impl.OsgiInstallerContext;
+import org.apache.sling.osgi.installer.impl.OsgiInstallerTask;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.FrameworkEvent;
 import org.osgi.framework.FrameworkListener;
 import org.osgi.service.log.LogService;
 
 /** Task that executes an OSGi "refresh packages" operation, synchronously */
-public class SynchronousRefreshPackagesTask extends OsgiControllerTask 
implements FrameworkListener {
+public class SynchronousRefreshPackagesTask extends OsgiInstallerTask 
implements FrameworkListener {
 
     /** Max time allowed to refresh packages (TODO configurable??) */
     public static final int MAX_REFRESH_PACKAGES_WAIT_SECONDS = 30;
 
        private int packageRefreshEventsCount;
-       private OsgiControllerContext ctx;
+       private OsgiInstallerContext ctx;
 
     /**
      * Handles the PACKAGES_REFRESHED framework event which is sent after
@@ -61,7 +61,7 @@
                return getClass().getSimpleName();
        }
 
-       public void execute(OsgiControllerContext ctx) throws Exception {
+       public void execute(OsgiInstallerContext ctx) throws Exception {
                this.ctx = ctx;
         final int targetEventCount = packageRefreshEventsCount + 1;
         final long start = System.currentTimeMillis();
@@ -72,7 +72,7 @@
         // this task executes
        for(Bundle b : ctx.getBundleContext().getBundles()) {
                if(b.getState() == Bundle.ACTIVE) {
-                       final OsgiControllerTask t = new 
BundleStartTask(b.getBundleId());
+                       final OsgiInstallerTask t = new 
BundleStartTask(b.getBundleId());
                        ctx.addTaskToCurrentCycle(t);
                if(ctx.getLogService() != null) {
                        ctx.getLogService().log(LogService.LOG_DEBUG, 

Modified: 
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/TaskUtilities.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/TaskUtilities.java?rev=804237&r1=804236&r2=804237&view=diff
==============================================================================
--- 
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/TaskUtilities.java
 (original)
+++ 
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/TaskUtilities.java
 Fri Aug 14 14:28:27 2009
@@ -5,7 +5,7 @@
 import java.util.jar.JarInputStream;
 import java.util.jar.Manifest;
 
-import org.apache.sling.osgi.installer.impl.OsgiControllerContext;
+import org.apache.sling.osgi.installer.impl.OsgiInstallerContext;
 import org.apache.sling.osgi.installer.impl.RegisteredResource;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -87,7 +87,7 @@
     }
     
     /** Get or create configuration */
-    static Configuration getConfiguration(ConfigurationPid cp, boolean 
createIfNeeded, OsgiControllerContext ocs)
+    static Configuration getConfiguration(ConfigurationPid cp, boolean 
createIfNeeded, OsgiInstallerContext ocs)
     throws IOException, InvalidSyntaxException
     {
        final ConfigurationAdmin configurationAdmin = 
ocs.getConfigurationAdmin();

Modified: 
sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockOsgiControllerContext.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockOsgiControllerContext.java?rev=804237&r1=804236&r2=804237&view=diff
==============================================================================
--- 
sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockOsgiControllerContext.java
 (original)
+++ 
sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockOsgiControllerContext.java
 Fri Aug 14 14:28:27 2009
@@ -23,12 +23,12 @@
 import org.osgi.service.log.LogService;
 import org.osgi.service.packageadmin.PackageAdmin;
 
-public class MockOsgiControllerContext implements OsgiControllerContext {
+public class MockOsgiControllerContext implements OsgiInstallerContext {
 
-       public void addTaskToCurrentCycle(OsgiControllerTask t) {
+       public void addTaskToCurrentCycle(OsgiInstallerTask t) {
        }
 
-       public void addTaskToNextCycle(OsgiControllerTask t) {
+       public void addTaskToNextCycle(OsgiInstallerTask t) {
        }
 
        public BundleContext getBundleContext() {
@@ -50,4 +50,7 @@
        public Storage getStorage() {
                return null;
        }
+
+    public void incrementCounter(int index) {
+    }
 }

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=804237&r1=804236&r2=804237&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
 Fri Aug 14 14:28:27 2009
@@ -19,6 +19,8 @@
 package org.apache.sling.osgi.installer.impl;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -26,6 +28,7 @@
 import java.io.FilterInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.Dictionary;
 import java.util.Hashtable;
 
 import org.apache.sling.osgi.installer.InstallableResource;
@@ -57,10 +60,49 @@
                assertEquals("TestInputStream must be closed by 
RegisteredResource", 1, t.closeCount);
        }
        
+    @org.junit.Test public void testResourceType() throws Exception {
+        {
+            final InputStream s = new ByteArrayInputStream("Some 
data".getBytes());
+            final RegisteredResource r = new LocalFileRegisteredResource(new 
InstallableResource("1.jar", s, "some digest"));
+            assertEquals(".jar URL creates a BUNDLE resource", 
+                    RegisteredResource.ResourceType.BUNDLE, 
r.getResourceType());
+            final InputStream rs = r.getInputStream();
+            assertNotNull("BUNDLE resource provides an InputStream", rs);
+            rs.close();
+            assertNull("BUNDLE resource does not provide a Dictionary", 
r.getDictionary());
+        }
+        
+        {
+            final InputStream s = new 
ByteArrayInputStream("foo=bar\nother=2".getBytes());
+            final RegisteredResource r = new LocalFileRegisteredResource(new 
InstallableResource("1.properties", s, null));
+            assertEquals(".properties URL creates a CONFIG resource", 
+                    RegisteredResource.ResourceType.CONFIG, 
r.getResourceType());
+            final InputStream rs = r.getInputStream();
+            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());
+        }
+        
+        {
+            final Hashtable<String, Object> data = new Hashtable<String, 
Object>();
+            data.put("foo", "bar");
+            data.put("other", 2);
+            final RegisteredResource r = new LocalFileRegisteredResource(new 
InstallableResource("1", data));
+            assertEquals("No-extension URL with Dictionary creates a CONFIG 
resource", 
+                    RegisteredResource.ResourceType.CONFIG, 
r.getResourceType());
+            final InputStream rs = r.getInputStream();
+            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());
+        }
+    }
+    
        @org.junit.Test public void testLocalFileCopy() throws Exception {
                final String data = "This is some data";
                final InputStream in = new 
ByteArrayInputStream(data.getBytes());
-               final LocalFileRegisteredResource r = new 
LocalFileRegisteredResource(new InstallableResource(data, in, "somedigest"));
+               final LocalFileRegisteredResource r = new 
LocalFileRegisteredResource(new InstallableResource("1.jar", in, "somedigest"));
                assertTrue("Local file exists", r.getDataFile(null).exists());
                assertEquals("Local file length matches our data", 
data.getBytes().length, r.getDataFile(null).length());
        }
@@ -68,14 +110,21 @@
     @org.junit.Test public void testMissingDigest() throws Exception {
         final String data = "This is some data";
         final InputStream in = new ByteArrayInputStream(data.getBytes());
+        
+        try {
+            new LocalFileRegisteredResource(new InstallableResource("1.jar", 
in, null));
+            fail("With jar extension, expected an IllegalArgumentException as 
digest is null");
+        } catch(IllegalArgumentException asExpected) {
+        }
+        
         try {
-            new LocalFileRegisteredResource(new InstallableResource(data, in, 
null));
-            fail("Expected an IllegalArgumentException as digest is null");
+            new LocalFileRegisteredResource(new InstallableResource("1.foo", 
in, null));
         } catch(IllegalArgumentException asExpected) {
+            fail("With non-jar extension, did not expect an 
IllegalArgumentException if digest is null");
         }
     }
     
-    @org.junit.Test public void testDictionaryDigestOutOfOrderData() throws 
Exception {
+    @org.junit.Test public void testDictionaryDigestFromDictionaries() throws 
Exception {
         final Hashtable<String, Object> d1 = new Hashtable<String, Object>();
         final Hashtable<String, Object> d2 = new Hashtable<String, Object>();
         
@@ -91,11 +140,26 @@
         final RegisteredResource r2 = new RegisteredResource(null, new 
InstallableResource("url1", d2));
         
         assertEquals(
-                "Two RegisteredResource with same values but different key 
orderings must have the same key", 
+                "Two RegisteredResource (Dictionary) with same values but 
different key orderings must have the same key", 
                 r1.getDigest(),
                 r2.getDigest()
         );
+    }
+    
+    @org.junit.Test public void testDictionaryDigestFromInputStreams() throws 
Exception {
+        final String d1 = "foo=bar\nsomething=another\n";
+        final String d2 = "something=another\nfoo=bar\n";
+        
+        final ByteArrayInputStream s1 = new 
ByteArrayInputStream(d1.getBytes());
+        final ByteArrayInputStream s2 = new 
ByteArrayInputStream(d2.getBytes());
         
-        // TODO do the same test starting with an InputStream, for configs
+        final RegisteredResource r1 = new RegisteredResource(null, new 
InstallableResource("url1.properties", s1, null));
+        final RegisteredResource r2 = new RegisteredResource(null, new 
InstallableResource("url2.properties", s2, null));
+        
+        assertEquals(
+                "Two RegisteredResource (InputStream) with same values but 
different key orderings must have the same key", 
+                r1.getDigest(),
+                r2.getDigest()
+        );
     }
 }
\ No newline at end of file

Modified: 
sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/StorageTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/StorageTest.java?rev=804237&r1=804236&r2=804237&view=diff
==============================================================================
--- 
sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/StorageTest.java
 (original)
+++ 
sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/StorageTest.java
 Fri Aug 14 14:28:27 2009
@@ -29,7 +29,7 @@
 /** Test the Storage class */
 public class StorageTest {
 
-       private final OsgiControllerContext ocs = new 
MockOsgiControllerContext();
+       private final OsgiInstallerContext ocs = new 
MockOsgiControllerContext();
        
     @org.junit.Test public void testEmptyDataFile() throws Exception {
         final Storage s = new Storage(Utilities.getTestFile(), ocs);

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=804237&r1=804236&r2=804237&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
 Fri Aug 14 14:28:27 2009
@@ -37,21 +37,21 @@
  */
 public class TaskOrderingTest {
 
-       private Set<OsgiControllerTask> taskSet;
+       private Set<OsgiInstallerTask> taskSet;
        
        @org.junit.Before public void setUp() {
            // The data type must be consistent with the "tasks" member
            // of the {...@link OsgiControllerImpl} class.
-               taskSet = new TreeSet<OsgiControllerTask>(); 
+               taskSet = new TreeSet<OsgiInstallerTask>(); 
        }
        
        private static RegisteredResource getRegisteredResource(String url) 
throws IOException {
                return new RegisteredResource(null, new 
InstallableResource(url, new Hashtable<String, Object>()));
        }
        
-       private void assertOrder(int testId, Collection<OsgiControllerTask> 
actual, OsgiControllerTask [] expected) {
+       private void assertOrder(int testId, Collection<OsgiInstallerTask> 
actual, OsgiInstallerTask [] expected) {
                int index = 0;
-               for(OsgiControllerTask t : actual) {
+               for(OsgiInstallerTask t : actual) {
                        if(!t.equals(expected[index])) {
                                fail("Test " + testId + ": at index " + index + 
", expected " + expected[index] + " but got " + t);
                        }
@@ -62,11 +62,11 @@
        @org.junit.Test 
        public void testBasicOrdering() throws Exception {
                int testIndex = 1;
-               final OsgiControllerTask [] tasksInOrder = {
+               final OsgiInstallerTask [] tasksInOrder = {
                        new ConfigInstallRemoveTask("someURI.cfg", null, null),
                        new ConfigInstallRemoveTask("someURI.cfg", 
getRegisteredResource("someURI.cfg"), null),
-                       new BundleInstallRemoveTask("someURI", null, null, 
null),
-                       new BundleInstallRemoveTask("someURI", 
getRegisteredResource("someURI.jar"), null, null),
+                       new BundleInstallRemoveTask("someURI.jar", null, new 
MockOsgiControllerContext()),
+                       new BundleInstallRemoveTask("someURI", 
getRegisteredResource("someURI.cfg"), new MockOsgiControllerContext()),
                        new SynchronousRefreshPackagesTask(),
                        new BundleStartTask(0),
                };
@@ -115,15 +115,15 @@
        @org.junit.Test 
        public void testMultipleConfigAndBundles() throws Exception {
                int testIndex = 1;
-               final OsgiControllerTask [] tasksInOrder = {
+               final OsgiInstallerTask [] tasksInOrder = {
                        new ConfigInstallRemoveTask("someURIa.cfg", null, null),
                        new ConfigInstallRemoveTask("someURIb.cfg", null, null),
                        new ConfigInstallRemoveTask("someURIa.cfg", 
getRegisteredResource("someURIa.cfg"), null),
                        new ConfigInstallRemoveTask("someURIb.cfg", 
getRegisteredResource("someURIb.cfg"), null),
-                       new BundleInstallRemoveTask("someURIa.jar", null, null, 
null),
-                       new BundleInstallRemoveTask("someURIb.jar", null, null, 
null),
-                       new BundleInstallRemoveTask("someURIa.jar", 
getRegisteredResource("someURIa.jar"), null, null),
-                       new BundleInstallRemoveTask("someURIb.jar", 
getRegisteredResource("someURIb.jar"), null, null),
+                       new BundleInstallRemoveTask("someURIa.nothing", null, 
new MockOsgiControllerContext()),
+                       new BundleInstallRemoveTask("someURIb.nothing", null, 
new MockOsgiControllerContext()),
+                       new BundleInstallRemoveTask("someURIa.nothing", 
getRegisteredResource("someURIa.nothing"), new MockOsgiControllerContext()),
+                       new BundleInstallRemoveTask("someURIb.nothing", 
getRegisteredResource("someURIb.nothing"), new MockOsgiControllerContext()),
                        new SynchronousRefreshPackagesTask(),
                        new BundleStartTask(0),
                };
@@ -139,11 +139,11 @@
        @org.junit.Test 
        public void testMultipleRefreshAndStart() throws Exception {
                int testIndex = 1;
-               final OsgiControllerTask [] tasksInOrder = {
+               final OsgiInstallerTask [] tasksInOrder = {
                        new ConfigInstallRemoveTask("someURI.cfg", null, null),
                        new ConfigInstallRemoveTask("someURI.cfg", 
getRegisteredResource("someURI.cfg"), null),
-                       new BundleInstallRemoveTask("someURI", null, null, 
null),
-                       new BundleInstallRemoveTask("someURI", 
getRegisteredResource("someURI.jar"), null, null),
+                       new BundleInstallRemoveTask("someURI", null, new 
MockOsgiControllerContext()),
+                       new BundleInstallRemoveTask("someURI", 
getRegisteredResource("someURI.nothing"), new MockOsgiControllerContext()),
                        new SynchronousRefreshPackagesTask(),
                        new BundleStartTask(0),
                        new BundleStartTask(1),
@@ -180,7 +180,7 @@
        @org.junit.Test 
        public void testBundleStartOrder() {
                int testIndex = 1;
-               final OsgiControllerTask [] tasksInOrder = {
+               final OsgiInstallerTask [] tasksInOrder = {
                        new BundleStartTask(0),
                        new BundleStartTask(1),
                        new BundleStartTask(5),

Modified: 
sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveIgnoreTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveIgnoreTest.java?rev=804237&r1=804236&r2=804237&view=diff
==============================================================================
--- 
sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveIgnoreTest.java
 (original)
+++ 
sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveIgnoreTest.java
 Fri Aug 14 14:28:27 2009
@@ -32,7 +32,7 @@
        private BundleInstallRemoveTask task;
        
     @org.junit.Before public void setup() {
-        task = new BundleInstallRemoveTask(null, null, null, new 
MockOsgiControllerContext());
+        task = new BundleInstallRemoveTask(null, null, new 
MockOsgiControllerContext());
     }
 
        @org.junit.Test public void testLowerVersion() {

Modified: 
sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallTest.java?rev=804237&r1=804236&r2=804237&view=diff
==============================================================================
--- 
sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallTest.java
 (original)
+++ 
sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallTest.java
 Fri Aug 14 14:28:27 2009
@@ -21,7 +21,7 @@
 import static org.junit.Assert.assertNull;
 
 import org.apache.sling.osgi.installer.OsgiInstaller;
-import org.junit.AfterClass;
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -42,9 +42,9 @@
         setupInstaller();
     }
     
-    @AfterClass
-    public void cleanup() {
-        super.cleanup();
+    @After
+    public void tearDown() {
+        super.tearDown();
     }
 
        @Test
@@ -60,8 +60,10 @@
        {
             assertNull("Test bundle must be absent before installing", 
findBundle(symbolicName));
            resetCounters();
-           
installer.addResource(getInstallableResource(getTestBundle("org.apache.sling.osgi.installer.it-"
 + POM_VERSION + "-testbundle-1.1.jar")));
-           waitForInstallerAction(OsgiInstaller.OSGI_TASKS_COUNTER, 1);
+           installer.addResource(getInstallableResource(
+                   getTestBundle("org.apache.sling.osgi.installer.it-" + 
POM_VERSION + "-testbundle-1.1.jar")));
+           // wait for two tasks: install and start
+           waitForInstallerAction(OsgiInstaller.OSGI_TASKS_COUNTER, 2);
            final Bundle b = findBundle(symbolicName);
                assertNotNull("Test bundle 1.1 must be found after 
waitForInstallerAction", b);
                bundleId = b.getBundleId();
@@ -69,18 +71,21 @@
                assertEquals("Version must be 1.1", "1.1", 
b.getHeaders().get(BUNDLE_VERSION));
        }
 
-       /** TODO
+        /** TODO
        // Upgrade to later version, verify
        {
-               c.scheduleInstallOrUpdate(uri, new 
FileInstallableResource(getTestBundle("org.apache.sling.osgi.installer.it-" + 
POM_VERSION + "-testbundle-1.2.jar")));
-               c.executeScheduledOperations();
+           resetCounters();
+            installer.addResource(getInstallableResource(
+                    getTestBundle("org.apache.sling.osgi.installer.it-" + 
POM_VERSION + "-testbundle-1.2.jar")));
+            // wait for two tasks: update (includes stop) and start
+            waitForInstallerAction(OsgiInstaller.OSGI_TASKS_COUNTER, 1);
                final Bundle b = findBundle(symbolicName);
                assertNotNull("Test bundle 1.2 must be found after 
waitForInstallerAction", b);
                assertEquals("Installed bundle must be started", Bundle.ACTIVE, 
b.getState());
-               assertEquals("Version must be 1.2 after upgrade", "1.2", 
b.getHeaders().get(BUNDLE_VERSION));
-               assertEquals("Bundle ID must not change after upgrade", 
bundleId, b.getBundleId());
+               assertEquals("Version must be 1.2 after update", "1.2", 
b.getHeaders().get(BUNDLE_VERSION));
+               assertEquals("Bundle ID must not change after update", 
bundleId, b.getBundleId());
        }
-       
+
        // Downgrade to lower version, installed bundle must not change
        {
                c.scheduleInstallOrUpdate(uri, new 
FileInstallableResource(getTestBundle("org.apache.sling.osgi.installer.it-" + 
POM_VERSION + "-testbundle-1.0.jar")));

Modified: 
sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java?rev=804237&r1=804236&r2=804237&view=diff
==============================================================================
--- 
sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java
 (original)
+++ 
sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java
 Fri Aug 14 14:28:27 2009
@@ -32,8 +32,6 @@
 
 import org.apache.sling.osgi.installer.InstallableResource;
 import org.apache.sling.osgi.installer.OsgiInstaller;
-import org.junit.Before;
-import org.junit.AfterClass;
 import org.ops4j.pax.exam.Inject;
 import org.ops4j.pax.exam.Option;
 import org.osgi.framework.Bundle;
@@ -75,7 +73,7 @@
         resetCounters();
     }
     
-    public void cleanup() {
+    public void tearDown() {
         if(configAdminTracker != null) {
             configAdminTracker.close();
             configAdminTracker = null;


Reply via email to