@Test public void testGwa2() throws IOException { try (DataInputStream dataInputStream = streamSimulator.getDataInputStream(); DataOutputStream dataOutputStream = streamSimulator.getDataOutputStream()) { Protocol protocol = new Protocol(dataInputStream, dataOutputStream); protocol.gwa("test"); Assert.fail(); } catch (ProtocolStateException ignored) { } }
@Test public void testGwa1() throws IOException { try (DataInputStream dataInputStream = streamSimulator.getDataInputStream(); DataOutputStream dataOutputStream = streamSimulator.getDataOutputStream()) { Protocol protocol = new Protocol(dataInputStream, dataOutputStream); streamSimulator.writeForInputStream("ROK 1 9"); protocol.ayt(); streamSimulator.writeForInputStream("ROK 0 "); protocol.sco("test"); streamSimulator.writeForInputStream("ROK 13 crashed=false"); protocol.ctt(); streamSimulator.writeForInputStream("ROK 21 testvalue1,testvalue2"); ReceiveMessage receiveMessage = protocol.gwa("test"); Assert.assertEquals(receiveMessage.getCommand(), Command.ROK); Assert.assertEquals( receiveMessage.getBody(), "testvalue1,testvalue2".getBytes(StandardCharsets.UTF_8)); Assert.assertEquals( streamSimulator.readLastFromOutputStream(), "GWA 4 test".getBytes(StandardCharsets.UTF_8)); } catch (ProtocolStateException ignored) { Assert.fail(); } }