@Test public void testProcessZuulFilterException() { FilterProcessor processor = new FilterProcessor(); processor = spy(processor); try { ZuulFilterResult r = new ZuulFilterResult(ExecutionStatus.FAILED); r.setException(new Exception("Test")); when(filter.runFilter()).thenReturn(r); when(filter.filterType()).thenReturn("post"); processor.processZuulFilter(filter); assertFalse(true); } catch (Throwable e) { assertEquals(e.getCause().getMessage(), "Test"); } }
public void testRuntimeExceptionWritable() throws Exception { // start server Server server = new TestServer(1, false); InetSocketAddress addr = NetUtils.getConnectAddress(server); server.start(); // start client Client client = new Client(LongRTEWritable.class, conf); try { client.call(new LongRTEWritable(RANDOM.nextLong()), addr, null, null); fail("Expected an exception to have been thrown"); } catch (IOException e) { // check error Throwable cause = e.getCause(); assertTrue(cause instanceof IOException); // it's double-wrapped Throwable cause2 = cause.getCause(); assertTrue(cause2 instanceof RuntimeException); assertEquals(LongRTEWritable.ERR_MSG, cause2.getMessage()); } }
@Test public void testRequestedClaimsSelectNoScope() throws Exception { // Given Bindings variables = testBindings( asSet("openid"), Collections.singletonMap("given_name", asSet("fred", "george"))); when(identity.getAttribute("cn")).thenReturn(asSet("Joe Bloggs")); // When/Then try { scriptEvaluator.evaluateScript(script, variables); } catch (Throwable e) { Throwable last = null; while (last != e) { if (e.getClass().equals(RuntimeException.class)) { break; } last = e; e = e.getCause(); } assertThat(e.getMessage()) .isEqualTo("No selection logic for given_name defined. Values: [george, fred]"); } }