Java Code Examples for com.mockobjects.servlet.MockServletContext#setupGetResource()

The following examples show how to use com.mockobjects.servlet.MockServletContext#setupGetResource() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TagTestUtils.java    From uyuni with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Setup the TagTestHelper class with the
 * appropriate infrastructure.
 * @param tag The Tag lib to test.
 * @param url URL to be passed into the Mock Servlet Context.
 * @param request The request that was created by the test to be used
 *        by this helper
 * @return TagTestHelper
 * @see com.mockobjects.helpers.TagTestHelper
 */
public static TagTestHelper setupTagTest(Tag tag, URL url,
                                         RhnMockHttpServletRequest request) {

    TagTestHelper tth = new TagTestHelper(tag);
    MockPageContext mpc = tth.getPageContext();
    MockServletContext ctx = (MockServletContext) mpc.getServletContext();
    if (request == null) {
        request = TestUtils.getRequestWithSessionAndUser();
    }
    request.setRequestURL("http://localhost:8080/rhnjava/index.jsp");
    request.addAttribute("requestedUri", "http://localhost:8080/rhnjava/index.jsp");
    request.setSession(new RhnMockHttpSession());
    mpc.setRequest(request);
    mpc.setJspWriter(new RhnMockJspWriter());

    if (url != null) {
        ctx.setupGetResource(url);
    }
    return tth;
}
 
Example 2
Source File: TagTestUtils.java    From spacewalk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Setup the TagTestHelper class with the
 * appropriate infrastructure.
 * @param tag The Tag lib to test.
 * @param url URL to be passed into the Mock Servlet Context.
 * @param request The request that was created by the test to be used
 *        by this helper
 * @return TagTestHelper
 * @see com.mockobjects.helpers.TagTestHelper
 */
public static TagTestHelper setupTagTest(Tag tag, URL url,
                                         RhnMockHttpServletRequest request) {

    TagTestHelper tth = new TagTestHelper(tag);
    MockPageContext mpc = tth.getPageContext();
    MockServletContext ctx = (MockServletContext) mpc.getServletContext();
    if (request == null) {
        request = TestUtils.getRequestWithSessionAndUser();
    }
    request.setRequestURL("http://localhost:8080/rhnjava/index.jsp");
    request.addAttribute("requestedUri", "http://localhost:8080/rhnjava/index.jsp");
    request.setSession(new RhnMockHttpSession());
    mpc.setRequest(request);
    mpc.setJspWriter(new RhnMockJspWriter());

    if (url != null) {
        ctx.setupGetResource(url);
    }
    return tth;
}