コード例 #1
0
  @Test
  public void refreshInvalid() throws FileNotFoundException {
    final RGraphicsState state = mock(RGraphicsState.class);

    when(state.current()).thenReturn(new TextVirtualFile("abc.txt", "text"));

    final RGraphicsPanel panel = new RGraphicsPanel(state);

    try {
      panel.refresh();

      fail();
    } catch (final IllegalStateException e) {
      verify(state, times(1)).current();
      verifyNoMoreInteractions(state);
    }
  }
コード例 #2
0
  @Test
  public void refreshNonexistent() throws FileNotFoundException {
    final RGraphicsState state = mock(RGraphicsState.class);

    when(state.current()).thenThrow(FileNotFoundException.class);

    final RGraphicsPanel panel = new RGraphicsPanel(state);

    try {
      panel.refresh();
    } catch (final AssertionError ignore) {
      /*
      state.current() generates FileNotFoundException,
      panel catches it and logs as error,
      but logger generates AssertionError with FileNotFoundException as a cause
      */
    }

    verify(state, times(1)).current();
    verifyNoMoreInteractions(state);
  }