コード例 #1
0
  @Test
  public void testAuthenticatesWithAppHandle() {
    user =
        createUser(
            TEST_VISTA_ID,
            TEST_DIVISION,
            TEST_DUZ,
            TEST_REMOTE_HOSTNAME + "(" + TEST_REMOTE_ADDRESS + ")" + TEST_APP_HANDLE,
            true,
            true,
            true,
            true,
            new SimpleGrantedAuthority("ROLE_ONE"),
            new SimpleGrantedAuthority("ROLE_TWO"));
    when(mockUserDetailService.login(
            TEST_VISTA_ID,
            TEST_DIVISION,
            TEST_APP_HANDLE,
            TEST_REMOTE_ADDRESS,
            TEST_REMOTE_HOSTNAME))
        .thenReturn(user);

    VistaAuthenticationToken token =
        new VistaAuthenticationToken(
            TEST_VISTA_ID,
            TEST_DIVISION,
            TEST_APP_HANDLE,
            TEST_REMOTE_ADDRESS,
            TEST_REMOTE_HOSTNAME);
    Authentication result = provider.authenticate(token);

    if (!(result instanceof VistaAuthenticationToken)) {
      fail("Should have returned instance of VistaAuthenticationToken");
    }
    assertNotSame(token, result);

    VistaAuthenticationToken castResult = (VistaAuthenticationToken) result;
    assertTrue(VistaUserDetails.class.isAssignableFrom(castResult.getPrincipal().getClass()));
    assertEquals(TEST_VISTA_ID, castResult.getVistaId());
    assertNull(castResult.getAccessCode());
    assertNull(castResult.getVerifyCode());
    assertEquals(TEST_APP_HANDLE, castResult.getAppHandle());
    assertEquals(TEST_REMOTE_ADDRESS, castResult.getRemoteAddress());
    assertEquals(TEST_REMOTE_HOSTNAME, castResult.getRemoteHostName());
    assertEquals(
        "ROLE_ONE",
        new ArrayList<GrantedAuthority>(castResult.getAuthorities()).get(0).getAuthority());
    assertEquals(
        "ROLE_TWO",
        new ArrayList<GrantedAuthority>(castResult.getAuthorities()).get(1).getAuthority());
    assertEquals(TEST_REMOTE_HOSTNAME + "(" + TEST_REMOTE_ADDRESS + ")", castResult.getDetails());

    verify(mockUserDetailService)
        .login(
            TEST_VISTA_ID,
            TEST_DIVISION,
            TEST_APP_HANDLE,
            TEST_REMOTE_ADDRESS,
            TEST_REMOTE_HOSTNAME);
  }
コード例 #2
0
ファイル: ControlTest.java プロジェクト: pkcool/civilian
  @Test
  public void testFormAdd() throws Exception {
    Form form = new Form(request);
    assertEquals(0, form.size());

    Button button = Button.button("OK");
    form.add(button);
    assertEquals(1, form.size());

    TextField field = new TextField("name");
    form.add(field, "Name");
    form.add(null); // ignored
    form.add(null, "Name"); // ignored
    assertEquals(2, form.size());
    assertSame(field, form.get(1));
    assertSame(field, form.get("name"));
    assertNull(form.get("x"));
    assertNull(form.get(null));
    try {
      // cannot add twice
      form.add(field);
      fail();
    } catch (IllegalStateException e) {
    }

    form.setRequired(true);
    assertTrue(field.isRequired());
    form.setReadOnly(true);
    assertTrue(field.isReadOnly());

    assertTrue(form.validate(true));

    form.remove(field);
    assertEquals(1, form.size());
  }
  @SuppressWarnings("unchecked")
  private void testFailedAuth(FilterTestEnv env) throws Exception {
    env.filter.setFilterProcessesUrl(env.req.getRequestURI());
    env.filter.setPostLoginUrl("/success");

    ConnectionFactory<Object> factory = mock(MockConnectionFactory.class);
    when(factory.getProviderId()).thenReturn("mock");
    env.req.setRequestURI(env.req.getRequestURI() + "/" + factory.getProviderId());

    SocialAuthenticationService<Object> authService = mock(SocialAuthenticationService.class);
    when(authService.getConnectionCardinality()).thenReturn(ConnectionCardinality.ONE_TO_ONE);
    when(authService.getConnectionFactory()).thenReturn(factory);
    when(authService.getAuthToken(env.req, env.res)).thenReturn(env.auth);
    env.addAuthService(authService);

    when(env.authManager.authenticate(env.auth)).thenThrow(new BadCredentialsException("Failed"));

    assertNull(SecurityContextHolder.getContext().getAuthentication());

    env.doFilter();

    assertNull(SecurityContextHolder.getContext().getAuthentication());

    assertEquals("http://localhost/register", env.res.getRedirectedUrl());
  }
