Package net.sourceforge.stripes.mock

Examples of net.sourceforge.stripes.mock.MockRoundtrip.execute()


    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


    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

    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

    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

    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

    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);
    }

    @Validate(required=true, on="validatePublicField")
View Full Code Here

    public void bindNestedMap() throws Exception {
        MockRoundtrip trip = getRoundtrip();
        trip.addParameter("testBean.longMap[1]", "1");
        trip.addParameter("testBean.longMap[2]", "2");
        trip.addParameter("testBean.longMap[3]", "3");
        trip.execute();

        MapBindingTests bean = trip.getActionBean(MapBindingTests.class);
        Assert.assertEquals(bean.getTestBean().getLongMap().get(1l), new Long(1));
        Assert.assertEquals(bean.getTestBean().getLongMap().get(2l), new Long(2));
        Assert.assertEquals(bean.getTestBean().getLongMap().get(3l), new Long(3));
View Full Code Here

     * @see http://www.stripesframework.org/jira/browse/STS-604
     */
    @Test(groups="fast")
    public void testValidatePublicField() throws Exception {
        MockRoundtrip trip = new MockRoundtrip(getMockServletContext(), getClass());
        trip.execute("validatePublicField");
        ActionBean actionBean = trip.getActionBean(getClass());
        Assert.assertEquals(actionBean.getContext().getValidationErrors().size(), 1);
    }

    public Integer shouldBeDoubled;
View Full Code Here

    @Test(groups="fast")
    public void bindKeyGreaterThanMaxInt() throws Exception {
        MockRoundtrip trip = getRoundtrip();
        trip.addParameter("testBean.longMap[9999999999l]", "1");
        trip.execute();

        MapBindingTests bean = trip.getActionBean(MapBindingTests.class);
        Assert.assertEquals(bean.getTestBean().getLongMap().get(9999999999l), new Long(1));
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.