コード例 #1
0
  @Test
  public void testPathfinder() throws Exception {
    Log.info(Log.FAC_TEST, "Starting testPathfinder");

    // Make the content
    ContentName testRoot = testHelper.getTestNamespace("testPathfinder");
    ContentName startingPoint =
        new ContentName(testRoot, "This", "is", "a", "longer", "path", "than", "necessary.");

    CCNStringObject targetObject =
        new CCNStringObject(
            new ContentName(startingPoint.parent().parent().parent(), TARGET_POSTFIX_NAME),
            "The target!",
            SaveType.REPOSITORY,
            writeHandle);
    targetObject.save();

    Pathfinder finder =
        new Pathfinder(
            startingPoint,
            null,
            TARGET_POSTFIX_NAME,
            true,
            false,
            SystemConfiguration.SHORT_TIMEOUT,
            null,
            readHandle);
    SearchResults results = finder.waitForResults();
    Assert.assertNotNull(results.getResult());

    Log.info(Log.FAC_TEST, "Completed testPathfinder");
  }
コード例 #2
0
ファイル: Flosser.java プロジェクト: CLao/BitNomen
 /**
  * Handle a top-level namespace.
  *
  * @param namespace
  * @throws IOException
  */
 public void handleNamespace(ContentName namespace) throws IOException {
   synchronized (_interests) {
     if (_shutdown) {
       Log.info(
           Log.FAC_TEST,
           "FLOSSER: in the process of shutting down. Not handling new namespace {0}.",
           namespace);
       return;
     }
     if (_interests.containsKey(namespace)) {
       Log.fine(Log.FAC_TEST, "FLOSSER: Already handling namespace: {0}", namespace);
       return;
     }
     Log.info(Log.FAC_TEST, "FLOSSER: handling namespace: {0}", namespace);
     Interest namespaceInterest = new Interest(namespace);
     _interests.put(namespace, namespaceInterest);
     _handle.expressInterest(namespaceInterest, this);
     Set<ContentName> subNamespaces = _subInterests.get(namespace);
     if (null == subNamespaces) {
       subNamespaces = new HashSet<ContentName>();
       _subInterests.put(namespace, subNamespaces);
       Log.info(Log.FAC_TEST, "FLOSSER: setup parent namespace: {0}", namespace);
     }
   }
 }
コード例 #3
0
ファイル: EnumeratedNameList.java プロジェクト: wjz/ccnx
 /**
  * Wait for new children to arrive.
  *
  * @param timeout Maximum time to wait for new data.
  * @return a boolean value that indicates whether new data was found.
  *     <p>Deprecated - see #getNewData(long)
  */
 @Deprecated
 public boolean waitForNewChildren(long timeout) {
   boolean foundNewData = false;
   synchronized (_childLock) {
     CCNTime lastUpdate = _lastUpdate;
     long timeRemaining = timeout;
     long startTime = System.currentTimeMillis();
     while (((null == _lastUpdate) || ((null != lastUpdate) && !_lastUpdate.after(lastUpdate)))
         && ((timeout == SystemConfiguration.NO_TIMEOUT) || (timeRemaining > 0))) {
       try {
         _childLock.wait(
             (timeout != SystemConfiguration.NO_TIMEOUT)
                 ? Math.min(timeRemaining, SystemConfiguration.CHILD_WAIT_INTERVAL)
                 : SystemConfiguration.CHILD_WAIT_INTERVAL);
         if (timeout != SystemConfiguration.NO_TIMEOUT) {
           timeRemaining = timeout - (System.currentTimeMillis() - startTime);
         }
       } catch (InterruptedException e) {
       }
       if (Log.isLoggable(Level.INFO)) {
         Log.info(
             "Waiting for new data on prefix: {0}, updated {1}, our update {2}, have {3} children {4} new.",
             _namePrefix,
             _lastUpdate,
             lastUpdate,
             ((null == _children) ? 0 : _children.size()),
             ((null == _newChildren) ? 0 : _newChildren.size()));
       }
     }
     if ((null != _lastUpdate) && ((null == lastUpdate) || (_lastUpdate.after(lastUpdate))))
       foundNewData = true;
   }
   return foundNewData;
 }
