Java 类org.apache.zookeeper.OpResult.CreateResult 实例源码

项目:fuck_zookeeper    文件:MultiTransactionTest.java   
/**
 * Exercise the equals methods of OpResult classes.
 */
@Test
public void testOpResultEquals() {
    opEquals(new CreateResult("/foo"),
            new CreateResult("/foo"),
            new CreateResult("nope"));

    opEquals(new CheckResult(),
            new CheckResult(),
            null);

    opEquals(new SetDataResult(new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
            new SetDataResult(new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
            new SetDataResult(new Stat(11, 12, 13, 14, 15, 16, 17, 18, 19, 110, 111)));

    opEquals(new ErrorResult(1),
            new ErrorResult(1),
            new ErrorResult(2));

    opEquals(new DeleteResult(),
            new DeleteResult(),
            null);

    opEquals(new ErrorResult(1),
            new ErrorResult(1),
            new ErrorResult(2));
}
项目:fuck_zookeeper    文件:MultiTransactionTest.java   
private void opEquals(OpResult expected, OpResult value, OpResult near) {
    assertEquals(value, value);
    assertFalse(value.equals(new Object()));
    assertFalse(value.equals(near));
    assertFalse(value.equals(value instanceof CreateResult ?
            new ErrorResult(1) : new CreateResult("nope2")));
    assertTrue(value.equals(expected));
}
项目:https-github.com-apache-zookeeper    文件:MultiTransactionTest.java   
/**
 * Exercise the equals methods of OpResult classes.
 */
@Test
public void testOpResultEquals() {
    opEquals(new CreateResult("/foo"),
             new CreateResult("/foo"),
             new CreateResult("nope"));

    opEquals(new CreateResult("/foo"),
             new CreateResult("/foo"),
             new CreateResult("/foo", new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)));

    opEquals(new CreateResult("/foo", new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
             new CreateResult("/foo", new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
             new CreateResult("nope", new Stat(11, 12, 13, 14, 15, 16, 17, 18, 19, 110, 111)));

    opEquals(new CreateResult("/foo", new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
             new CreateResult("/foo", new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
             new CreateResult("/foo"));

    opEquals(new CheckResult(),
             new CheckResult(),
             null);

    opEquals(new SetDataResult(new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
             new SetDataResult(new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
             new SetDataResult(new Stat(11, 12, 13, 14, 15, 16, 17, 18, 19, 110, 111)));

    opEquals(new ErrorResult(1),
             new ErrorResult(1),
             new ErrorResult(2));

    opEquals(new DeleteResult(),
             new DeleteResult(),
             null);

    opEquals(new ErrorResult(1),
             new ErrorResult(1),
             new ErrorResult(2));
}
项目:https-github.com-apache-zookeeper    文件:MultiTransactionTest.java   
private void opEquals(OpResult expected, OpResult value, OpResult near) {
    assertEquals(value, value);
    assertFalse(value.equals(new Object()));
    assertFalse(value.equals(near));
    assertFalse(value.equals(value instanceof CreateResult ?
            new ErrorResult(1) : new CreateResult("nope2")));
    assertTrue(value.equals(expected));
}
项目:ZooKeeper    文件:MultiTransactionTest.java   
/**
 * Exercise the equals methods of OpResult classes.
 */
@Test
public void testOpResultEquals() {
    opEquals(new CreateResult("/foo"),
            new CreateResult("/foo"),
            new CreateResult("nope"));

    opEquals(new CheckResult(),
            new CheckResult(),
            null);

    opEquals(new SetDataResult(new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
            new SetDataResult(new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
            new SetDataResult(new Stat(11, 12, 13, 14, 15, 16, 17, 18, 19, 110, 111)));

    opEquals(new ErrorResult(1),
            new ErrorResult(1),
            new ErrorResult(2));

    opEquals(new DeleteResult(),
            new DeleteResult(),
            null);

    opEquals(new ErrorResult(1),
            new ErrorResult(1),
            new ErrorResult(2));
}
项目:ZooKeeper    文件:MultiTransactionTest.java   
private void opEquals(OpResult expected, OpResult value, OpResult near) {
    assertEquals(value, value);
    assertFalse(value.equals(new Object()));
    assertFalse(value.equals(near));
    assertFalse(value.equals(value instanceof CreateResult ?
            new ErrorResult(1) : new CreateResult("nope2")));
    assertTrue(value.equals(expected));
}
项目:StreamProcessingInfrastructure    文件:MultiTransactionTest.java   
/**
 * Exercise the equals methods of OpResult classes.
 */
@Test
public void testOpResultEquals() {
    opEquals(new CreateResult("/foo"),
            new CreateResult("/foo"),
            new CreateResult("nope"));

    opEquals(new CheckResult(),
            new CheckResult(),
            null);

    opEquals(new SetDataResult(new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
            new SetDataResult(new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
            new SetDataResult(new Stat(11, 12, 13, 14, 15, 16, 17, 18, 19, 110, 111)));

    opEquals(new ErrorResult(1),
            new ErrorResult(1),
            new ErrorResult(2));

    opEquals(new DeleteResult(),
            new DeleteResult(),
            null);

    opEquals(new ErrorResult(1),
            new ErrorResult(1),
            new ErrorResult(2));
}
项目:StreamProcessingInfrastructure    文件:MultiTransactionTest.java   
private void opEquals(OpResult expected, OpResult value, OpResult near) {
    assertEquals(value, value);
    assertFalse(value.equals(new Object()));
    assertFalse(value.equals(near));
    assertFalse(value.equals(value instanceof CreateResult ?
            new ErrorResult(1) : new CreateResult("nope2")));
    assertTrue(value.equals(expected));
}
项目:bigstreams    文件:MultiTransactionTest.java   
/**
 * Exercise the equals methods of OpResult classes.
 */
@Test
public void testOpResultEquals() {
    opEquals(new CreateResult("/foo"),
            new CreateResult("/foo"),
            new CreateResult("nope"));

    opEquals(new CheckResult(),
            new CheckResult(),
            null);

    opEquals(new SetDataResult(new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
            new SetDataResult(new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
            new SetDataResult(new Stat(11, 12, 13, 14, 15, 16, 17, 18, 19, 110, 111)));

    opEquals(new ErrorResult(1),
            new ErrorResult(1),
            new ErrorResult(2));

    opEquals(new DeleteResult(),
            new DeleteResult(),
            null);

    opEquals(new ErrorResult(1),
            new ErrorResult(1),
            new ErrorResult(2));
}
项目:bigstreams    文件:MultiTransactionTest.java   
private void opEquals(OpResult expected, OpResult value, OpResult near) {
    assertEquals(value, value);
    assertFalse(value.equals(new Object()));
    assertFalse(value.equals(near));
    assertFalse(value.equals(value instanceof CreateResult ?
            new ErrorResult(1) : new CreateResult("nope2")));
    assertTrue(value.equals(expected));
}
项目:zookeeper    文件:MultiTransactionTest.java   
/**
 * Exercise the equals methods of OpResult classes.
 */
@Test
public void testOpResultEquals() {
    opEquals(new CreateResult("/foo"),
            new CreateResult("/foo"),
            new CreateResult("nope"));

    opEquals(new CheckResult(),
            new CheckResult(),
            null);

    opEquals(new SetDataResult(new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
            new SetDataResult(new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
            new SetDataResult(new Stat(11, 12, 13, 14, 15, 16, 17, 18, 19, 110, 111)));

    opEquals(new ErrorResult(1),
            new ErrorResult(1),
            new ErrorResult(2));

    opEquals(new DeleteResult(),
            new DeleteResult(),
            null);

    opEquals(new ErrorResult(1),
            new ErrorResult(1),
            new ErrorResult(2));
}
项目:zookeeper    文件:MultiTransactionTest.java   
private void opEquals(OpResult expected, OpResult value, OpResult near) {
    assertEquals(value, value);
    assertFalse(value.equals(new Object()));
    assertFalse(value.equals(near));
    assertFalse(value.equals(value instanceof CreateResult ?
            new ErrorResult(1) : new CreateResult("nope2")));
    assertTrue(value.equals(expected));
}
项目:SecureKeeper    文件:MultiTransactionTest.java   
/**
 * Exercise the equals methods of OpResult classes.
 */
@Test
public void testOpResultEquals() {
    opEquals(new CreateResult("/foo"),
             new CreateResult("/foo"),
             new CreateResult("nope"));

    opEquals(new CreateResult("/foo"),
             new CreateResult("/foo"),
             new CreateResult("/foo", new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)));

    opEquals(new CreateResult("/foo", new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
             new CreateResult("/foo", new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
             new CreateResult("nope", new Stat(11, 12, 13, 14, 15, 16, 17, 18, 19, 110, 111)));

    opEquals(new CreateResult("/foo", new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
             new CreateResult("/foo", new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
             new CreateResult("/foo"));

    opEquals(new CheckResult(),
             new CheckResult(),
             null);

    opEquals(new SetDataResult(new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
             new SetDataResult(new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
             new SetDataResult(new Stat(11, 12, 13, 14, 15, 16, 17, 18, 19, 110, 111)));

    opEquals(new ErrorResult(1),
             new ErrorResult(1),
             new ErrorResult(2));

    opEquals(new DeleteResult(),
             new DeleteResult(),
             null);

    opEquals(new ErrorResult(1),
             new ErrorResult(1),
             new ErrorResult(2));
}
项目:SecureKeeper    文件:MultiTransactionTest.java   
private void opEquals(OpResult expected, OpResult value, OpResult near) {
    assertEquals(value, value);
    assertFalse(value.equals(new Object()));
    assertFalse(value.equals(near));
    assertFalse(value.equals(value instanceof CreateResult ?
            new ErrorResult(1) : new CreateResult("nope2")));
    assertTrue(value.equals(expected));
}
项目:SecureKeeper    文件:MultiTransactionTest.java   
/**
 * Exercise the equals methods of OpResult classes.
 */
@Test
public void testOpResultEquals() {
    opEquals(new CreateResult("/foo"),
             new CreateResult("/foo"),
             new CreateResult("nope"));

    opEquals(new CreateResult("/foo"),
             new CreateResult("/foo"),
             new CreateResult("/foo", new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)));

    opEquals(new CreateResult("/foo", new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
             new CreateResult("/foo", new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
             new CreateResult("nope", new Stat(11, 12, 13, 14, 15, 16, 17, 18, 19, 110, 111)));

    opEquals(new CreateResult("/foo", new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
             new CreateResult("/foo", new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
             new CreateResult("/foo"));

    opEquals(new CheckResult(),
             new CheckResult(),
             null);

    opEquals(new SetDataResult(new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
             new SetDataResult(new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
             new SetDataResult(new Stat(11, 12, 13, 14, 15, 16, 17, 18, 19, 110, 111)));

    opEquals(new ErrorResult(1),
             new ErrorResult(1),
             new ErrorResult(2));

    opEquals(new DeleteResult(),
             new DeleteResult(),
             null);

    opEquals(new ErrorResult(1),
             new ErrorResult(1),
             new ErrorResult(2));
}
项目:SecureKeeper    文件:MultiTransactionTest.java   
private void opEquals(OpResult expected, OpResult value, OpResult near) {
    assertEquals(value, value);
    assertFalse(value.equals(new Object()));
    assertFalse(value.equals(near));
    assertFalse(value.equals(value instanceof CreateResult ?
            new ErrorResult(1) : new CreateResult("nope2")));
    assertTrue(value.equals(expected));
}
项目:StreamBench    文件:MultiTransactionTest.java   
/**
 * Exercise the equals methods of OpResult classes.
 */
@Test
public void testOpResultEquals() {
    opEquals(new CreateResult("/foo"),
            new CreateResult("/foo"),
            new CreateResult("nope"));

    opEquals(new CheckResult(),
            new CheckResult(),
            null);

    opEquals(new SetDataResult(new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
            new SetDataResult(new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
            new SetDataResult(new Stat(11, 12, 13, 14, 15, 16, 17, 18, 19, 110, 111)));

    opEquals(new ErrorResult(1),
            new ErrorResult(1),
            new ErrorResult(2));

    opEquals(new DeleteResult(),
            new DeleteResult(),
            null);

    opEquals(new ErrorResult(1),
            new ErrorResult(1),
            new ErrorResult(2));
}
项目:StreamBench    文件:MultiTransactionTest.java   
private void opEquals(OpResult expected, OpResult value, OpResult near) {
    assertEquals(value, value);
    assertFalse(value.equals(new Object()));
    assertFalse(value.equals(near));
    assertFalse(value.equals(value instanceof CreateResult ?
            new ErrorResult(1) : new CreateResult("nope2")));
    assertTrue(value.equals(expected));
}
项目:LoadBalanced_zk    文件:MultiTransactionTest.java   
/**
 * Exercise the equals methods of OpResult classes.
 */
@Test
public void testOpResultEquals() {
    opEquals(new CreateResult("/foo"),
            new CreateResult("/foo"),
            new CreateResult("nope"));

    opEquals(new CheckResult(),
            new CheckResult(),
            null);

    opEquals(new SetDataResult(new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
            new SetDataResult(new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
            new SetDataResult(new Stat(11, 12, 13, 14, 15, 16, 17, 18, 19, 110, 111)));

    opEquals(new ErrorResult(1),
            new ErrorResult(1),
            new ErrorResult(2));

    opEquals(new DeleteResult(),
            new DeleteResult(),
            null);

    opEquals(new ErrorResult(1),
            new ErrorResult(1),
            new ErrorResult(2));
}
项目:LoadBalanced_zk    文件:MultiTransactionTest.java   
private void opEquals(OpResult expected, OpResult value, OpResult near) {
    assertEquals(value, value);
    assertFalse(value.equals(new Object()));
    assertFalse(value.equals(near));
    assertFalse(value.equals(value instanceof CreateResult ?
            new ErrorResult(1) : new CreateResult("nope2")));
    assertTrue(value.equals(expected));
}
项目:LoadBalanced_zk    文件:MultiTransactionTest.java   
/**
 * Exercise the equals methods of OpResult classes.
 */
@Test
public void testOpResultEquals() {
    opEquals(new CreateResult("/foo"),
            new CreateResult("/foo"),
            new CreateResult("nope"));

    opEquals(new CheckResult(),
            new CheckResult(),
            null);

    opEquals(new SetDataResult(new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
            new SetDataResult(new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
            new SetDataResult(new Stat(11, 12, 13, 14, 15, 16, 17, 18, 19, 110, 111)));

    opEquals(new ErrorResult(1),
            new ErrorResult(1),
            new ErrorResult(2));

    opEquals(new DeleteResult(),
            new DeleteResult(),
            null);

    opEquals(new ErrorResult(1),
            new ErrorResult(1),
            new ErrorResult(2));
}
项目:LoadBalanced_zk    文件:MultiTransactionTest.java   
private void opEquals(OpResult expected, OpResult value, OpResult near) {
    assertEquals(value, value);
    assertFalse(value.equals(new Object()));
    assertFalse(value.equals(near));
    assertFalse(value.equals(value instanceof CreateResult ?
            new ErrorResult(1) : new CreateResult("nope2")));
    assertTrue(value.equals(expected));
}
项目:zookeeper-pkg    文件:MultiTransactionTest.java   
/**
 * Exercise the equals methods of OpResult classes.
 */
@Test
public void testOpResultEquals() {
    opEquals(new CreateResult("/foo"),
            new CreateResult("/foo"),
            new CreateResult("nope"));

    opEquals(new CheckResult(),
            new CheckResult(),
            null);

    opEquals(new SetDataResult(new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
            new SetDataResult(new Stat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
            new SetDataResult(new Stat(11, 12, 13, 14, 15, 16, 17, 18, 19, 110, 111)));

    opEquals(new ErrorResult(1),
            new ErrorResult(1),
            new ErrorResult(2));

    opEquals(new DeleteResult(),
            new DeleteResult(),
            null);

    opEquals(new ErrorResult(1),
            new ErrorResult(1),
            new ErrorResult(2));
}
项目:zookeeper-pkg    文件:MultiTransactionTest.java   
private void opEquals(OpResult expected, OpResult value, OpResult near) {
    assertEquals(value, value);
    assertFalse(value.equals(new Object()));
    assertFalse(value.equals(near));
    assertFalse(value.equals(value instanceof CreateResult ?
            new ErrorResult(1) : new CreateResult("nope2")));
    assertTrue(value.equals(expected));
}
项目:https-github.com-apache-zookeeper    文件:MultiAsyncTransactionTest.java   
/**
 * ZOOKEEPER-1624: PendingChanges of create sequential node request didn't
 * get rollbacked correctly when multi-op failed. This cause
 * create sequential node request in subsequent multi-op to failed because
 * sequential node name generation is incorrect.
 *
 * The check is to make sure that each request in multi-op failed with
 * the correct reason.
 */
@Test
public void testSequentialNodeCreateInAsyncMulti() throws Exception {
    final int iteration = 4;
    final List<MultiResult> results = new ArrayList<MultiResult>();

    pendingOps.set(iteration);

    List<Op> ops = Arrays.asList(
            Op.create("/node-", new byte[0], Ids.OPEN_ACL_UNSAFE,
                      CreateMode.PERSISTENT_SEQUENTIAL),
            Op.create("/dup", new byte[0], Ids.OPEN_ACL_UNSAFE,
                      CreateMode.PERSISTENT));


    for (int i = 0; i < iteration; ++i) {
        zk.multi(ops, new MultiCallback() {
            @Override
            public void processResult(int rc, String path, Object ctx,
                    List<OpResult> opResults) {
                MultiResult result = new MultiResult();
                result.results = opResults;
                result.rc = rc;
                results.add(result);
                finishPendingOps();
            }
        }, null);
    }

    waitForPendingOps(CONNECTION_TIMEOUT);

    // Check that return code of all request are correct
    assertEquals(KeeperException.Code.OK.intValue(), results.get(0).rc);
    assertEquals(KeeperException.Code.NODEEXISTS.intValue(), results.get(1).rc);
    assertEquals(KeeperException.Code.NODEEXISTS.intValue(), results.get(2).rc);
    assertEquals(KeeperException.Code.NODEEXISTS.intValue(), results.get(3).rc);

    // Check that the first operation is successful in all request
    assertTrue(results.get(0).results.get(0) instanceof CreateResult);
    assertEquals(KeeperException.Code.OK.intValue(),
            ((ErrorResult) results.get(1).results.get(0)).getErr());
    assertEquals(KeeperException.Code.OK.intValue(),
            ((ErrorResult) results.get(2).results.get(0)).getErr());
    assertEquals(KeeperException.Code.OK.intValue(),
            ((ErrorResult) results.get(3).results.get(0)).getErr());

    // Check that the second operation failed after the first request
    assertEquals(KeeperException.Code.NODEEXISTS.intValue(),
            ((ErrorResult) results.get(1).results.get(1)).getErr());
    assertEquals(KeeperException.Code.NODEEXISTS.intValue(),
            ((ErrorResult) results.get(2).results.get(1)).getErr());
    assertEquals(KeeperException.Code.NODEEXISTS.intValue(),
            ((ErrorResult) results.get(3).results.get(1)).getErr());

}
项目:SecureKeeper    文件:MultiAsyncTransactionTest.java   
/**
 * ZOOKEEPER-1624: PendingChanges of create sequential node request didn't
 * get rollbacked correctly when multi-op failed. This cause
 * create sequential node request in subsequent multi-op to failed because
 * sequential node name generation is incorrect.
 *
 * The check is to make sure that each request in multi-op failed with
 * the correct reason.
 */
@Test
public void testSequentialNodeCreateInAsyncMulti() throws Exception {
    final int iteration = 4;
    final List<MultiResult> results = new ArrayList<MultiResult>();

    pendingOps.set(iteration);

    List<Op> ops = Arrays.asList(
            Op.create("/node-", new byte[0], Ids.OPEN_ACL_UNSAFE,
                      CreateMode.PERSISTENT_SEQUENTIAL),
            Op.create("/dup", new byte[0], Ids.OPEN_ACL_UNSAFE,
                      CreateMode.PERSISTENT));


    for (int i = 0; i < iteration; ++i) {
        zk.multi(ops, new MultiCallback() {
            @Override
            public void processResult(int rc, String path, Object ctx,
                    List<OpResult> opResults) {
                MultiResult result = new MultiResult();
                result.results = opResults;
                result.rc = rc;
                results.add(result);
                finishPendingOps();
            }
        }, null);
    }

    waitForPendingOps(CONNECTION_TIMEOUT);

    // Check that return code of all request are correct
    assertEquals(KeeperException.Code.OK.intValue(), results.get(0).rc);
    assertEquals(KeeperException.Code.NODEEXISTS.intValue(), results.get(1).rc);
    assertEquals(KeeperException.Code.NODEEXISTS.intValue(), results.get(2).rc);
    assertEquals(KeeperException.Code.NODEEXISTS.intValue(), results.get(3).rc);

    // Check that the first operation is successful in all request
    assertTrue(results.get(0).results.get(0) instanceof CreateResult);
    assertEquals(KeeperException.Code.OK.intValue(),
            ((ErrorResult) results.get(1).results.get(0)).getErr());
    assertEquals(KeeperException.Code.OK.intValue(),
            ((ErrorResult) results.get(2).results.get(0)).getErr());
    assertEquals(KeeperException.Code.OK.intValue(),
            ((ErrorResult) results.get(3).results.get(0)).getErr());

    // Check that the second operation failed after the first request
    assertEquals(KeeperException.Code.NODEEXISTS.intValue(),
            ((ErrorResult) results.get(1).results.get(1)).getErr());
    assertEquals(KeeperException.Code.NODEEXISTS.intValue(),
            ((ErrorResult) results.get(2).results.get(1)).getErr());
    assertEquals(KeeperException.Code.NODEEXISTS.intValue(),
            ((ErrorResult) results.get(3).results.get(1)).getErr());

}
项目:SecureKeeper    文件:MultiAsyncTransactionTest.java   
/**
 * ZOOKEEPER-1624: PendingChanges of create sequential node request didn't
 * get rollbacked correctly when multi-op failed. This cause
 * create sequential node request in subsequent multi-op to failed because
 * sequential node name generation is incorrect.
 *
 * The check is to make sure that each request in multi-op failed with
 * the correct reason.
 */
@Test
public void testSequentialNodeCreateInAsyncMulti() throws Exception {
    final int iteration = 4;
    final List<MultiResult> results = new ArrayList<MultiResult>();

    pendingOps.set(iteration);

    List<Op> ops = Arrays.asList(
            Op.create("/node-", new byte[0], Ids.OPEN_ACL_UNSAFE,
                      CreateMode.PERSISTENT_SEQUENTIAL),
            Op.create("/dup", new byte[0], Ids.OPEN_ACL_UNSAFE,
                      CreateMode.PERSISTENT));


    for (int i = 0; i < iteration; ++i) {
        zk.multi(ops, new MultiCallback() {
            @Override
            public void processResult(int rc, String path, Object ctx,
                    List<OpResult> opResults) {
                MultiResult result = new MultiResult();
                result.results = opResults;
                result.rc = rc;
                results.add(result);
                finishPendingOps();
            }
        }, null);
    }

    waitForPendingOps(CONNECTION_TIMEOUT);

    // Check that return code of all request are correct
    assertEquals(KeeperException.Code.OK.intValue(), results.get(0).rc);
    assertEquals(KeeperException.Code.NODEEXISTS.intValue(), results.get(1).rc);
    assertEquals(KeeperException.Code.NODEEXISTS.intValue(), results.get(2).rc);
    assertEquals(KeeperException.Code.NODEEXISTS.intValue(), results.get(3).rc);

    // Check that the first operation is successful in all request
    assertTrue(results.get(0).results.get(0) instanceof CreateResult);
    assertEquals(KeeperException.Code.OK.intValue(),
            ((ErrorResult) results.get(1).results.get(0)).getErr());
    assertEquals(KeeperException.Code.OK.intValue(),
            ((ErrorResult) results.get(2).results.get(0)).getErr());
    assertEquals(KeeperException.Code.OK.intValue(),
            ((ErrorResult) results.get(3).results.get(0)).getErr());

    // Check that the second operation failed after the first request
    assertEquals(KeeperException.Code.NODEEXISTS.intValue(),
            ((ErrorResult) results.get(1).results.get(1)).getErr());
    assertEquals(KeeperException.Code.NODEEXISTS.intValue(),
            ((ErrorResult) results.get(2).results.get(1)).getErr());
    assertEquals(KeeperException.Code.NODEEXISTS.intValue(),
            ((ErrorResult) results.get(3).results.get(1)).getErr());

}