garydgregory commented on a change in pull request #113: Tls improvements
URL: 
https://github.com/apache/httpcomponents-core/pull/113#discussion_r263998416
 
 

 ##########
 File path: 
httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicServerAndRequesterTest.java
 ##########
 @@ -37,48 +39,66 @@
 import org.apache.hc.core5.http.HttpHeaders;
 import org.apache.hc.core5.http.HttpHost;
 import org.apache.hc.core5.http.HttpStatus;
-import org.apache.hc.core5.http.io.SocketConfig;
+import org.apache.hc.core5.http.URIScheme;
 import org.apache.hc.core5.http.impl.bootstrap.HttpRequester;
 import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
 import org.apache.hc.core5.http.impl.bootstrap.RequesterBootstrap;
 import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.apache.hc.core5.http.impl.bootstrap.StandardFilters;
 import org.apache.hc.core5.http.io.HttpFilterChain;
 import org.apache.hc.core5.http.io.HttpFilterHandler;
+import org.apache.hc.core5.http.io.SocketConfig;
 import org.apache.hc.core5.http.io.entity.EntityUtils;
 import org.apache.hc.core5.http.io.entity.StringEntity;
 import org.apache.hc.core5.http.message.BasicClassicHttpRequest;
 import org.apache.hc.core5.http.protocol.HttpContext;
 import org.apache.hc.core5.http.protocol.HttpCoreContext;
 import org.apache.hc.core5.io.CloseMode;
+import org.apache.hc.core5.testing.SSLTestContexts;
 import org.apache.hc.core5.util.Timeout;
-import org.slf4j.LoggerFactory;
-import org.slf4j.Logger;
 import org.hamcrest.CoreMatchers;
 import org.junit.Assert;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExternalResource;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
+@RunWith(Parameterized.class)
 public class ClassicServerAndRequesterTest {
 
+    @Parameterized.Parameters(name = "{0}")
+    public static Collection<Object[]> protocols() {
+        return Arrays.asList(new Object[][]{
+                { URIScheme.HTTP },
+                { URIScheme.HTTPS }
+        });
+    }
+
     private static final Timeout TIMEOUT = Timeout.ofSeconds(30);
 
     private final Logger log = LoggerFactory.getLogger(getClass());
 
+    private final URIScheme scheme;
     private HttpServer server;
 
+    public ClassicServerAndRequesterTest(final URIScheme scheme) {
+        this.scheme = scheme;
+    }
+
     @Rule
     public ExternalResource serverResource = new ExternalResource() {
 
         @Override
         protected void before() throws Throwable {
             log.debug("Starting up test server");
             server = ServerBootstrap.bootstrap()
-                    .setSocketConfig(
-                            SocketConfig.custom()
-                                    .setSoTimeout(TIMEOUT)
-                                    .build())
+                    .setSslContext(scheme == URIScheme.HTTPS  ? 
SSLTestContexts.createServerSSLContext() : null)
 
 Review comment:
   Maybe refactor as `SSLTestContexts.createServerSSLContext(scheme)` to hide 
and reuse the ternary expression.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to