Skip to content
Permalink
Browse files

[JENKINS-28041] fix failing unittest

  • Loading branch information
olivergondza committed Jun 9, 2015
1 parent 0e846fc commit b6bff4f2c078dc0f1474a96ab18f629c213aa509
Showing with 14 additions and 7 deletions.
  1. +14 −7 core/src/test/java/hudson/cli/handlers/ViewOptionHandlerTest.java
@@ -157,10 +157,12 @@

denyAccessOn(outer);

parseFailedWith(AccessDeniedException.class, "outer/nested/inner");
assertEquals(
"Access denied for: outer",
parseFailedWith(CmdLineException.class, "outer/nested/inner")
);

verify(outer).checkPermission(View.READ);
verifyNoMoreInteractions(outer);

verifyZeroInteractions(nested);
verifyZeroInteractions(inner);
@@ -171,10 +173,12 @@

denyAccessOn(nested);

parseFailedWith(AccessDeniedException.class, "outer/nested/inner");
assertEquals(
"Access denied for: nested",
parseFailedWith(CmdLineException.class, "outer/nested/inner")
);

verify(nested).checkPermission(View.READ);
verifyNoMoreInteractions(nested);

verifyZeroInteractions(inner);
verifyZeroInteractions(setter);
@@ -184,17 +188,20 @@

denyAccessOn(inner);

parseFailedWith(AccessDeniedException.class, "outer/nested/inner");
assertEquals(
"Access denied for: inner",
parseFailedWith(CmdLineException.class, "outer/nested/inner")
);

verify(inner).checkPermission(View.READ);
verifyNoMoreInteractions(inner);

verifyZeroInteractions(setter);
}

private void denyAccessOn(View view) {

doThrow(new AccessDeniedException(null)).when(view).checkPermission(View.READ);
final AccessDeniedException ex = new AccessDeniedException("Access denied for: " + view.getViewName());
doThrow(ex).when(view).checkPermission(View.READ);
}

private String parseFailedWith(Class<? extends Exception> type, final String... params) throws Exception {

0 comments on commit b6bff4f

Please sign in to comment.
You can’t perform that action at this time.