public void testHttpRequestNotOK() throws Exception { server.enqueue(new MockResponse().setStatus("HTTP/1.1 401 Unauthorized")); server.start(); // reflectBaseUrl(); BusData response = collector.getBusData(testTime, Sensor.At_Stop); assertTrue(response != null); }
public void testEmptyResponse() throws Exception { server.enqueue(new MockResponse().setBody("[]")); server.start(); // reflectBaseUrl(); BusData response = collector.getBusData(testTime, Sensor.Ambient_Temperature); assertEquals(response.getSensor(), Sensor.UNKNOWN); }
/** * Run before every test. Chooses a vin number and makes the server speak https. * * @throws Exception */ @Override public void setUp() throws Exception { super.setUp(); server = new MockWebServer(); server.useHttps((SSLSocketFactory) SSLSocketFactory.getDefault(), true); collector.chooseBus("Ericsson$Vin_Num_001"); }
/** * ************************************************************************************************************** * THE TESTS TODO: Currently the mocking has problems with the https handshake so the test are * perform on live data. When this issue is fixed uncoment the reflectBaseUrl call to test on the * mock server. * * <p>************************************************************************************************************** */ public void testBusDataStamped() throws Exception { BusData response = collector.getBusData(testTime, Sensor.At_Stop); assertTrue(response.getTimestamp() == 1443513325166l); }