Package net.sourceforge.stripes.mock

Examples of net.sourceforge.stripes.mock.MockRoundtrip


    }


    /** Makes a roundtrip using the current instances' type. */
    protected MockRoundtrip getRoundtrip() {
        return new MockRoundtrip(ctx, GenericsBindingTests.class);
    }
View Full Code Here


        return new MockRoundtrip(ctx, GenericsBindingTests.class);
    }

    @Test(groups="fast")
    public void testSimpleTypeVariable() throws Exception {
        MockRoundtrip trip = getRoundtrip();
        trip.getRequest().addLocale(Locale.ENGLISH);
        trip.addParameter("number", "123.4");
        trip.execute();

        GenericsBindingTests bean = trip.getActionBean(GenericsBindingTests.class);
        Assert.assertNotNull(bean.getNumber());
        Assert.assertEquals(bean.getNumber(), new Double(123.4));
    }
View Full Code Here

        Assert.assertEquals(bean.getNumber(), new Double(123.4));
    }

    @Test(groups="fast")
    public void testGenericBean() throws Exception {
        MockRoundtrip trip = getRoundtrip();
        trip.getRequest().addLocale(Locale.ENGLISH);
        trip.addParameter("genericBean.genericA", "123.4");
        trip.addParameter("genericBean.genericB", "true");
        trip.execute();

        GenericsBindingTests bean = trip.getActionBean(GenericsBindingTests.class);
        Assert.assertNotNull(bean.getGenericBean().getGenericA());
        Assert.assertEquals(bean.getGenericBean().getGenericA(), new Double(123.4));
        Assert.assertNotNull(bean.getGenericBean().getGenericB());
        Assert.assertEquals(bean.getGenericBean().getGenericB(), Boolean.TRUE);
    }
View Full Code Here

        Assert.assertEquals(bean.getGenericBean().getGenericB(), Boolean.TRUE);
    }

    @Test(groups="fast")
    public void testTypeVariableLists() throws Exception {
        MockRoundtrip trip = getRoundtrip();
        trip.addParameter("list[0]", "true");
        trip.addParameter("list[1]", "false");
        trip.addParameter("list[2]", "yes");
        trip.execute();

        GenericsBindingTests bean = trip.getActionBean(GenericsBindingTests.class);
        Assert.assertNotNull(bean.getList());
        Assert.assertEquals(bean.getList().get(0), Boolean.TRUE);
        Assert.assertEquals(bean.getList().get(1), Boolean.FALSE);
        Assert.assertEquals(bean.getList().get(2), Boolean.TRUE);
    }
View Full Code Here

        Assert.assertEquals(bean.getList().get(2), Boolean.TRUE);
    }

    @Test(groups="fast")
    public void testTypeVariableMaps() throws Exception {
        MockRoundtrip trip = getRoundtrip();
        trip.addParameter("map[10]", "1/1/2010");
        trip.addParameter("map[20]", "1/1/2020");
        trip.addParameter("map[30]", "1/1/2030");
        trip.execute();

        GenericsBindingTests bean = trip.getActionBean(GenericsBindingTests.class);
        Assert.assertNotNull(bean.getMap());
        Assert.assertEquals(bean.getMap().get(10l), makeDate(2010,1,1));
        Assert.assertEquals(bean.getMap().get(20l), makeDate(2020,1,1));
        Assert.assertEquals(bean.getMap().get(30l), makeDate(2030,1,1));
    }
View Full Code Here

        Assert.assertEquals(bean.getMap().get(30l), makeDate(2030,1,1));
    }

    @Test(groups="fast")
    public void testTypeVariableNestedProperties() throws Exception {
        MockRoundtrip trip = getRoundtrip();
        trip.addParameter("bean.longProperty", "1234");
        trip.addParameter("bean.stringProperty", "foobar");
        trip.execute();

        GenericsBindingTests bean = trip.getActionBean(GenericsBindingTests.class);
        Assert.assertNotNull(bean.getBean());
        Assert.assertEquals(bean.getBean().getLongProperty(), new Long(1234));
        Assert.assertEquals(bean.getBean().getStringProperty(), "foobar");
    }
View Full Code Here

     * When we invoke the action without an event it should get routed to the default
     * handler in this class, not the one in the super class!
     */
    @Test(groups="fast")
    public void invokeDefault() throws Exception {
        MockRoundtrip trip = new MockRoundtrip(ctx,
                                               InheritanceTests.class);
        trip.execute();
        Assert.assertEquals(trip.getDestination(), "/child.jsp", "Wrong default handler called!");
    }
View Full Code Here

     */
    @Test(groups="fast")
    public void testInheritedValidations() throws Exception {
        MockServletContext ctx = StripesTestFixture.createServletContext();
        try {
            MockRoundtrip trip = new MockRoundtrip(ctx, InheritanceTests.class);
            trip.addParameter("two", "not25chars");
            trip.addParameter("three", "3");
            trip.addParameter("four", "onetwothree");
            trip.execute("/Validate.action");

            ValidationErrors errors = trip.getValidationErrors();
            Assert.assertNull(errors.get("one"), "Field one should not have errors.");
            Assert.assertEquals(errors.get("two").size(), 1, "Field two should not have 1 error.");
            Assert.assertEquals(errors.get("three").size(), 1, "Field three should not have errors.");
            Assert.assertEquals(errors.get("four").size(), 1, "Field one should not have errors.");
        } finally {
View Full Code Here

*/
public class InvalidDateKeyBreaksInvariant_STS_651 extends FilterEnabledTestBase {

    /** 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
    public void bindInvalidDateKeysInMapBreaksMapInvariant() throws Exception {
        MockRoundtrip trip = getRoundtrip();
        trip.addParameter("mapDateDate['notadate']", "01/01/2000");
        trip.execute();

        MapBindingTests bean = trip.getActionBean(MapBindingTests.class);
        Map<Date, Date> mapDateDate = bean.getMapDateDate();
        try {
            // there should be only java.util.Date objects as keys of the map
            for (Date dateKey : mapDateDate.keySet()) {
                // if we go this far then it's ok, but we try to see
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.