incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r792130 - in /sling/trunk/contrib/extensions/jcrinstall/osgi/src: main/java/org/apache/sling/osgi/installer/impl/ main/java/org/apache/sling/osgi/installer/impl/tasks/ test/java/org/apache/sling/osgi/installer/impl/
Date Wed, 08 Jul 2009 13:18:01 GMT
Author: bdelacretaz
Date: Wed Jul  8 13:18:01 2009
New Revision: 792130

URL: http://svn.apache.org/viewvc?rev=792130&view=rev
Log:
SLING-1037 - TaskOrderingTest added

Added:
    sling/trunk/contrib/extensions/jcrinstall/osgi/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java
  (with props)
Modified:
    sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java
    sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/TaskOrder.java

Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java?rev=792130&r1=792129&r2=792130&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java
(original)
+++ sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java
Wed Jul  8 13:18:01 2009
@@ -53,11 +53,14 @@
 	private final BundleContext bundleContext;
     private final Storage storage;
     private ResourceOverrideRules roRules;
+    
+    // The data type of the "tasks" member must be consistent with the {@link TaskOrderingTest}
class
     private final Set<OsgiControllerTask> tasks = new TreeSet<OsgiControllerTask>();
     private final Set<OsgiControllerTask> tasksForNextCycle = new TreeSet<OsgiControllerTask>();
     private final Set<OsgiControllerTask> tasksForThisCycle = new TreeSet<OsgiControllerTask>();
     private final ServiceTracker logServiceTracker;
     private int threadCounter;
+    private final PackageAdmin packageAdmin;
 
     public static final String BUNDLE_EXTENSION = ".jar";
     public static final String STORAGE_FILENAME = "controller.storage";
@@ -65,9 +68,6 @@
     /** Storage key: digest of an InstallableData */
     public static final String KEY_DIGEST = "data.digest";
 
-    // TODO unused?
-    private final PackageAdmin packageAdmin;
-
     /** Default value for getLastModified() */
     public static final long LAST_MODIFIED_NOT_FOUND = -1;
 

Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/TaskOrder.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/TaskOrder.java?rev=792130&r1=792129&r2=792130&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/TaskOrder.java
(original)
+++ sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/TaskOrder.java
Wed Jul  8 13:18:01 2009
@@ -24,6 +24,6 @@
 	static final String CONFIG_INSTALL_ORDER = "20-";
 	static final String BUNDLE_UNINSTALL_ORDER = "30-";
 	static final String BUNDLE_INSTALL_ORDER = "40-";
-	static final String BUNDLE_START_ORDER = "50-";
-	static final String REFRESH_PACKAGES_ORDER = "60-";
+	static final String REFRESH_PACKAGES_ORDER = "50-";
+	static final String BUNDLE_START_ORDER = "60-";
 }