コード例 #4
0
ファイル: ControlTest.java プロジェクト: pkcool/civilian
  @Test
  public void testTextField() {
    TextField field = new TextField("email");
    assertEquals("email", field.getName());

    assertEquals("text", field.getInputType());
    field.setInputType(TextField.INPUT_TYPE_EMAIL);
    assertEquals("email", field.getInputType());

    assertSame(field, field.toFocusControl());
    assertSame(field, field.toInputField());

    assertEquals(0, field.getMaxLength());
    assertEquals(0, field.getSize());

    field.setMaxLength(100);
    assertEquals(50, field.getSize());
    assertEquals(100, field.getMaxLength());

    field.setSize(25);
    assertEquals(25, field.getSize());

    assertEquals(100, field.getMaxLength());

    assertNull(field.getPattern());
    field.setPattern("*@*");
    assertEquals("*@*", field.getPattern());

    assertNull(field.getPlaceholder());
    field.setPlaceholder("enter email");
    assertEquals("enter email", field.getPlaceholder());

    assertNull(field.getId());
    field.setId("xyz");
    assertEquals("xyz", field.getId());

    assertEquals("", field.getLabel());
    assertFalse(field.hasLabel());
    field.setLabel("label");
    assertEquals("label", field.getLabel());
    field.setLabel(null);
    assertEquals("", field.getLabel());

    assertNull(field.getData());
    field.setData(this);
    assertSame(this, field.getData());

    assertEquals(1, field.getRows());
    assertEquals(Control.Category.INPUT, field.getCategory());
    assertEquals("", field.format());

    assertEquals("TextField[email=null]", field.toString());

    assertOut(
        field,
        "<input type='email' name='email' value='' size='25' maxlength='100' id='xyz' placeholder='enter email' pattern='*@*'>");
  }
コード例 #5
0
 @Test
 public void testRefresh_resetsTimelineCursors() {
   delegate = new TimelineDelegate<>(mockTimeline);
   delegate.timelineStateHolder.setNextCursor(new TimelineCursor(ANY_POSITION, ANY_POSITION));
   delegate.timelineStateHolder.setPreviousCursor(new TimelineCursor(ANY_POSITION, ANY_POSITION));
   delegate.refresh(null);
   assertNull(delegate.timelineStateHolder.positionForNext());
   assertNull(delegate.timelineStateHolder.positionForPrevious());
 }
コード例 #6
0
 @Test
 public void testConstructor() {
   delegate = new TimelineDelegate<>(mockTimeline, mockObservable, testItems);
   assertEquals(mockTimeline, delegate.timeline);
   assertEquals(mockObservable, delegate.listAdapterObservable);
   assertEquals(testItems, delegate.itemList);
   assertNotNull(delegate.timelineStateHolder);
   // initial positions must be null
   assertNull(delegate.timelineStateHolder.positionForNext());
   assertNull(delegate.timelineStateHolder.positionForPrevious());
 }
コード例 #7
0
ファイル: IoUtilTest.java プロジェクト: pkcool/civilian
  @Test
  public void testExtension() throws Exception {
    File f = new File("test.css");
    assertEquals("test", IoUtil.cutExtension(f));

    assertNull(null, IoUtil.getExtension("test"));

    assertNull(IoUtil.normExtension(""));
    assertNull(IoUtil.normExtension(null));
    assertEquals("css", IoUtil.normExtension(".css"));
    assertEquals("css", IoUtil.normExtension("css"));
  }
コード例 #8
0
  @Test
  public void getNullableBooleanWithColumnNameWorks() throws SQLException {
    ResultSet mockResultSet = mock(ResultSet.class);
    when(mockResultSet.getBoolean("foo")).thenReturn(true);

    assertEquals(true, ResultSets.getNullableBoolean(mockResultSet, "foo").booleanValue());
    assertEquals(true, ResultSets.enhance(mockResultSet).getNullableBoolean("foo").booleanValue());

    when(mockResultSet.getBoolean("foo")).thenReturn(false);
    when(mockResultSet.wasNull()).thenReturn(true);
    assertNull(ResultSets.getNullableBoolean(mockResultSet, "foo"));
    assertNull(ResultSets.enhance(mockResultSet).getNullableBoolean("foo"));
  }
