コード例 #1
0
ファイル: ResetTest.java プロジェクト: nathansgreen/mockito
 @Test
 public void shouldStubbingNotBeTreatedAsInteraction() {
   when(mock.simpleMethod("one")).thenThrow(new RuntimeException());
   doThrow(new RuntimeException()).when(mock).simpleMethod("two");
   reset(mock);
   verifyZeroInteractions(mock);
 }
コード例 #2
0
 @Test
 public void enableLTW_withAjWeavingDisabled() {
   AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
   ctx.register(EnableLTWConfig_withAjWeavingDisabled.class);
   ctx.refresh();
   LoadTimeWeaver loadTimeWeaver = ctx.getBean("loadTimeWeaver", LoadTimeWeaver.class);
   verifyZeroInteractions(loadTimeWeaver);
 }
コード例 #3
0
 @Test
 public void enableLTW_withAjWeavingAutodetect() {
   AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
   ctx.register(EnableLTWConfig_withAjWeavingAutodetect.class);
   ctx.refresh();
   LoadTimeWeaver loadTimeWeaver = ctx.getBean("loadTimeWeaver", LoadTimeWeaver.class);
   // no expectations -> a class file transformer should NOT be added
   // because no META-INF/aop.xml is present on the classpath
   verifyZeroInteractions(loadTimeWeaver);
 }
コード例 #4
0
 @Test
 public void testSaveCertification_InvalidDates() throws Exception {
   action.setCertification(certification);
   action.setEffectiveDate("12/2010");
   action.setExpirationDate("11/2010");
   assertEquals(ActionSupport.INPUT, action.saveCertification());
   verifyZeroInteractions(mockProfileService);
   assertEquals(
       action.getText("error.expiration.date.before.effective"),
       action.getFieldErrors().get("expirationDate").get(0));
 }
  /**
   * Unit test for OPENDJ-1247: a locally timed out request which is not a bind or startTLS should
   * result in a client side timeout error, but the connection should remain valid. In addition, no
   * abandon request should be sent.
   */
  @Test
  public void testClientSideTimeoutForSearchRequest() throws Exception {
    resetState();
    registerSearchEvent();
    registerAbandonEvent();

    for (int i = 0; i < ITERATIONS; i++) {
      final Connection connection = factory.getConnection();
      try {
        waitForConnect();
        final ConnectionEventListener listener = mock(ConnectionEventListener.class);
        connection.addConnectionEventListener(listener);
        final PromiseImpl<LdapException, NeverThrowsException> promise = PromiseImpl.create();
        final LdapPromise<SearchResultEntry> connectionPromise =
            connection.readEntryAsync(DN.valueOf("cn=test"), null);
        connectionPromise.onFailure(getFailureHandler(promise));
        waitForSearch();

        LdapException e = promise.getOrThrow(TEST_TIMEOUT, TimeUnit.SECONDS);
        verifyResultCodeIsClientSideTimeout(e);
        // Wait for the request to timeout.
        try {
          connectionPromise.getOrThrow(TEST_TIMEOUT, TimeUnit.SECONDS);
          fail("The search request succeeded unexpectedly");
        } catch (TimeoutResultException te) {
          verifyResultCodeIsClientSideTimeout(te);
        }

        // The connection should still be valid.
        assertThat(connection.isValid()).isTrue();
        verifyZeroInteractions(listener);
        /*
         * FIXME: The search should have been abandoned (see comment in
         * LDAPConnection for explanation).
         */
        // waitForAbandon();
      } finally {
        connection.close();
      }
    }
  }
コード例 #6
0
ファイル: ResetTest.java プロジェクト: nathansgreen/mockito
 @Test
 public void shouldRemoveAllInteractions() throws Exception {
   mock.simpleMethod(1);
   reset(mock);
   verifyZeroInteractions(mock);
 }