コード例 #4
0
  /**
   * Interface to retrieve only new data from enumeration responses as it arrives. This method
   * blocks and waits for data, but grabs the new data for processing. In threadPoolContext it will
   * in effect remove the data from every other listener who is listening in threadPoolContext, in
   * effect handing the new children to the first consumer to wake up and make the other ones go
   * around again. There is currently no support for more than one simultaneous thread pool.
   *
   * @param threadPoolContext Are we getting data in threadPoolContext? (described above).
   * @param timeout maximum amount of time to wait, 0 to wait forever.
   * @return SortedSet<ContentName> Returns the array of single-component content name children that
   *     are new to us, or null if we reached the timeout before new data arrived
   */
  public SortedSet<ContentName> getNewData(boolean threadPoolContext, long timeout) {
    SortedSet<ContentName> childArray = null;
    synchronized (_childLock) { // reentrant
      Long id = threadPoolContext ? 0 : Thread.currentThread().getId();
      NewChildrenByThread ncbt = _newChildrenByThread.get(id);
      SortedSet<ContentName> newChildren = ncbt == null ? null : ncbt._newChildren;
      while ((null == newChildren) || newChildren.size() == 0) {
        waitForNewChildren(threadPoolContext, timeout);
        ncbt = _newChildrenByThread.get(id);
        newChildren = ncbt._newChildren;
        if (timeout != SystemConfiguration.NO_TIMEOUT) break;
      }

      if (Log.isLoggable(Log.FAC_SEARCH, Level.INFO)) {
        Log.info(
            Log.FAC_SEARCH,
            "Waiting for new data on prefix: {0} got {1}.",
            _namePrefix,
            ((null == newChildren) ? 0 : newChildren.size()));
      }

      if (null != newChildren) {
        childArray = newChildren;
        ncbt._newChildren = null;
      }
    }
    return childArray;
  }
コード例 #5
0
  @Test
  public void testLinkToUnversioned() throws Exception {
    Log.info(Log.FAC_TEST, "Starting testLinkToUnversioned");

    // test dereferencing link to unversioned data.
    CCNRepositoryWriter writer = new CCNRepositoryWriter(putHandle);
    ContentName unversionedDataName =
        testHelper.getTestChildName("testLinkToUnversioned", "UnversionedBigData");
    // generate some segmented data; doesn't version the name
    writer.newVersion(unversionedDataName, bigDataContent);

    Link uvBigDataLink =
        new Link(
            unversionedDataName,
            "big",
            new LinkAuthenticator(new PublisherID(putHandle.keyManager().getDefaultKeyID())));
    ContentObject bigDataTarget =
        uvBigDataLink.dereference(SystemConfiguration.SETTABLE_SHORT_TIMEOUT, getHandle);
    Log.info(
        Log.FAC_TEST,
        "BigData: Dereferenced link "
            + uvBigDataLink
            + ", retrieved content "
            + ((null == bigDataTarget) ? "null" : bigDataTarget.name()));
    Assert.assertNotNull(bigDataTarget);
    Assert.assertTrue(uvBigDataLink.targetName().isPrefixOf(bigDataTarget.name()));
    Assert.assertTrue(SegmentationProfile.isFirstSegment(bigDataTarget.name()));

    Log.info(Log.FAC_TEST, "Completed testLinkToUnversioned");
  }
コード例 #6
0
ファイル: TextXMLCodecTest.java プロジェクト: remap/ws-ndn
  @Test
  public void testParseDateTime() {
    Log.info(Log.FAC_TEST, "Starting testParseDateTime");

    CCNTime now = CCNTime.now();
    testDateTime(now);

    now.setNanos(384);
    testDateTime(now);

    now.setNanos(1105384);
    testDateTime(now);
    now.setNanos(550105384);
    testDateTime(now);
    now.setNanos(550000000);

    testDateTime(now);
    now.setNanos(953405384);
    testDateTime(now);

    now.setNanos(110672800);
    testDateTime(now);

    Log.info(Log.FAC_TEST, "Completed testParseDateTime");
  }
