Package net.sourceforge.stripes.mock

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


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

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


        TypeConverter<?> tc = factory.getTypeConverter(Integer.class, locale);
        try {
            factory.add(Integer.class, MyIntegerTypeConverter.class);
            trip.addParameter("shouldBeDoubled", "42");
            trip.addParameter("shouldNotBeDoubled", "42");
            trip.execute("validateTypeConverters");
            ValidationAnnotationsTest actionBean = trip.getActionBean(getClass());
            Assert.assertEquals(actionBean.shouldBeDoubled, new Integer(84));
            Assert.assertEquals(actionBean.shouldNotBeDoubled, new Integer(42));
        }
        finally {
View Full Code Here

        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

        try {
            MockRoundtrip trip = new MockRoundtrip(getMockServletContext(), getClass());
            factory.add(String.class, MyStringTypeConverter.class);
            trip.addParameter("shouldBeUpperCased", "test");
            trip.addParameter("shouldNotBeUpperCased", "test");
            trip.execute("validateTypeConverters");
            ValidationAnnotationsTest actionBean = trip.getActionBean(getClass());
            Assert.assertEquals(actionBean.shouldBeUpperCased, "TEST");
            Assert.assertEquals(actionBean.shouldNotBeUpperCased, "test");
        }
        finally {
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

     */
    @Test(groups="fast")
    public void testValidateEncryptedEmptyString() throws Exception {
        MockRoundtrip trip = new MockRoundtrip(getMockServletContext(), getClass());
        trip.addParameter("encryptedParam", CryptoUtil.encrypt(""));
        trip.execute("validateEncrypted");
        ValidationAnnotationsTest actionBean = trip.getActionBean(getClass());
        Assert.assertNull(actionBean.encryptedParam);
    }
}
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 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

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

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