Package net.sourceforge.stripes.mock

Examples of net.sourceforge.stripes.mock.MockRoundtrip


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

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


        return new MockRoundtrip(context, 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

        Assert.assertEquals(bean.getMapEnumString().get(Color.blue), "Blue");
    }

    @Test(groups="fast")
    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

        Assert.assertEquals(bean.getTestBean().getLongMap().get(3l), new Long(3));
    }

    @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

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.