コード例 #7
0
ファイル: PipelineTest.java プロジェクト: RazortoothRTC/ccnx
  // test interface with versioning
  @Test
  public void testVersionedNameWithPipeline() {
    Log.info(Log.FAC_TEST, "Starting testVersionedNameWithPipeline");

    long received = 0;
    byte[] bytes = new byte[1024];

    try {
      vistream =
          new CCNVersionedInputStream(VersioningProfile.cutLastVersion(testName), readHandle);
    } catch (IOException e1) {
      Log.info(Log.FAC_TEST, "failed to open stream for pipeline test: " + e1.getMessage());
      Assert.fail();
    }

    while (!vistream.eof()) {
      try {
        received += vistream.read(bytes);
      } catch (IOException e) {
        Log.warning(Log.FAC_TEST, "failed to read segments: " + e.getMessage());
        Assert.fail();
      }
    }
    Log.info(Log.FAC_TEST, "read " + received + " from stream");
    Assert.assertTrue(received == bytesWritten);

    Log.info(Log.FAC_TEST, "Completed testVersionedNameWithPipeline");
  }
コード例 #8
0
  /**
   * Handles packets received from the repository after the start write request. It's looking for a
   * RepoInfo packet indicating a repository has responded.
   */
  public Interest handleContent(ContentObject co, Interest interest) {

    if (Log.isLoggable(Log.FAC_REPO, Level.INFO))
      Log.info(Log.FAC_REPO, "handleContent: got potential repo message: {0}", co.name());
    if (co.signedInfo().getType() != ContentType.DATA) return null;
    RepositoryInfo repoInfo = new RepositoryInfo();
    try {
      repoInfo.decode(co.content());
      switch (repoInfo.getType()) {
        case INFO:
          for (Client client : _clients) {
            if (client._name.isPrefixOf(co.name())) {
              if (Log.isLoggable(Log.FAC_REPO, Level.FINE))
                Log.fine(Log.FAC_REPO, "Marked client {0} initialized", client._name);
              synchronized (this) {
                client._initialized = true;
                notifyAll();
              }
            }
          }
          break;
        default:
          break;
      }
    } catch (ContentDecodingException e) {
      Log.info(
          Log.FAC_REPO,
          "ContentDecodingException parsing RepositoryInfo: {0} from content object {1}, skipping.",
          e.getMessage(),
          co.name());
    }

    return null;
  }
コード例 #9
0
  public void testGetResponses() {
    try {
      int i = 0;

      while (i < 500) {
        Thread.sleep(50);
        i++;
        // break out early if possible
        synchronized (names) {
          Log.info("checking names: {0}", names.size());
          if (names.size() == 3) {
            Log.info("we got all three responses!");
            break;
          }
        }
      }
      Assert.assertTrue(names.size() == 3);
      Assert.assertTrue(names.contains(_repo));
      Assert.assertTrue(names.contains(_class));
      Assert.assertTrue(names.contains(_class2));

      // cleanup - cancel our enumerations
      getne.cancelEnumerationsWithPrefix(_prefix);

    } catch (InterruptedException e) {
      Assert.fail("Error while waiting for results to come in. " + e.getMessage());
    }
  }
コード例 #10
0
ファイル: CollectionTest.java プロジェクト: remap/ws-ndn
  @Test
  public void testEqualsObject() {
    Log.info(Log.FAC_TEST, "Starting testEqualsObject");

    Collection cd = new Collection();
    Collection cd2 = new Collection();
    Collection cd3 = new Collection();

    for (int i = 0; i < lrs.length; ++i) {
      cd.add(lrs[i]);
      cd2.add(lrs[i]);
      cd3.add(lrs[lrs.length - i - 1]);
    }
    Assert.assertEquals(cd, cd2);
    Assert.assertFalse(cd.equals(cd3));
    cd.remove(2);
    Collection cd4 = cd2.clone();
    Assert.assertFalse(cd.equals(cd2));
    Assert.assertEquals(cd4, cd2);
    cd2.remove(2);
    Assert.assertEquals(cd, cd2);

    cd2.remove(2); // remove last entry
    cd2.add(new Link(name3, las[2]));
    cd2.add(new Link(name4, las[3]));
    Assert.assertEquals(cd2, cd4);

    Log.info(Log.FAC_TEST, "Completed testEqualsObject");
  }
