Exemplo n.º 1
0
  @Test
  public void testInit() throws Exception {

    System.out.println("************************************************************");
    System.out.println("***************************Init*****************************");
    System.out.println("************************************************************");
    localBucketIndex.start();

    System.out.println("*************************");
    System.out.println(localBucketIndex.getIndex().get());
    System.out.println("*************************");

    Assert.assertEquals(
        "20120710/bucket-0", localBucketIndex.getIndex().get().get(new Sequence(120710, 0)));
    Assert.assertEquals(
        "20120710/bucket-1", localBucketIndex.getIndex().get().get(new Sequence(120710, 1)));

    System.out.println("*************************************************************");
    System.out.println("****************************End******************************");
    System.out.println("*************************************************************");
  }
Exemplo n.º 2
0
  @Test
  public void testAddBucket() throws Exception {
    System.out.println("*************************************************************");
    System.out.println("***********************testAddBucket*************************");
    System.out.println("*************************************************************");
    localBucketIndex.start();

    work = new File(System.getProperty("java.io.tmpdir", "."), "Puma/20120711/bucket-0");
    work.getParentFile().mkdirs();

    try {
      if (work.createNewFile()) System.out.println("create a file!");
    } catch (IOException e1) {
      e1.printStackTrace();
    }

    Sequence sequence = new Sequence(120711, 0);

    Bucket bucket = null;
    try {
      bucket = new LocalFileBucket(work, sequence, 10, "20120711/bucket-0", false);
      localBucketIndex.add(bucket);

    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (StorageClosedException e) {
      e.printStackTrace();
    }

    Assert.assertEquals("20120711/bucket-0", localBucketIndex.getIndex().get().get(sequence));
    try {
      bucket.stop();
    } catch (IOException e) {
      e.printStackTrace();
    }
    System.out.println("*************************************************************");
    System.out.println("****************************End******************************");
    System.out.println("*************************************************************");
  }