Refactor: Using FakeAdbServer in unit tests.

This commit is contained in:
Samuel Carlsson 2014-03-20 17:04:46 +01:00
parent aecd17a446
commit 1ff8504e3d
2 changed files with 30 additions and 2 deletions

View File

@ -8,17 +8,18 @@ import se.vidstige.jadb.JadbConnection;
import se.vidstige.jadb.JadbDevice;
import se.vidstige.jadb.server.AdbServer;
import se.vidstige.jadb.server.SocketServer;
import se.vidstige.jadb.test.fakes.FakeAdbServer;
import java.util.List;
public class MockedTestCases {
private SocketServer server;
private FakeAdbServer server;
private JadbConnection connection;
@Before
public void setUp() throws Exception{
server = new AdbServer(15037);
server = new FakeAdbServer(15037);
server.start();
connection = new JadbConnection("localhost", 15037);
}

View File

@ -0,0 +1,27 @@
package se.vidstige.jadb.test.fakes;
import se.vidstige.jadb.server.AdbDeviceResponder;
import se.vidstige.jadb.server.AdbResponder;
import se.vidstige.jadb.server.AdbServer;
import java.io.IOException;
/**
* Created by vidstige on 2014-03-20.
*/
public class FakeAdbServer implements AdbResponder, AdbDeviceResponder {
private final AdbServer server;
public FakeAdbServer(int port) {
server = new AdbServer(port);
}
public void start() throws InterruptedException {
server.start();
}
public void stop() throws IOException, InterruptedException {
server.stop();
}
}