コード例 #9
0
  @Test
  public void getNullableFloatWithColumnIndexWorks() throws SQLException {
    ResultSet mockResultSet = mock(ResultSet.class);
    when(mockResultSet.getFloat(2)).thenReturn(7.0F);

    assertEquals(7.0F, ResultSets.getNullableFloat(mockResultSet, 2).floatValue(), 0.0001);
    assertEquals(7.0F, ResultSets.enhance(mockResultSet).getNullableFloat(2).floatValue(), 0.0001);

    when(mockResultSet.getFloat(2)).thenReturn(0.0F);
    when(mockResultSet.wasNull()).thenReturn(true);
    assertNull(ResultSets.getNullableFloat(mockResultSet, 2));
    assertNull(ResultSets.enhance(mockResultSet).getNullableFloat(2));
  }
コード例 #10
0
 // should do nothing
 @Test
 public void testPreviousCallback_successReceivedZeroItems() {
   delegate = new TimelineDelegate<>(mockTimeline, mockObservable, testItems);
   final TimelineStateHolder timelineStateHolder = new TimelineStateHolder();
   final TimelineDelegate.PreviousCallback cb = delegate.new PreviousCallback(timelineStateHolder);
   cb.success(
       new Result<>(new TimelineResult<>(TEST_TIMELINE_CURSOR, Collections.emptyList()), null));
   // assert that the cursors and itemList are left unmodified
   assertNull(timelineStateHolder.positionForNext());
   assertNull(timelineStateHolder.positionForPrevious());
   assertEquals(testItems.size(), delegate.itemList.size());
   verifyZeroInteractions(mockObservable);
 }
コード例 #11
0
  @Test
  public void testPublishToParentScopeWithListenerMethods() {
    MultipleListeners listener = new MultipleListeners();

    applicationEventBus.subscribe(listener);
    sessionEventBus.publish(EventScope.APPLICATION, this, "Hello World");

    assertNull(listener.theIntegerEvent);
    assertNull(listener.theIntegerPayload);
    assertNotNull(listener.theStringEvent);
    assertEquals("Hello World", listener.theStringEvent.getPayload());
    assertEquals("Hello World", listener.theStringPayload);
  }
コード例 #12
0
  @Test
  public void testPropagateToChildWithListenerMethods() {
    MultipleListeners listener = new MultipleListeners();

    applicationEventBus.subscribe(listener);
    applicationEventBus.publish(this, "Hello World");

    assertNull(listener.theIntegerEvent);
    assertNull(listener.theIntegerPayload);
    assertNotNull(listener.theStringEvent);
    assertEquals("Hello World", listener.theStringEvent.getPayload());
    assertEquals("Hello World", listener.theStringPayload);
  }
コード例 #13
0
  @Test
  public void getNullableByteWithColumnIndexWorks() throws SQLException {
    ResultSet mockResultSet = mock(ResultSet.class);
    when(mockResultSet.getByte(2)).thenReturn((byte) 7);

    assertEquals(7, ResultSets.getNullableByte(mockResultSet, 2).byteValue());
    assertEquals(7, ResultSets.enhance(mockResultSet).getNullableByte(2).byteValue());

    when(mockResultSet.getByte(2)).thenReturn((byte) 0);
    when(mockResultSet.wasNull()).thenReturn(true);
    assertNull(ResultSets.getNullableByte(mockResultSet, 2));
    assertNull(ResultSets.enhance(mockResultSet).getNullableByte(2));
  }
コード例 #14
0
  @Test
  public void getNullableLongWithColumnNameWorks() throws SQLException {
    ResultSet mockResultSet = mock(ResultSet.class);
    when(mockResultSet.getLong("foo")).thenReturn(7L);

    assertEquals(7L, ResultSets.getNullableLong(mockResultSet, "foo").longValue());
    assertEquals(7L, ResultSets.enhance(mockResultSet).getNullableLong("foo").longValue());

    when(mockResultSet.getLong("foo")).thenReturn(0L);
    when(mockResultSet.wasNull()).thenReturn(true);
    assertNull(ResultSets.getNullableLong(mockResultSet, "foo"));
    assertNull(ResultSets.enhance(mockResultSet).getNullableLong("foo"));
  }
