Examples of NetworkManager


Examples of org.hive2hive.core.network.NetworkManager

    // delete file 1
    File file1 = new File(root1, "file 1");
    file1.delete();

    /** do some modifications on the remote **/
    NetworkManager remoteClient = network.get(0);

    // add a file 4 within folder 1
    File file4 = new File(new File(root0, "folder 1"), "file 4");
    FileUtils.write(file4, NetworkTestUtil.randomString());
    UseCaseTestUtil.uploadNewFile(remoteClient, file4);
View Full Code Here

Examples of org.hive2hive.core.network.NetworkManager

    File folder = new File(root1, "folder 1");
    File file3 = new File(folder, "file 3");
    FileUtils.write(file3, NetworkTestUtil.randomString());

    /** do some modifications on the remote **/
    NetworkManager remoteClient = network.get(0);

    // modify file 2
    File file2 = new File(root0, "file 2");
    String file2Content = NetworkTestUtil.randomString();
    FileUtils.write(file2, file2Content);
View Full Code Here

Examples of org.hive2hive.core.network.NetworkManager

  }

  @Test
  public void testGetProcessStepSuccess() throws NoPeerConnectionException {
    H2HTestData data = new H2HTestData(NetworkTestUtil.randomString());
    NetworkManager getter = network.get(0);
    NetworkManager holder = network.get(1);

    String locationKey = holder.getNodeId();
    String contentKey = NetworkTestUtil.randomString();

    // put in the memory of 2nd peer
    holder.getDataManager()
        .putUnblocked(
            new Parameters().setLocationKey(holder.getNodeId()).setContentKey(contentKey)
                .setData(data)).awaitUninterruptibly();

    TestGetProcessStep getStep = new TestGetProcessStep(locationKey, contentKey, getter.getDataManager());
    UseCaseTestUtil.executeProcess(getStep);
View Full Code Here

Examples of org.hive2hive.core.network.NetworkManager

    Assert.assertEquals(data.getTestString(), ((H2HTestData) getStep.getContent()).getTestString());
  }

  @Test
  public void testGetProcessStepRollBack() throws NoPeerConnectionException, InvalidProcessStateException {
    NetworkManager getter = network.get(0);
    NetworkManager holder = network.get(1);

    String locationKey = holder.getNodeId();
    String contentKey = NetworkTestUtil.randomString();

    TestGetProcessStepRollBack getStepRollBack = new TestGetProcessStepRollBack(locationKey, contentKey,
        getter.getDataManager());
    TestProcessComponentListener listener = new TestProcessComponentListener();
View Full Code Here

Examples of org.hive2hive.core.network.NetworkManager

  public void uploadFile() throws Exception {
    /** create a network, register a user and add a file **/
    network = NetworkTestUtil.createNetwork(networkSize);

    userCredentials = NetworkTestUtil.generateRandomCredentials();
    NetworkManager uploader = network.get(networkSize - 1);
    downloader = network.get(new Random().nextInt(networkSize - 2));

    // register and login both users
    File uploaderRoot = FileTestUtil.getTempDirectory();
    UseCaseTestUtil.registerAndLogin(userCredentials, uploader, uploaderRoot);
View Full Code Here

Examples of org.hive2hive.core.network.NetworkManager

  }

  @Test
  public void testRootToDirectory() throws IOException, IllegalFileLocation, GetFailedException,
      InterruptedException, NoSessionException, NoPeerConnectionException {
    NetworkManager client = network.get(1);
    UseCaseTestUtil.login(userCredentials, client, root);

    // add a file to the network
    File file = FileTestUtil.createFileRandomContent(3, root, CHUNK_SIZE);
    UseCaseTestUtil.uploadNewFile(client, file);
View Full Code Here

Examples of org.hive2hive.core.network.NetworkManager

  }

  @Test
  public void testDirectoryToRoot() throws IOException, IllegalFileLocation, GetFailedException,
      InterruptedException, NoSessionException, NoPeerConnectionException {
    NetworkManager client = network.get(1);
    UseCaseTestUtil.login(userCredentials, client, root);

    // add the source folder
    File folder = new File(root, "folder");
    folder.mkdir();
View Full Code Here

Examples of org.hive2hive.core.network.NetworkManager

  }

  @Test
  public void testDirectoryToDirectory() throws IOException, IllegalFileLocation, GetFailedException,
      InterruptedException, NoSessionException, NoPeerConnectionException {
    NetworkManager client = network.get(1);
    UseCaseTestUtil.login(userCredentials, client, root);

    // add the source folder
    File sourceFolder = new File(root, "source-folder");
    sourceFolder.mkdir();
View Full Code Here

Examples of org.hive2hive.core.network.NetworkManager

  }

  @Test
  public void testRename() throws IOException, IllegalFileLocation, GetFailedException,
      InterruptedException, NoSessionException, NoPeerConnectionException {
    NetworkManager client = network.get(1);
    UseCaseTestUtil.login(userCredentials, client, root);

    // add a file to the network
    File file = new File(root, "test-file");
    FileUtils.write(file, NetworkTestUtil.randomString());
View Full Code Here

Examples of org.hive2hive.core.network.NetworkManager

    network = NetworkTestUtil.createNetwork(networkSize);
  }

  @Test
  public void testPutProcessSuccess() throws ClassNotFoundException, IOException, NoPeerConnectionException {
    NetworkManager putter = network.get(0);
    putter.getConnection().getPeer().getPeerBean().storage(new H2HStorageMemory());
    NetworkManager proxy = network.get(1);
    proxy.getConnection().getPeer().getPeerBean().storage(new H2HStorageMemory());

    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());
    UseCaseTestUtil.executeProcess(putStep);

    FutureGet futureGet = proxy.getDataManager().getUnblocked(
        new Parameters().setLocationKey(locationKey).setContentKey(contentKey));
    futureGet.awaitUninterruptibly();
    assertEquals(data, ((H2HTestData) futureGet.getData().object()).getTestString());
  }
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.