private void useProxy(boolean ssl, int skipPosition, int skipBytes, boolean intermediateChange) throws Exception {
useProxy(ssl, skipPosition, skipBytes, -1, intermediateChange);
}
private void useProxy(boolean ssl, int skipPosition, int skipBytes, int flipPosition, boolean intermediateChange) throws Exception {
NetworkErrorProxy p = new NetworkErrorProxy(PROXY_PORT, LOCALHOST, port);
p.skipBytes(skipPosition, skipBytes);
p.flipByte(flipPosition);
p.run();
NodeStore store = new SegmentNodeStore(storeS);
final StandbyServer server = new StandbyServer(port, storeS, ssl);
server.start();
addTestContent(store, "server");
storeS.flush(); // this speeds up the test a little bit...
StandbyClient cl = new StandbyClient(LOCALHOST, PROXY_PORT, storeC, ssl);
cl.run();
try {
if (skipBytes > 0 || flipPosition >= 0) {
assertFalse("stores are not expected to be equal", storeS.getHead().equals(storeC.getHead()));
assertEquals(storeC2.getHead(), storeC.getHead());
p.reset();
if (intermediateChange) {
addTestContent(store, "server2");
storeS.flush();
}
cl.run();
}
assertEquals(storeS.getHead(), storeC.getHead());
} finally {
server.close();
cl.close();
p.close();
}
}