Exemplo n.º 1
0
 @Test
 public void testGco2() throws IOException {
   try (DataInputStream dataInputStream = streamSimulator.getDataInputStream();
       DataOutputStream dataOutputStream = streamSimulator.getDataOutputStream()) {
     Protocol protocol = new Protocol(dataInputStream, dataOutputStream);
     protocol.gco();
     Assert.fail();
   } catch (ProtocolStateException ignored) {
   }
 }
Exemplo n.º 2
0
 @Test
 public void testAyt2() 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 1 9");
     protocol.ayt();
     Assert.fail();
   } catch (ProtocolStateException ignored) {
   }
 }
Exemplo n.º 3
0
 @Test
 public void testCtf1() 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 0 ");
     protocol.swa("test");
     streamSimulator.writeForInputStream("ROK 13 crashed=false");
     ReceiveMessage receiveMessage = protocol.ctf("abc123".getBytes(StandardCharsets.UTF_8));
     Assert.assertEquals(receiveMessage.getCommand(), Command.ROK);
     Assert.assertEquals(
         receiveMessage.getBody(), "crashed=false".getBytes(StandardCharsets.UTF_8));
     Assert.assertEquals(
         streamSimulator.readLastFromOutputStream(),
         "CTF 6 abc123".getBytes(StandardCharsets.UTF_8));
   } catch (ProtocolStateException ignored) {
     Assert.fail();
   }
 }
Exemplo n.º 4
0
 @Test
 public void testAyt1() throws IOException {
   try (DataInputStream dataInputStream = streamSimulator.getDataInputStream();
       DataOutputStream dataOutputStream = streamSimulator.getDataOutputStream()) {
     Protocol protocol = new Protocol(dataInputStream, dataOutputStream);
     streamSimulator.writeForInputStream("ROK 1 9");
     ReceiveMessage receiveMessage = protocol.ayt();
     Assert.assertEquals(receiveMessage.getCommand(), Command.ROK);
     Assert.assertEquals(
         receiveMessage.getBody(), String.valueOf(9).getBytes(StandardCharsets.UTF_8));
     Assert.assertEquals(
         streamSimulator.readLastFromOutputStream(), "AYT 0 ".getBytes(StandardCharsets.UTF_8));
   } catch (ProtocolStateException ignored) {
     Assert.fail();
   }
 }
Exemplo n.º 5
0
 @Test
 public void testScp1() 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 0 ");
     Map<String, String> parameter = new HashMap<>(1);
     parameter.put("testkey1", "testvalue1");
     parameter.put("testkey2", "testvalue2");
     ReceiveMessage receiveMessage = protocol.scp(parameter);
     Assert.assertEquals(receiveMessage.getCommand(), Command.ROK);
     Assert.assertEquals(receiveMessage.getBody(), BYTES);
     Assert.assertEquals(
         streamSimulator.readLastFromOutputStream(),
         ("SCP 39 testkey2=testvalue2," + "testkey1=testvalue1").getBytes(StandardCharsets.UTF_8));
   } catch (ProtocolStateException ignored) {
     Assert.fail();
   }
 }
Exemplo n.º 6
0
 @AfterMethod
 public void tearDown() throws IOException {
   streamSimulator.exit();
 }
Exemplo n.º 7
0
 @BeforeMethod
 public void setUp() throws IOException {
   streamSimulator = new StreamSimulator();
   streamSimulator.init();
 }