Package org.apache.cocoon.environment.mock

Examples of org.apache.cocoon.environment.mock.MockRequest


        List beans = new ArrayList(2);
        beans.add(new TestBean("1", "One"));
        beans.add(new TestBean("2", "Two"));
        Map flowContextObject = new HashMap();
        flowContextObject.put("beans", beans);
        Request request = new MockRequest();
        Map objectModel = new HashMap();
        FlowHelper.setContextObject(objectModel, flowContextObject);
        objectModel.put(ObjectModelHelper.REQUEST_OBJECT, request);
        Map contextObjectModel = new HashMap();
        contextObjectModel.put(ContextHelper.CONTEXT_OBJECT_MODEL, objectModel);
View Full Code Here


        beans.add(null);
        beans.add(new TestBean("1", "One"));
        beans.add(new TestBean("2", "Two"));
        Map flowContextObject = new HashMap();
        flowContextObject.put("beans", beans);
        Request request = new MockRequest();
        Map objectModel = new HashMap();
        FlowHelper.setContextObject(objectModel, flowContextObject);
        objectModel.put(ObjectModelHelper.REQUEST_OBJECT, request);
        Map contextObjectModel = new HashMap();
        contextObjectModel.put(ContextHelper.CONTEXT_OBJECT_MODEL, objectModel);
View Full Code Here

     */
    public void testValueDoesParseAndValidate() throws Exception {
        Form form = WidgetTestHelper.loadForm(getManager(), this, "FieldTestCase.model.xml");
        Field field = (Field)form.getChild("intfield");
        Action button = (Action)form.getChild("action");
        MockRequest request;
       
        request = new MockRequest();
        request.addParameter("intfield", "11");
        request.addParameter("action", "pressed");
        form.process(new FormContext(request));
       
        // No parsing nor validation where performed
        Document doc = WidgetTestHelper.getWidgetFragment(field, null);
        WidgetTestHelper.assertXPathEquals("Displayed value", "11", VALUE_PATH, doc);
View Full Code Here

     */
    public void testValueDoesNotParse() throws Exception {
        Form form = WidgetTestHelper.loadForm(getManager(), this, "FieldTestCase.model.xml");
        Field field = (Field)form.getChild("intfield");
        Action button = (Action)form.getChild("action");
        MockRequest request;
       
        request = new MockRequest();
        request.addParameter("intfield", "foo");
        request.addParameter("action", "pressed");
        form.process(new FormContext(request));
       
        // No parsing nor validation where performed
        Document doc = WidgetTestHelper.getWidgetFragment(field, null);
        WidgetTestHelper.assertXPathEquals("Displayed velue", "foo", VALUE_PATH, doc);
View Full Code Here

     */
    public void testValueDoesNotValidate() throws Exception {
        Form form = WidgetTestHelper.loadForm(getManager(), this, "FieldTestCase.model.xml");
        Field field = (Field)form.getChild("intfield");
        Action button = (Action)form.getChild("action");
        MockRequest request;
       
        request = new MockRequest();
        request.addParameter("intfield", "1");
        request.addParameter("action", "pressed");
        form.process(new FormContext(request));
       
        // No parsing nor validation where performed
        Document doc = WidgetTestHelper.getWidgetFragment(field, null);
        WidgetTestHelper.assertXPathEquals("Displayed value", "1", VALUE_PATH, doc);
View Full Code Here

     */
    public void testSetEmptyValueWhenValueChangedOnRequest() throws Exception {
        Form form = WidgetTestHelper.loadForm(getManager(), this, "FieldTestCase.model.xml");
        Field field = (Field)form.getChild("stringfield");
        Action button = (Action)form.getChild("action");
        MockRequest request;
       
        // Set a value in stringfield and submit with an action
        // (no validation, thus no call to doParse())
        request = new MockRequest();
        request.addParameter("stringfield", "bar");
        request.addParameter("action", "pressed");
        form.process(new FormContext(request));
       
        // Verify submit widget, just to be sure that validation did not occur
        assertEquals("Form submit widget", button, form.getSubmitWidget());
       
View Full Code Here

     */
    public void testOldValuePresentInEventEvenIfNotParsed() throws Exception {
        Form form = WidgetTestHelper.loadForm(getManager(), this, "FieldTestCase.model.xml");
        Field field = (Field)form.getChild("stringfield");
        Action button = (Action)form.getChild("action");
        MockRequest request;
       
        // Set a value on "stringfield", and submit using an action so that
        // it stays in unparsed state
        request = new MockRequest();
        request.addParameter("stringfield", "foo");
        request.addParameter("action", "pressed");
        form.process(new FormContext(request));

        // Now add an event listener that will check old an new value
        field.addValueChangedListener(new ValueChangedListener (){
            public void valueChanged(ValueChangedEvent event) {
                assertEquals("Old value", "foo", (String)event.getOldValue());
                assertEquals("New value", "bar", (String)event.getNewValue());
            }
        });
       
        // Change value to "bar", still without explicit validation
        // That will call the event listener
        request = new MockRequest();
        request.addParameter("stringfield", "bar");
        request.addParameter("button", "pressed");
        form.process(new FormContext(request));
    }
View Full Code Here

     * Request parameters are not read when a field is not in active state
     */
    public void testParameterNotReadWhenDisabled() throws Exception {
        Form form = WidgetTestHelper.loadForm(getManager(), this, "FieldTestCase.model.xml");
        Field field = (Field)form.getChild("stringfield");
        MockRequest request;

        // Disable the form
        form.setState(WidgetState.DISABLED);
        field.setValue("foo");
       
        request = new MockRequest();
        request.addParameter("stringfield", "bar");
        form.process(new FormContext(request));
       
        // Check that "bar" was not read
        assertEquals("foo", field.getValue());
       
View Full Code Here

        List beans = new ArrayList(2);
        beans.add(new TestBean("1", "One"));
        beans.add(new TestBean("2", "Two"));
        Map flowContextObject = new HashMap();
        flowContextObject.put("beans", beans);
        Request request = new MockRequest();
        Map objectModel = new HashMap();
        FlowHelper.setContextObject(objectModel, flowContextObject);
        objectModel.put(ObjectModelHelper.REQUEST_OBJECT, request);
        Map contextObjectModel = new HashMap();
        contextObjectModel.put(ContextHelper.CONTEXT_OBJECT_MODEL, objectModel);
View Full Code Here

        beans.add(null);
        beans.add(new TestBean("1", "One"));
        beans.add(new TestBean("2", "Two"));
        Map flowContextObject = new HashMap();
        flowContextObject.put("beans", beans);
        Request request = new MockRequest();
        Map objectModel = new HashMap();
        FlowHelper.setContextObject(objectModel, flowContextObject);
        objectModel.put(ObjectModelHelper.REQUEST_OBJECT, request);
        Map contextObjectModel = new HashMap();
        contextObjectModel.put(ContextHelper.CONTEXT_OBJECT_MODEL, objectModel);
View Full Code Here

TOP

Related Classes of org.apache.cocoon.environment.mock.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.