コード例 #15
0
  @Test
  public void getNullableIntWithColumnNameWorks() throws SQLException {
    ResultSet mockResultSet = mock(ResultSet.class);
    when(mockResultSet.getInt("foo")).thenReturn(7);

    assertEquals(7, ResultSets.getNullableInt(mockResultSet, "foo").intValue());
    assertEquals(7, ResultSets.enhance(mockResultSet).getNullableInt("foo").intValue());

    when(mockResultSet.getInt("foo")).thenReturn(0);
    when(mockResultSet.wasNull()).thenReturn(true);
    assertNull(ResultSets.getNullableInt(mockResultSet, "foo"));
    assertNull(ResultSets.enhance(mockResultSet).getNullableInt("foo"));
  }
コード例 #16
0
  @Test
  public void verifyEmptyServicesRegistry() {
    final SimpleService s = new SimpleService("http://www.google.com");

    defaultServicesManagerImpl
        .getAllServices()
        .stream()
        .forEach(svc -> defaultServicesManagerImpl.delete(svc.getId()));

    assertTrue(this.defaultServicesManagerImpl.getAllServices().size() == 0);
    assertNull(this.defaultServicesManagerImpl.findServiceBy(s));
    assertNull(this.defaultServicesManagerImpl.findServiceBy(1000));
  }
コード例 #17
0
  @Test
  public void getEnumFromNameWithColumnIndexWorks() throws SQLException {
    ResultSet mockResultSet = mock(ResultSet.class);
    when(mockResultSet.getString(2)).thenReturn("FOO");

    assertEquals(TestEnum.FOO, ResultSets.getEnumFromName(mockResultSet, 2, TestEnum.class));
    assertEquals(
        TestEnum.FOO, ResultSets.enhance(mockResultSet).getEnumFromName(2, TestEnum.class));

    when(mockResultSet.getString(2)).thenReturn(null);
    assertNull(ResultSets.getEnumFromName(mockResultSet, 2, TestEnum.class));
    assertNull(ResultSets.enhance(mockResultSet).getEnumFromName(2, TestEnum.class));
  }
コード例 #18
0
  @Test
  public void getEnumFromOrdinalWithColumnIndexWorks() throws SQLException {
    ResultSet mockResultSet = mock(ResultSet.class);
    when(mockResultSet.getInt(2)).thenReturn(0);

    assertEquals(TestEnum.FOO, ResultSets.getEnumFromOrdinal(mockResultSet, 2, TestEnum.class));
    assertEquals(
        TestEnum.FOO, ResultSets.enhance(mockResultSet).getEnumFromOrdinal(2, TestEnum.class));

    when(mockResultSet.getInt(2)).thenReturn(0);
    when(mockResultSet.wasNull()).thenReturn(true);
    assertNull(ResultSets.getEnumFromOrdinal(mockResultSet, 2, TestEnum.class));
    assertNull(ResultSets.enhance(mockResultSet).getEnumFromOrdinal(2, TestEnum.class));
  }
コード例 #19
0
  @Test
  public void testCreateRoomByUser() {
    when(service.getUserBySession(anyString())).thenReturn(null);
    Room endRoom = gameServer.createRoom("aaa", "aaa", null);
    assertNull(endRoom);

    Room room = new RoomFFA("aaa");
    UserProfile profile = spy(new UserProfile("aa", "bb"));
    when(service.getUserBySession(anyString())).thenReturn(profile);
    when(profile.getCurrentroom()).thenReturn(room);

    endRoom = gameServer.createRoom("aaa", "aaa", null);
    assertNull(endRoom);
  }
コード例 #20
0
  @Test
  public void getNullableDoubleWithColumnNameWorks() throws SQLException {
    ResultSet mockResultSet = mock(ResultSet.class);
    when(mockResultSet.getDouble("foo")).thenReturn(7.0);

    assertEquals(7.0, ResultSets.getNullableDouble(mockResultSet, "foo").doubleValue(), 0.0001);
    assertEquals(
        7.0, ResultSets.enhance(mockResultSet).getNullableDouble("foo").doubleValue(), 0.0001);

    when(mockResultSet.getDouble("foo")).thenReturn(0.0);
    when(mockResultSet.wasNull()).thenReturn(true);
    assertNull(ResultSets.getNullableDouble(mockResultSet, "foo"));
    assertNull(ResultSets.enhance(mockResultSet).getNullableDouble("foo"));
  }
