0
votes

How do I set parameters into my HttpServletRequest in JMock? I search around the Google, many are old and the methods deprecated. The official website is only telling me how to use the tools but it doesn't state how to set parameters for HttpServletRequest?

Please have some guides. Thanks.

1

1 Answers

0
votes

found out the way now, just using new Expectations() syntax.

    context.checking(new Expectations() {{
        oneOf(req).getParameter("sitename"); will(returnValue(siteName));
        oneOf(req).getParameter("pagename"); will(returnValue(pageName));
        oneOf(req).getParameter("textcolor"); will(returnValue(textColor));
        oneOf(req).getParameter("buttoncolor"); will(returnValue(buttonColor));
        oneOf(req).getParameter("bordercolor"); will(returnValue(borderColor));
        oneOf(req).getParameter("subscribetext"); will(returnValue(subscribeText));
        oneOf(req).getParameter("unsubscribetext"); will(returnValue(unsubscribeText));
        allowing(req).getRequestDispatcher(result);
        allowing(req).getRequestURL();
    }});