Пример #1
0
 @Test
 public void testScp2() throws IOException {
   try (DataInputStream dataInputStream = streamSimulator.getDataInputStream();
       DataOutputStream dataOutputStream = streamSimulator.getDataOutputStream()) {
     Protocol protocol = new Protocol(dataInputStream, dataOutputStream);
     protocol.scp(new HashMap<>(0));
     Assert.fail();
   } catch (ProtocolStateException ignored) {
   }
 }
Пример #2
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();
   }
 }