sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1595172 - in /sling/trunk/contrib/crankstart: core/src/test/java/org/apache/sling/crankstart/ core/src/test/resources/ launcher/src/main/java/org/apache/sling/crankstart/launcher/ launcher/src/test/java/org/apache/sling/crankstart/launcher...
Date Fri, 16 May 2014 12:15:24 GMT
Author: bdelacretaz
Date: Fri May 16 12:15:23 2014
New Revision: 1595172

URL: http://svn.apache.org/r1595172
Log:
Use variables in launcher test

Added:
    sling/trunk/contrib/crankstart/launcher/src/test/resources/
    sling/trunk/contrib/crankstart/launcher/src/test/resources/launcher-test.txt
Modified:
    sling/trunk/contrib/crankstart/core/src/test/java/org/apache/sling/crankstart/CrankstartParserImplTest.java
    sling/trunk/contrib/crankstart/core/src/test/resources/parser-test.txt
    sling/trunk/contrib/crankstart/launcher/src/main/java/org/apache/sling/crankstart/launcher/CrankstartBootstrap.java
    sling/trunk/contrib/crankstart/launcher/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java

Modified: sling/trunk/contrib/crankstart/core/src/test/java/org/apache/sling/crankstart/CrankstartParserImplTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/crankstart/core/src/test/java/org/apache/sling/crankstart/CrankstartParserImplTest.java?rev=1595172&r1=1595171&r2=1595172&view=diff
==============================================================================
--- sling/trunk/contrib/crankstart/core/src/test/java/org/apache/sling/crankstart/CrankstartParserImplTest.java
(original)
+++ sling/trunk/contrib/crankstart/core/src/test/java/org/apache/sling/crankstart/CrankstartParserImplTest.java
Fri May 16 12:15:23 2014
@@ -89,7 +89,7 @@ public class CrankstartParserImplTest {
         final String [] a = (String[])o;
         assertEquals("Expecting two entries in array", 2, a.length);
         assertEquals("Expecting correct first array value", "one that has a OK.VAR1_7 variable",
a[0]);
-        assertEquals("Expecting correct second array value", "two", a[1]);
+        assertEquals("Expecting correct second array value", "two has OK.ONE_6 and OK.OTHER_8
variables", a[1]);
         assertEquals("Expecting correct another value", "property with several words", props.get("another"));
         assertEquals("Expecting correct variable value", "This is OK.VARB_7 now", props.get("OK.VARA_7"));
         

Modified: sling/trunk/contrib/crankstart/core/src/test/resources/parser-test.txt
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/crankstart/core/src/test/resources/parser-test.txt?rev=1595172&r1=1595171&r2=1595172&view=diff
==============================================================================
--- sling/trunk/contrib/crankstart/core/src/test/resources/parser-test.txt (original)
+++ sling/trunk/contrib/crankstart/core/src/test/resources/parser-test.txt Fri May 16 12:15:23
2014
@@ -9,7 +9,7 @@ verb2 single_qualifier
 config the.pid.goes.here
   foo = bar
   array = one that has a ${ok.var1} variable
-  array = two
+  array = two has ${ok.one} and ${ok.other} variables
   another=property with several words
   ${ok.varA} = This is ${ok.varB} now 
 another command

Modified: sling/trunk/contrib/crankstart/launcher/src/main/java/org/apache/sling/crankstart/launcher/CrankstartBootstrap.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/crankstart/launcher/src/main/java/org/apache/sling/crankstart/launcher/CrankstartBootstrap.java?rev=1595172&r1=1595171&r2=1595172&view=diff
==============================================================================
--- sling/trunk/contrib/crankstart/launcher/src/main/java/org/apache/sling/crankstart/launcher/CrankstartBootstrap.java
(original)
+++ sling/trunk/contrib/crankstart/launcher/src/main/java/org/apache/sling/crankstart/launcher/CrankstartBootstrap.java
Fri May 16 12:15:23 2014
@@ -17,6 +17,7 @@
 package org.apache.sling.crankstart.launcher;
 
 import java.io.BufferedReader;
+import java.io.Closeable;
 import java.io.File;
 import java.io.FileReader;
 import java.io.FileWriter;
@@ -80,7 +81,9 @@ public class CrankstartBootstrap {
             final Callable<Object> c = (Callable<Object>)launcherClassloader.loadClass(callableClass).newInstance();
             c.call();
         } finally {
-            launcherClassloader.close();
+            if(launcherClassloader instanceof Closeable) {
+                ((Closeable)launcherClassloader).close();
+            }
             cleanup();
         }
     }

Modified: sling/trunk/contrib/crankstart/launcher/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/crankstart/launcher/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java?rev=1595172&r1=1595171&r2=1595172&view=diff
==============================================================================
--- sling/trunk/contrib/crankstart/launcher/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
(original)
+++ sling/trunk/contrib/crankstart/launcher/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java
Fri May 16 12:15:23 2014
@@ -1,11 +1,14 @@
 package org.apache.sling.crankstart.launcher;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
 
 import java.io.File;
 import java.io.IOException;
-import java.io.StringReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
 import java.net.ServerSocket;
 import java.util.Random;
 
@@ -28,6 +31,7 @@ public class CrankstartBootstrapTest {
     private static final HttpClient client = new HttpClient();
     private static Thread crankstartThread;
     private static String baseUrl = "http://localhost:" + port;
+    public static final String TEST_RESOURCE = "/launcher-test.txt";
             
     @Rule
     public final RetryRule retryRule = new RetryRule();
@@ -50,34 +54,15 @@ public class CrankstartBootstrapTest {
         return result;
     }
     
-    private final static String CRANKSTART = 
-        "classpath mvn:org.apache.felix/org.apache.felix.framework/4.4.0\n"
-        + "classpath mvn:org.slf4j/slf4j-api/1.6.2\n"
-        + "classpath mvn:org.ops4j.pax.url/pax-url-aether/1.6.0\n"
-        + "classpath mvn:org.ops4j.pax.url/pax-url-commons/1.6.0\n"
-        + "classpath mvn:org.apache.sling/org.apache.sling.crankstart.core/0.0.1-SNAPSHOT\n"
-        + "classpath mvn:org.apache.sling/org.apache.sling.crankstart.api/0.0.1-SNAPSHOT\n"
-        + "osgi.property org.osgi.service.http.port ${http.port}\n"
-        + "osgi.property org.osgi.framework.storage " + getOsgiStoragePath() + "\n"
-        + "start.framework\n"
-        + "bundle mvn:org.apache.felix/org.apache.felix.http.jetty/2.2.0\n"
-        + "bundle mvn:org.apache.felix/org.apache.felix.eventadmin/1.3.2\n"
-        + "bundle mvn:org.apache.felix/org.apache.felix.scr/1.8.2\n"
-        + "bundle mvn:org.apache.sling/org.apache.sling.commons.osgi/2.2.1-SNAPSHOT\n"
-        + "bundle mvn:org.apache.sling/org.apache.sling.commons.log/2.1.2\n"
-        + "bundle mvn:org.apache.sling/org.apache.sling.crankstart.test.services/0.0.1-SNAPSHOT\n"
-        + "bundle mvn:org.apache.felix/org.apache.felix.configadmin/1.6.0\n"
-        + "start.all.bundles\n"
-        + "config org.apache.sling.crankstart.testservices.SingleConfigServlet\n"
-        + "  path=/single\n"
-        + "  message=doesn't matter\n"
-        + "log felix http service should come up at http://localhost:${http.port}\n"
-    ;
-    
     @BeforeClass
     public static void setup() {
         final GetMethod get = new GetMethod(baseUrl);
         System.setProperty("http.port", String.valueOf(port));
+        System.setProperty("osgi.storage.path", getOsgiStoragePath());
+        
+        final InputStream is = CrankstartBootstrapTest.class.getResourceAsStream(TEST_RESOURCE);
+        assertNotNull("Expecting test resource to be found:" + TEST_RESOURCE, is);
+        final Reader input = new InputStreamReader(is);
         
         try {
             client.executeMethod(get);
@@ -88,9 +73,14 @@ public class CrankstartBootstrapTest {
         crankstartThread = new Thread() {
             public void run() {
                 try {
-                    new CrankstartBootstrap(new StringReader(CRANKSTART)).start();
+                    new CrankstartBootstrap(input).start();
                 } catch(Exception e) {
                     fail("CrankstartBootstrap exception:" + e);
+                } finally {
+                    try {
+                        input.close();
+                    } catch(IOException ignoreTheresNotMuchWeCanDoAnyway) {
+                    }
                 }
             }
         };

Added: sling/trunk/contrib/crankstart/launcher/src/test/resources/launcher-test.txt
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/crankstart/launcher/src/test/resources/launcher-test.txt?rev=1595172&view=auto
==============================================================================
--- sling/trunk/contrib/crankstart/launcher/src/test/resources/launcher-test.txt (added)
+++ sling/trunk/contrib/crankstart/launcher/src/test/resources/launcher-test.txt Fri May 16
12:15:23 2014
@@ -0,0 +1,39 @@
+# Test the crankstart launcher by setting up an HTTP
+# server with a few servlets that require specific OSGi configurations
+
+# Default values for our variables
+defaults pax.version 1.6.0
+defaults single.path /single
+
+# Bootstrap classpath
+classpath mvn:org.apache.felix/org.apache.felix.framework/4.4.0
+classpath mvn:org.slf4j/slf4j-api/1.6.2
+classpath mvn:org.ops4j.pax.url/pax-url-aether/${pax.version}
+classpath mvn:org.ops4j.pax.url/pax-url-commons/${pax.version}
+classpath mvn:org.apache.sling/org.apache.sling.crankstart.core/0.0.1-SNAPSHOT
+classpath mvn:org.apache.sling/org.apache.sling.crankstart.api/0.0.1-SNAPSHOT
+
+# OSGi properties
+osgi.property org.osgi.service.http.port ${http.port}
+osgi.property org.osgi.framework.storage ${osgi.storage.path}
+
+# Start the framework
+start.framework
+
+# Start ConfigAdmin, HTTP service and SCR
+bundle mvn:org.apache.felix/org.apache.felix.http.jetty/2.2.0
+bundle mvn:org.apache.felix/org.apache.felix.eventadmin/1.3.2
+bundle mvn:org.apache.felix/org.apache.felix.scr/1.8.2
+bundle mvn:org.apache.sling/org.apache.sling.commons.osgi/2.2.1-SNAPSHOT
+bundle mvn:org.apache.sling/org.apache.sling.commons.log/2.1.2
+bundle mvn:org.apache.sling/org.apache.sling.crankstart.test.services/0.0.1-SNAPSHOT
+bundle mvn:org.apache.felix/org.apache.felix.configadmin/1.6.0
+start.all.bundles
+
+# OSGi configs that activate our test servlets
+config org.apache.sling.crankstart.testservices.SingleConfigServlet
+  path=${single.path}
+  message=doesn't matter
+
+# Informative log  
+log felix http service should come up at http://localhost:${http.port}



Mime
View raw message