/** * Disconnect a single client from server. */ public void killClient(int clientNumber) { ClientMock client = clientMocks.get(clientNumber); ServerConnectionMock connection = client.getConnection(); serverMock.removeClientConnection(connection); connection.setOpen(false); connection.getReceivedDeltas().clear(); connection.getSentDeltas().clear(); connection.setServerMock(null); }
/** * Reconnect a single client from server * @throws OperationException * @throws TransformException */ public void reconnectClient(int clientNumber) throws ChannelException, TransformException, OperationException { ClientMock client = clientMocks.get(clientNumber); ServerConnectionMock connection = client.getConnection(); serverMock.addClientConnection(connection); connection.setServerMock(serverMock); connection.setOpen(true); connection.reconnect(client.getReconnectionVersions()); }
throws TransformException, OperationException { for (int i = 0; i < numClients; i++) { ServerConnectionMock serverConnectionMock = new ServerConnectionMock(); serverConnectionMock.setServerMock(serverMock); serverMock.addClientConnection(serverConnectionMock); serverConnectionMock.setListener(clientCC);
public void init(int version, String intialBlipXml) { HashedVersion signature = genSignature(version); serverConnectionMock = new ServerConnectionMock(); ConcurrencyControl clientCC = new ConcurrencyControl(logger, signature); serverConnectionMock.setListener(clientCC); clientMock = new ClientMock( clientCC, intialBlipXml != null ? parse(intialBlipXml) : null, DEFAULT_CREATOR, serverConnectionMock); clientCC.initialise(serverConnectionMock, clientMock); try { clientCC.onOpen(signature, signature); } catch (ChannelException e) { fail("onOpen failed: " + e); } }
/** * Check client didn't send anything. */ public TestConfig checkClientSentOps() { List<WaveletDelta> serverGot = serverConnectionMock.getSentDeltas(); assertEquals(0, serverGot.size()); return this; }
/** * Pretend we are disconnected to the server. */ public TestConfig disconnectFromServer() { serverConnectionMock.setOpen(false); return this; }
/** * Prevents sending the delta to the server. But the connection * still seems connected. */ public void preventSending(int clientNumber) { ClientMock client = clientMocks.get(clientNumber); ServerConnectionMock connection = client.getConnection(); serverMock.removeClientConnection(connection); connection.setServerMock(null); }
/** * Send all the ghosted deltas from a client. */ public void sendGhostDeltas(int clientNumber) { ClientMock client = clientMocks.get(clientNumber); ServerConnectionMock connection = client.getConnection(); connection.sendGhosts(); }
/** * Turn all the deltas sent by a client into ghosts. * @param ghostSend should the client's out going ops be ghosted. */ public void ghostClientDeltas(int clientNumber, boolean ghostSend) { ClientMock client = clientMocks.get(clientNumber); ServerConnectionMock connection = client.getConnection(); connection.setGhostSend(ghostSend); }
/** * Check client sent signatures from the given version. * @param versions Each version number is after the operation as applied. */ public TestConfig checkClientSentOpen(int ... versions) { List<HashedVersion> signatures = serverConnectionMock.getReconnectSignatures(); assertEquals(versions.length, signatures.size()); for (int i = 0; i < versions.length; i++) { assertEquals(genSignature(versions[i]), signatures.get(i)); } signatures.clear(); return this; }
/** * Reconnect a single client from server * @throws OperationException * @throws TransformException */ public void reconnectClient(int clientNumber) throws ChannelException, TransformException, OperationException { ClientMock client = clientMocks.get(clientNumber); ServerConnectionMock connection = client.getConnection(); serverMock.addClientConnection(connection); connection.setServerMock(serverMock); connection.setOpen(true); connection.reconnect(client.getReconnectionVersions()); }
throws TransformException, OperationException { for (int i = 0; i < numClients; i++) { ServerConnectionMock serverConnectionMock = new ServerConnectionMock(); serverConnectionMock.setServerMock(serverMock); serverMock.addClientConnection(serverConnectionMock); serverConnectionMock.setListener(clientCC);
public void init(int version, String intialBlipXml) { HashedVersion signature = genSignature(version); serverConnectionMock = new ServerConnectionMock(); ConcurrencyControl clientCC = new ConcurrencyControl(logger, signature); serverConnectionMock.setListener(clientCC); clientMock = new ClientMock( clientCC, intialBlipXml != null ? parse(intialBlipXml) : null, DEFAULT_CREATOR, serverConnectionMock); clientCC.initialise(serverConnectionMock, clientMock); try { clientCC.onOpen(signature, signature); } catch (ChannelException e) { fail("onOpen failed: " + e); } }
/** * Check client didn't send anything. */ public TestConfig checkClientSentOps() { List<WaveletDelta> serverGot = serverConnectionMock.getSentDeltas(); assertEquals(0, serverGot.size()); return this; }
/** * Pretend we are disconnected to the server. */ public TestConfig disconnectFromServer() { serverConnectionMock.setOpen(false); return this; }
/** * Prevents sending the delta to the server. But the connection * still seems connected. */ public void preventSending(int clientNumber) { ClientMock client = clientMocks.get(clientNumber); ServerConnectionMock connection = client.getConnection(); serverMock.removeClientConnection(connection); connection.setServerMock(null); }
/** * Send all the ghosted deltas from a client. */ public void sendGhostDeltas(int clientNumber) { ClientMock client = clientMocks.get(clientNumber); ServerConnectionMock connection = client.getConnection(); connection.sendGhosts(); }
/** * Turn all the deltas sent by a client into ghosts. * @param ghostSend should the client's out going ops be ghosted. */ public void ghostClientDeltas(int clientNumber, boolean ghostSend) { ClientMock client = clientMocks.get(clientNumber); ServerConnectionMock connection = client.getConnection(); connection.setGhostSend(ghostSend); }
/** * Check client sent signatures from the given version. * @param versions Each version number is after the operation as applied. */ public TestConfig checkClientSentOpen(int ... versions) { List<HashedVersion> signatures = serverConnectionMock.getReconnectSignatures(); assertEquals(versions.length, signatures.size()); for (int i = 0; i < versions.length; i++) { assertEquals(genSignature(versions[i]), signatures.get(i)); } signatures.clear(); return this; }