/** Test that not setting the any properties returns in an (almost) empty Blob */
 @Test
 public void testExceptionsThrown() {
   ControlParameters controlParameters = new ControlParameters();
   Blob encoded = controlParameters.wireEncode();
   assertEquals(2, encoded.buf().limit());
   // only TLV type 104 and length 0 should be set
 }
Esempio n. 2
0
  /**
   * Make and sign a command interest to enable or disable LocalControlHeader.
   *
   * @param enable If true, use "enable-local-control". Otherwise, use "disable-local-control".
   * @param localControlFeature The value for the ControlParameters as follows: 1 = IncomingFaceId,
   *     2 = NextHopFaceId, 3 = CachingPolicy.
   * @return
   */
  private Interest makeLocalControlCommand(boolean enable, int localControlFeature)
      throws SecurityException {
    ControlParameters controlParameters = new ControlParameters();
    controlParameters.setLocalControlFeature(localControlFeature);

    Interest interest = new Interest(new Name("/localhost/nfd/faces"));
    interest.getName().append(enable ? "enable-local-control" : "disable-local-control");
    interest.getName().append(controlParameters.wireEncode());
    face_.makeCommandInterest(interest);

    return interest;
  }
 /**
  * Test encoding/decoding with no name defined
  *
  * @throws EncodingException
  */
 @Test
 public void testEncodeDecodeWithNoName() throws EncodingException {
   ControlParameters controlParameters = new ControlParameters();
   controlParameters.setStrategy(new Name("/localhost/nfd/strategy/broadcast"));
   controlParameters.setUri("null://");
   // encode
   Blob encoded = controlParameters.wireEncode();
   // decode
   ControlParameters decodedControlParameters = new ControlParameters();
   decodedControlParameters.wireDecode(encoded);
   // compare
   assertEquals(
       controlParameters.getStrategy().toUri(), decodedControlParameters.getStrategy().toUri());
   assertEquals(controlParameters.getUri(), decodedControlParameters.getUri());
 }
 /**
  * Test encoding/decoding
  *
  * @throws EncodingException
  */
 @Test
 public void testEncodeDecode() throws EncodingException {
   ControlParameters controlParameters = new ControlParameters();
   controlParameters.setName(new Name("/test/control/parameters"));
   controlParameters.setFaceId(1);
   // encode
   Blob encoded = controlParameters.wireEncode();
   // decode
   ControlParameters decodedControlParameters = new ControlParameters();
   decodedControlParameters.wireDecode(encoded);
   // compare
   assertEquals(controlParameters.getName().toUri(), decodedControlParameters.getName().toUri());
   assertEquals(controlParameters.getFaceId(), decodedControlParameters.getFaceId());
   assertEquals(
       "decoded forwarding flags childInherit is different",
       controlParameters.getForwardingFlags().getChildInherit(),
       decodedControlParameters.getForwardingFlags().getChildInherit());
   assertEquals(
       "decoded forwarding flags capture is different",
       controlParameters.getForwardingFlags().getCapture(),
       decodedControlParameters.getForwardingFlags().getCapture());
 }