Specifying port explicitly in unit tests.

This commit is contained in:
Samuel Carlsson
2014-03-20 10:37:12 +01:00
parent dbe57d0279
commit 06c62dca59
2 changed files with 12 additions and 2 deletions

View File

@ -17,7 +17,7 @@ public class MockedTestCases {
@Before
public void setUp() throws Exception{
server = new AdbServer();
server = new AdbServer(15037);
server.start();
connection = new JadbConnection("localhost", 15037);
}

View File

@ -7,7 +7,8 @@ import java.net.Socket;
// >set ANDROID_ADB_SERVER_PORT=15037
public class AdbServer implements Runnable {
private int port = 15037;
private static final int DEFAULT_PORT = 15037;
private final int port;
private ServerSocket socket;
private Thread thread;
private final Object lockObject = new Object();
@ -17,6 +18,15 @@ public class AdbServer implements Runnable {
AdbServer server = new AdbServer();
server.run();
}
public AdbServer()
{
this(DEFAULT_PORT);
}
public AdbServer(int port)
{
this.port = port;
}
public void start() throws InterruptedException
{