Package net.sourceforge.stripes.mock

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


    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));
View Full Code Here


    @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

            trip2.addParameter(StripesConstants.URL_KEY_FLASH_SCOPE_ID, id);

            Assert.assertNull(trip2.getRequest().getAttribute("foo"),
                              "Request attribute 'foo' should not exist prior to request.");

            trip2.execute("DoNothing");
            Assert.assertEquals("foo123", trip2.getRequest().getAttribute("foo"),
                                "Request attribute 'foo' should have been set by FlashScope.");

            Assert.assertEquals(FlashScope.getAllFlashScopes(trip2.getRequest()).size(), 0,
                                "FlashScope should have been removed from session after use.");
View Full Code Here

            MockRoundtrip trip3 = new MockRoundtrip(ctx, FlashScopeTests.class, (MockHttpSession) trip
                    .getRequest().getSession());

            // Get the flash scope ID from the redirect URL and add it back as a parameter
            trip3.addParameter(StripesConstants.URL_KEY_FLASH_SCOPE_ID, id);
            trip3.execute("FlashBean");

            try {
                ActionBeanContext tmp = trip3.getActionBean(getClass()).getContext();
                HttpServletResponse response = tmp.getResponse();
                HttpServletRequest request = tmp.getRequest();
View Full Code Here

     */
    @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!");
    }

    // Overridden getter methods that simply allow additional validations to be added

View Full Code Here

        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.");
View Full Code Here

    @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
View Full Code Here

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

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

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

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

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

        GenericsBindingTests2 bean = trip.getActionBean(GenericsBindingTests2.class);
        Assert.assertNotNull(bean.getList());
        Assert.assertEquals(bean.getList().get(0), Boolean.TRUE);
        Assert.assertEquals(bean.getList().get(1), Boolean.FALSE);
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.