jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1378923 - in /jackrabbit/oak/trunk/oak-run: pom.xml src/main/java/org/apache/jackrabbit/oak/run/Main.java src/test/java/org/apache/jackrabbit/oak/run/BasicServerTest.java
Date Thu, 30 Aug 2012 13:22:49 GMT
Author: mreutegg
Date: Thu Aug 30 13:22:48 2012
New Revision: 1378923

URL: http://svn.apache.org/viewvc?rev=1378923&view=rev
Log:
OAK-282: Use random port in oak-run tests

Modified:
    jackrabbit/oak/trunk/oak-run/pom.xml
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java
    jackrabbit/oak/trunk/oak-run/src/test/java/org/apache/jackrabbit/oak/run/BasicServerTest.java

Modified: jackrabbit/oak/trunk/oak-run/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/pom.xml?rev=1378923&r1=1378922&r2=1378923&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-run/pom.xml Thu Aug 30 13:22:48 2012
@@ -73,6 +73,33 @@
           </execution>
         </executions>
       </plugin>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+        <version>1.7</version>
+        <executions>
+          <execution>
+            <id>reserve-network-port</id>
+            <goals>
+                <goal>reserve-network-port</goal>
+            </goals>
+            <phase>process-resources</phase>
+            <configuration>
+              <portNames>
+                <portName>jetty.http.port</portName>
+              </portNames>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <systemPropertyVariables>
+            <jetty.http.port>${jetty.http.port}</jetty.http.port>
+          </systemPropertyVariables>
+        </configuration>
+      </plugin>
     </plugins>
   </build>
 

Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java?rev=1378923&r1=1378922&r2=1378923&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java (original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java Thu
Aug 30 13:22:48 2012
@@ -105,17 +105,23 @@ public class Main {
         private final MicroKernel[] kernels;
 
         public HttpServer(String uri, String[] args) {
+            int port = java.net.URI.create(uri).getPort();
+            if (port == -1) {
+                // use default
+                port = PORT;
+            }
+
             context = new ServletContextHandler(ServletContextHandler.SECURITY);
             context.setContextPath("/");
 
             if (args.length == 0) {
                 System.out.println("Starting an in-memory repository");
-                System.out.println(URI + " -> [memory]");
+                System.out.println(uri + " -> [memory]");
                 kernels = new MicroKernel[] { new MicroKernelImpl() };
                 addServlets(kernels[0], "");
             } else if (args.length == 1) {
                 System.out.println("Starting a standalone repository");
-                System.out.println(URI + " -> " + args[0]);
+                System.out.println(uri + " -> " + args[0]);
                 kernels = new MicroKernel[] { new MicroKernelImpl(args[0]) };
                 addServlets(kernels[0], "");
             } else {
@@ -123,13 +129,13 @@ public class Main {
                 kernels = new MicroKernel[args.length];
                 for (int i = 0; i < args.length; i++) {
                     // FIXME: Use a clustered MicroKernel implementation
-                    System.out.println(URI + "/node" + i + "/ -> " + args[i]);
+                    System.out.println(uri + "/node" + i + "/ -> " + args[i]);
                     kernels[i] = new MicroKernelImpl(args[i]);
                     addServlets(kernels[i], "/node" + i);
                 }
             }
 
-            server = new Server(PORT);
+            server = new Server(port);
             server.setHandler(context);
         }
 

Modified: jackrabbit/oak/trunk/oak-run/src/test/java/org/apache/jackrabbit/oak/run/BasicServerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/test/java/org/apache/jackrabbit/oak/run/BasicServerTest.java?rev=1378923&r1=1378922&r2=1378923&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/test/java/org/apache/jackrabbit/oak/run/BasicServerTest.java
(original)
+++ jackrabbit/oak/trunk/oak-run/src/test/java/org/apache/jackrabbit/oak/run/BasicServerTest.java
Thu Aug 30 13:22:48 2012
@@ -29,11 +29,22 @@ import static org.junit.Assert.assertEqu
 
 public class BasicServerTest {
 
+    private static final String SERVER_URL;
+
+    static {
+        String p = System.getProperty("jetty.http.port");
+        if (p != null) {
+            SERVER_URL = "http://localhost:" + p + "/";
+        } else {
+            SERVER_URL = Main.URI;
+        }
+    }
+
     private Main.HttpServer server;
 
     @Before
     public void startServer() throws Exception {
-        server = new Main.HttpServer(Main.URI, new String[0]);
+        server = new Main.HttpServer(SERVER_URL, new String[0]);
         server.start();
     }
 
@@ -45,7 +56,7 @@ public class BasicServerTest {
     @Test
     public void testServerOk() throws Exception {
 
-        URL server = new URL(Main.URI);
+        URL server = new URL(SERVER_URL);
         HttpURLConnection conn = (HttpURLConnection) server.openConnection();
         conn.setRequestProperty("Authorization",
                 "Basic " + Base64.encode("a:a"));



Mime
View raw message