incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r722885 - in /incubator/sling/trunk/extensions/jcrinstall/testing: ./ src/test/java/org/apache/sling/jcr/jcrinstall/integrationtest/
Date Wed, 03 Dec 2008 13:49:16 GMT
Author: bdelacretaz
Date: Wed Dec  3 05:49:14 2008
New Revision: 722885

URL: http://svn.apache.org/viewvc?rev=722885&view=rev
Log:
SLING-734 - pom properties handling fixed

Modified:
    incubator/sling/trunk/extensions/jcrinstall/testing/pom.xml
    incubator/sling/trunk/extensions/jcrinstall/testing/src/test/java/org/apache/sling/jcr/jcrinstall/integrationtest/InstallClonedBundlesTest.java
    incubator/sling/trunk/extensions/jcrinstall/testing/src/test/java/org/apache/sling/jcr/jcrinstall/integrationtest/JcrinstallTestBase.java

Modified: incubator/sling/trunk/extensions/jcrinstall/testing/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/testing/pom.xml?rev=722885&r1=722884&r2=722885&view=diff
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/testing/pom.xml (original)
+++ incubator/sling/trunk/extensions/jcrinstall/testing/pom.xml Wed Dec  3 05:49:14 2008
@@ -84,7 +84,10 @@
         <sling.testbundles.path>${project.build.directory}/testbundles</sling.testbundles.path>
         
         <!-- Can be used to run tests with more or less bundles -->
-        <sling.test.scale.factor>10</sling.test.scale.factor>
+        <sling.test.scale.factor>1</sling.test.scale.factor>
+        
+        <!--  How long to wait for the expected number of bundles to be active, in tests
-->
+        <sling.test.bundles.wait.seconds>20</sling.test.bundles.wait.seconds>
     </properties>
 
     <build>
@@ -327,6 +330,10 @@
                             <name>sling.test.scale.factor</name>
                             <value>${sling.test.scale.factor}</value>
                         </property>
+                        <property>
+                            <name>sling.test.bundles.wait.seconds</name>
+                            <value>${sling.test.bundles.wait.seconds}</value>
+                        </property>
                     </systemProperties>
                 </configuration>
             </plugin>
@@ -412,6 +419,18 @@
                                                 http://${test.host}:${http.port}/${project.build.finalName}/${webdav.workspace.path}
                                             </value>
                                         </property>
+				                        <property>
+				                            <name>sling.testbundles.path</name>
+				                            <value>${sling.testbundles.path}</value>
+				                        </property>
+				                        <property>
+				                            <name>sling.test.scale.factor</name>
+				                            <value>${sling.test.scale.factor}</value>
+				                        </property>
+				                        <property>
+				                            <name>sling.test.bundles.wait.seconds</name>
+				                            <value>${sling.test.bundles.wait.seconds}</value>
+				                        </property>
                                     </systemProperties>
                                 </configuration>
                             </execution>

Modified: incubator/sling/trunk/extensions/jcrinstall/testing/src/test/java/org/apache/sling/jcr/jcrinstall/integrationtest/InstallClonedBundlesTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/testing/src/test/java/org/apache/sling/jcr/jcrinstall/integrationtest/InstallClonedBundlesTest.java?rev=722885&r1=722884&r2=722885&view=diff
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/testing/src/test/java/org/apache/sling/jcr/jcrinstall/integrationtest/InstallClonedBundlesTest.java
(original)
+++ incubator/sling/trunk/extensions/jcrinstall/testing/src/test/java/org/apache/sling/jcr/jcrinstall/integrationtest/InstallClonedBundlesTest.java
Wed Dec  3 05:49:14 2008
@@ -32,13 +32,13 @@
 		}
 		
 		assertActiveBundleCount("after adding bundles", 
-				activeBeforeTest + nBundles, DEFAULT_BUNDLES_TIMEOUT);
+				activeBeforeTest + nBundles, defaultBundlesTimeout);
 		
 		for(String path : installed) {
 			removeClonedBundle(path);
 		}
 		
 		assertActiveBundleCount("after removing added bundles", 
-				activeBeforeTest, DEFAULT_BUNDLES_TIMEOUT);
+				activeBeforeTest, defaultBundlesTimeout);
 	}
 }

