Package org.apache.click.servlet

Examples of org.apache.click.servlet.MockRequest


*/
public class DateFieldTest extends TestCase {

    public void testNullParameter() {
        MockContext mockContext = MockContext.initContext();
        MockRequest request = mockContext.getMockRequest();

        DateField dateField = new DateField("dateField");
        assertEquals("dateField", dateField.getName());
       
        request.getParameterMap().put("dateField", "");       
        dateField.onProcess();       
        Date date = dateField.getDate();
        assertNull(date);
       
        request.getParameterMap().put("dateField", " ");       
        dateField.onProcess();       
        date = dateField.getDate();
        assertNull(date);

        request.getParameterMap().put("dateField", null);       
        dateField.onProcess();       
        date = dateField.getDate();
        assertNull(date);
       
        dateField.setValue(null);
View Full Code Here


     *
     * CLK-316
     */
    public void testIntegerCacheValue() {
        MockContext mockContext = MockContext.initContext();
        MockRequest request = mockContext.getMockRequest();
       
        DateField dateField = new DateField("dateField");
        dateField.setFormatPattern("dd MMM yyyy H m s S");
        String requestParam = "06 Oct 2008 2 30 59 999";
        request.getParameterMap().put("dateField", requestParam);

        assertTrue(dateField.onProcess());

        // Check that the value equals the request parameter
        assertEquals(requestParam, dateField.getValue());
View Full Code Here

            if (locale == null) {
                locale = Locale.getDefault();
            }
            if (getRequest() == null) {
                setRequest(new MockRequest(locale, getServletContext(),
                    getSession()));
            }
            getRequest().setAttribute(ClickServlet.MOCK_MODE_ENABLED, Boolean.TRUE);
            getServletContext().setAttribute(ClickServlet.MOCK_MODE_ENABLED,
                Boolean.TRUE);
View Full Code Here

        MockResponse response = new MockResponse();

        MockSession session = new MockSession(servletContext);

        MockRequest request = new MockRequest(locale, MockServletContext.DEFAULT_CONTEXT_PATH,
            servletPath, servletContext, session);

        return initContext(servletConfig, request, response, servlet);
    }
View Full Code Here

     * a Controls action listener.
     */
    @SuppressWarnings("unchecked")
    public void testDynamicRequest() {
        MockContext context = MockContext.initContext();
        MockRequest request = context.getMockRequest();

        TextArea textArea = new TextArea("text");
        assertEquals("text", textArea.getName());

        request.setParameter("param", "value");
        request.getParameterMap().put("text", "textvalue");

        // Registry a listener which must be invoked
        textArea.setActionListener(new ActionListener() {
            private static final long serialVersionUID = 1L;

View Full Code Here

     */
    public void testRequestParameterBinding() {
        MockContainer container = new MockContainer("web");
        container.start();

        MockRequest request = container.getRequest();
        String bigDecimalValue = "100.99";
        String stringValue = "hello";
        String boolValue = "true";

        request.setParameter("bigDecimal", bigDecimalValue);
        request.setParameter("string", stringValue);
        request.setParameter("bool", boolValue);

        RequestBindingPage page = container.testPage(RequestBindingPage.class);

        assertEquals(bigDecimalValue.toString(), page.getBigDecimal().toString());
        assertEquals(stringValue, page.getString());
View Full Code Here

            if (locale == null) {
                locale = Locale.getDefault();
            }
            if (getRequest() == null) {
                setRequest(new MockRequest(locale, getServletContext(),
                    getSession()));
            }
            getRequest().setAttribute(ClickServlet.MOCK_MODE_ENABLED, Boolean.TRUE);
            getServletContext().setAttribute(ClickServlet.MOCK_MODE_ENABLED,
                Boolean.TRUE);
View Full Code Here

    /**
     * Test Field onProcess.
     */
    public void testOnProcess() {
        MockContext context = MockContext.initContext();
        MockRequest request = context.getMockRequest();

        Field field = new TextField("text");
        field.setRequired(true);

        assertEquals("", field.getValue());

        // Test with valid request parameter
        String expectedValue = "textvalue";

        request.setParameter("text", expectedValue);

        field.onProcess();

        // Perform tests
        assertEquals(expectedValue, field.getValue());
        assertTrue(field.isValid());

        // Test with empty  request parameter
        expectedValue = "";
        request.setParameter("text", expectedValue);

        field.onProcess();

        // Perform tests
        assertEquals(expectedValue, field.getValue());
View Full Code Here

     * Test MockContext.
     */
    public void testContext() {
        MockServletContext servletContext = new MockServletContext();
        MockContext.initContext(new MockServletConfig(servletContext),
            new MockRequest(), new MockResponse(), new ClickServlet());
    }
View Full Code Here

    /**
     * Test that context can properly fire action listeners.
     */
    public void testFireActionListeners() {
        MockContext context = MockContext.initContext();
        MockRequest request = context.getMockRequest();
        request.setParameter("save", "save");

        submitCalled = false;
        Submit submit = new Submit("save");
        // Registry a listener which must be invoked
        submit.setActionListener(new ActionListener() {
View Full Code Here

TOP

Related Classes of org.apache.click.servlet.MockRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.