Package net.tomp2p.futures

Examples of net.tomp2p.futures.FutureGet


    // send message
    assertTrue(nodeA.getMessageManager().send(message, getPublicKey(nodeB)));

    // wait till callback handler gets executed
    H2HWaiter w = new H2HWaiter(10);
    FutureGet futureGet = null;
    do {
      w.tickASecond();
      futureGet = nodeB.getDataManager().getUnblocked(
          new Parameters().setLocationKey(nodeA.getNodeId()).setContentKey(contentKey));
      futureGet.awaitUninterruptibly();
    } while (futureGet.getData() == null);

    // load and verify if same secret was shared
    String receivedSecret = ((H2HTestData) futureGet.getData().object()).getTestString();
    futureGet = nodeB.getDataManager().getUnblocked(
        new Parameters().setLocationKey(nodeB.getNodeId()).setContentKey(contentKey));
    futureGet.awaitUninterruptibly();
    String originalSecret = ((H2HTestData) futureGet.getData().object()).getTestString();
    assertEquals(originalSecret, receivedSecret);
  }
View Full Code Here


    // send message
    assertTrue(nodeA.getMessageManager().send(message, getPublicKey(nodeB)));

    // wait till callback handler gets executed
    H2HWaiter w = new H2HWaiter(10);
    FutureGet futureGet = null;
    do {
      w.tickASecond();
      futureGet = nodeB.getDataManager().getUnblocked(
          new Parameters().setLocationKey(nodeA.getNodeId()).setContentKey(contentKey));
      futureGet.awaitUninterruptibly();
    } while (futureGet.getData() == null);

    // load and verify if same secret was shared
    String receivedSecret = ((H2HTestData) futureGet.getData().object()).getTestString();
    futureGet = nodeB.getDataManager().getUnblocked(
        new Parameters().setLocationKey(nodeB.getNodeId()).setContentKey(contentKey));
    futureGet.awaitUninterruptibly();
    String originalSecret = ((H2HTestData) futureGet.getData().object()).getTestString();
    assertEquals(originalSecret, receivedSecret);
  }
View Full Code Here

    // send message
    assertTrue(nodeA.getMessageManager().sendDirect(message, getPublicKey(nodeB)));

    // wait till callback handler gets executed
    H2HWaiter w = new H2HWaiter(10);
    FutureGet futureGet = null;
    do {
      w.tickASecond();
      futureGet = nodeB.getDataManager().getUnblocked(
          new Parameters().setLocationKey(nodeA.getNodeId()).setContentKey(contentKey));
      futureGet.awaitUninterruptibly();
    } while (futureGet.getData() == null);

    // load and verify if same secret was shared
    String receivedSecret = ((H2HTestData) futureGet.getData().object()).getTestString();
    futureGet = nodeB.getDataManager().getUnblocked(
        new Parameters().setLocationKey(nodeB.getNodeId()).setContentKey(contentKey));
    futureGet.awaitUninterruptibly();
    String originalSecret = ((H2HTestData) futureGet.getData().object()).getTestString();
    assertEquals(originalSecret, receivedSecret);
  }
View Full Code Here

    // send message
    assertTrue(nodeA.getMessageManager().sendDirect(message, getPublicKey(nodeB)));

    // wait till callback handler gets executed
    H2HWaiter w = new H2HWaiter(10);
    FutureGet futureGet = null;
    do {
      w.tickASecond();
      futureGet = nodeB.getDataManager().getUnblocked(
          new Parameters().setLocationKey(nodeA.getNodeId()).setContentKey(contentKey));
      futureGet.awaitUninterruptibly();
    } while (futureGet.getData() == null);

    // load and verify if same secret was shared
    String receivedSecret = ((H2HTestData) futureGet.getData().object()).getTestString();
    futureGet = nodeB.getDataManager().getUnblocked(
        new Parameters().setLocationKey(nodeB.getNodeId()).setContentKey(contentKey));
    futureGet.awaitUninterruptibly();
    String originalSecret = ((H2HTestData) futureGet.getData().object()).getTestString();
    assertEquals(originalSecret, receivedSecret);
  }
View Full Code Here

        .keyPair(parameters.getProtectionKeys()).start();
  }

  @Override
  public NetworkContent get(IParameters parameters) {
    FutureGet futureGet = getUnblocked(parameters);
    FutureGetListener listener = new FutureGetListener(parameters);
    futureGet.addListener(listener);
    return listener.awaitAndGet();
  }