コード例 #11
0
ファイル: EnumeratedNameList.java プロジェクト: wjz/ccnx
 /**
  * Cancels ongoing name enumeration. Previously-accumulated information about children of this
  * name are still stored and available for use.
  *
  * @return void
  */
 public synchronized void stopEnumerating() {
   if (!_enumerating) {
     if (Log.isLoggable(Level.INFO)) {
       Log.info("Enumerated name list: Not enumerating, so not canceling prefix.");
     }
     return;
   }
   _enumerator.cancelPrefix(_namePrefix);
   _enumerating = false;
 }
コード例 #12
0
ファイル: CollectionTest.java プロジェクト: remap/ws-ndn
  @Test
  public void testCollectionData() {
    Log.info(Log.FAC_TEST, "Starting testCollectionData");

    Collection cd = new Collection();
    Assert.assertNotNull(cd);
    Assert.assertTrue(cd.validate());

    Log.info(Log.FAC_TEST, "Completed testCollectionData");
  }
コード例 #13
0
ファイル: BasicPolicy.java プロジェクト: remap/ws-ndn
 public static PolicyXML createPolicyXML(InputStream stream) throws ContentDecodingException {
   Log.info(Log.FAC_REPO, "Creating policy file");
   XMLDecoder decoder = XMLCodecFactory.getDecoder(TextXMLCodec.codecName());
   decoder.beginDecoding(stream);
   PolicyXML pxml = new PolicyXML();
   pxml.decode(decoder);
   Log.fine(Log.FAC_REPO, "Finished pxml decoding");
   decoder.endDecoding();
   return pxml;
 }
コード例 #14
0
  @Override
  /**
   * Send out a start write request to any listening repositories and wait for a response.
   *
   * @param name the basename of the stream to start
   * @param shape currently ignored - can only be Shape.STREAM
   * @throws IOException if there is no response from a repository
   */
  public void startWrite(ContentName name, Shape shape) throws IOException {

    if (Log.isLoggable(Log.FAC_REPO, Level.INFO))
      Log.info(
          Log.FAC_REPO,
          "RepositoryFlowControl.startWrite called for name {0}, shape {1}",
          name,
          shape);
    Client client = new Client(name, shape);
    _clients.add(client);

    // A nonce is used because if we tried to write data with the same name more than once, we could
    // retrieve the
    // the previous answer from the cache, and the repo would never be informed of our start write.
    ContentName repoWriteName = new ContentName(name, COMMAND_MARKER_REPO_START_WRITE, NONCE);
    Interest writeInterest = new Interest(repoWriteName);
    if (localRepo || SystemConfiguration.FC_LOCALREPOSITORY) {
      // this is meant to be written to a local repository, not any/multiple connected repos
      writeInterest.scope(1);
    }

    _handle.expressInterest(writeInterest, this);

    synchronized (this) {
      _writeInterests.add(writeInterest);
    }

    // Wait for information to be returned from a repo
    try {
      new Waiter(getTimeout()) {
        @Override
        protected boolean check(Object o, Object check) throws Exception {
          return ((Client) check)._initialized;
        }
      }.wait(this, client);
    } catch (Exception e) {
      Log.warning(Log.FAC_REPO, e.getClass() + " : " + e.getMessage());
    }

    synchronized (this) {
      if (!client._initialized) {
        _clients.remove();
        Log.warning(Log.FAC_REPO, "No response from a repository, cannot add name space : " + name);
        throw new IOException("No response from a repository for " + name);
      }
    }
  }
コード例 #15
0
  @Test
  public void testMissingTarget() throws Exception {
    Log.info(Log.FAC_TEST, "Starting testMissingTarget");

    Link linkToNowhere =
        new Link(testHelper.getTestChildName("testMissingTarget", "linkToNowhere"));
    ContentObject nothing = linkToNowhere.dereference(SystemConfiguration.SHORT_TIMEOUT, getHandle);
    Assert.assertNull(nothing);

    Log.info(Log.FAC_TEST, "Completed testMissingTarget");
  }
