sebastian-nagel commented on code in PR #870:
URL: https://github.com/apache/nutch/pull/870#discussion_r2571801576


##########
build.xml:
##########
@@ -86,6 +86,10 @@
     <ivy:dependencytree />
   </target>
 
+  <target name="dependencytests" depends="resolve-test" description="Show unit 
tests dependency tree">

Review Comment:
   +1



##########
src/plugin/protocol-http/src/test/org/apache/nutch/protocol/http/TestProtocolHttpByProxy.java:
##########
@@ -30,26 +31,43 @@
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
+import java.io.IOException;
+import java.net.ServerSocket;
+
 /**
  * Test cases for protocol-http by proxy
  */
 public class TestProtocolHttpByProxy extends AbstractHttpProtocolPluginTest {
 
   public static final String PROXY_HOST = "localhost";
-  public static final Integer PROXY_PORT = 8888;
+  public Integer proxyPort = 8888;
 
   public static final String TARGET_HOST = "www.baidu.com";
   public static final Integer TARGET_PORT = 443;
+  
+  private HttpProxyServer server;
 
   @BeforeEach
   public void setUp() throws Exception {
     super.setUp();
+    proxyPort = findOpenPort();
     conf.set("http.proxy.host", PROXY_HOST);
-    conf.set("http.proxy.port", PROXY_PORT.toString());
+    conf.set("http.proxy.port", proxyPort.toString());
     http.setConf(conf);
 
-    HttpProxyServer server = DefaultHttpProxyServer.bootstrap()
-        .withPort(PROXY_PORT).start();
+    server = DefaultHttpProxyServer.bootstrap()
+        .withPort(proxyPort).start();
+  }
+  
+  private Integer findOpenPort() throws IOException {

Review Comment:
   Great! This was an annoying issue, the protocol tests failing randomly from 
time to time because the port was occupied.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to