View Full Code Here

    futureGet.addListener(listener);
    return listener.awaitAndGet();
  }

  public NetworkContent getVersion(IParameters parameters) {
    FutureGet futureGet = getUnblocked(parameters);
    FutureGetListener listener = new FutureGetListener(parameters);
    futureGet.addListener(listener);
    return listener.awaitAndGet();
  }
View Full Code Here

  @Override
  public NetworkContent getUserProfileTask(String userId) {
    IParameters parameters = new Parameters().setLocationKey(userId).setDomainKey(
        H2HConstants.USER_PROFILE_TASK_DOMAIN);

    FutureGet futureGet = getPeer()
        .get(parameters.getLKey())
        .from(new Number640(parameters.getLKey(), parameters.getDKey(), Number160.ZERO,
            Number160.ZERO))
        .to(new Number640(parameters.getLKey(), parameters.getDKey(), Number160.MAX_VALUE,
            Number160.MAX_VALUE)).ascending().returnNr(1).start();
    FutureGetListener listener = new FutureGetListener(parameters);
    futureGet.addListener(listener);
    return listener.awaitAndGet();
  }
View Full Code Here

    // initialize the process and the one and only step to test
    PutUserProfileStep step = new PutUserProfileStep(credentials, context, putter.getDataManager());
    UseCaseTestUtil.executeProcess(step);

    // get the user profile which should be stored at the proxy
    FutureGet global = client.getDataManager().getUnblocked(
        new Parameters().setLocationKey(credentials.getProfileLocationKey()).setContentKey(
            H2HConstants.USER_PROFILE));
    global.awaitUninterruptibly();
    global.getFutureRequests().awaitUninterruptibly();
    EncryptedNetworkContent found = (EncryptedNetworkContent) global.getData().object();
    Assert.assertNotNull(found);

    // decrypt it using the same password as set above
    SecretKey decryptionKeys = PasswordUtil.generateAESKeyFromPassword(credentials.getPassword(),
        credentials.getPin(), H2HConstants.KEYLENGTH_USER_PROFILE);
View Full Code Here

    String data = NetworkTestUtil.randomString();
    String contentKey = NetworkTestUtil.randomString();
    Parameters parameters = new Parameters().setLocationKey(nodeB.getNodeId()).setContentKey(contentKey);

    // check if selected location is empty
    FutureGet futureGet = nodeA.getDataManager().getUnblocked(parameters);
    futureGet.awaitUninterruptibly();
    assertNull(futureGet.getData());

    // create a message with target node B
    final TestMessage message = new TestMessage(nodeB.getNodeId(), contentKey, new H2HTestData(data));

    // initialize the process and the one and only step to test
    BaseMessageProcessStep step = new BaseMessageProcessStep(nodeA.getMessageManager()) {

      @Override
      protected void doExecute() throws InvalidProcessStateException {
        try {
          send(message, getPublicKey(nodeB));
        } catch (SendFailedException e) {
          Assert.fail(e.getMessage());
        }
      }

      @Override
      public void handleResponseMessage(ResponseMessage responseMessage) {
        Assert.fail("Should be not used.");
      }
    };
    UseCaseTestUtil.executeProcess(step);

    // wait till message gets handled
    H2HWaiter w = new H2HWaiter(10);
    do {
      w.tickASecond();
      futureGet = nodeA.getDataManager().getUnblocked(parameters);
      futureGet.awaitUninterruptibly();
    } while (futureGet.getData() == null);

    // verify that data arrived
    String result = ((H2HTestData) futureGet.getData().object()).getTestString();
    assertEquals(data, result);
  }
View Full Code Here

    step.start();

    UseCaseTestUtil.waitTillFailed(listener, 20);

    // get the locations which should be stored at the proxy --> they should be null
    FutureGet futureGet = proxy.getDataManager().getUnblocked(
        new Parameters().setLocationKey(credentials.getProfileLocationKey()).setContentKey(
            H2HConstants.USER_LOCATIONS));
    futureGet.awaitUninterruptibly();
    assertNull(futureGet.getData());
  }
View Full Code Here

TOP

Related Classes of net.tomp2p.futures.FutureGet

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.