You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2013/05/13 17:24:13 UTC

svn commit: r1481915 - in /lucene/dev/branches/branch_4x: ./ dev-tools/maven/lucene/replicator/pom.xml.template lucene/ lucene/replicator/ lucene/replicator/src/test/org/apache/lucene/replicator/ReplicatorTestCase.java

Author: shaie
Date: Mon May 13 15:24:12 2013
New Revision: 1481915

URL: http://svn.apache.org/r1481915
Log:
make ReplicatorTestCase.newHttpServer respect tests.jettyConnector for freebsd issues

Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/dev-tools/maven/lucene/replicator/pom.xml.template
    lucene/dev/branches/branch_4x/lucene/   (props changed)
    lucene/dev/branches/branch_4x/lucene/replicator/   (props changed)
    lucene/dev/branches/branch_4x/lucene/replicator/src/test/org/apache/lucene/replicator/ReplicatorTestCase.java

Modified: lucene/dev/branches/branch_4x/dev-tools/maven/lucene/replicator/pom.xml.template
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/dev-tools/maven/lucene/replicator/pom.xml.template?rev=1481915&r1=1481914&r2=1481915&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/dev-tools/maven/lucene/replicator/pom.xml.template (original)
+++ lucene/dev/branches/branch_4x/dev-tools/maven/lucene/replicator/pom.xml.template Mon May 13 15:24:12 2013
@@ -59,8 +59,48 @@
       <artifactId>lucene-facet</artifactId>
       <version>${project.version}</version>
     </dependency>
+    <dependency>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <!-- HttpReplicator requires this dependency. -->
+      <exclusions>
+        <exclusion>
+          <groupId>commons-logging</groupId>
+          <artifactId>commons-logging</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-server</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-servlet</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-util</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>jcl-over-slf4j</artifactId>
+    </dependency>
   </dependencies>
   <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-surefire-plugin</artifactId>
+          <configuration>
+            <systemPropertyVariables>
+              <tests.jettyConnector>${tests.jettyConnector}</tests.jettyConnector>
+            </systemPropertyVariables>
+          </configuration>
+        </plugin>
+      </plugins>
+    </pluginManagement>
     <sourceDirectory>${module-path}/src/java</sourceDirectory>
     <testSourceDirectory>${module-path}/src/test</testSourceDirectory>
     <testResources>

Modified: lucene/dev/branches/branch_4x/lucene/replicator/src/test/org/apache/lucene/replicator/ReplicatorTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/replicator/src/test/org/apache/lucene/replicator/ReplicatorTestCase.java?rev=1481915&r1=1481914&r2=1481915&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/replicator/src/test/org/apache/lucene/replicator/ReplicatorTestCase.java (original)
+++ lucene/dev/branches/branch_4x/lucene/replicator/src/test/org/apache/lucene/replicator/ReplicatorTestCase.java Mon May 13 15:24:12 2013
@@ -18,6 +18,7 @@ package org.apache.lucene.replicator;
  */
 
 import java.net.SocketException;
+import java.util.Random;
 
 import org.apache.http.conn.ClientConnectionManager;
 import org.apache.http.impl.conn.PoolingClientConnectionManager;
@@ -26,6 +27,12 @@ import org.apache.lucene.util.LuceneTest
 import org.eclipse.jetty.server.Connector;
 import org.eclipse.jetty.server.Handler;
 import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.bio.SocketConnector;
+import org.eclipse.jetty.server.nio.SelectChannelConnector;
+import org.eclipse.jetty.server.session.HashSessionIdManager;
+import org.eclipse.jetty.server.ssl.SslSelectChannelConnector;
+import org.eclipse.jetty.server.ssl.SslSocketConnector;
+import org.eclipse.jetty.util.ssl.SslContextFactory;
 import org.eclipse.jetty.util.thread.QueuedThreadPool;
 import org.junit.AfterClass;
 
@@ -61,11 +68,68 @@ public abstract class ReplicatorTestCase
         
         server.setHandler(handler);
         
-        QueuedThreadPool threadPool = new QueuedThreadPool();
-        threadPool.setDaemon(true);
-        threadPool.setMaxIdleTimeMs(0);
-        server.setThreadPool(threadPool);
+        final String connectorName = System.getProperty("tests.jettyConnector", "SelectChannel");
+
+        // if this property is true, then jetty will be configured to use SSL
+        // leveraging the same system properties as java to specify
+        // the keystore/truststore if they are set
+        //
+        // This means we will use the same truststore, keystore (and keys) for
+        // the server as well as any client actions taken by this JVM in
+        // talking to that server, but for the purposes of testing that should 
+        // be good enough
+        final boolean useSsl = Boolean.getBoolean("tests.jettySsl");
+        final SslContextFactory sslcontext = new SslContextFactory(false);
+
+        if (useSsl) {
+          if (null != System.getProperty("javax.net.ssl.keyStore")) {
+            sslcontext.setKeyStorePath
+              (System.getProperty("javax.net.ssl.keyStore"));
+          }
+          if (null != System.getProperty("javax.net.ssl.keyStorePassword")) {
+            sslcontext.setKeyStorePassword
+              (System.getProperty("javax.net.ssl.keyStorePassword"));
+          }
+          if (null != System.getProperty("javax.net.ssl.trustStore")) {
+            sslcontext.setTrustStore
+              (System.getProperty("javax.net.ssl.trustStore"));
+          }
+          if (null != System.getProperty("javax.net.ssl.trustStorePassword")) {
+            sslcontext.setTrustStorePassword
+              (System.getProperty("javax.net.ssl.trustStorePassword"));
+          }
+          sslcontext.setNeedClientAuth(Boolean.getBoolean("tests.jettySsl.clientAuth"));
+        }
+
+        final Connector connector;
+        final QueuedThreadPool threadPool;
+        if ("SelectChannel".equals(connectorName)) {
+          final SelectChannelConnector c = useSsl ? new SslSelectChannelConnector(sslcontext) : new SelectChannelConnector();
+          c.setReuseAddress(true);
+          c.setLowResourcesMaxIdleTime(1500);
+          connector = c;
+          threadPool = (QueuedThreadPool) c.getThreadPool();
+        } else if ("Socket".equals(connectorName)) {
+          final SocketConnector c = useSsl ? new SslSocketConnector(sslcontext) : new SocketConnector();
+          c.setReuseAddress(true);
+          connector = c;
+          threadPool = (QueuedThreadPool) c.getThreadPool();
+        } else {
+          throw new IllegalArgumentException("Illegal value for system property 'tests.jettyConnector': " + connectorName);
+        }
+
+        connector.setPort(port);
+        connector.setHost("127.0.0.1");
+        if (threadPool != null) {
+          threadPool.setDaemon(true);
+          threadPool.setMaxThreads(10000);
+          threadPool.setMaxIdleTimeMs(5000);
+          threadPool.setMaxStopTimeMs(30000);
+        }
         
+        server.setConnectors(new Connector[] {connector});
+        server.setSessionIdManager(new HashSessionIdManager(new Random()));
+
         // this will test the port
         server.start();