コード例 #16
0
ファイル: PipelineTest.java プロジェクト: RazortoothRTC/ccnx
  @Test
  public void testGetFirstDigest() {
    Log.info(Log.FAC_TEST, "Starting testGetFirstDigest");

    long received = 0;
    byte[] bytes = new byte[1024];

    try {
      istream = new CCNInputStream(testName, readHandle);
    } catch (IOException e1) {
      Log.warning(Log.FAC_TEST, "failed to open stream for pipeline test: " + e1.getMessage());
      Assert.fail();
    }

    try {
      Assert.assertTrue(DataUtils.arrayEquals(firstDigest, istream.getFirstDigest()));
    } catch (IOException e3) {
      Log.warning(Log.FAC_TEST, "failed to get first digest for pipeline test:");
      Assert.fail();
    }
    try {
      istream.close();
    } catch (IOException e2) {
      Log.warning(Log.FAC_TEST, "failed to close stream for pipeline test: " + e2.getMessage());
      Assert.fail();
    }
    Log.info(Log.FAC_TEST, "start first segment digest " + DataUtils.printBytes(firstDigest));

    try {
      istream = new CCNInputStream(testName, readHandle);
    } catch (IOException e1) {
      Log.warning(Log.FAC_TEST, "failed to open stream for pipeline test: " + e1.getMessage());
      Assert.fail();
    }

    while (!istream.eof()) {
      try {
        received += istream.read(bytes);
      } catch (IOException e) {
        Log.warning(Log.FAC_TEST, "failed to read segments: " + e.getMessage());
        Assert.fail();
      }
    }
    Assert.assertTrue(received == bytesWritten);
    try {
      Assert.assertTrue(DataUtils.arrayEquals(firstDigest, istream.getFirstDigest()));
    } catch (IOException e) {
      Log.warning(Log.FAC_TEST, "failed to get first digest after reading in pipeline test:");
      Assert.fail();
    }
    Log.info(Log.FAC_TEST, "end first segment digest " + DataUtils.printBytes(firstDigest));

    Log.info(Log.FAC_TEST, "Completed testGetFirstDigest");
  }
コード例 #17
0
ファイル: CollectionTest.java プロジェクト: remap/ws-ndn
  @Test
  public void testSize() {
    Log.info(Log.FAC_TEST, "Starting testSize");

    Collection cd = new Collection();
    for (int i = 0; i < lrs.length; ++i) {
      cd.add(lrs[i]);
    }
    Assert.assertTrue(cd.size() == lrs.length);

    Log.info(Log.FAC_TEST, "Completed testSize");
  }
コード例 #18
0
ファイル: CollectionTest.java プロジェクト: remap/ws-ndn
  @Test
  public void testValidate() {
    Log.info(Log.FAC_TEST, "Starting testValidate");

    Collection cd = new Collection();
    Assert.assertTrue(cd.validate());
    cd.add(lrs[0]);
    Assert.assertTrue(cd.validate());
    cd.remove(0);
    Assert.assertTrue(cd.validate());

    Log.info(Log.FAC_TEST, "Completed testValidate");
  }
コード例 #19
0
ファイル: CollectionTest.java プロジェクト: remap/ws-ndn
  @Test
  public void testRemoveInt() {
    Log.info(Log.FAC_TEST, "Starting testRemoveInt");

    Collection cd = new Collection();
    for (int i = 0; i < lrs.length; ++i) {
      cd.add(lrs[i]);
    }
    cd.remove(0);
    Assert.assertEquals(cd.get(0), lrs[1]);

    Log.info(Log.FAC_TEST, "Completed testRemoveInt");
  }
コード例 #20
0
ファイル: Flosser.java プロジェクト: CLao/BitNomen
 public void stop() {
   Log.info(Log.FAC_TEST, "Stop flossing.");
   synchronized (_interests) {
     _shutdown = true;
     stopMonitoringNamespaces();
     Log.info(
         Log.FAC_TEST,
         "Stopped flossing: remaining namespaces {0} (should be 0), subnamespaces {1} (should be 0).",
         _interests.size(),
         _subInterests.size());
   }
   _handle.close();
 }