コード例 #21
0
  @SuppressWarnings("unchecked")
  @Test(timeout = 30000)
  public void testConnectAndDispatchMessages_Balanced() throws Exception {
    assertNull(connector1.getNodeName());
    assertNull(connector2.getNodeName());

    final AtomicInteger counter1 = new AtomicInteger(0);
    final AtomicInteger counter2 = new AtomicInteger(0);

    connector1.subscribe(String.class.getName(), new CountingCommandHandler(counter1));
    connector1.connect(20);
    assertTrue(
        "Expected connector 1 to connect within 10 seconds",
        connector1.awaitJoined(10, TimeUnit.SECONDS));

    connector2.subscribe(String.class.getName(), new CountingCommandHandler(counter2));
    connector2.connect(80);
    assertTrue("Connector 2 failed to connect", connector2.awaitJoined());

    // wait for both connectors to have the same view
    waitForConnectorSync();

    List<FutureCallback> callbacks = new ArrayList<>();

    for (int t = 0; t < 100; t++) {
      FutureCallback<Object, Object> callback = new FutureCallback<>();
      String message = "message" + t;
      if ((t & 1) == 0) {
        connector1.send(message, new GenericCommandMessage<>(message), callback);
      } else {
        connector2.send(message, new GenericCommandMessage<>(message), callback);
      }
      callbacks.add(callback);
    }
    for (FutureCallback callback : callbacks) {
      assertEquals("The Reply!", callback.get());
    }
    assertEquals(100, counter1.get() + counter2.get());
    System.out.println("Node 1 got " + counter1.get());
    System.out.println("Node 2 got " + counter2.get());
    verify(mockCommandBus1, atMost(40))
        .dispatch(any(CommandMessage.class), isA(CommandCallback.class));
    verify(mockCommandBus2, atLeast(60))
        .dispatch(any(CommandMessage.class), isA(CommandCallback.class));
    assertEquals(connector1.getMembers(), connector2.getMembers());
    assertNotNull(connector1.getNodeName());
    assertNotNull(connector2.getNodeName());
    assertNotEquals(connector1.getNodeName(), connector2.getNodeName());
  }
コード例 #22
0
  @Test
  public void savePageWithSameBaseCommitAndNonconflictingChanges()
      throws IOException, GitAPIException {
    register(globalRepoManager.createProjectCentralRepository(PROJECT, USER));
    ILockedRepository repo =
        globalRepoManager.createProjectBranchRepository(PROJECT, BRANCH_1, null);
    register(repo);
    Page page =
        Page.fromText("title", "a\nb\nc\nd\ne\nf\ng\nh\ni\nj\n"); // $NON-NLS-1$ //$NON-NLS-2$
    pageStore.savePage(PROJECT, BRANCH_1, PAGE, page, null, USER);
    String baseCommit = pageStore.getPageMetadata(PROJECT, BRANCH_1, PAGE).getCommit();

    page = Page.fromText("title", "a\nbbb\nc\nd\ne\nf\ng\nh\ni\nj\n"); // $NON-NLS-1$ //$NON-NLS-2$
    pageStore.savePage(PROJECT, BRANCH_1, PAGE, page, baseCommit, USER);
    page = Page.fromText("title", "a\nb\nc\nd\ne\nf\ng\nh\niii\nj\n"); // $NON-NLS-1$ //$NON-NLS-2$
    MergeConflict conflict = pageStore.savePage(PROJECT, BRANCH_1, PAGE, page, baseCommit, USER);

    Page result = pageStore.getPage(PROJECT, BRANCH_1, PAGE, true);
    assertNull(conflict);
    assertEquals(
        "a\nbbb\nc\nd\ne\nf\ng\nh\niii\nj\n",
        ((PageTextData) result.getData()).getText()); // $NON-NLS-1$

    assertClean(repo.r());
  }
コード例 #23
0
 @Test
 public void testJoinRoomNoRoom() {
   when(service.getUserBySession(anyString())).thenReturn(new UserProfile("aa", "bb"));
   when(rooms.containsKey(anyString())).thenReturn(false);
   Room room = gameServer.joinRoom("aa", "aa", "aa");
   assertNull(room);
 }
