Exemplo n.º 1
0
  @Test
  public void testLinkQueue() throws Exception {
    Log.info(Log.FAC_TEST, "Started testLinkQueue");

    String prefix = String.format("/repotest/test_%016X", rnd.nextLong());
    String queuenamestring = prefix + "/queue";
    String objnamestring = prefix + "/obj";
    ContentName queuename = ContentName.fromNative(queuenamestring);
    ContentName objname = ContentName.fromNative(objnamestring);
    int objsize = 1024 * 600;
    CCNHandle recvhandle = CCNHandle.getHandle();
    CCNHandle sendhandle = CCNHandle.open(recvhandle.keyManager());

    char[] buf = new char[objsize];
    Arrays.fill(buf, 'x');
    String objfill = String.valueOf(buf);

    VersioningInterest vi = new VersioningInterest(recvhandle);
    TestListener listener = new TestListener();
    vi.expressInterest(queuename, listener);

    Thread.sleep(1000);

    CCNStringObject so =
        new CCNStringObject(objname, objfill, SaveType.LOCALREPOSITORY, sendhandle);
    so.save();
    so.close();

    Link link = new Link(so.getVersionedName());
    LinkObject lo = new LinkObject(queuename, link, SaveType.LOCALREPOSITORY, sendhandle);
    lo.save();
    lo.close();

    sendhandle.close();

    // now see if we got it in the TestListener

    Assert.assertTrue(listener.cl.waitForValue(1, 60000));

    ReceivedData rd = listener.received.get(0);

    ContentObject co = rd.object;

    CCNStringObject so2 = new CCNStringObject(co.name(), recvhandle);

    Assert.assertEquals(so, so2);

    Log.info(Log.FAC_TEST, "Completed testLinkQueue");
  }
  @BeforeClass
  public static void setUpBeforeClass() throws Exception {

    CCNTestHelper testHelper = new CCNTestHelper(GroupRecursiveKeyUpdateTestRepo.class);
    directoryBase = testHelper.getTestNamespace("testInOrder");
    userNamespace =
        GroupAccessControlProfile.userNamespaceName(UserConfiguration.defaultNamespace());
    groupNamespace =
        GroupAccessControlProfile.groupNamespaceName(UserConfiguration.defaultNamespace());
    userKeyStorePrefix = ContentName.fromNative(UserConfiguration.defaultNamespace(), "_keystore_");

    // create user identities with TestUserData
    td = new CreateUserData(userKeyStorePrefix, numberOfusers, true, "password".toCharArray());
    td.publishUserKeysToRepository(userNamespace);
    friendlyNames = td.friendlyNames().toArray(new String[0]);

    // create ACM
    handle = td.getHandleForUser(friendlyNames[1]);
    acm = new GroupAccessControlManager(directoryBase, groupNamespace, userNamespace, handle);
    acm.publishMyIdentity(
        ContentName.fromNative(userNamespace, friendlyNames[1]),
        handle.keyManager().getDefaultPublicKey());
  }