Package net.sourceforge.stripes.mock

Examples of net.sourceforge.stripes.mock.MockRoundtrip


     * Tests that validateTwo is run event though there are errors and valiateAlways did not run,
     * because validateTwo is marked to run always.
     */
    @Test(groups="fast")
    public void testEventTwoWithErrors() throws Exception {
        MockRoundtrip trip = new MockRoundtrip(StripesTestFixture.getServletContext(), getClass());
        trip.addParameter("numberZero", ""); // required field always
        trip.addParameter("numberTwo", "")// required field for event one
        trip.execute("eventTwo");

        ValidationFlowTest test = trip.getActionBean(getClass());
        Assert.assertEquals(0, test.validateAlwaysRan);
        Assert.assertEquals(0, test.validateOneRan);
        Assert.assertEquals(1, test.validateTwoRan);
        Assert.assertEquals(2, test.getContext().getValidationErrors().size());
    }
View Full Code Here


  public void setTypelessMap(Map typelessMap) { this.typelessMap = typelessMap; }


    /** Helper method to create a roundtrip with the TestActionBean class. */
    protected MockRoundtrip getRoundtrip() {
        return new MockRoundtrip(getMockServletContext(), MapBindingTests.class);
    }
View Full Code Here

        return new MockRoundtrip(getMockServletContext(), MapBindingTests.class);
    }

    @Test(groups="fast")
    public void bindSingleQuotedStringKey() throws Exception {
        MockRoundtrip trip = getRoundtrip();
        trip.addParameter("mapStringLong['one']", "1");
        trip.addParameter("mapStringLong['two']", "2");
        trip.addParameter("mapStringLong['three']", "3");
        trip.execute();

        MapBindingTests bean = trip.getActionBean(MapBindingTests.class);
        Assert.assertEquals(bean.getMapStringLong().get("one"), new Long(1));
        Assert.assertEquals(bean.getMapStringLong().get("two"), new Long(2));
        Assert.assertEquals(bean.getMapStringLong().get("three"), new Long(3));
    }
View Full Code Here

        Assert.assertEquals(bean.getMapStringLong().get("three"), new Long(3));
    }

    @Test(groups="fast")
    public void bindDoubleQuotedStringKey() throws Exception {
        MockRoundtrip trip = getRoundtrip();
        trip.addParameter("mapStringLong[\"one\"]", "1");
        trip.addParameter("mapStringLong[\"two\"]", "2");
        trip.addParameter("mapStringLong[\"three\"]", "3");
        trip.execute();

        MapBindingTests bean = trip.getActionBean(MapBindingTests.class);
        Assert.assertEquals(bean.getMapStringLong().get("one"), new Long(1));
        Assert.assertEquals(bean.getMapStringLong().get("two"), new Long(2));
        Assert.assertEquals(bean.getMapStringLong().get("three"), new Long(3));
    }
View Full Code Here

        Assert.assertEquals(bean.getMapStringLong().get("three"), new Long(3));
    }

    @Test(groups="fast")
    public void bindSingleLetterStringKey() throws Exception {
        MockRoundtrip trip = getRoundtrip();
        trip.addParameter("mapStringLong['a']", "1");
        trip.addParameter("mapStringLong['b']", "2");
        trip.addParameter("mapStringLong['c']", "3");
        trip.execute();

        MapBindingTests bean = trip.getActionBean(MapBindingTests.class);
        Assert.assertEquals(bean.getMapStringLong().get("a"), new Long(1));
        Assert.assertEquals(bean.getMapStringLong().get("b"), new Long(2));
        Assert.assertEquals(bean.getMapStringLong().get("c"), new Long(3));
    }
View Full Code Here

        Assert.assertEquals(bean.getMapStringLong().get("c"), new Long(3));
    }

    @Test(groups="fast")
    public void bindUnquotedShortKey() throws Exception {
        MockRoundtrip trip = getRoundtrip();
        trip.addParameter("mapShortInteger[1]",    "1");
        trip.addParameter("mapShortInteger[200]""2");
        trip.addParameter("mapShortInteger[3000]", "3");
        trip.execute();

        MapBindingTests bean = trip.getActionBean(MapBindingTests.class);
        Assert.assertEquals(bean.getMapShortInteger().get( (short) 1 ), new Integer(1));
        Assert.assertEquals(bean.getMapShortInteger().get( (short) 200), new Integer(2));
        Assert.assertEquals(bean.getMapShortInteger().get( (short) 3000), new Integer(3));
    }
View Full Code Here

        Assert.assertEquals(bean.getMapShortInteger().get( (short) 3000), new Integer(3));
    }

    @Test(groups="fast")
    public void bindSingleQuotedShortKey() throws Exception {
        MockRoundtrip trip = getRoundtrip();
        trip.addParameter("mapShortInteger['1']",    "1");
        trip.addParameter("mapShortInteger['200']""2");
        trip.addParameter("mapShortInteger['3000']", "3");
        trip.execute();

        MapBindingTests bean = trip.getActionBean(MapBindingTests.class);
        Assert.assertEquals(bean.getMapShortInteger().get( (short) 1 ), new Integer(1));
        Assert.assertEquals(bean.getMapShortInteger().get( (short) 200), new Integer(2));
        Assert.assertEquals(bean.getMapShortInteger().get( (short) 3000), new Integer(3));
    }
View Full Code Here

        Assert.assertEquals(bean.getMapShortInteger().get( (short) 3000), new Integer(3));
    }

    @Test(groups="fast")
    public void bindDoubleQuotedShortKey() throws Exception {
        MockRoundtrip trip = getRoundtrip();
        trip.addParameter("mapShortInteger[\"1\"]",    "1");
        trip.addParameter("mapShortInteger[\"200\"]""2");
        trip.addParameter("mapShortInteger[\"3000\"]", "3");
        trip.execute();

        MapBindingTests bean = trip.getActionBean(MapBindingTests.class);
        Assert.assertEquals(bean.getMapShortInteger().get( (short) 1 ), new Integer(1));
        Assert.assertEquals(bean.getMapShortInteger().get( (short) 200), new Integer(2));
        Assert.assertEquals(bean.getMapShortInteger().get( (short) 3000), new Integer(3));
    }
View Full Code Here

        Assert.assertEquals(bean.getMapShortInteger().get( (short) 3000), new Integer(3));
    }

    @Test(groups="fast")
    public void bindSingleQuotedEnumKey() throws Exception {
        MockRoundtrip trip = getRoundtrip();
        trip.addParameter("mapEnumString['red']",    "Red");
        trip.addParameter("mapEnumString['green']""Green");
        trip.addParameter("mapEnumString['blue']",   "Blue");
        trip.execute();

        MapBindingTests bean = trip.getActionBean(MapBindingTests.class);
        Assert.assertEquals(bean.getMapEnumString().get(Color.red), "Red");
        Assert.assertEquals(bean.getMapEnumString().get(Color.green), "Green");
        Assert.assertEquals(bean.getMapEnumString().get(Color.blue), "Blue");
    }
View Full Code Here

     *
     * @see http://www.stripesframework.org/jira/browse/STS-600
     */
    @Test(groups="fast")
    public void testValidateRequiredAndIgnored() throws Exception {
        MockRoundtrip trip = new MockRoundtrip(getMockServletContext(), getClass());
        trip.execute("validateRequiredAndIgnored");
        ActionBean actionBean = trip.getActionBean(getClass());
        Assert.assertEquals(actionBean.getContext().getValidationErrors().size(), 0);
    }
View Full Code Here

TOP

Related Classes of net.sourceforge.stripes.mock.MockRoundtrip

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.