コード例 #24
0
ファイル: ControlTest.java プロジェクト: pkcool/civilian
  @Test
  public void testIntegerField() {
    IntField field = new IntField("n");
    assertOut(field, "<input type='number' name='n' value=''>");

    field.setName("ifield");
    when(request.getParameter("ifield")).thenReturn("a");
    assertFalse(field.read(request));
    assertEquals(Control.Status.PARSE_ERROR, field.getStatus());
    assertTrue(field.getError() instanceof NumberFormatException);
    assertNull(field.getValue());
    assertEquals("a", field.getErrorValue());
    assertEquals("a", field.format());

    field.setReadOnly(true);
    assertFalse(field.read(request));

    field.setReadOnly(false);
    when(request.getParameter("ifield")).thenReturn("");
    assertTrue(field.read(request));
    assertEquals(null, field.getValue());

    field.setRequired(true);
    assertFalse(field.read(request));
    assertEquals(null, field.getValue());

    field = new IntField("n");
    field.setMin(20);
    field.setMax(30);
    field.setStep(2);
    assertOut(field, "<input type='number' name='n' value='' min='20' max='30' step='2'>");
  }
コード例 #25
0
ファイル: SSLAuthTest.java プロジェクト: candlepin/candlepin
 /**
  * DN is set but does not contain UID
  *
  * @throws Exception
  */
 @Test
 public void noUuidOnCert() throws Exception {
   mockCert("OU=something");
   when(this.consumerCurator.findByUuid(anyString()))
       .thenReturn(new Consumer("machine_name", "test user", null, null));
   assertNull(this.auth.getPrincipal(httpRequest));
 }
コード例 #26
0
  @Test
  public void nextEmptyBalancer() {
    Balancer<Void, MockDatabase> balancer =
        this.factory.createBalancer(Collections.<MockDatabase>emptySet());

    assertNull(balancer.next());
  }
  @Test
  public void testFailedAuthenticationInvokesFailureHandler() throws Exception {
    // Setup our HTTP request
    MockHttpServletRequest request = createMockAuthenticationRequest();

    // Setup our filter configuration
    MockFilterConfig config = new MockFilterConfig(null, null);

    // Setup our expectation that the filter chain will not be invoked, as we redirect to
    // authenticationFailureUrl
    MockFilterChain chain = new MockFilterChain(false);
    MockHttpServletResponse response = new MockHttpServletResponse();

    // Setup our test object, to deny access
    MockAuthenticationFilter filter = new MockAuthenticationFilter(false);
    AuthenticationFailureHandler failureHandler = mock(AuthenticationFailureHandler.class);
    filter.setAuthenticationFailureHandler(failureHandler);

    // Test
    filter.doFilter(request, response, chain);

    verify(failureHandler)
        .onAuthenticationFailure(
            any(HttpServletRequest.class),
            any(HttpServletResponse.class),
            any(AuthenticationException.class));

    assertNull(SecurityContextHolder.getContext().getAuthentication());
  }
 @Test(expected = IllegalArgumentException.class)
 public void verifyDeleteServiceNoService() throws Exception {
   final MockHttpServletResponse response = new MockHttpServletResponse();
   this.controller.deleteRegisteredService(1200, response);
   assertNull(this.servicesManager.findServiceBy(1200));
   assertFalse(response.getContentAsString().contains("serviceName"));
 }
コード例 #29
0
  @Test
  public void testRestoreWithInterrupt() throws Exception {

    Configuration taskConfig = new Configuration();
    StreamConfig cfg = new StreamConfig(taskConfig);
    cfg.setTimeCharacteristic(TimeCharacteristic.ProcessingTime);
    cfg.setStreamOperator(new StreamSource<>(new TestSource()));

    StreamStateHandle lockingHandle = new InterruptLockingStateHandle();

    TaskDeploymentDescriptor tdd = createTaskDeploymentDescriptor(taskConfig, lockingHandle);
    Task task = createTask(tdd);

    // start the task and wait until it is in "restore"
    task.startTaskThread();
    IN_RESTORE_LATCH.await();

    // trigger cancellation and signal to continue
    task.cancelExecution();

    task.getExecutingThread().join(30000);

    if (task.getExecutionState() == ExecutionState.CANCELING) {
      fail("Task is stuck and not canceling");
    }

    assertEquals(ExecutionState.CANCELED, task.getExecutionState());
    assertNull(task.getFailureCause());
  }
コード例 #30
0
  @Test
  public void testNullFlatValue2Document() {

    Document doc = processor.toRawValue(field, null, null, context);

    assertNull("Document must be null!", doc);
  }