Added: sling/trunk/contrib/extensions/jcrinstall/osgi/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/osgi/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java?rev=792130&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/jcrinstall/osgi/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java
(added)
+++ sling/trunk/contrib/extensions/jcrinstall/osgi/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java
Wed Jul  8 13:18:01 2009
@@ -0,0 +1,190 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.osgi.installer.impl;
+
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertTrue;
+import java.util.Collection;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.apache.sling.osgi.installer.impl.tasks.BundleInstallRemoveTask;
+import org.apache.sling.osgi.installer.impl.tasks.BundleStartTask;
+import org.apache.sling.osgi.installer.impl.tasks.ConfigInstallRemoveTask;
+import org.apache.sling.osgi.installer.impl.tasks.SynchronousRefreshPackagesTask;
+
+/** Test the ordering and duplicates elimination of
+ * 	OsgiControllerTasks
+ */
+public class TaskOrderingTest {
+
+	private Set<OsgiControllerTask> 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>(); 
+	}
+	
+	private void assertOrder(int testId, Collection<OsgiControllerTask> actual, OsgiControllerTask
[] expected) {
+		int index = 0;
+		for(OsgiControllerTask t : actual) {
+			if(!t.equals(expected[index])) {
+				fail("Test " + testId + ": at index " + index + ", expected " + expected[index] + " but
got " + t);
+			}
+			index++;
+		}
+	}
+	
+	@org.junit.Test 
+	public void testBasicOrdering() {
+		int testIndex = 1;
+		final OsgiControllerTask [] tasksInOrder = {
+			new ConfigInstallRemoveTask("someURI.cfg", null, null),
+			new ConfigInstallRemoveTask("someURI.cfg", new MockInstallableData("someURI.cfg"), null),
+			new BundleInstallRemoveTask("someURI", null, null, null),
+			new BundleInstallRemoveTask("someURI", new MockInstallableData("someURI.jar"), null, null),
+			new SynchronousRefreshPackagesTask(),
+			new BundleStartTask(0),
+		};
+	
+		taskSet.clear();
+		taskSet.add(tasksInOrder[5]);
+		taskSet.add(tasksInOrder[4]);
+		taskSet.add(tasksInOrder[3]);
+		taskSet.add(tasksInOrder[2]);
+		taskSet.add(tasksInOrder[1]);
+		taskSet.add(tasksInOrder[0]);
+		
+		assertOrder(testIndex++, taskSet, tasksInOrder);
+		
+		taskSet.clear();
+		taskSet.add(tasksInOrder[0]);
+		taskSet.add(tasksInOrder[1]);
+		taskSet.add(tasksInOrder[2]);
+		taskSet.add(tasksInOrder[3]);
+		taskSet.add(tasksInOrder[4]);
+		taskSet.add(tasksInOrder[5]);
+		
+		assertOrder(testIndex++, taskSet, tasksInOrder);
+		
+		taskSet.clear();
+		taskSet.add(tasksInOrder[1]);
+		taskSet.add(tasksInOrder[0]);
+		taskSet.add(tasksInOrder[3]);
+		taskSet.add(tasksInOrder[2]);
+		taskSet.add(tasksInOrder[5]);
+		taskSet.add(tasksInOrder[4]);
+		
+		assertOrder(testIndex++, taskSet, tasksInOrder);
+		
+		taskSet.clear();
+		taskSet.add(tasksInOrder[2]);
+		taskSet.add(tasksInOrder[3]);
+		taskSet.add(tasksInOrder[4]);
+		taskSet.add(tasksInOrder[5]);
+		taskSet.add(tasksInOrder[0]);
+		taskSet.add(tasksInOrder[1]);
+		
+		assertOrder(testIndex++, taskSet, tasksInOrder);
+	}
+	
+	@org.junit.Test 
+	public void testMultipleConfigAndBundles() {
+		int testIndex = 1;
+		final OsgiControllerTask [] tasksInOrder = {
+			new ConfigInstallRemoveTask("someURIa.cfg", null, null),
+			new ConfigInstallRemoveTask("someURIb.cfg", null, null),
+			new ConfigInstallRemoveTask("someURIa.cfg", new MockInstallableData("someURIa.cfg"), null),
+			new ConfigInstallRemoveTask("someURIb.cfg", new MockInstallableData("someURIb.cfg"), null),
+			new BundleInstallRemoveTask("someURIa.jar", null, null, null),
+			new BundleInstallRemoveTask("someURIb.jar", null, null, null),
+			new BundleInstallRemoveTask("someURIa.jar", new MockInstallableData("someURIa.jar"), null,
null),
+			new BundleInstallRemoveTask("someURIb.jar", new MockInstallableData("someURIb.jar"), null,
null),
+			new SynchronousRefreshPackagesTask(),
+			new BundleStartTask(0),
+		};
+	
+		taskSet.clear();
+		for(int i = tasksInOrder.length -1 ; i >= 0; i--) {
+			taskSet.add(tasksInOrder[i]);
+		}
+		
+		assertOrder(testIndex++, taskSet, tasksInOrder);
+	}
+	
+	@org.junit.Test 
+	public void testMultipleRefreshAndStart() {
+		int testIndex = 1;
+		final OsgiControllerTask [] tasksInOrder = {
+			new ConfigInstallRemoveTask("someURI.cfg", null, null),
+			new ConfigInstallRemoveTask("someURI.cfg", new MockInstallableData("someURI.cfg"), null),
+			new BundleInstallRemoveTask("someURI", null, null, null),
+			new BundleInstallRemoveTask("someURI", new MockInstallableData("someURI.jar"), null, null),
+			new SynchronousRefreshPackagesTask(),
+			new BundleStartTask(0),
+			new BundleStartTask(1),
+		};
+		
+		taskSet.clear();
+		taskSet.add(tasksInOrder[6]);
+		taskSet.add(tasksInOrder[6]);
+		taskSet.add(new SynchronousRefreshPackagesTask());
+		taskSet.add(tasksInOrder[5]);
+		taskSet.add(tasksInOrder[5]);
+		taskSet.add(tasksInOrder[4]);
+		taskSet.add(new SynchronousRefreshPackagesTask());
+		taskSet.add(new SynchronousRefreshPackagesTask());
+		taskSet.add(tasksInOrder[4]);
+		taskSet.add(tasksInOrder[4]);
+		taskSet.add(tasksInOrder[3]);
+		taskSet.add(new SynchronousRefreshPackagesTask());
+		taskSet.add(tasksInOrder[3]);
+		taskSet.add(tasksInOrder[2]);
+		taskSet.add(new SynchronousRefreshPackagesTask());
+		taskSet.add(tasksInOrder[2]);
+		taskSet.add(tasksInOrder[1]);
+		taskSet.add(new SynchronousRefreshPackagesTask());
+		taskSet.add(tasksInOrder[1]);
+		taskSet.add(new SynchronousRefreshPackagesTask());
+		taskSet.add(tasksInOrder[0]);
+		taskSet.add(new SynchronousRefreshPackagesTask());
+		taskSet.add(tasksInOrder[0]);
+		
+		assertOrder(testIndex++, taskSet, tasksInOrder);
+	}
+	
+	@org.junit.Test 
+	public void testBundleStartOrder() {
+		int testIndex = 1;
+		final OsgiControllerTask [] tasksInOrder = {
+			new BundleStartTask(0),
+			new BundleStartTask(1),
+			new BundleStartTask(5),
+			new BundleStartTask(11),
+			new BundleStartTask(51)
+		};
+		
+		taskSet.clear();
+		for(int i = tasksInOrder.length -1 ; i >= 0; i--) {
+			taskSet.add(tasksInOrder[i]);
+		}
+		assertOrder(testIndex++, taskSet, tasksInOrder);
+	}
+}

Propchange: sling/trunk/contrib/extensions/jcrinstall/osgi/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/contrib/extensions/jcrinstall/osgi/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL



Mime
View raw message