コード例 #21
0
ファイル: EnumeratedNameList.java プロジェクト: wjz/ccnx
 /**
  * Wait for new children to arrive until there is a period of length timeout during which no new
  * child arrives.
  *
  * @param timeout The maximum amount of time to wait between consecutive children arrivals.
  *     <p>Deprecated - see #getNewData(long)
  */
 @Deprecated
 public void waitForNoUpdates(long timeout) {
   Log.info(
       "Waiting for updates on prefix {0} with max timeout of {1} ms between consecutive children arrivals.",
       _namePrefix, timeout);
   long startTime = System.currentTimeMillis();
   while (waitForNewChildren(timeout)) {
     Log.info("Child or children found on prefix {0}", _namePrefix);
   }
   Log.info(
       "Quit waiting for updates on prefix {0} after waiting in total {1} ms.",
       _namePrefix, (System.currentTimeMillis() - startTime));
 }
コード例 #22
0
  @Test
  public void testDereference() throws Exception {
    Log.info(Log.FAC_TEST, "Starting testDereference");

    Link versionedLink = new Link(data[1].getVersionedName());

    // Should get back a segment, ideally first, of that specific version.
    ContentObject versionedTarget =
        versionedLink.dereference(SystemConfiguration.getDefaultTimeout(), putHandle);
    Log.info(
        Log.FAC_TEST,
        "Dereferenced link {0}, retrieved content {1}",
        versionedLink,
        ((null == versionedTarget) ? "null" : versionedTarget.name()));
    Assert.assertNotNull(versionedTarget);
    Assert.assertTrue(versionedLink.targetName().isPrefixOf(versionedTarget.name()));
    Assert.assertTrue(SegmentationProfile.isFirstSegment(versionedTarget.name()));

    Link unversionedLink = new Link(data[1].getBaseName(), "unversioned", null);
    ContentObject unversionedTarget =
        unversionedLink.dereference(SystemConfiguration.getDefaultTimeout(), getHandle);
    Log.info(
        Log.FAC_TEST,
        "Dereferenced link {0}, retrieved content {1}",
        unversionedLink,
        ((null == unversionedTarget) ? "null" : unversionedTarget.name()));
    Assert.assertNotNull(unversionedTarget);
    Assert.assertTrue(unversionedLink.targetName().isPrefixOf(unversionedTarget.name()));
    Assert.assertTrue(
        data[data.length - 1].getVersionedName().isPrefixOf(unversionedTarget.name()));
    Assert.assertTrue(SegmentationProfile.isFirstSegment(unversionedTarget.name()));

    Link bigDataLink =
        new Link(
            bigData,
            "big",
            new LinkAuthenticator(new PublisherID(putHandle.keyManager().getDefaultKeyID())));
    ContentObject bigDataTarget =
        bigDataLink.dereference(SystemConfiguration.getDefaultTimeout(), putHandle);
    Log.info(
        Log.FAC_TEST,
        "BigData: Dereferenced link "
            + bigDataLink
            + ", retrieved content "
            + ((null == bigDataTarget) ? "null" : bigDataTarget.name()));
    Assert.assertNotNull(bigDataTarget);
    Assert.assertTrue(bigDataLink.targetName().isPrefixOf(bigDataTarget.name()));
    Assert.assertTrue(SegmentationProfile.isFirstSegment(bigDataTarget.name()));

    Log.info(Log.FAC_TEST, "Completed testDereference");
  }
コード例 #23
0
  @Test
  public void multiResponderNameEnumerationTest() {
    Log.info(Log.FAC_TEST, "Starting multiResponderNameEnumerationTest");

    try {
      getne.registerPrefix(_prefix);
    } catch (IOException e) {
      Assert.fail("Could not register name for responses.");
    }

    testGetResponses();

    Log.info(Log.FAC_TEST, "Completed multiResponderNameEnumerationTest");
  }
