Java 类org.apache.zookeeper.server.persistence.Util 实例源码

项目:fuck_zookeeper    文件:ZooKeeperServerMainTest.java   
private void addRequestToSyncProcessor() {
    long zxid = ZxidUtils.makeZxid(3, 7);
    TxnHeader hdr = new TxnHeader(1, 1, zxid, 1,
            ZooDefs.OpCode.setData);
    Record txn = new SetDataTxn("/foo" + zxid, new byte[0], 1);
    byte[] buf;
    try {
        buf = Util.marshallTxnEntry(hdr, txn);
    } catch (IOException e) {
        LOG.error("IOException while adding request to SyncRequestProcessor", e);
        Assert.fail("IOException while adding request to SyncRequestProcessor!");
        return;
    }
    NettyServerCnxnFactory factory = new NettyServerCnxnFactory();
    final MockNettyServerCnxn nettyCnxn = new MockNettyServerCnxn(null,
            this, factory);
    Request req = new Request(nettyCnxn, 1, 1, ZooDefs.OpCode.setData,
            ByteBuffer.wrap(buf), null);
    req.hdr = hdr;
    req.txn = txn;
    syncProcessor.processRequest(req);
}
项目:fuck_zookeeper    文件:ZooKeeperServerTest.java   
@Test
public void testSortDataDirAscending() {
    File[] files = new File[5];

    files[0] = new File("foo.10027c6de");
    files[1] = new File("foo.10027c6df");
    files[2] = new File("bar.10027c6dd");
    files[3] = new File("foo.10027c6dc");
    files[4] = new File("foo.20027c6dc");

    File[] orig = files.clone();

    List<File> filelist = Util.sortDataDir(files, "foo", true);

    Assert.assertEquals(orig[2], filelist.get(0));
    Assert.assertEquals(orig[3], filelist.get(1));
    Assert.assertEquals(orig[0], filelist.get(2));
    Assert.assertEquals(orig[1], filelist.get(3));
    Assert.assertEquals(orig[4], filelist.get(4));
}
项目:fuck_zookeeper    文件:ZooKeeperServerTest.java   
@Test
public void testSortDataDirDescending() {
    File[] files = new File[5];

    files[0] = new File("foo.10027c6de");
    files[1] = new File("foo.10027c6df");
    files[2] = new File("bar.10027c6dd");
    files[3] = new File("foo.10027c6dc");
    files[4] = new File("foo.20027c6dc");

    File[] orig = files.clone();

    List<File> filelist = Util.sortDataDir(files, "foo", false);

    Assert.assertEquals(orig[4], filelist.get(0));
    Assert.assertEquals(orig[1], filelist.get(1));
    Assert.assertEquals(orig[0], filelist.get(2));
    Assert.assertEquals(orig[3], filelist.get(3));
    Assert.assertEquals(orig[2], filelist.get(4));
}
项目:https-github.com-apache-zookeeper    文件:ZooKeeperServerTest.java   
@Test
public void testSortDataDirAscending() {
    File[] files = new File[5];

    files[0] = new File("foo.10027c6de");
    files[1] = new File("foo.10027c6df");
    files[2] = new File("bar.10027c6dd");
    files[3] = new File("foo.10027c6dc");
    files[4] = new File("foo.20027c6dc");

    File[] orig = files.clone();

    List<File> filelist = Util.sortDataDir(files, "foo", true);

    Assert.assertEquals(orig[2], filelist.get(0));
    Assert.assertEquals(orig[3], filelist.get(1));
    Assert.assertEquals(orig[0], filelist.get(2));
    Assert.assertEquals(orig[1], filelist.get(3));
    Assert.assertEquals(orig[4], filelist.get(4));
}
项目:https-github.com-apache-zookeeper    文件:ZooKeeperServerTest.java   
@Test
public void testSortDataDirDescending() {
    File[] files = new File[5];

    files[0] = new File("foo.10027c6de");
    files[1] = new File("foo.10027c6df");
    files[2] = new File("bar.10027c6dd");
    files[3] = new File("foo.10027c6dc");
    files[4] = new File("foo.20027c6dc");

    File[] orig = files.clone();

    List<File> filelist = Util.sortDataDir(files, "foo", false);

    Assert.assertEquals(orig[4], filelist.get(0));
    Assert.assertEquals(orig[1], filelist.get(1));
    Assert.assertEquals(orig[0], filelist.get(2));
    Assert.assertEquals(orig[3], filelist.get(3));
    Assert.assertEquals(orig[2], filelist.get(4));
}
项目:ZooKeeper    文件:ZooKeeperServerMainTest.java   
private void addRequestToSyncProcessor() {
    long zxid = ZxidUtils.makeZxid(3, 7);
    TxnHeader hdr = new TxnHeader(1, 1, zxid, 1,
            ZooDefs.OpCode.setData);
    Record txn = new SetDataTxn("/foo" + zxid, new byte[0], 1);
    byte[] buf;
    try {
        buf = Util.marshallTxnEntry(hdr, txn);
    } catch (IOException e) {
        LOG.error("IOException while adding request to SyncRequestProcessor", e);
        Assert.fail("IOException while adding request to SyncRequestProcessor!");
        return;
    }
    NettyServerCnxnFactory factory = new NettyServerCnxnFactory();
    final MockNettyServerCnxn nettyCnxn = new MockNettyServerCnxn(null,
            this, factory);
    Request req = new Request(nettyCnxn, 1, 1, ZooDefs.OpCode.setData,
            ByteBuffer.wrap(buf), null);
    req.hdr = hdr;
    req.txn = txn;
    syncProcessor.processRequest(req);
}
项目:ZooKeeper    文件:ZooKeeperServerTest.java   
@Test
public void testSortDataDirAscending() {
    File[] files = new File[5];

    files[0] = new File("foo.10027c6de");
    files[1] = new File("foo.10027c6df");
    files[2] = new File("bar.10027c6dd");
    files[3] = new File("foo.10027c6dc");
    files[4] = new File("foo.20027c6dc");

    File[] orig = files.clone();

    List<File> filelist = Util.sortDataDir(files, "foo", true);

    Assert.assertEquals(orig[2], filelist.get(0));
    Assert.assertEquals(orig[3], filelist.get(1));
    Assert.assertEquals(orig[0], filelist.get(2));
    Assert.assertEquals(orig[1], filelist.get(3));
    Assert.assertEquals(orig[4], filelist.get(4));
}
项目:ZooKeeper    文件:ZooKeeperServerTest.java   
@Test
public void testSortDataDirDescending() {
    File[] files = new File[5];

    files[0] = new File("foo.10027c6de");
    files[1] = new File("foo.10027c6df");
    files[2] = new File("bar.10027c6dd");
    files[3] = new File("foo.10027c6dc");
    files[4] = new File("foo.20027c6dc");

    File[] orig = files.clone();

    List<File> filelist = Util.sortDataDir(files, "foo", false);

    Assert.assertEquals(orig[4], filelist.get(0));
    Assert.assertEquals(orig[1], filelist.get(1));
    Assert.assertEquals(orig[0], filelist.get(2));
    Assert.assertEquals(orig[3], filelist.get(3));
    Assert.assertEquals(orig[2], filelist.get(4));
}
项目:StreamProcessingInfrastructure    文件:ZooKeeperServerMainTest.java   
private void addRequestToSyncProcessor() {
    long zxid = ZxidUtils.makeZxid(3, 7);
    TxnHeader hdr = new TxnHeader(1, 1, zxid, 1,
            ZooDefs.OpCode.setData);
    Record txn = new SetDataTxn("/foo" + zxid, new byte[0], 1);
    byte[] buf;
    try {
        buf = Util.marshallTxnEntry(hdr, txn);
    } catch (IOException e) {
        LOG.error("IOException while adding request to SyncRequestProcessor", e);
        Assert.fail("IOException while adding request to SyncRequestProcessor!");
        return;
    }
    NettyServerCnxnFactory factory = new NettyServerCnxnFactory();
    final MockNettyServerCnxn nettyCnxn = new MockNettyServerCnxn(null,
            this, factory);
    Request req = new Request(nettyCnxn, 1, 1, ZooDefs.OpCode.setData,
            ByteBuffer.wrap(buf), null);
    req.hdr = hdr;
    req.txn = txn;
    syncProcessor.processRequest(req);
}
项目:StreamProcessingInfrastructure    文件:ZooKeeperServerTest.java   
@Test
public void testSortDataDirAscending() {
    File[] files = new File[5];

    files[0] = new File("foo.10027c6de");
    files[1] = new File("foo.10027c6df");
    files[2] = new File("bar.10027c6dd");
    files[3] = new File("foo.10027c6dc");
    files[4] = new File("foo.20027c6dc");

    File[] orig = files.clone();

    List<File> filelist = Util.sortDataDir(files, "foo", true);

    Assert.assertEquals(orig[2], filelist.get(0));
    Assert.assertEquals(orig[3], filelist.get(1));
    Assert.assertEquals(orig[0], filelist.get(2));
    Assert.assertEquals(orig[1], filelist.get(3));
    Assert.assertEquals(orig[4], filelist.get(4));
}
项目:StreamProcessingInfrastructure    文件:ZooKeeperServerTest.java   
@Test
public void testSortDataDirDescending() {
    File[] files = new File[5];

    files[0] = new File("foo.10027c6de");
    files[1] = new File("foo.10027c6df");
    files[2] = new File("bar.10027c6dd");
    files[3] = new File("foo.10027c6dc");
    files[4] = new File("foo.20027c6dc");

    File[] orig = files.clone();

    List<File> filelist = Util.sortDataDir(files, "foo", false);

    Assert.assertEquals(orig[4], filelist.get(0));
    Assert.assertEquals(orig[1], filelist.get(1));
    Assert.assertEquals(orig[0], filelist.get(2));
    Assert.assertEquals(orig[3], filelist.get(3));
    Assert.assertEquals(orig[2], filelist.get(4));
}
项目:StreamProcessingInfrastructure    文件:ZooKeeperServerTest.java   
@Test
public void testInvalidSnapshot() {
    File f = null;
    File tmpFileDir = null;
    try {
        tmpFileDir = ClientBase.createTmpDir();
        f = new File(tmpFileDir, "snapshot.0");
        if (!f.exists()) {
            f.createNewFile();
        }
        Assert.assertFalse("Snapshot file size is greater than 9 bytes", Util.isValidSnapshot(f));
        Assert.assertTrue("Can't delete file", f.delete());
    } catch (IOException e) {
    } finally {
        if (null != tmpFileDir) {
            ClientBase.recursiveDelete(tmpFileDir);
        }
    }
}
项目:bigstreams    文件:ZooKeeperServerTest.java   
@Test
public void testSortDataDirAscending() {
    File[] files = new File[5];

    files[0] = new File("foo.10027c6de");
    files[1] = new File("foo.10027c6df");
    files[2] = new File("bar.10027c6dd");
    files[3] = new File("foo.10027c6dc");
    files[4] = new File("foo.20027c6dc");

    File[] orig = files.clone();

    List<File> filelist = Util.sortDataDir(files, "foo", true);

    Assert.assertEquals(orig[2], filelist.get(0));
    Assert.assertEquals(orig[3], filelist.get(1));
    Assert.assertEquals(orig[0], filelist.get(2));
    Assert.assertEquals(orig[1], filelist.get(3));
    Assert.assertEquals(orig[4], filelist.get(4));
}
项目:bigstreams    文件:ZooKeeperServerTest.java   
@Test
public void testSortDataDirDescending() {
    File[] files = new File[5];

    files[0] = new File("foo.10027c6de");
    files[1] = new File("foo.10027c6df");
    files[2] = new File("bar.10027c6dd");
    files[3] = new File("foo.10027c6dc");
    files[4] = new File("foo.20027c6dc");

    File[] orig = files.clone();

    List<File> filelist = Util.sortDataDir(files, "foo", false);

    Assert.assertEquals(orig[4], filelist.get(0));
    Assert.assertEquals(orig[1], filelist.get(1));
    Assert.assertEquals(orig[0], filelist.get(2));
    Assert.assertEquals(orig[3], filelist.get(3));
    Assert.assertEquals(orig[2], filelist.get(4));
}
项目:bigstreams    文件:ZooKeeperServerTest.java   
@Test
public void testInvalidSnapshot() {
    File f = null;
    File tmpFileDir = null;
    try {
        tmpFileDir = ClientBase.createTmpDir();
        f = new File(tmpFileDir, "snapshot.0");
        if (!f.exists()) {
            f.createNewFile();
        }
        Assert.assertFalse("Snapshot file size is greater than 9 bytes", Util.isValidSnapshot(f));
        Assert.assertTrue("Can't delete file", f.delete());
    } catch (IOException e) {
    } finally {
        if (null != tmpFileDir) {
            ClientBase.recursiveDelete(tmpFileDir);
        }
    }
}
项目:bigstreams    文件:ZooKeeperServerTest.java   
@Test
public void testSortDataDirAscending() {
    File[] files = new File[5];

    files[0] = new File("foo.10027c6de");
    files[1] = new File("foo.10027c6df");
    files[2] = new File("bar.10027c6dd");
    files[3] = new File("foo.10027c6dc");
    files[4] = new File("foo.20027c6dc");

    File[] orig = files.clone();

    List<File> filelist = Util.sortDataDir(files, "foo", true);

    Assert.assertEquals(orig[2], filelist.get(0));
    Assert.assertEquals(orig[3], filelist.get(1));
    Assert.assertEquals(orig[0], filelist.get(2));
    Assert.assertEquals(orig[1], filelist.get(3));
    Assert.assertEquals(orig[4], filelist.get(4));
}
项目:bigstreams    文件:ZooKeeperServerTest.java   
@Test
public void testSortDataDirDescending() {
    File[] files = new File[5];

    files[0] = new File("foo.10027c6de");
    files[1] = new File("foo.10027c6df");
    files[2] = new File("bar.10027c6dd");
    files[3] = new File("foo.10027c6dc");
    files[4] = new File("foo.20027c6dc");

    File[] orig = files.clone();

    List<File> filelist = Util.sortDataDir(files, "foo", false);

    Assert.assertEquals(orig[4], filelist.get(0));
    Assert.assertEquals(orig[1], filelist.get(1));
    Assert.assertEquals(orig[0], filelist.get(2));
    Assert.assertEquals(orig[3], filelist.get(3));
    Assert.assertEquals(orig[2], filelist.get(4));
}
项目:zookeeper    文件:ZooKeeperServerMainTest.java   
private void addRequestToSyncProcessor() {
    long zxid = ZxidUtils.makeZxid(3, 7);
    TxnHeader hdr = new TxnHeader(1, 1, zxid, 1,
            ZooDefs.OpCode.setData);
    Record txn = new SetDataTxn("/foo" + zxid, new byte[0], 1);
    byte[] buf;
    try {
        buf = Util.marshallTxnEntry(hdr, txn);
    } catch (IOException e) {
        LOG.error("IOException while adding request to SyncRequestProcessor", e);
        Assert.fail("IOException while adding request to SyncRequestProcessor!");
        return;
    }
    NettyServerCnxnFactory factory = new NettyServerCnxnFactory();
    final MockNettyServerCnxn nettyCnxn = new MockNettyServerCnxn(null,
            this, factory);
    Request req = new Request(nettyCnxn, 1, 1, ZooDefs.OpCode.setData,
            ByteBuffer.wrap(buf), null);
    req.hdr = hdr;
    req.txn = txn;
    syncProcessor.processRequest(req);
}
项目:zookeeper    文件:ZooKeeperServerTest.java   
@Test
public void testSortDataDirAscending() {
    File[] files = new File[5];

    files[0] = new File("foo.10027c6de");
    files[1] = new File("foo.10027c6df");
    files[2] = new File("bar.10027c6dd");
    files[3] = new File("foo.10027c6dc");
    files[4] = new File("foo.20027c6dc");

    File[] orig = files.clone();

    List<File> filelist = Util.sortDataDir(files, "foo", true);

    Assert.assertEquals(orig[2], filelist.get(0));
    Assert.assertEquals(orig[3], filelist.get(1));
    Assert.assertEquals(orig[0], filelist.get(2));
    Assert.assertEquals(orig[1], filelist.get(3));
    Assert.assertEquals(orig[4], filelist.get(4));
}
项目:zookeeper    文件:ZooKeeperServerTest.java   
@Test
public void testSortDataDirDescending() {
    File[] files = new File[5];

    files[0] = new File("foo.10027c6de");
    files[1] = new File("foo.10027c6df");
    files[2] = new File("bar.10027c6dd");
    files[3] = new File("foo.10027c6dc");
    files[4] = new File("foo.20027c6dc");

    File[] orig = files.clone();

    List<File> filelist = Util.sortDataDir(files, "foo", false);

    Assert.assertEquals(orig[4], filelist.get(0));
    Assert.assertEquals(orig[1], filelist.get(1));
    Assert.assertEquals(orig[0], filelist.get(2));
    Assert.assertEquals(orig[3], filelist.get(3));
    Assert.assertEquals(orig[2], filelist.get(4));
}
项目:zookeeper    文件:ZooKeeperServerTest.java   
@Test
public void testInvalidSnapshot() {
    File f = null;
    File tmpFileDir = null;
    try {
        tmpFileDir = ClientBase.createTmpDir();
        f = new File(tmpFileDir, "snapshot.0");
        if (!f.exists()) {
            f.createNewFile();
        }
        Assert.assertFalse("Snapshot file size is greater than 9 bytes", Util.isValidSnapshot(f));
        Assert.assertTrue("Can't delete file", f.delete());
    } catch (IOException e) {
    } finally {
        if (null != tmpFileDir) {
            ClientBase.recursiveDelete(tmpFileDir);
        }
    }
}
项目:SecureKeeper    文件:ZooKeeperServerTest.java   
@Test
public void testSortDataDirAscending() {
    File[] files = new File[5];

    files[0] = new File("foo.10027c6de");
    files[1] = new File("foo.10027c6df");
    files[2] = new File("bar.10027c6dd");
    files[3] = new File("foo.10027c6dc");
    files[4] = new File("foo.20027c6dc");

    File[] orig = files.clone();

    List<File> filelist = Util.sortDataDir(files, "foo", true);

    Assert.assertEquals(orig[2], filelist.get(0));
    Assert.assertEquals(orig[3], filelist.get(1));
    Assert.assertEquals(orig[0], filelist.get(2));
    Assert.assertEquals(orig[1], filelist.get(3));
    Assert.assertEquals(orig[4], filelist.get(4));
}
项目:SecureKeeper    文件:ZooKeeperServerTest.java   
@Test
public void testSortDataDirDescending() {
    File[] files = new File[5];

    files[0] = new File("foo.10027c6de");
    files[1] = new File("foo.10027c6df");
    files[2] = new File("bar.10027c6dd");
    files[3] = new File("foo.10027c6dc");
    files[4] = new File("foo.20027c6dc");

    File[] orig = files.clone();

    List<File> filelist = Util.sortDataDir(files, "foo", false);

    Assert.assertEquals(orig[4], filelist.get(0));
    Assert.assertEquals(orig[1], filelist.get(1));
    Assert.assertEquals(orig[0], filelist.get(2));
    Assert.assertEquals(orig[3], filelist.get(3));
    Assert.assertEquals(orig[2], filelist.get(4));
}
项目:SecureKeeper    文件:ZooKeeperServerTest.java   
@Test
public void testInvalidSnapshot() {
    File f = null;
    File tmpFileDir = null;
    try {
        tmpFileDir = ClientBase.createTmpDir();
        f = new File(tmpFileDir, "snapshot.0");
        if (!f.exists()) {
            f.createNewFile();
        }
        Assert.assertFalse("Snapshot file size is greater than 9 bytes", Util.isValidSnapshot(f));
        Assert.assertTrue("Can't delete file", f.delete());
    } catch (IOException e) {
    } finally {
        if (null != tmpFileDir) {
            ClientBase.recursiveDelete(tmpFileDir);
        }
    }
}
项目:SecureKeeper    文件:ZooKeeperServerTest.java   
@Test
public void testSortDataDirAscending() {
    File[] files = new File[5];

    files[0] = new File("foo.10027c6de");
    files[1] = new File("foo.10027c6df");
    files[2] = new File("bar.10027c6dd");
    files[3] = new File("foo.10027c6dc");
    files[4] = new File("foo.20027c6dc");

    File[] orig = files.clone();

    List<File> filelist = Util.sortDataDir(files, "foo", true);

    Assert.assertEquals(orig[2], filelist.get(0));
    Assert.assertEquals(orig[3], filelist.get(1));
    Assert.assertEquals(orig[0], filelist.get(2));
    Assert.assertEquals(orig[1], filelist.get(3));
    Assert.assertEquals(orig[4], filelist.get(4));
}
项目:SecureKeeper    文件:ZooKeeperServerTest.java   
@Test
public void testSortDataDirDescending() {
    File[] files = new File[5];

    files[0] = new File("foo.10027c6de");
    files[1] = new File("foo.10027c6df");
    files[2] = new File("bar.10027c6dd");
    files[3] = new File("foo.10027c6dc");
    files[4] = new File("foo.20027c6dc");

    File[] orig = files.clone();

    List<File> filelist = Util.sortDataDir(files, "foo", false);

    Assert.assertEquals(orig[4], filelist.get(0));
    Assert.assertEquals(orig[1], filelist.get(1));
    Assert.assertEquals(orig[0], filelist.get(2));
    Assert.assertEquals(orig[3], filelist.get(3));
    Assert.assertEquals(orig[2], filelist.get(4));
}
项目:SecureKeeper    文件:ZooKeeperServerTest.java   
@Test
public void testInvalidSnapshot() {
    File f = null;
    File tmpFileDir = null;
    try {
        tmpFileDir = ClientBase.createTmpDir();
        f = new File(tmpFileDir, "snapshot.0");
        if (!f.exists()) {
            f.createNewFile();
        }
        Assert.assertFalse("Snapshot file size is greater than 9 bytes", Util.isValidSnapshot(f));
        Assert.assertTrue("Can't delete file", f.delete());
    } catch (IOException e) {
    } finally {
        if (null != tmpFileDir) {
            ClientBase.recursiveDelete(tmpFileDir);
        }
    }
}
项目:StreamBench    文件:ZooKeeperServerTest.java   
@Test
public void testSortDataDirAscending() {
    File[] files = new File[5];

    files[0] = new File("foo.10027c6de");
    files[1] = new File("foo.10027c6df");
    files[2] = new File("bar.10027c6dd");
    files[3] = new File("foo.10027c6dc");
    files[4] = new File("foo.20027c6dc");

    File[] orig = files.clone();

    List<File> filelist = Util.sortDataDir(files, "foo", true);

    Assert.assertEquals(orig[2], filelist.get(0));
    Assert.assertEquals(orig[3], filelist.get(1));
    Assert.assertEquals(orig[0], filelist.get(2));
    Assert.assertEquals(orig[1], filelist.get(3));
    Assert.assertEquals(orig[4], filelist.get(4));
}
项目:StreamBench    文件:ZooKeeperServerTest.java   
@Test
public void testSortDataDirDescending() {
    File[] files = new File[5];

    files[0] = new File("foo.10027c6de");
    files[1] = new File("foo.10027c6df");
    files[2] = new File("bar.10027c6dd");
    files[3] = new File("foo.10027c6dc");
    files[4] = new File("foo.20027c6dc");

    File[] orig = files.clone();

    List<File> filelist = Util.sortDataDir(files, "foo", false);

    Assert.assertEquals(orig[4], filelist.get(0));
    Assert.assertEquals(orig[1], filelist.get(1));
    Assert.assertEquals(orig[0], filelist.get(2));
    Assert.assertEquals(orig[3], filelist.get(3));
    Assert.assertEquals(orig[2], filelist.get(4));
}
项目:StreamBench    文件:ZooKeeperServerTest.java   
@Test
public void testInvalidSnapshot() {
    File f = null;
    File tmpFileDir = null;
    try {
        tmpFileDir = ClientBase.createTmpDir();
        f = new File(tmpFileDir, "snapshot.0");
        if (!f.exists()) {
            f.createNewFile();
        }
        Assert.assertFalse("Snapshot file size is greater than 9 bytes", Util.isValidSnapshot(f));
        Assert.assertTrue("Can't delete file", f.delete());
    } catch (IOException e) {
    } finally {
        if (null != tmpFileDir) {
            ClientBase.recursiveDelete(tmpFileDir);
        }
    }
}
项目:LoadBalanced_zk    文件:ZooKeeperServerTest.java   
@Test
public void testSortDataDirAscending() {
    File[] files = new File[5];

    files[0] = new File("foo.10027c6de");
    files[1] = new File("foo.10027c6df");
    files[2] = new File("bar.10027c6dd");
    files[3] = new File("foo.10027c6dc");
    files[4] = new File("foo.20027c6dc");

    File[] orig = files.clone();

    List<File> filelist = Util.sortDataDir(files, "foo", true);

    Assert.assertEquals(orig[2], filelist.get(0));
    Assert.assertEquals(orig[3], filelist.get(1));
    Assert.assertEquals(orig[0], filelist.get(2));
    Assert.assertEquals(orig[1], filelist.get(3));
    Assert.assertEquals(orig[4], filelist.get(4));
}
项目:LoadBalanced_zk    文件:ZooKeeperServerTest.java   
@Test
public void testSortDataDirDescending() {
    File[] files = new File[5];

    files[0] = new File("foo.10027c6de");
    files[1] = new File("foo.10027c6df");
    files[2] = new File("bar.10027c6dd");
    files[3] = new File("foo.10027c6dc");
    files[4] = new File("foo.20027c6dc");

    File[] orig = files.clone();

    List<File> filelist = Util.sortDataDir(files, "foo", false);

    Assert.assertEquals(orig[4], filelist.get(0));
    Assert.assertEquals(orig[1], filelist.get(1));
    Assert.assertEquals(orig[0], filelist.get(2));
    Assert.assertEquals(orig[3], filelist.get(3));
    Assert.assertEquals(orig[2], filelist.get(4));
}
项目:LoadBalanced_zk    文件:ZooKeeperServerTest.java   
@Test
public void testInvalidSnapshot() {
    File f = null;
    File tmpFileDir = null;
    try {
        tmpFileDir = ClientBase.createTmpDir();
        f = new File(tmpFileDir, "snapshot.0");
        if (!f.exists()) {
            f.createNewFile();
        }
        Assert.assertFalse("Snapshot file size is greater than 9 bytes", Util.isValidSnapshot(f));
        Assert.assertTrue("Can't delete file", f.delete());
    } catch (IOException e) {
    } finally {
        if (null != tmpFileDir) {
            ClientBase.recursiveDelete(tmpFileDir);
        }
    }
}
项目:LoadBalanced_zk    文件:ZooKeeperServerTest.java   
@Test
public void testSortDataDirAscending() {
    File[] files = new File[5];

    files[0] = new File("foo.10027c6de");
    files[1] = new File("foo.10027c6df");
    files[2] = new File("bar.10027c6dd");
    files[3] = new File("foo.10027c6dc");
    files[4] = new File("foo.20027c6dc");

    File[] orig = files.clone();

    List<File> filelist = Util.sortDataDir(files, "foo", true);

    Assert.assertEquals(orig[2], filelist.get(0));
    Assert.assertEquals(orig[3], filelist.get(1));
    Assert.assertEquals(orig[0], filelist.get(2));
    Assert.assertEquals(orig[1], filelist.get(3));
    Assert.assertEquals(orig[4], filelist.get(4));
}
项目:LoadBalanced_zk    文件:ZooKeeperServerTest.java   
@Test
public void testSortDataDirDescending() {
    File[] files = new File[5];

    files[0] = new File("foo.10027c6de");
    files[1] = new File("foo.10027c6df");
    files[2] = new File("bar.10027c6dd");
    files[3] = new File("foo.10027c6dc");
    files[4] = new File("foo.20027c6dc");

    File[] orig = files.clone();

    List<File> filelist = Util.sortDataDir(files, "foo", false);

    Assert.assertEquals(orig[4], filelist.get(0));
    Assert.assertEquals(orig[1], filelist.get(1));
    Assert.assertEquals(orig[0], filelist.get(2));
    Assert.assertEquals(orig[3], filelist.get(3));
    Assert.assertEquals(orig[2], filelist.get(4));
}
项目:LoadBalanced_zk    文件:ZooKeeperServerTest.java   
@Test
public void testInvalidSnapshot() {
    File f = null;
    File tmpFileDir = null;
    try {
        tmpFileDir = ClientBase.createTmpDir();
        f = new File(tmpFileDir, "snapshot.0");
        if (!f.exists()) {
            f.createNewFile();
        }
        Assert.assertFalse("Snapshot file size is greater than 9 bytes", Util.isValidSnapshot(f));
        Assert.assertTrue("Can't delete file", f.delete());
    } catch (IOException e) {
    } finally {
        if (null != tmpFileDir) {
            ClientBase.recursiveDelete(tmpFileDir);
        }
    }
}
项目:zookeeper.dsc    文件:ZooKeeperServerTest.java   
@Test
public void testSortDataDirAscending() {
    File[] files = new File[5];

    files[0] = new File("foo.10027c6de");
    files[1] = new File("foo.10027c6df");
    files[2] = new File("bar.10027c6dd");
    files[3] = new File("foo.10027c6dc");
    files[4] = new File("foo.20027c6dc");

    File[] orig = files.clone();

    List<File> filelist = Util.sortDataDir(files, "foo", true);

    assertEquals(orig[2], filelist.get(0));
    assertEquals(orig[3], filelist.get(1));
    assertEquals(orig[0], filelist.get(2));
    assertEquals(orig[1], filelist.get(3));
    assertEquals(orig[4], filelist.get(4));
}
项目:zookeeper.dsc    文件:ZooKeeperServerTest.java   
@Test
public void testSortDataDirDescending() {
    File[] files = new File[5];

    files[0] = new File("foo.10027c6de");
    files[1] = new File("foo.10027c6df");
    files[2] = new File("bar.10027c6dd");
    files[3] = new File("foo.10027c6dc");
    files[4] = new File("foo.20027c6dc");

    File[] orig = files.clone();

    List<File> filelist = Util.sortDataDir(files, "foo", false);

    assertEquals(orig[4], filelist.get(0));
    assertEquals(orig[1], filelist.get(1));
    assertEquals(orig[0], filelist.get(2));
    assertEquals(orig[3], filelist.get(3));
    assertEquals(orig[2], filelist.get(4));
}
项目:zookeeper.dsc    文件:ZooKeeperServerTest.java   
@Test
public void testInvalidSnapshot() {
    File f = null;
    File tmpFileDir = null;
    try {
        tmpFileDir = ClientBase.createTmpDir();
        f = new File(tmpFileDir, "snapshot.0");
        if (!f.exists()) {
            f.createNewFile();
        }
        Assert.assertFalse("Snapshot file size is greater than 9 bytes",
                Util.isValidSnapshot(f));
        Assert.assertTrue("Can't delete file", f.delete());
    } catch (IOException e) {
    } finally {
        if (null != tmpFileDir) {
            ClientBase.recursiveDelete(tmpFileDir);
        }
    }
}
项目:zookeeper-pkg    文件:ZooKeeperServerTest.java   
@Test
public void testSortDataDirAscending() {
    File[] files = new File[5];

    files[0] = new File("foo.10027c6de");
    files[1] = new File("foo.10027c6df");
    files[2] = new File("bar.10027c6dd");
    files[3] = new File("foo.10027c6dc");
    files[4] = new File("foo.20027c6dc");

    File[] orig = files.clone();

    List<File> filelist = Util.sortDataDir(files, "foo", true);

    Assert.assertEquals(orig[2], filelist.get(0));
    Assert.assertEquals(orig[3], filelist.get(1));
    Assert.assertEquals(orig[0], filelist.get(2));
    Assert.assertEquals(orig[1], filelist.get(3));
    Assert.assertEquals(orig[4], filelist.get(4));
}