|
@@ -18,6 +18,9 @@
|
|
|
|
|
|
package org.apache.hadoop.yarn.webapp;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
+
|
|
|
+import org.apache.hadoop.net.ServerSocketUtil;
|
|
|
import org.junit.Before;
|
|
|
import com.sun.jersey.test.framework.JerseyTest;
|
|
|
import com.sun.jersey.test.framework.WebAppDescriptor;
|
|
@@ -28,15 +31,8 @@ public abstract class JerseyTestBase extends JerseyTest {
|
|
|
}
|
|
|
|
|
|
@Before
|
|
|
- public void initializeJerseyPort() {
|
|
|
- int jerseyPort = 9998;
|
|
|
- String port = System.getProperty("jersey.test.port");
|
|
|
- if(null != port) {
|
|
|
- jerseyPort = Integer.parseInt(port) + 10;
|
|
|
- if(jerseyPort > 65535) {
|
|
|
- jerseyPort = 9998;
|
|
|
- }
|
|
|
- }
|
|
|
+ public void initializeJerseyPort() throws IOException {
|
|
|
+ int jerseyPort = ServerSocketUtil.getPort(9998, 10);
|
|
|
System.setProperty("jersey.test.port", Integer.toString(jerseyPort));
|
|
|
}
|
|
|
}
|