コード例 #24
0
  @Test
  public void testWrongPublisher() throws Exception {
    Log.info(Log.FAC_TEST, "Starting testWrongPublisher");

    byte[] fakePublisher = new byte[PublisherID.PUBLISHER_ID_LEN];
    PublisherID wrongPublisher = new PublisherID(new PublisherPublicKeyDigest(fakePublisher));

    Link linkToWrongPublisher = new Link(bigData, new LinkAuthenticator(wrongPublisher));
    ContentObject nothing =
        linkToWrongPublisher.dereference(SystemConfiguration.SHORT_TIMEOUT, getHandle);
    Assert.assertNull(nothing);

    Log.info(Log.FAC_TEST, "Completed testWrongPublisher");
  }
コード例 #25
0
ファイル: CollectionTest.java プロジェクト: remap/ws-ndn
  @Test
  public void testAddGet() {
    Log.info(Log.FAC_TEST, "Starting testAddGet");

    Collection cd = new Collection();
    for (int i = 0; i < lrs.length; ++i) {
      cd.add(lrs[i]);
    }
    for (int i = 0; i < lrs.length; ++i) {
      Assert.assertEquals(cd.get(i), lrs[i]);
    }

    Log.info(Log.FAC_TEST, "Completed testAddGet");
  }
コード例 #26
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");
  }
コード例 #27
0
ファイル: FaceManager.java プロジェクト: RazortoothRTC/ccnx
 public FaceInstance(byte[] raw) {
   ByteArrayInputStream bais = new ByteArrayInputStream(raw);
   XMLDecoder decoder = XMLCodecFactory.getDecoder(BinaryXMLCodec.CODEC_NAME);
   try {
     decoder.beginDecoding(bais);
     decode(decoder);
     decoder.endDecoding();
   } catch (ContentDecodingException e) {
     String reason = e.getMessage();
     Log.fine("Unexpected error decoding FaceInstance from bytes.  reason: " + reason + "\n");
     Log.warningStackTrace(e);
     throw new IllegalArgumentException(
         "Unexpected error decoding FaceInstance from bytes.  reason: " + reason);
   }
 }
コード例 #28
0
ファイル: CollectionTest.java プロジェクト: remap/ws-ndn
  @Test
  public void testEncodeDecodeByteArray() {
    Log.info(Log.FAC_TEST, "Starting testEncodeDecodeByteArray");

    Collection cd = new Collection();
    Collection cdec = new Collection();
    Collection bdec = new Collection();

    for (int i = 0; i < lrs.length; ++i) {
      cd.add(lrs[i]);
    }
    XMLEncodableTester.encodeDecodeByteArrayTest("Collection", cd, cdec, bdec);

    Log.info(Log.FAC_TEST, "Completed testEncodeDecodeByteArray");
  }
コード例 #29
0
ファイル: Flosser.java プロジェクト: CLao/BitNomen
  public void logNamespaces() {

    ContentName[] namespaces = getNamespaces().toArray(new ContentName[getNamespaces().size()]);
    for (ContentName name : namespaces) {
      Log.info("Flosser: monitoring namespace: " + name);
    }
  }
コード例 #30
0
  @BeforeClass
  public static void setUpBeforeClass() throws Exception {
    CCNTestBase.setUpBeforeClass();
    CCNTime version = new CCNTime();
    ContentName stringName = testHelper.getClassChildName(STRING_VALUE_NAME);
    for (int i = 0; i < data.length; ++i) {
      // save multiple versions of the same object.
      data[i] = new CCNStringObject(stringName, "Value " + i, SaveType.REPOSITORY, putHandle);
      Log.info(Log.FAC_TEST, "Saving as version " + version);
      data[i].save(version);
      version.increment(1); // avoid version collisions
    }

    gone =
        new CCNStringObject(
            testHelper.getClassChildName(GONE_VALUE_NAME),
            GONE_VALUE_NAME,
            SaveType.REPOSITORY,
            putHandle);
    gone.saveAsGone();
    TestUtils.checkObject(putHandle, gone);

    bigData = testHelper.getClassChildName(BIG_VALUE_NAME);

    bigDataContent = new byte[bigDataLength];
    Random rand = new Random();
    rand.nextBytes(bigDataContent);
    bigValueDigest = CCNDigestHelper.digest(bigDataContent);

    // generate some segmented data
    CCNRepositoryWriter writer = new CCNRepositoryWriter(putHandle);
    writer.newVersion(bigData, bigDataContent);
  }