Examples of NetworkManager


Examples of org.hive2hive.core.network.NetworkManager

    assertEquals(data, ((H2HTestData) futureGet.getData().object()).getTestString());
  }

  @Test
  public void testPutProcessFailure() throws NoPeerConnectionException, InvalidProcessStateException {
    NetworkManager putter = network.get(0);
    putter.getConnection().getPeer().getPeerBean().storage(new DenyingPutTestStorage());
    NetworkManager proxy = network.get(1);
    proxy.getConnection().getPeer().getPeerBean().storage(new DenyingPutTestStorage());

    String locationKey = proxy.getNodeId();
    String contentKey = NetworkTestUtil.randomString();
    String data = NetworkTestUtil.randomString();

    // initialize the process and the one and only step to test
    TestPutProcessStep putStep = new TestPutProcessStep(locationKey, contentKey, new H2HTestData(data),
        putter.getDataManager());
    TestProcessComponentListener listener = new TestProcessComponentListener();
    putStep.attachListener(listener);
    putStep.start();

    // wait for the process to finish
    UseCaseTestUtil.waitTillFailed(listener, 10);

    FutureGet futureGet = proxy.getDataManager().getUnblocked(
        new Parameters().setLocationKey(locationKey).setContentKey(contentKey));
    futureGet.awaitUninterruptibly();
    assertNull(futureGet.getData());
  }
View Full Code Here

Examples of org.hive2hive.core.network.NetworkManager

  @Test(expected = NoSessionException.class)
  public void testUploadNoSession() throws IOException, IllegalFileLocation, NoSessionException,
      InvalidProcessStateException, NoPeerConnectionException {
    // skip the login and continue with the newfile process
    NetworkManager client = network.get(2);

    File file = FileTestUtil.createFileRandomContent(1, uploaderRoot, CHUNK_SIZE);
    IProcessComponent process = ProcessFactory.instance().createNewFileProcess(file, client);
    TestProcessComponentListener listener = new TestProcessComponentListener();
    process.attachListener(listener);
View Full Code Here

Examples of org.hive2hive.core.network.NetworkManager

  }

  private void verifyUpload(File originalFile, int expectedChunks) throws IOException, GetFailedException,
      NoSessionException, NoPeerConnectionException, InvalidProcessStateException {
    // pick new client to test
    NetworkManager client = network.get(1);

    // test if there is something in the user profile
    UserProfile gotProfile = UseCaseTestUtil.getUserProfile(client, userCredentials);
    Assert.assertNotNull(gotProfile);
View Full Code Here

Examples of org.hive2hive.core.network.NetworkManager

  }

  @Test
  public void testRegisterProcessSuccess() throws InvalidProcessStateException, ClassNotFoundException,
      IOException, GetFailedException, NoPeerConnectionException {
    NetworkManager client = network.get(0);
    NetworkManager otherClient = network.get(1);

    UserCredentials credentials = NetworkTestUtil.generateRandomCredentials();
    UseCaseTestUtil.register(credentials, client);

    // verify put user profile
    UserProfile getUserProfile = UseCaseTestUtil.getUserProfile(otherClient, credentials);

    assertNotNull(getUserProfile);
    assertEquals(credentials.getUserId(), getUserProfile.getUserId());

    // verify put locations
    FutureGet getLocations = otherClient.getDataManager().getUnblocked(
        new Parameters().setLocationKey(credentials.getUserId()).setContentKey(
            H2HConstants.USER_LOCATIONS));
    getLocations.awaitUninterruptibly();
    getLocations.getFutureRequests().awaitUninterruptibly();
    Locations locations = (Locations) getLocations.getData().object();

    assertNotNull(locations);
    assertEquals(credentials.getUserId(), locations.getUserId());
    assertTrue(locations.getPeerAddresses().isEmpty());

    // verify put user public key
    FutureGet getKey = otherClient.getDataManager().getUnblocked(
        new Parameters().setLocationKey(credentials.getUserId()).setContentKey(
            H2HConstants.USER_PUBLIC_KEY));
    getKey.awaitUninterruptibly();
    getKey.getFutureRequests().awaitUninterruptibly();
    UserPublicKey publicKey = (UserPublicKey) getKey.getData().object();
View Full Code Here

Examples of org.hive2hive.core.network.NetworkManager

  public void testStepSuccessAndRollbackWithChunk() throws InterruptedException, NoPeerConnectionException,
      DataLengthException, InvalidKeyException, IllegalStateException, InvalidCipherTextException,
      IllegalBlockSizeException, BadPaddingException, IOException, SignatureException,
      InvalidProcessStateException {
    // where the process runs
    NetworkManager getter = network.get(0);
    // where the data gets stored
    NetworkManager proxy = network.get(1);

    // generate necessary keys
    KeyPair encryptionKeys = EncryptionUtil.generateRSAKeyPair(H2HConstants.KEYLENGTH_CHUNK);
    KeyPair protectionKeysOld = EncryptionUtil.generateRSAKeyPair();
    KeyPair protectionKeysNew = EncryptionUtil.generateRSAKeyPair();

    // generate a fake chunk
    Chunk chunk = new Chunk(proxy.getNodeId(), NetworkTestUtil.randomString().getBytes(), 0);
    // encrypt the chunk
    HybridEncryptedContent encryptedChunk = H2HEncryptionUtil.encryptHybrid(chunk,
        encryptionKeys.getPublic());

    // initialize put
View Full Code Here

Examples of org.hive2hive.core.network.NetworkManager

  }

  @Test
  public void testStepSuccessful() throws InterruptedException, ClassNotFoundException, IOException,
      NoPeerConnectionException {
    NetworkManager putter = network.get(0); // where the process runs
    putter.getConnection().getPeer().getPeerBean().storage(new H2HStorageMemory());
    NetworkManager proxy = network.get(1); // where the user profile is stored
    proxy.getConnection().getPeer().getPeerBean().storage(new H2HStorageMemory());

    // create the needed objects
    String userId = proxy.getNodeId();
    Locations newLocations = new Locations(userId);
    newLocations.addPeerAddress(putter.getConnection().getPeer().getPeerAddress());
    KeyPair protectionKeys = EncryptionUtil.generateRSAKeyPair();

    // initialize the process and the one and only step to test
    PutLocationContext context = new PutLocationContext(newLocations, protectionKeys);
    PutUserLocationsStep step = new PutUserLocationsStep(context, context, putter.getDataManager());
    UseCaseTestUtil.executeProcess(step);

    // get the locations
    FutureGet future = proxy.getDataManager().getUnblocked(
        new Parameters().setLocationKey(userId).setContentKey(H2HConstants.USER_LOCATIONS));
    future.awaitUninterruptibly();
    Assert.assertNotNull(future.getData());
    Locations found = (Locations) future.getData().object();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.