lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sar...@apache.org
Subject [2/2] lucene-solr:branch_6_0: SOLR-9028: Fix 2 SSL test related bugs...
Date Fri, 20 May 2016 19:57:46 GMT
SOLR-9028: Fix 2 SSL test related bugs...

1) SolrTestCaseJ4 should always reset the HttpClientConfigurer in afterClass, regardless of
wether ssl was used
   (when SSL is not used, the active configurer explicitly excludes SSL)
2) HttpClientUtilTest.testSSLSystemProperties made no sense as written.  setSSLSystemProperties()
didn't have any
   effect on what was being tested, even if it was useful it would only have affected what
keystore/truststore were
   used, not wether HTTPS was supported or not.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/fdd8d17a
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/fdd8d17a
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/fdd8d17a

Branch: refs/heads/branch_6_0
Commit: fdd8d17af4e78ebb65159d74c5cb7a7d46bc2f80
Parents: 9645d42
Author: Chris Hostetter <hossman@apache.org>
Authored: Sat Apr 30 22:22:09 2016 -0700
Committer: Steve Rowe <sarowe@apache.org>
Committed: Fri May 20 15:57:19 2016 -0400

----------------------------------------------------------------------
 .../solr/client/solrj/impl/HttpClientUtilTest.java   | 15 ++++++++++-----
 .../src/java/org/apache/solr/SolrTestCaseJ4.java     |  4 +---
 2 files changed, 11 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fdd8d17a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpClientUtilTest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpClientUtilTest.java
b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpClientUtilTest.java
index c881b7a..ba8b8f4 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpClientUtilTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpClientUtilTest.java
@@ -23,6 +23,8 @@ import static org.junit.Assert.assertTrue;
 import java.io.IOException;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import org.apache.lucene.util.LuceneTestCase;
+
 import org.apache.http.auth.AuthScope;
 import org.apache.http.client.config.AuthSchemes;
 import org.apache.http.client.HttpClient;
@@ -40,8 +42,9 @@ import org.apache.solr.common.params.ModifiableSolrParams;
 import org.apache.solr.common.params.SolrParams;
 import org.apache.solr.util.SSLTestConfig;
 import org.junit.Test;
+import org.junit.Assume;
 
-public class HttpClientUtilTest {
+public class HttpClientUtilTest extends LuceneTestCase {
 
   @Test
   public void testNoParamsSucceeds() throws IOException {
@@ -121,11 +124,14 @@ public class HttpClientUtilTest {
   @Test
   @SuppressWarnings("deprecation")
   public void testSSLSystemProperties() throws IOException {
+    HttpClientUtil.setConfigurer(new HttpClientConfigurer());
     CloseableHttpClient client = HttpClientUtil.createClient(null);
     try {
-      SSLTestConfig.setSSLSystemProperties();
-      assertNotNull("HTTPS scheme could not be created using the javax.net.ssl.* system properties.",

-          client.getConnectionManager().getSchemeRegistry().get("https"));
+      // We could use SSLContext.setDefault to *ensure* that SSL is supported by default,
+      // but if the platform default doesn't already support it, something is seriously wonky
+      // with the JVM, so let's not push our luck
+      Assume.assumeNotNull("HTTPS scheme could not be created using JVM/Configurer defaults",

+                           client.getConnectionManager().getSchemeRegistry().get("https"));
       
       System.clearProperty(HttpClientUtil.SYS_PROP_CHECK_PEER_NAME);
       client.close();
@@ -147,7 +153,6 @@ public class HttpClientUtilTest {
       client = HttpClientUtil.createClient(null);
       assertEquals(AllowAllHostnameVerifier.class, getHostnameVerifier(client).getClass());
     } finally {
-      SSLTestConfig.clearSSLSystemProperties();
       System.clearProperty(HttpClientUtil.SYS_PROP_CHECK_PEER_NAME);
       client.close();
     }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fdd8d17a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
----------------------------------------------------------------------
diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
index a377d77..578f2e3 100644
--- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
+++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
@@ -269,9 +269,7 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
       System.clearProperty("useCompoundFile");
       System.clearProperty("urlScheme");
       
-      if (isSSLMode()) {
-        HttpClientUtil.setConfigurer(new HttpClientConfigurer());
-      }
+      HttpClientUtil.setConfigurer(new HttpClientConfigurer());
 
       // clean up static
       sslConfig = null;


Mime
View raw message