incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1057284 [2/2] - in /sling/trunk/installer/core/src: main/java/org/apache/sling/installer/api/ main/java/org/apache/sling/installer/api/tasks/ main/java/org/apache/sling/installer/core/impl/ main/java/org/apache/sling/installer/core/impl/co...
Date Mon, 10 Jan 2011 17:06:31 GMT
Modified: sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/BundleTaskCreator.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/BundleTaskCreator.java?rev=1057284&r1=1057283&r2=1057284&view=diff
==============================================================================
--- sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/BundleTaskCreator.java
(original)
+++ sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/BundleTaskCreator.java
Mon Jan 10 17:06:30 2011
@@ -23,6 +23,7 @@ import org.apache.sling.installer.api.ta
 import org.apache.sling.installer.api.tasks.InstallTaskFactory;
 import org.apache.sling.installer.api.tasks.RegisteredResource;
 import org.apache.sling.installer.api.tasks.RegisteredResourceGroup;
+import org.apache.sling.installer.core.impl.InternalService;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
@@ -36,7 +37,7 @@ import org.slf4j.LoggerFactory;
 /**
  * Task creator for bundles
  */
-public class BundleTaskCreator implements InstallTaskFactory {
+public class BundleTaskCreator implements InternalService, InstallTaskFactory {
 
     /** The logger */
     private final Logger logger =  LoggerFactory.getLogger(this.getClass());
@@ -52,18 +53,18 @@ public class BundleTaskCreator implement
     private static final String MAVEN_SNAPSHOT_MARKER = "SNAPSHOT";
 
     /** Tracker for the package admin. */
-    private final ServiceTracker packageAdminTracker;
+    private ServiceTracker packageAdminTracker;
 
     /** Tracker for the start level service. */
-    private final ServiceTracker startLevelTracker;
+    private ServiceTracker startLevelTracker;
 
     /** The bundle context. */
-    private final BundleContext bundleContext;
+    private BundleContext bundleContext;
 
     /**
-     * Constructor
+     * @see org.apache.sling.installer.core.impl.InternalService#init(org.osgi.framework.BundleContext)
      */
-    public BundleTaskCreator(final BundleContext bc) {
+    public void init(final BundleContext bc) {
         this.bundleContext = bc;
         // create and start tracker
         this.packageAdminTracker = new ServiceTracker(bc, PACKAGE_ADMIN_NAME, null);
@@ -73,11 +74,24 @@ public class BundleTaskCreator implement
     }
 
     /**
-     * Deactivate creator.
+     * @see org.apache.sling.installer.core.impl.InternalService#deactivate()
      */
     public void deactivate() {
-        this.packageAdminTracker.close();
-        this.startLevelTracker.close();
+        if ( this.packageAdminTracker != null ) {
+            this.packageAdminTracker.close();
+            this.packageAdminTracker = null;
+        }
+        if ( this.startLevelTracker != null ) {
+            this.startLevelTracker.close();
+            this.startLevelTracker = null;
+        }
+    }
+
+    /**
+     * @see org.apache.sling.installer.core.impl.InternalService#getDescription()
+     */
+    public String getDescription() {
+        return "Apache Sling Bundle Install Task Factory";
     }
 
     public BundleContext getBundleContext() {

Modified: sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/DictionaryDigestTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/DictionaryDigestTest.java?rev=1057284&r1=1057283&r2=1057284&view=diff
==============================================================================
--- sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/DictionaryDigestTest.java
(original)
+++ sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/DictionaryDigestTest.java
Mon Jan 10 17:06:30 2011
@@ -36,8 +36,9 @@ public class DictionaryDigestTest {
 		d.put("array", new String[] { "a", "b"});
 	}
 
-    private RegisteredResourceImpl create(final InstallableResource is) throws IOException
{
-        return RegisteredResourceImpl.create(new MockBundleContext(), is, "test", new FileUtil(new
MockBundleContext()));
+    private InternalResource create(final InstallableResource is) throws IOException {
+        new FileUtil(new MockBundleContext());
+        return InternalResource.create("test", is);
     }
 
     private String testDigestChanged(Dictionary<String, Object> d,

Modified: sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/MockBundleResource.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/MockBundleResource.java?rev=1057284&r1=1057283&r2=1057284&view=diff
==============================================================================
--- sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/MockBundleResource.java
(original)
+++ sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/MockBundleResource.java
Mon Jan 10 17:06:30 2011
@@ -67,7 +67,7 @@ public class MockBundleResource implemen
 	}
 
 	/**
-	 * @see org.apache.sling.installer.api.tasks.RegisteredResource#cleanup()
+	 * Clean up
 	 */
 	public void cleanup() {
 	    // nothing to do

Modified: sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/RegisteredResourceComparatorTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/RegisteredResourceComparatorTest.java?rev=1057284&r1=1057283&r2=1057284&view=diff
==============================================================================
--- sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/RegisteredResourceComparatorTest.java
(original)
+++ sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/RegisteredResourceComparatorTest.java
Mon Jan 10 17:06:30 2011
@@ -54,8 +54,13 @@ public class RegisteredResourceComparato
             data = new Hashtable<String, Object>();
             data.put("foo", "bar");
         }
+        new FileUtil(new MockBundleContext());
         final InstallableResource r = new InstallableResource(url, null, data, digest, null,
priority);
-        return RegisteredResourceImpl.create(null, r, "test", new FileUtil(new MockBundleContext()));
+        final InternalResource internal = InternalResource.create("test", r);
+        final RegisteredResourceImpl rr = RegisteredResourceImpl.create(internal);
+        rr.update(new DefaultTransformer().transform(rr));
+
+        return rr;
     }
 
     private void assertOrder(RegisteredResource[] inOrder) {

Modified: sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/RegisteredResourceTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/RegisteredResourceTest.java?rev=1057284&r1=1057283&r2=1057284&view=diff
==============================================================================
--- sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/RegisteredResourceTest.java
(original)
+++ sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/RegisteredResourceTest.java
Mon Jan 10 17:06:30 2011
@@ -23,7 +23,6 @@ import static org.junit.Assert.assertFal
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 import java.io.ByteArrayInputStream;
 import java.io.File;
@@ -35,6 +34,7 @@ import java.util.Hashtable;
 
 import org.apache.sling.installer.api.InstallableResource;
 import org.apache.sling.installer.api.tasks.RegisteredResource;
+import org.apache.sling.installer.api.tasks.TransformationResult;
 import org.junit.Test;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
@@ -52,6 +52,7 @@ public class RegisteredResourceTest {
         {
             final InputStream s = new FileInputStream(getTestBundle("testbundle-1.0.jar"));
             final RegisteredResource r = create(new InstallableResource("test:1.jar", s,
null, "some digest", null, null));
+
             assertEquals(".jar URL creates a BUNDLE resource",
                     InstallableResource.TYPE_BUNDLE, r.getType());
             final InputStream rs = r.getInputStream();
@@ -83,14 +84,16 @@ public class RegisteredResourceTest {
 	    final BundleContext bc = new MockBundleContext();
 	    final File f = getTestBundle("testbundle-1.0.jar");
         final InputStream s = new FileInputStream(f);
-		RegisteredResourceImpl.create(bc, new InstallableResource("test:1.jar", s, null, "somedigest",
null, null), "test", new FileUtil(bc) {
+        FileUtil.SHARED = new FileUtil(bc) {
 
             @Override
             public File createNewDataFile(final String hint) {
                 return localFile;
             }
 
-		});
+        };
+
+		InternalResource.create("test", new InstallableResource("test:1.jar", s, null, "somedigest",
null, null));
 		assertTrue("Local file exists", localFile.exists());
 
 		assertEquals("Local file length matches our data", f.length(), localFile.length());
@@ -100,11 +103,8 @@ public class RegisteredResourceTest {
         final String data = "This is some data";
         final InputStream in = new ByteArrayInputStream(data.getBytes());
 
-        try {
-            create(new InstallableResource("test:1.jar", in, null, null, null, null));
-            fail("With jar extension, expected an IOException as digest is null");
-        } catch(IOException asExpected) {
-        }
+        create(new InstallableResource("test:1.jar", in, null, null, null, null));
+        assertNotNull(create(new InstallableResource("test:1.jar", in, null, null, null,
null)).getDigest());
     }
 
     @org.junit.Test public void testBundleManifest() throws Exception {
@@ -160,7 +160,14 @@ public class RegisteredResourceTest {
         );
     }
 
-    private RegisteredResourceImpl create(final InstallableResource is) throws IOException
{
-        return RegisteredResourceImpl.create(new MockBundleContext(), is, "test", new FileUtil(new
MockBundleContext()));
+    private RegisteredResource create(final InstallableResource is) throws IOException {
+        new FileUtil(new MockBundleContext());
+        final InternalResource internal = InternalResource.create("test", is);
+        final RegisteredResourceImpl rr = RegisteredResourceImpl.create(internal);
+        final TransformationResult tr = new DefaultTransformer().transform(rr);
+        if ( tr != null ) {
+            rr.update(tr);
+        }
+        return rr;
     }
 }
\ No newline at end of file

Modified: sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/TaskOrderingTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/TaskOrderingTest.java?rev=1057284&r1=1057283&r2=1057284&view=diff
==============================================================================
--- sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/TaskOrderingTest.java
(original)
+++ sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/TaskOrderingTest.java
Mon Jan 10 17:06:30 2011
@@ -50,10 +50,14 @@ public class TaskOrderingTest {
 	}
 
 	private static EntityResourceList getRegisteredResource(String url) throws IOException {
-	    final EntityResourceList erl = new EntityResourceList();
-	    erl.addOrUpdate(RegisteredResourceImpl.create(null,
-		        new InstallableResource(url, null, new Hashtable<String, Object>(), null,
null, null),
-		        "test", new FileUtil(new MockBundleContext())));
+        new FileUtil(new MockBundleContext());
+        final InternalResource internal = InternalResource.create("test",
+                new InstallableResource(url, null, new Hashtable<String, Object>(),
null, null, null));
+        final RegisteredResourceImpl rr = RegisteredResourceImpl.create(internal);
+        rr.update(new DefaultTransformer().transform(rr));
+
+        final EntityResourceList erl = new EntityResourceList();
+	    erl.addOrUpdate(rr);
 	    return erl;
 	}
 

Modified: sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/tasks/MockBundleTaskCreator.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/tasks/MockBundleTaskCreator.java?rev=1057284&r1=1057283&r2=1057284&view=diff
==============================================================================
--- sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/tasks/MockBundleTaskCreator.java
(original)
+++ sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/tasks/MockBundleTaskCreator.java
Mon Jan 10 17:06:30 2011
@@ -23,7 +23,6 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.sling.installer.core.impl.MockBundleContext;
-import org.apache.sling.installer.core.impl.tasks.BundleTaskCreator;
 import org.osgi.framework.Version;
 
 /** BundleTaskCreator that simulates the presence and state of bundles */
@@ -32,7 +31,7 @@ class MockBundleTaskCreator extends Bund
     private final Map<String, BundleInfo> fakeBundleInfo = new HashMap<String, BundleInfo>();
 
     public MockBundleTaskCreator() throws IOException {
-        super(new MockBundleContext());
+        this.init(new MockBundleContext());
     }
 
     void addBundleInfo(String symbolicName, String version, int state) {



Mime
View raw message