@Test public void wifiConnectThreadStartTest() throws Exception { WiFiConnection wifi = createMock(WiFiConnection.class); NavData navData = new NavData(); PacketDemo packetDemo = new PacketDemo(); mockStatic(Tools.class); wifi.connect(); expectLastCall(); expect(Tools.get_state_bit(navData.drone_state, 6)).andReturn(false); wifi.sendAtCommand("AT*CONFIG=#SEQ#,\"custom:session_id\",\"ca0000d1\""); expectLastCall(); expect(Tools.get_state_bit(navData.drone_state, 6)).andReturn(true); wifi.sendAtCommand("AT*CTRL=#SEQ#,5,0"); expectLastCall(); expect(wifi.isRunning()).andReturn(true).anyTimes(); // wifi.setRunning(false); // expectLastCall(); replayAll(); Drone drone = Drone.getInstance(); Whitebox.setInternalState(drone, "wifi", wifi); Whitebox.setInternalState(navData, "drone_state", 0); Whitebox.setInternalState(drone, "navData", navData); drone.connect(); // Thread.sleep(500); ThreadNavData threadNavData = Whitebox.getInternalState(drone, "threadNavData"); ThreadCmd threadCmd = Whitebox.getInternalState(drone, "threadCmd"); // threadNavData.stop(); assertFalse("Drone.threadCmd is in state NEW", threadCmd.getState() == Thread.State.NEW); assertFalse( "Drone.threadCmd is in state TERMINATED", threadCmd.getState() == Thread.State.TERMINATED); assertFalse( "Drone.threadNavData is in state NEW", threadNavData.getState() == Thread.State.NEW); assertFalse( "Drone.threadNavData is in state TERMINATED", threadNavData.getState() == Thread.State.TERMINATED); threadCmd.stop(); threadNavData.stop(); verifyAll(); }