incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1076264 - in /sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl: RegisteredResourceComparatorTest.java RegisteredResourceTest.java TaskOrderingTest.java
Date Wed, 02 Mar 2011 15:48:17 GMT
Author: cziegeler
Date: Wed Mar  2 15:48:16 2011
New Revision: 1076264

URL: http://svn.apache.org/viewvc?rev=1076264&view=rev
Log:
SLING-1999 : Split Installer Core and Configuration Support

Modified:
    sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/RegisteredResourceComparatorTest.java
    sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/RegisteredResourceTest.java
    sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/TaskOrderingTest.java

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=1076264&r1=1076263&r2=1076264&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
Wed Mar  2 15:48:16 2011
@@ -31,6 +31,7 @@ import java.util.TreeSet;
 
 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;
 
 public class RegisteredResourceComparatorTest {
@@ -58,7 +59,16 @@ public class RegisteredResourceComparato
         final InstallableResource r = new InstallableResource(url, null, data, digest, null,
priority);
         final InternalResource internal = InternalResource.create("test", r);
         final RegisteredResourceImpl rr = RegisteredResourceImpl.create(internal);
-        return (RegisteredResourceImpl)rr.clone(new DefaultTransformer().transform(rr)[0]);
+        TransformationResult[] tr = new DefaultTransformer().transform(rr);
+        if ( tr == null ) {
+            final TransformationResult result = new TransformationResult();
+            result.setId(url);
+            result.setResourceType(InstallableResource.TYPE_CONFIG);
+            tr = new TransformationResult[] {
+                      result
+            };
+        }
+        return (RegisteredResourceImpl)rr.clone(tr[0]);
     }
 
     private void assertOrder(RegisteredResource[] inOrder) {
@@ -138,7 +148,7 @@ public class RegisteredResourceComparato
         assertOrder(inOrder);
     }
 
-//    @Test
+    @Test
     public void testConfigPriority() throws IOException {
         final RegisteredResource [] inOrder = new RegisteredResource [3];
         inOrder[0] = getConfig("pid", null, 2);
@@ -147,7 +157,7 @@ public class RegisteredResourceComparato
         assertOrder(inOrder);
     }
 
-//    @Test
+    @Test
     public void testConfigDigests() throws IOException {
     	final Dictionary<String, Object> data = new Hashtable<String, Object>();
         data.put("foo", "bar");
@@ -161,7 +171,7 @@ public class RegisteredResourceComparato
         assertEquals("Digests must be included in configs comparison", 0, a2.compareTo(b2));
     }
 
-//    @Test
+    @Test
     public void testConfigPid() throws IOException {
         final RegisteredResource [] inOrder = new RegisteredResource [3];
         inOrder[0] = getConfig("pidA", null, 0);
@@ -170,7 +180,7 @@ public class RegisteredResourceComparato
         assertOrder(inOrder);
     }
 
