public class MemoryWebSocketStoreTest extends Assert {
@Test
public void testAddAndRemove() throws Exception {
MemoryWebSocketStore store = new MemoryWebSocketStore();
WebSocket webSocket1 = EasyMock.createMock(WebSocket.class);
WebSocket webSocket2 = EasyMock.createMock(WebSocket.class);
String connectionKey1 = UUID.randomUUID().toString();
String connectionKey2 = UUID.randomUUID().toString();
store.addWebSocket(connectionKey1, webSocket1);
verifyGet(store, connectionKey1, webSocket1, true);
assertEquals(1, store.getAllWebSockets().size());
store.addWebSocket(connectionKey2, webSocket2);
verifyGet(store, connectionKey2, webSocket2, true);
verifyGet(store, connectionKey1, webSocket1, true);
assertEquals(2, store.getAllWebSockets().size());
store.removeWebSocket(connectionKey1);
verifyGet(store, connectionKey1, webSocket1, false);
store.removeWebSocket(webSocket2);
verifyGet(store, connectionKey2, webSocket2, false);
assertEquals(0, store.getAllWebSockets().size());
}