/** * 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; }
/** * 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; }
/** * Pretend the server echos back client's operation. */ public TestConfig serverDoEchoBack(int startVersion, long timestamp) throws TransformException, OperationException { TransformedWaveletDelta d = TransformedWaveletDelta.cloneOperations( clientMock.getParticipantId(), genSignature(startVersion + 1), timestamp, Arrays.asList(SERVER_UTIL.noOp())); serverConnectionMock.triggerServerDeltas(Collections.singletonList(d)); return this; }
/** * Pretend server did some ops at the given op version using different deltas. * * We generate a predictable signature here for testing later. Each signature is the * version on the server after the ops. */ public TestConfig serverDoOps(int startVersion, int numOps) throws TransformException, OperationException { ArrayList<TransformedWaveletDelta> deltas = CollectionUtils.newArrayList(); for (int i = 0; i < numOps; i++) { TransformedWaveletDelta d = TransformedWaveletDelta.cloneOperations( SERVER_UTIL.getAuthor(), genSignature(startVersion + i + 1), 0L, Arrays.asList(SERVER_UTIL.noOp())); deltas.add(d); } serverConnectionMock.triggerServerDeltas(deltas); return this; }
/** * Pretend server did some ops at the given op version using different deltas. * * We generate a predictable signature here for testing later. Each signature is the * version on the server after the ops. */ public TestConfig serverDoOps(int startVersion, int numOps) throws TransformException, OperationException { ArrayList<TransformedWaveletDelta> deltas = CollectionUtils.newArrayList(); for (int i = 0; i < numOps; i++) { TransformedWaveletDelta d = TransformedWaveletDelta.cloneOperations( SERVER_UTIL.getAuthor(), genSignature(startVersion + i + 1), 0L, Arrays.asList(SERVER_UTIL.noOp())); deltas.add(d); } serverConnectionMock.triggerServerDeltas(deltas); return this; }
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); } }
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); } }
/** * Pretend the server acked the given version. * * We generate a predictable signature here for testing later. Which is the version on the * server after the op. * * @param version The new version after the operations from the client is applied. * @param numApplied Number of operations applied on the server. * @throws OperationException * @throws TransformException */ public TestConfig serverAck(int version, int numApplied) throws TransformException, OperationException { serverConnectionMock.triggerServerSuccess(numApplied, genSignature(version)); return this; }
/** * Pretend the server acked the given version. * * We generate a predictable signature here for testing later. Which is the version on the * server after the op. * * @param version The new version after the operations from the client is applied. * @param numApplied Number of operations applied on the server. * @throws OperationException * @throws TransformException */ public TestConfig serverAck(int version, int numApplied) throws TransformException, OperationException { serverConnectionMock.triggerServerSuccess(numApplied, genSignature(version)); return this; }
/** * Pretend client did some insert at the given op versions. * @throws OperationException * @throws TransformException */ public TestConfig serverDoInsert(int startVersion, int insertionPoint, String content, int remaining) throws OperationException, TransformException { TransformedWaveletDelta d = TransformedWaveletDelta.cloneOperations(SERVER_UTIL.getAuthor(), genSignature(startVersion + 1), 0L, Arrays.asList( SERVER_UTIL.insert(insertionPoint, content, remaining, null))); serverConnectionMock.triggerServerDeltas(Collections.singletonList(d)); return this; }
/** * Server open the connection at the given version and tells of the last version. */ public TestConfig serverDoOpen(int startVersion, int endVersion) throws ChannelException { serverConnectionMock.triggerOnOpen(genSignature(startVersion), genSignature(endVersion)); return this; }
/** * Pretend the server echos back client's operation. Timestamp default to 0L. */ public TestConfig serverDoEchoBackDocOp(int startVersion, String blipId) throws TransformException, OperationException { TransformedWaveletDelta d = TransformedWaveletDelta.cloneOperations( clientMock.getParticipantId(), genSignature(startVersion + 1), 0L, Arrays.asList(noOpDocOp(blipId))); serverConnectionMock.triggerServerDeltas(Collections.singletonList(d)); return this; }
/** * Server open the connection at the given version and tells of the last version. */ public TestConfig serverDoOpen(int startVersion, int endVersion) throws ChannelException { serverConnectionMock.triggerOnOpen(genSignature(startVersion), genSignature(endVersion)); return this; }
/** * Pretend the server echos back client's operation. Timestamp default to 0L. */ public TestConfig serverDoEchoBackDocOp(int startVersion, String blipId) throws TransformException, OperationException { TransformedWaveletDelta d = TransformedWaveletDelta.cloneOperations( clientMock.getParticipantId(), genSignature(startVersion + 1), 0L, Arrays.asList(noOpDocOp(blipId))); serverConnectionMock.triggerServerDeltas(Collections.singletonList(d)); return this; }
/** * Pretend the server echos back client's operation. */ public TestConfig serverDoEchoBack(int startVersion, long timestamp) throws TransformException, OperationException { TransformedWaveletDelta d = TransformedWaveletDelta.cloneOperations( clientMock.getParticipantId(), genSignature(startVersion + 1), timestamp, Arrays.asList(SERVER_UTIL.noOp())); serverConnectionMock.triggerServerDeltas(Collections.singletonList(d)); return this; }
/** * Pretend client did some insert at the given op versions. * @throws OperationException * @throws TransformException */ public TestConfig serverDoInsert(int startVersion, int insertionPoint, String content, int remaining) throws OperationException, TransformException { TransformedWaveletDelta d = TransformedWaveletDelta.cloneOperations(SERVER_UTIL.getAuthor(), genSignature(startVersion + 1), 0L, Arrays.asList( SERVER_UTIL.insert(insertionPoint, content, remaining, null))); serverConnectionMock.triggerServerDeltas(Collections.singletonList(d)); return this; }