Modified: incubator/sling/trunk/extensions/jcrinstall/testing/src/test/java/org/apache/sling/jcr/jcrinstall/integrationtest/JcrinstallTestBase.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/testing/src/test/java/org/apache/sling/jcr/jcrinstall/integrationtest/JcrinstallTestBase.java?rev=722885&r1=722884&r2=722885&view=diff
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/testing/src/test/java/org/apache/sling/jcr/jcrinstall/integrationtest/JcrinstallTestBase.java
(original)
+++ incubator/sling/trunk/extensions/jcrinstall/testing/src/test/java/org/apache/sling/jcr/jcrinstall/integrationtest/JcrinstallTestBase.java
Wed Dec  3 05:49:14 2008
@@ -31,14 +31,15 @@
 /** Base class for jcrinstall test cases */
 public class JcrinstallTestBase extends HttpTestBase {
 	
-	public static final int DEFAULT_BUNDLES_TIMEOUT = 10;
 	public static final String JCRINSTALL_STATUS_PATH = "/system/sling/jcrinstall";
 	public static final String DEFAULT_INSTALL_PATH = "/libs/jcrinstall/testing/install";
 	public static final String DEFAULT_BUNDLE_NAME_PATTERN = "observer";
 	private static long bundleCounter = System.currentTimeMillis();
 	private static Set<String> installedClones;
 	public static final String SCALE_FACTOR_PROP = "sling.test.scale.factor";
-	protected final int scaleFactor = Integer.getInteger(SCALE_FACTOR_PROP);
+	public static final String DEFAULT_TIMEOUT_PROP = "sling.test.bundles.wait.seconds";
+	protected int scaleFactor;
+	protected int defaultBundlesTimeout;
 	
     private class ShutdownThread extends Thread {
         @Override
@@ -58,16 +59,23 @@
     @Override
 	protected void setUp() throws Exception {
 		super.setUp();
-		
-		if(scaleFactor < 1) {
-			throw new IllegalArgumentException("scaleFactor < 1, " + SCALE_FACTOR_PROP + " system
property missing?");
-		}
+		scaleFactor = requireIntProperty(SCALE_FACTOR_PROP);
+		defaultBundlesTimeout = requireIntProperty(DEFAULT_TIMEOUT_PROP);
+    }
+    
+    protected int requireIntProperty(String systemPropertyKey) throws Exception {
+    	final String s = System.getProperty(systemPropertyKey);
+    	if(s == null) {
+    		throw new Exception("Missing system property '" + systemPropertyKey + "'");
+    	}
+    	return Integer.valueOf(s);
     }
     
     /** Fail test if active bundles count is not expectedCount, after 
      * 	at most timeoutSeconds */
     protected void assertActiveBundleCount(String message, int expectedCount, int timeoutSeconds)
throws IOException {
-    	final long timeout = System.currentTimeMillis() + timeoutSeconds * 1000L;
+    	final long start = System.currentTimeMillis();
+    	final long timeout = start + timeoutSeconds * 1000L;
     	int count = 0;
     	while(System.currentTimeMillis() < timeout) {
     		count = getActiveBundlesCount();
@@ -75,7 +83,9 @@
     			return;
     		}
     	}
-    	fail(message + ": expected " + expectedCount + " active bundles, found " + count);
+    	final long delta = System.currentTimeMillis() - start;
+    	fail(message + ": expected " + expectedCount + " active bundles, found " + count
+    			+ " after waiting " + delta / 1000.0 + " seconds");
     }
     
     protected int getActiveBundlesCount() throws IOException {



Mime
View raw message