Package org.hive2hive.core.processes.util

Examples of org.hive2hive.core.processes.util.TestProcessComponentListener


  }
 
  @Test
  public void listenerStateTest() throws InvalidProcessStateException {
   
    TestProcessComponentListener listener = new TestProcessComponentListener();
    assertFalse(listener.hasSucceeded());
    assertFalse(listener.hasFailed());
    assertFalse(listener.hasFinished());
   
    listener.onSucceeded();
    assertTrue(listener.hasSucceeded());
    assertFalse(listener.hasFailed());
    assertTrue(listener.hasFinished());
    listener.reset();
   
    listener.onFailed(new RollbackReason("Test fail."));
    assertFalse(listener.hasSucceeded());
    assertTrue(listener.hasFailed());
    assertTrue(listener.hasFinished());
    listener.reset();
  }
View Full Code Here


  }
 
  @Test
  public void listenerResetTest() {
   
    TestProcessComponentListener listener = new TestProcessComponentListener();
    assertFalse(listener.hasSucceeded());
    assertFalse(listener.hasFailed());
    assertFalse(listener.hasFinished());
   
    listener.onSucceeded();
    listener.onFailed(new RollbackReason("Test fail."));
    assertTrue(listener.hasSucceeded());
    assertTrue(listener.hasFailed());
    assertTrue(listener.hasFinished());
   
    listener.reset();
    assertFalse(listener.hasSucceeded());
    assertFalse(listener.hasFailed());
    assertFalse(listener.hasFinished());
  }
View Full Code Here

      IllegalArgumentException, NoPeerConnectionException, NoSessionException {
    NetworkManager notifier = network.get(0);
    CountingNotificationMessageFactory msgFactory = new CountingNotificationMessageFactory(notifier);
    IProcessComponent process = ProcessFactory.instance().createNotificationProcess(msgFactory,
        new HashSet<String>(0), notifier);
    TestProcessComponentListener listener = new TestProcessComponentListener();
    process.attachListener(listener);
    process.start();

    // wait until all messages are sent
    UseCaseTestUtil.waitTillSucceded(listener, 10);
View Full Code Here

    users.add(userACredentials.getUserId());
    users.add(userBCredentials.getUserId());
    CountingNotificationMessageFactory msgFactory = new CountingNotificationMessageFactory(notifier);
    IProcessComponent process = ProcessFactory.instance().createNotificationProcess(msgFactory, users,
        notifier);
    TestProcessComponentListener listener = new TestProcessComponentListener();
    process.attachListener(listener);

    // kick out peer 3 (B)
    network.get(3).getConnection().getPeer().setObjectDataReply(new DenyingMessageReplyHandler());
    process.start();
View Full Code Here

    users.add(userACredentials.getUserId());
    users.add(userBCredentials.getUserId());
    CountingNotificationMessageFactory msgFactory = new CountingNotificationMessageFactory(notifier);
    IProcessComponent process = ProcessFactory.instance().createNotificationProcess(msgFactory, users,
        notifier);
    TestProcessComponentListener listener = new TestProcessComponentListener();
    process.attachListener(listener);

    // kick out peer 3 and 4 (B)
    network.get(3).getConnection().getPeer().setObjectDataReply(new DenyingMessageReplyHandler());
    network.get(4).getConnection().getPeer().setObjectDataReply(new DenyingMessageReplyHandler());
View Full Code Here

    Set<String> users = new HashSet<String>(1);
    users.add(userACredentials.getUserId());
    CountingNotificationMessageFactory msgFactory = new CountingNotificationMessageFactory(notifier);
    IProcessComponent process = ProcessFactory.instance().createNotificationProcess(msgFactory, users,
        notifier);
    TestProcessComponentListener listener = new TestProcessComponentListener();
    process.attachListener(listener);

    // kick out Peer 1
    network.get(1).getConnection().getPeer().setObjectDataReply(new DenyingMessageReplyHandler());
    process.start();
View Full Code Here

    UserProfile testProfile = new UserProfile(credentials.getUserId());
    IConsumeUserProfile context = new ConsumeProfileContext(testProfile);

    // initialize the process and the one and only step to test
    PutUserProfileStep step = new PutUserProfileStep(credentials, context, putter.getDataManager());
    TestProcessComponentListener listener = new TestProcessComponentListener();
    step.attachListener(listener);
    step.start();

    UseCaseTestUtil.waitTillFailed(listener, 20);
View Full Code Here

  public void testUploadSameVersion() throws IllegalFileLocation, GetFailedException, IOException,
      NoSessionException, InvalidProcessStateException, IllegalArgumentException,
      NoPeerConnectionException {
    // upload the same content again
    IProcessComponent process = ProcessFactory.instance().createUpdateFileProcess(file, uploader);
    TestProcessComponentListener listener = new TestProcessComponentListener();
    process.attachListener(listener);
    process.start();

    H2HWaiter waiter = new H2HWaiter(60);
    do {
      waiter.tickASecond();
    } while (!listener.hasFailed());

    // verify if the md5 hash did not change
    UserProfile userProfile = UseCaseTestUtil.getUserProfile(downloader, userCredentials);
    FileIndex fileNode = (FileIndex) userProfile.getFileByPath(file, uploaderRoot);
    Assert.assertTrue(H2HEncryptionUtil.compareMD5(file, fileNode.getMD5()));
View Full Code Here

    final int versionToRestore = 2;

    TestVersionSelector selector = new TestVersionSelector(versionToRestore);
    ProcessComponent process = ProcessFactory.instance().createRecoverFileProcess(file, selector, client);
    TestProcessComponentListener listener = new TestProcessComponentListener();
    process.attachListener(listener);
    process.start();
    UseCaseTestUtil.waitTillSucceded(listener, 120);

    // to verify, find the restored file
View Full Code Here

      @Override
      public void handleResponseMessage(ResponseMessage responseMessage) {
        Assert.fail("Should be not used.");
      }
    };
    TestProcessComponentListener listener = new TestProcessComponentListener();
    step.attachListener(listener);
    step.start();
    // wait for the process to finish
    UseCaseTestUtil.waitTillFailed(listener, 10);
View Full Code Here

TOP

Related Classes of org.hive2hive.core.processes.util.TestProcessComponentListener

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.