Example #1
0
  @Before
  public void setUp() throws Exception {
    r1 = mock(Router.class);
    r2 = mock(Router.class);

    router = new MetaRouter();
    router.addRouter(r1);
    router.addRouter(r2);
  }
Example #2
0
  /**
   * Test method for {@link
   * de.highbyte_le.weberknecht.request.routing.MetaRouter#routeUri(java.lang.String)}.
   */
  @Test
  public void testRouteUri() {
    HttpServletRequest foo = mock(HttpServletRequest.class);
    HttpServletRequest bar = mock(HttpServletRequest.class);
    HttpServletRequest foobar = mock(HttpServletRequest.class);

    RoutingTarget targetFoo = new RoutingTarget("foo", "do", null);
    RoutingTarget targetBar = new RoutingTarget("bar", "do", null);
    when(r1.routeUri(foo)).thenReturn(targetFoo);
    when(r2.routeUri(bar)).thenReturn(targetBar);

    assertEquals(targetFoo, router.routeUri(foo));
    assertEquals(targetBar, router.routeUri(bar));
    assertNull(router.routeUri(foobar));

    verify(r1, times(1)).routeUri(foo);
    verify(r1, times(1)).routeUri(bar);
    verify(r2, times(0)).routeUri(foo);
    verify(r2, times(1)).routeUri(bar);
  }