-//    @Test
+    @Test
     public void testConfigComposite() throws IOException {
         final RegisteredResource [] inOrder = new RegisteredResource [4];
         inOrder[0] = getConfig("pidA", null, 10);

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=1076264&r1=1076263&r2=1076264&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
Wed Mar  2 15:48:16 2011
@@ -28,6 +28,7 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.Collections;
 import java.util.Dictionary;
 import java.util.Hashtable;
 
@@ -61,12 +62,12 @@ public class RegisteredResourceTest {
             assertNull("BUNDLE resource does not provide a Dictionary", r.getDictionary());
             assertEquals("RegisteredResource entity ID must match", "bundle:osgi-installer-testbundle",
r.getEntityId());
         }
-/**
+
         {
             final Hashtable<String, Object> data = new Hashtable<String, Object>();
             data.put("foo", "bar");
             data.put("other", 2);
-            final TaskResource r = create(new InstallableResource("test:1", null, data, null,
null, null));
+            final TaskResource r = create(new InstallableResource("configuration:1", null,
data, null, null, null));
             assertEquals("No-extension URL with Dictionary creates a CONFIG resource",
                     InstallableResource.TYPE_CONFIG, r.getType());
             final InputStream rs = r.getInputStream();
@@ -76,7 +77,6 @@ public class RegisteredResourceTest {
             assertEquals("CONFIG resource dictionary has two properties", 2, d.size());
             assertNotNull("CONFIG resource has a pid attribute", r.getAttribute(Constants.SERVICE_PID));
         }
-        */
     }
 
 	@org.junit.Test public void testLocalFileCopy() throws Exception {
@@ -171,6 +171,12 @@ public class RegisteredResourceTest {
         final TransformationResult[] tr = new DefaultTransformer().transform(rr);
         if ( tr != null ) {
             return rr.clone(tr[0]);
+        } else if ( is.getId().startsWith("configuration:") ) {
+            final TransformationResult result = new TransformationResult();
+            result.setId(is.getId().substring(14));
+            result.setResourceType(InstallableResource.TYPE_CONFIG);
+            result.setAttributes(Collections.singletonMap(Constants.SERVICE_PID, (Object)result.getId()));
+            return rr.clone(result);
         }
         return rr;
     }

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=1076264&r1=1076263&r2=1076264&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
Wed Mar  2 15:48:16 2011
@@ -28,6 +28,7 @@ import java.util.TreeSet;
 
 import org.apache.sling.installer.api.InstallableResource;
 import org.apache.sling.installer.api.tasks.InstallTask;
+import org.apache.sling.installer.api.tasks.TransformationResult;
 import org.apache.sling.installer.core.impl.tasks.BundleInstallTask;
 import org.apache.sling.installer.core.impl.tasks.BundleRemoveTask;
 import org.apache.sling.installer.core.impl.tasks.BundleStartTask;
@@ -52,7 +53,16 @@ public class TaskOrderingTest {
         final InternalResource internal = InternalResource.create("test",
                 new InstallableResource(url, null, new Hashtable<String, Object>(),
null, null, null));
         RegisteredResourceImpl rr = RegisteredResourceImpl.create(internal);
-        rr = (RegisteredResourceImpl)rr.clone(new DefaultTransformer().transform(rr)[0]);
+        TransformationResult[] tr = new DefaultTransformer().transform(rr);
+        if ( tr == null ) {
+            final TransformationResult result = new TransformationResult();
+            result.setId(url);
+            result.setResourceType(InstallableResource.TYPE_CONFIG);
+            tr = new TransformationResult[] {
+                      result
+            };
+        }
+        rr = (RegisteredResourceImpl)rr.clone(tr[0]);
 
         final EntityResourceList erl = new EntityResourceList("test");
 	    erl.addOrUpdate(rr);
@@ -69,12 +79,10 @@ public class TaskOrderingTest {
 		}
 	}
 
-//	@org.junit.Test
+	@org.junit.Test
 	public void testBasicOrdering() throws Exception {
 		int testIndex = 1;
 		final InstallTask [] tasksInOrder = {
-//		    new ConfigRemoveTask(getRegisteredResource("test:a"), null),
-//          new ConfigInstallTask(getRegisteredResource("test:a"), null),
 		    new BundleRemoveTask(getRegisteredResource("test:url"), null),
 		    new BundleUpdateTask(getRegisteredResource("test:url"), null),
 		    new BundleInstallTask(getRegisteredResource("test:url"), null),
@@ -83,8 +91,6 @@ public class TaskOrderingTest {
 		};
 
 		taskSet.clear();
-//      taskSet.add(tasksInOrder[6]);
-//  	taskSet.add(tasksInOrder[5]);
 		taskSet.add(tasksInOrder[4]);
 		taskSet.add(tasksInOrder[3]);
 		taskSet.add(tasksInOrder[2]);
@@ -99,8 +105,6 @@ public class TaskOrderingTest {
 		taskSet.add(tasksInOrder[2]);
 		taskSet.add(tasksInOrder[3]);
 		taskSet.add(tasksInOrder[4]);
-//		taskSet.add(tasksInOrder[5]);
-//		taskSet.add(tasksInOrder[6]);
 
 		assertOrder(testIndex++, taskSet, tasksInOrder);
 
@@ -108,17 +112,13 @@ public class TaskOrderingTest {
 		taskSet.add(tasksInOrder[3]);
 		taskSet.add(tasksInOrder[2]);
         taskSet.add(tasksInOrder[0]);
-//		taskSet.add(tasksInOrder[5]);
 		taskSet.add(tasksInOrder[4]);
         taskSet.add(tasksInOrder[1]);
-//		taskSet.add(tasksInOrder[6]);
 
 		assertOrder(testIndex++, taskSet, tasksInOrder);
 
 		taskSet.clear();
 		taskSet.add(tasksInOrder[4]);
-//		taskSet.add(tasksInOrder[5]);
-//		taskSet.add(tasksInOrder[6]);
         taskSet.add(tasksInOrder[0]);
 		taskSet.add(tasksInOrder[2]);
 		taskSet.add(tasksInOrder[3]);
@@ -127,7 +127,7 @@ public class TaskOrderingTest {
 		assertOrder(testIndex++, taskSet, tasksInOrder);
 	}
 
-//	@org.junit.Test
+	@org.junit.Test
 	public void testMultipleConfigAndBundles() throws Exception {
 		int testIndex = 1;
 		final InstallTask [] tasksInOrder = {
@@ -152,7 +152,7 @@ public class TaskOrderingTest {
         assertOrder(testIndex++, taskSet, tasksInOrder);
 	}
 
-//	@org.junit.Test
+	@org.junit.Test
 	public void testMultipleRefreshAndStart() throws Exception {
 		int testIndex = 1;
 		final InstallTask [] tasksInOrder = {
@@ -186,7 +186,7 @@ public class TaskOrderingTest {
 		assertOrder(testIndex++, taskSet, tasksInOrder);
 	}
 
-//	@org.junit.Test
+	@org.junit.Test
 	public void testBundleStartOrder() {
 		int testIndex = 1;
 		final InstallTask [] tasksInOrder = {
@@ -210,9 +210,4 @@ public class TaskOrderingTest {
 
         assertOrder(testIndex++, taskSet, tasksInOrder);
 	}
-
-	@org.junit.Test
-	public void testDummy() {
-	    // as we commented out all other tests we need this one
-	}
 }



Mime
View raw message