@Test public void whenRefererDontMatchAControllerShouldForwardToPage() throws Exception { PageResult page = mock(PageResult.class); when(request.getHeader("Referer")).thenReturn("http: when(request.getContextPath()).thenReturn("/vraptor"); when(router.parse("/no-controller", HttpMethod.GET, request)).thenThrow(new ResourceNotFoundException()); doReturn(page).when(result).use(page()); refererResult.forward(); verify(page).forwardTo("/no-controller"); }
public void forward() throws IllegalStateException { String referer = getReferer(); try { ResourceMethod method = router.parse(referer, HttpMethod.GET, request); executeMethod(method, result.use(logic()).forwardTo(method.getResource().getType())); } catch (ResourceNotFoundException e) { result.use(page()).forwardTo(referer); } catch (MethodNotAllowedException e) { result.use(page()).forwardTo(referer); } }
DefaultRefererResult implements RefererResult { public void forward() throws IllegalStateException { String referer = getReferer(); try { ResourceMethod method = router.parse(referer, HttpMethod.GET, request); executeMethod(method, result.use(logic()).forwardTo(method.getResource().getType())); } catch (ResourceNotFoundException e) { result.use(page()).forwardTo(referer); } catch (MethodNotAllowedException e) { result.use(page()).forwardTo(referer); } } }
DefaultRefererResult implements RefererResult { public void forward() throws IllegalStateException { String referer = getReferer(); try { ResourceMethod method = router.parse(referer, HttpMethod.GET, request); executeMethod(method, result.use(logic()).forwardTo(method.getResource().getType())); } catch (ResourceNotFoundException e) { result.use(page()).forwardTo(referer); } catch (MethodNotAllowedException e) { result.use(page()).forwardTo(referer); } } DefaultRefererResult(Result result, MutableRequest request, Router router,
				ParametersProvider provider, Localization localization); }
DefaultRefererResult implements RefererResult { public void forward() throws IllegalStateException { String referer = getReferer(); try { ResourceMethod method = router.parse(referer, HttpMethod.GET, request); executeMethod(method, result.use(logic()).forwardTo(method.getResource().getType())); } catch (ResourceNotFoundException e) { result.use(page()).forwardTo(referer); } catch (MethodNotAllowedException e) { result.use(page()).forwardTo(referer); } } DefaultRefererResult(Result result, MutableRequest request, Router router,
				ParametersProvider provider, Localization localization); void forward(); void redirect(); }
DefaultRefererResult implements RefererResult { public void forward() throws IllegalStateException { String referer = getReferer(); try { ResourceMethod method = router.parse(referer, HttpMethod.GET, request); executeMethod(method, result.use(logic()).forwardTo(method.getResource().getType())); } catch (ResourceNotFoundException e) { result.use(page()).forwardTo(referer); } catch (MethodNotAllowedException e) { result.use(page()).forwardTo(referer); } } DefaultRefererResult(Result result, MutableRequest request, Router router,
				ParametersProvider provider, Localization localization); void forward(); void redirect();  }