Package freenet.keys

Examples of freenet.keys.ClientCHKBlock


    CHKStore store = new CHKStore();
    new RAMFreenetStore<CHKBlock>(store, 10);

    // Encode a block
    String test = "test";
    ClientCHKBlock block = encodeBlock(test, newFormat);
    store.put(block.getBlock(), false);

    ClientCHK key = block.getClientKey();

    CHKBlock verify = store.fetch(key.getNodeCHK(), false, false, null);
    String data = decodeBlock(verify, key);
    assertEquals(test, data);
  }
View Full Code Here


    CHKStore store = new CHKStore();
    new RAMFreenetStore<CHKBlock>(store, 10);

    // Encode a block
    String test = "test";
    ClientCHKBlock block = encodeBlock(test, false);
    store.put(block.getBlock(), true);

    ClientCHK key = block.getClientKey();

    CHKBlock verify = store.fetch(key.getNodeCHK(), false, false, null);
    String data = decodeBlock(verify, key);
    assertEquals(test, data);
   
    // ignoreOldBlocks works.
    assertEquals(null, store.fetch(key.getNodeCHK(), false, true, null));
   
    // Put it with oldBlock = false should unset the flag.
    store.put(block.getBlock(), false);
   
    verify = store.fetch(key.getNodeCHK(), false, true, null);
    data = decodeBlock(verify, key);
    assertEquals(test, data);
  }
View Full Code Here

    for(int i=0;i<5;i++) {
     
      // Encode a block
      String test = "test" + i;
      ClientCHKBlock block = encodeBlock(test, newFormat);
      store.put(block.getBlock(), false);
     
      ClientCHK key = block.getClientKey();
     
      CHKBlock verify = store.fetch(key.getNodeCHK(), false, false, null);
      String data = decodeBlock(verify, key);
      assertEquals(test, data);
    }
View Full Code Here

    for(int i=0;i<5;i++) {
     
      // Encode a block
      String test = "test" + i;
      // Use new format for every other block to ensure they are mixed in the same store.
      ClientCHKBlock block = encodeBlock(test, (i & 1) == 1);
      if(write)
        store.put(block.getBlock(), false);
     
      ClientCHK key = block.getClientKey();
     
      CHKBlock verify = store.fetch(key.getNodeCHK(), false, false, null);
      if(expectFailure)
        assertEquals(null, verify);
      else {
View Full Code Here

    CHKStore store = new CHKStore();
    RAMFreenetStore<CHKBlock> ramStore = new RAMFreenetStore<CHKBlock>(store, 10);

    // Encode a block
    String test = "test";
    ClientCHKBlock block = encodeBlock(test, true);
    store.put(block.getBlock(), false);

    ClientCHK key = block.getClientKey();

    CHKBlock verify = store.fetch(key.getNodeCHK(), false, false, null);
    String data = decodeBlock(verify, key);
    assertEquals(test, data);
View Full Code Here

    CHKStore store = new CHKStore();
    RAMFreenetStore<CHKBlock> ramStore = new RAMFreenetStore<CHKBlock>(store, 10);

    // Encode a block
    String test = "test";
    ClientCHKBlock block = encodeBlock(test, true);
    store.put(block.getBlock(), false);

    ClientCHK key = block.getClientKey();

    CHKBlock verify = store.fetch(key.getNodeCHK(), false, false, null);
    String data = decodeBlock(verify, key);
    assertEquals(test, data);
View Full Code Here

    assertEquals(test, newData);
    saltStore.close();
  }

  private String decodeBlock(CHKBlock verify, ClientCHK key) throws CHKVerifyException, CHKDecodeException, IOException {
    ClientCHKBlock cb = new ClientCHKBlock(verify, key);
    Bucket output = cb.decode(new ArrayBucketFactory(), 32768, false);
    byte[] buf = BucketTools.toByteArray(output);
    return new String(buf, "UTF-8");
  }
View Full Code Here

    CHKStore store = new CHKStore();
    new SlashdotStore<CHKBlock>(store, 10, 30*1000, 5*1000, new TrivialTicker(exec), tbf);
   
    // Encode a block
    String test = "test";
    ClientCHKBlock block = encodeBlock(test);
    store.put(block.getBlock(), false);
   
    ClientCHK key = block.getClientKey();
   
    CHKBlock verify = store.fetch(key.getNodeCHK(), false, false, null);
    String data = decodeBlock(verify, key);
    assertEquals(test, data);
  }
View Full Code Here

    CHKStore store = new CHKStore();
    new SlashdotStore<CHKBlock>(store, 10, 500, 100, new TrivialTicker(exec), tbf);
   
    // Encode a block
    String test = "test";
    ClientCHKBlock block = encodeBlock(test);
    store.put(block.getBlock(), false);
   
    Thread.sleep(2000);
   
    ClientCHK key = block.getClientKey();
   
    CHKBlock verify = store.fetch(key.getNodeCHK(), false, false, null);
    if(verify == null) return; // Expected outcome
    String data = decodeBlock(verify, key);
    System.err.println("Got data: "+data+" but should have been deleted!");
View Full Code Here

    System.err.println("Got data: "+data+" but should have been deleted!");
    assertTrue(false);
  }

  private String decodeBlock(CHKBlock verify, ClientCHK key) throws CHKVerifyException, CHKDecodeException, IOException {
    ClientCHKBlock cb = new ClientCHKBlock(verify, key);
    Bucket output = cb.decode(new ArrayBucketFactory(), 32768, false);
    byte[] buf = BucketTools.toByteArray(output);
    return new String(buf, "UTF-8");
  }
View Full Code Here

TOP

Related Classes of freenet.keys.ClientCHKBlock

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.