@Test public void testOngoingConversation() throws Exception { String messageString = "123456\n379"; setupProtcolWithMessageAndExitToken(messageString, "dont call exit"); assertEquals( "123456", protocol.readMessage()); assertEquals( "379", protocol.readMessage()); assertTrue(!protocol.isEndOfConversation()); }
@Override public String readMessage() throws IOException { StringBuilder sb = new StringBuilder(); boolean endOfRead = false; while (!endOfRead) { char charRead = readCharacter(); if (charRead == recordTerminator || charRead == EOF) { endOfRead = true; } else { sb.append(charRead); } } String message = sb.toString(); if (message.equals(endToken)) { setEndOfConversation( true ); return null; } return message; }
AbstractCharacterTerminatedMessageProtocol extends AbstractMessageProtocol { @Override public String readMessage() throws IOException { StringBuilder sb = new StringBuilder(); boolean endOfRead = false; while (!endOfRead) { char charRead = readCharacter(); if (charRead == recordTerminator || charRead == EOF) { endOfRead = true; } else { sb.append(charRead); } } String message = sb.toString(); if (message.equals(endToken)) { setEndOfConversation( true ); return null; } return message; } }
AbstractCharacterTerminatedMessageProtocol extends AbstractMessageProtocol { @Override public String readMessage() throws IOException { StringBuilder sb = new StringBuilder(); boolean endOfRead = false; while (!endOfRead) { char charRead = readCharacter(); if (charRead == recordTerminator || charRead == EOF) { endOfRead = true; } else { sb.append(charRead); } } String message = sb.toString(); if (message.equals(endToken)) { setEndOfConversation( true ); return null; } return message; } AbstractCharacterTerminatedMessageProtocol(Socket socket, char recordTerminator); }
AbstractCharacterTerminatedMessageProtocol extends AbstractMessageProtocol { @Override public String readMessage() throws IOException { StringBuilder sb = new StringBuilder(); boolean endOfRead = false; while (!endOfRead) { char charRead = readCharacter(); if (charRead == recordTerminator || charRead == EOF) { endOfRead = true; } else { sb.append(charRead); } } String message = sb.toString(); if (message.equals(endToken)) { setEndOfConversation( true ); return null; } return message; } AbstractCharacterTerminatedMessageProtocol(Socket socket, char recordTerminator); boolean clientSendsToken(); @Override String readMessage(); }
AbstractCharacterTerminatedMessageProtocol extends AbstractMessageProtocol { @Override public String readMessage() throws IOException { StringBuilder sb = new StringBuilder(); boolean endOfRead = false; while (!endOfRead) { char charRead = readCharacter(); if (charRead == recordTerminator || charRead == EOF) { endOfRead = true; } else { sb.append(charRead); } } String message = sb.toString(); if (message.equals(endToken)) { setEndOfConversation( true ); return null; } return message; } AbstractCharacterTerminatedMessageProtocol(Socket socket, char recordTerminator); boolean clientSendsToken(); @Override String readMessage();  }