From e93bdb165855c00bbdc6f5861d1e328d9454975f Mon Sep 17 00:00:00 2001 From: Samuel Carlsson Date: Wed, 26 Mar 2014 10:09:31 +0100 Subject: [PATCH] Asserting no unexpected pushes where sent. --- test/se/vidstige/jadb/test/MockedTestCases.java | 1 + test/se/vidstige/jadb/test/fakes/FakeAdbServer.java | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/test/se/vidstige/jadb/test/MockedTestCases.java b/test/se/vidstige/jadb/test/MockedTestCases.java index 0758434..99bbb94 100644 --- a/test/se/vidstige/jadb/test/MockedTestCases.java +++ b/test/se/vidstige/jadb/test/MockedTestCases.java @@ -31,6 +31,7 @@ public class MockedTestCases { public void tearDown() throws Exception { connection.close(); server.stop(); + server.verifyExpectations(); } @Test diff --git a/test/se/vidstige/jadb/test/fakes/FakeAdbServer.java b/test/se/vidstige/jadb/test/fakes/FakeAdbServer.java index 8a91c6d..7b34f65 100644 --- a/test/se/vidstige/jadb/test/fakes/FakeAdbServer.java +++ b/test/se/vidstige/jadb/test/fakes/FakeAdbServer.java @@ -47,6 +47,10 @@ public class FakeAdbServer implements AdbResponder { devices.add(new DeviceResponder(serial)); } + public void verifyExpectations() { + org.junit.Assert.assertEquals(0, remoteFileExpectations.size()); + } + private static class RemoteFileExpectation { private final String serial; @@ -83,7 +87,7 @@ public class FakeAdbServer implements AdbResponder { } } - private List _remoteFileExpectations = new ArrayList(); + private List remoteFileExpectations = new ArrayList(); public void expectPush(String serial, RemoteFile path, String contents){ expectPush(serial, path, contents.getBytes(Charset.forName("UTF-8"))); @@ -91,11 +95,11 @@ public class FakeAdbServer implements AdbResponder { public void expectPush(String serial, RemoteFile path, byte[] contents) { - _remoteFileExpectations.add(new RemoteFileExpectation(serial, path, contents)); + remoteFileExpectations.add(new RemoteFileExpectation(serial, path, contents)); } private void filePushed(String serial, RemoteFile path, byte[] contents) { - boolean removed = _remoteFileExpectations.remove(new RemoteFileExpectation(serial, path, contents)); + boolean removed = remoteFileExpectations.remove(new RemoteFileExpectation(serial, path, contents)); if (!removed) throw new RuntimeException("Unexpected push to device " + serial + " at " + path.getPath()); }