diff --git a/core/src/test/java/edu/wpi/grip/core/operations/network/MockGripNetworkModule.java b/core/src/test/java/edu/wpi/grip/core/operations/network/MockGripNetworkModule.java index afa34b3907..1aac03e77c 100644 --- a/core/src/test/java/edu/wpi/grip/core/operations/network/MockGripNetworkModule.java +++ b/core/src/test/java/edu/wpi/grip/core/operations/network/MockGripNetworkModule.java @@ -1,6 +1,5 @@ package edu.wpi.grip.core.operations.network; -import edu.wpi.grip.core.operations.network.networktables.TestingNTManager; import edu.wpi.grip.core.operations.network.ros.MockROSManager; import edu.wpi.grip.core.operations.network.ros.ROSNetworkPublisherFactory; @@ -25,6 +24,6 @@ protected void configure() { bind(MapNetworkReceiverFactory.class) .annotatedWith(Names.named("ntManager")) - .to(TestingNTManager.class); + .to(MockNetworkReceiver.class); } } diff --git a/core/src/test/java/edu/wpi/grip/core/operations/network/MockNetworkReceiver.java b/core/src/test/java/edu/wpi/grip/core/operations/network/MockNetworkReceiver.java new file mode 100644 index 0000000000..6d90778633 --- /dev/null +++ b/core/src/test/java/edu/wpi/grip/core/operations/network/MockNetworkReceiver.java @@ -0,0 +1,9 @@ +package edu.wpi.grip.core.operations.network; + +public class MockNetworkReceiver implements MapNetworkReceiverFactory { + + @Override + public NetworkReceiver create(String path) { + return null; + } +} diff --git a/core/src/test/java/edu/wpi/grip/core/operations/network/networktables/TestingNTManager.java b/core/src/test/java/edu/wpi/grip/core/operations/network/networktables/TestingNTManager.java index 558f78b410..0afd6aa860 100644 --- a/core/src/test/java/edu/wpi/grip/core/operations/network/networktables/TestingNTManager.java +++ b/core/src/test/java/edu/wpi/grip/core/operations/network/networktables/TestingNTManager.java @@ -12,7 +12,7 @@ * This class encapsulates the way we map various settings to the global NetworkTables state. */ @Singleton -public class TestingNTManager extends NTManager { +public class TestingNTManager extends NTManager implements AutoCloseable { private static final Logger logger = Logger.getLogger(TestingNTManager.class.getName()); @@ -33,4 +33,9 @@ public TestingNTManager() { NetworkTable.initialize(); } + @Override + public void close() { + NetworkTable.shutdown(); + } + } diff --git a/core/src/test/java/edu/wpi/grip/core/sources/NetworkTableEntrySourceTest.java b/core/src/test/java/edu/wpi/grip/core/sources/NetworkTableEntrySourceTest.java index a09426937e..e8d8eef4b3 100644 --- a/core/src/test/java/edu/wpi/grip/core/sources/NetworkTableEntrySourceTest.java +++ b/core/src/test/java/edu/wpi/grip/core/sources/NetworkTableEntrySourceTest.java @@ -10,6 +10,7 @@ import edu.wpi.first.wpilibj.networktables.NetworkTablesJNI; import org.junit.After; +import org.junit.Before; import org.junit.Test; import static org.junit.Assert.assertEquals; @@ -20,9 +21,9 @@ public class NetworkTableEntrySourceTest { private final EventBus eventBus; private final MockOutputSocketFactory osf; - private final TestingNTManager testingNtManager; private NetworkTableEntrySource source; + private TestingNTManager testingNtManager; private static final double TEST_NUMBER = 13.13; private static final String TEST_STRING = "Some test string"; @@ -33,6 +34,10 @@ public class NetworkTableEntrySourceTest { public NetworkTableEntrySourceTest() { eventBus = new EventBus(); osf = new MockOutputSocketFactory(eventBus); + } + + @Before + public void setUp() { testingNtManager = new TestingNTManager(); NetworkTablesJNI.putBoolean(BOOLEAN_PATH, true); @@ -41,8 +46,9 @@ public NetworkTableEntrySourceTest() { } @After - public void cleanup() { + public void tearDown() { eventBus.post(new SourceRemovedEvent(source)); + testingNtManager.close(); } @Test