@Test public void testUnsubscribe() throws IOException { OutputStream outputStream = mock(OutputStream.class); Socket socket = mock(Socket.class ); when(socket.getOutputStream()).thenReturn(outputStream); PubSubConnection connection = new PubSubConnection(socket); connection.unsubscribe("bazbar"); ArgumentCaptor<byte[]> captor = ArgumentCaptor.forClass(byte[].class); verify(outputStream).write(captor.capture()); assertArrayEquals(captor.getValue(), "UNSUBSCRIBE bazbar\r\n".getBytes()); }
public void unsubscribe(String channelName) throws IOException { if (closed.get()) throw new IOException("Connection closed!"); byte[] command = Util.combine(UNSUBSCRIBE_COMMAND, channelName.getBytes(), CRLF); outputStream.write(command); }
PubSubConnection { public void unsubscribe(String channelName) throws IOException { if (closed.get()) throw new IOException("Connection closed!"); byte[] command = Util.combine(UNSUBSCRIBE_COMMAND, channelName.getBytes(), CRLF); outputStream.write(command); } }
PubSubConnection { public void unsubscribe(String channelName) throws IOException { if (closed.get()) throw new IOException("Connection closed!"); byte[] command = Util.combine(UNSUBSCRIBE_COMMAND, channelName.getBytes(), CRLF); outputStream.write(command); } PubSubConnection(Socket socket); }
PubSubConnection { public void unsubscribe(String channelName) throws IOException { if (closed.get()) throw new IOException("Connection closed!"); byte[] command = Util.combine(UNSUBSCRIBE_COMMAND, channelName.getBytes(), CRLF); outputStream.write(command); } PubSubConnection(Socket socket); void subscribe(String channelName); void unsubscribe(String channelName); PubSubReply read(); void close(); }
PubSubConnection { public void unsubscribe(String channelName) throws IOException { if (closed.get()) throw new IOException("Connection closed!"); byte[] command = Util.combine(UNSUBSCRIBE_COMMAND, channelName.getBytes(), CRLF); outputStream.write(command); } PubSubConnection(Socket socket); void subscribe(String channelName); void unsubscribe(String channelName); PubSubReply read(); void close();  }