Search in sources :

Example 1 with RequestDispatcherWrapper

use of org.apache.sling.engine.impl.helper.ExternalServletContextWrapper.RequestDispatcherWrapper in project sling by apache.

the class ExternalServletContextWrapperTest method testGetRequestDispatcher.

/**
     * Tests that the RequestDispatcher is wrapped.
     */
@Test
public void testGetRequestDispatcher() {
    final RequestDispatcher rd = context.mock(RequestDispatcher.class);
    final ServletContext ctx = context.mock(ServletContext.class);
    context.checking(new Expectations() {

        {
            oneOf(ctx).getRequestDispatcher("foo.jsp");
            will(returnValue(rd));
        }
    });
    ExternalServletContextWrapper wrapper = new ExternalServletContextWrapper(ctx);
    RequestDispatcher dispatcher = wrapper.getRequestDispatcher("foo.jsp");
    assertTrue(dispatcher instanceof RequestDispatcherWrapper);
    assertEquals(rd, ((RequestDispatcherWrapper) dispatcher).getDelegate());
}
Also used : Expectations(org.jmock.Expectations) RequestDispatcherWrapper(org.apache.sling.engine.impl.helper.ExternalServletContextWrapper.RequestDispatcherWrapper) ServletContext(javax.servlet.ServletContext) RequestDispatcher(javax.servlet.RequestDispatcher) Test(org.junit.Test)

Aggregations

RequestDispatcher (javax.servlet.RequestDispatcher)1 ServletContext (javax.servlet.ServletContext)1 RequestDispatcherWrapper (org.apache.sling.engine.impl.helper.ExternalServletContextWrapper.RequestDispatcherWrapper)1 Expectations (org.jmock.Expectations)1 Test (org.junit.Test)1