Ejemplo n.º 1
0
  /**
   * Tests executing of {@link Component#handleVerificationToken(String)}: verification token passed
   * properly and life cycle method call handled properly.
   *
   * @throws ComponentExecutionException on unexpected error
   * @throws ComponentException on unexpected error
   * @throws InterruptedException on unexpected error
   * @throws ExecutionException on unexpected error
   */
  @Test(timeout = TEST_TIMEOUT_500_MSEC)
  public void testHandleVerificationToken()
      throws ComponentExecutionException, ComponentException, InterruptedException,
          ExecutionException {

    final String someToken = "some-token";

    ComponentExecutionRelatedInstances compExeRelatedInstancesStub =
        createComponentExecutionRelatedInstancesStub(true);

    Component compMock = EasyMock.createStrictMock(Component.class);
    compMock.handleVerificationToken(someToken);
    EasyMock.expectLastCall();
    EasyMock.replay(compMock);
    compExeRelatedInstancesStub.component.set(compMock);

    ComponentExecutionType compExeType = ComponentExecutionType.HandleVerificationToken;
    compExeType.setVerificationToken(someToken);
    ComponentExecutor compExecutor =
        new ComponentExecutor(compExeRelatedInstancesStub, compExeType);
    compExecutor.bindComponentExecutionPermitsService(createComponentExecutionPermitServiceMock());

    compExecutor.executeByConsideringLimitations();

    assertFalse(compExeRelatedInstancesStub.compExeRelatedStates.isComponentCancelled.get());
    EasyMock.verify(compMock);
  }