Package net.sourceforge.stripes.mock

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


        MockRoundtrip trip = getRoundtrip();
        trip.addParameter("mapEnumTestBean['red'].longProperty", "1");
        trip.addParameter("mapEnumTestBean['red'].intProperty", "2");
        trip.addParameter("mapEnumTestBean['green'].longProperty", "3");
        trip.addParameter("mapEnumTestBean['green'].intProperty", "4");
        trip.execute();

        MapBindingTests bean = trip.getActionBean(MapBindingTests.class);
        Assert.assertNotNull(bean.getMapEnumTestBean().get(Color.red));
        Assert.assertNotNull(bean.getMapEnumTestBean().get(Color.green));
        Assert.assertEquals(bean.getMapEnumTestBean().get(Color.red).getLongProperty(), new Long(1));
View Full Code Here


    @Test(groups="fast")
    public void bindDateKeysInMap() throws Exception {
        MockRoundtrip trip = getRoundtrip();
        trip.getRequest().addLocale(Locale.ENGLISH);
        trip.addParameter("mapDateDate['31-Dec-1999']", "01/01/2000");
        trip.execute();

        Calendar cal = Calendar.getInstance();
        cal.clear();
        cal.set(1999,Calendar.DECEMBER,31);
        Date key = cal.getTime();
View Full Code Here

    public void bindThroughTypelessMap() throws Exception {
        MockRoundtrip trip = getRoundtrip();
        trip.addParameter("typelessMap[1].longProperty", "1234");
        trip.addParameter("typelessMap[2l].nestedBean.longProperty", "4321");
        trip.addParameter("typelessMap['foo'].enumProperty", "Sixth");
        trip.execute();

        MapBindingTests bean = trip.getActionBean(MapBindingTests.class);
        Assert.assertEquals( ((TestBean) bean.getTypelessMap().get(1)).getLongProperty(), new Long(1234));
        Assert.assertEquals( ((TestBean) bean.getTypelessMap().get(2l)).getNestedBean().getLongProperty(), new Long(4321));
        Assert.assertEquals( ((TestBean) bean.getTypelessMap().get("foo")).getEnumProperty(), TestEnum.Sixth);
View Full Code Here

    @Test(groups="fast")
    public void positiveCase() throws Exception {
        MockServletContext ctx = StripesTestFixture.getServletContext();
        MockRoundtrip trip = new MockRoundtrip(ctx, FlashScopeTests.class);
        trip.addParameter("foo", "foo123");
        trip.execute();

        String url = trip.getDestination();
        Matcher matcher = FLASH_ID_REGEX.matcher(url);
        Assert.assertTrue(matcher.matches(),
                          "Redirect URL should contain request parameter for flash scope id.");
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(StripesTestFixture.getServletContext(),
                                               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

        MockRoundtrip trip = new MockRoundtrip(StripesTestFixture.getServletContext(),
                                               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

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.