Skip to content

Commit

Permalink
[network] DHCPTest.java (openhab#5726)
Browse files Browse the repository at this point in the history
In maven the tests tends to fail, so by using an assume we can disable it automaticly if the precondition does not hold.

Signed-off-by: Martin van Wingerden <martin@martinvw.nl>
Signed-off-by: Tim Roberts <timmarkroberts@gmail.com>
  • Loading branch information
martinvw authored and tmrobert8 committed Jan 21, 2020
1 parent 9b3a218 commit 90881f5
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;
import static org.junit.Assume.assumeTrue;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*;

Expand All @@ -34,7 +35,9 @@ public class DHCPTest {
public void testService() throws SocketException {
String testIP = "10.1.2.3";
IPRequestReceivedCallback dhcpListener = mock(IPRequestReceivedCallback.class);
assertThat(DHCPListenService.instance, is(nullValue()));

// if this is not the case this test is not very useful, we don't always have the static field under control.
assumeTrue(DHCPListenService.instance == null);
DHCPListenService.register(testIP, dhcpListener);
assertThat(DHCPListenService.instance, is(notNullValue()));
DHCPListenService.unregister(testIP);
Expand Down

0 comments on commit 90881f5

Please sign in to comment.