/** * We create a perfectly valid 'exists' request, except that the opcode is wrong. * @return * @throws Exception */ @Test public void testNonExistingOpCode() throws Exception { TestableZooKeeper zk = createClient(); final String path = "/m1"; RequestHeader h = new RequestHeader(); h.setType(888); // This code does not exists ExistsRequest request = new ExistsRequest(); request.setPath(path); request.setWatch(false); ExistsResponse response = new ExistsResponse(); ReplyHeader r = zk.submitRequest(h, request, response, null); Assert.assertEquals(r.getErr(), Code.UNIMPLEMENTED.intValue()); try { zk.exists("/m1", false); fail("The connection should have been closed"); } catch (KeeperException.ConnectionLossException expected) { } }
/** * We create a perfectly valid 'exists' request, except that the opcode is wrong. * @return * @throws Exception */ @Test public void testNonExistingOpCode() throws Exception { TestableZooKeeper zk = createClient(); final String path = "/m1"; RequestHeader h = new RequestHeader(); h.setType(888); // This code does not exists ExistsRequest request = new ExistsRequest(); request.setPath(path); request.setWatch(false); ExistsResponse response = new ExistsResponse(); ReplyHeader r = zk.submitRequest(h, request, response, null); Assert.assertEquals(r.getErr(), Code.UNIMPLEMENTED.intValue()); zk.testableWaitForShutdown(CONNECTION_TIMEOUT); }
/** * We create a perfectly valid 'exists' request, except that the opcode is wrong. * @return * @throws Exception */ @Test public void testNonExistingOpCode() throws Exception { final CountDownLatch clientDisconnected = new CountDownLatch(1); Watcher watcher = new Watcher() { @Override public synchronized void process(WatchedEvent event) { if (event.getState() == KeeperState.Disconnected) { clientDisconnected.countDown(); } } }; TestableZooKeeper zk = new TestableZooKeeper(hostPort, CONNECTION_TIMEOUT, watcher); final String path = "/m1"; RequestHeader h = new RequestHeader(); h.setType(888); // This code does not exists ExistsRequest request = new ExistsRequest(); request.setPath(path); request.setWatch(false); ExistsResponse response = new ExistsResponse(); ReplyHeader r = zk.submitRequest(h, request, response, null); Assert.assertEquals(r.getErr(), Code.UNIMPLEMENTED.intValue()); // Sending a nonexisting opcode should cause the server to disconnect Assert.assertTrue("failed to disconnect", clientDisconnected.await(5000, TimeUnit.MILLISECONDS)); }
public IExistsResponse() { this(new ExistsResponse()); }
public IExistsResponse(Stat stat) { this(new ExistsResponse(stat)); }
public IExistsResponse(ExistsResponse record) { super(record); }