Package net.sourceforge.stripes.test

Examples of net.sourceforge.stripes.test.TestBean


    @SuppressWarnings({ "unchecked", "rawtypes" })
    @Before(stages=LifecycleStage.BindingAndValidation)
    public void populateTypelessMap() {
        this.typelessMap = new HashMap();
        this.typelessMap.put(1, new TestBean());
        this.typelessMap.put(2l, new TestBean());
        this.typelessMap.put("foo", new TestBean());
    }
View Full Code Here


        trip.addParameter("testBean.longProperty", "20");
        trip.addParameter("testBean.booleanProperty", "true");
        trip.addParameter("testBean.enumProperty", "Third");
        trip.execute();

        TestBean bean = trip.getActionBean(TestActionBean.class).getTestBean();
        Assert.assertNotNull(bean);
        Assert.assertEquals(bean.getIntProperty()10);
        Assert.assertEquals(bean.getLongProperty(), new Long(20));
        Assert.assertEquals(bean.isBooleanProperty(), true);
        Assert.assertEquals(bean.getEnumProperty(), TestEnum.Third);
    }
View Full Code Here

    public void bindNestedSet() throws Exception {
        MockRoundtrip trip = getRoundtrip();
        trip.addParameter("testBean.stringSet", "foo", "bar", "splat");
        trip.execute();

        TestBean bean = trip.getActionBean(TestActionBean.class).getTestBean();
        Assert.assertNotNull(bean);
        Assert.assertNotNull(bean.getStringSet());
        Assert.assertEquals(bean.getStringSet().size(), 3);
        Assert.assertTrue(bean.getStringSet().contains("foo"));
        Assert.assertTrue(bean.getStringSet().contains("bar"));
        Assert.assertTrue(bean.getStringSet().contains("splat"));
    }
View Full Code Here

    }

    @Test(groups="fast")
    public void testGetPropertyTypeWithBackToBackMapIndexing() {
        PropertyExpression expr = PropertyExpression.getExpression("nestedMap['foo']['bar']");
        PropertyExpressionEvaluation eval = new PropertyExpressionEvaluation(expr, new TestBean());
        Class<?> type = eval.getType();
        Assert.assertEquals(type, Boolean.class);
    }
View Full Code Here

    }

    @Test(groups="fast")
    public void testGetPropertyTypeWithBackToBackListArrayIndexing() {
        PropertyExpression expr = PropertyExpression.getExpression("genericArray[1][0]");
        PropertyExpressionEvaluation eval = new PropertyExpressionEvaluation(expr, new TestBean());
        Class<?> type = eval.getType();
        Assert.assertEquals(type, Float.class);
    }
View Full Code Here

    //////////////////////////////////////////////////////////////////////////////////////

    @Test(groups="fast")
    public void testGetSimpleProperties() throws Exception {
        TestBean root = new TestBean();
        root.setStringProperty("testValue");
        root.setIntProperty(77);
        root.setLongProperty(777l);
        root.setEnumProperty(TestEnum.Seventh);

        Assert.assertEquals("testValue", BeanUtil.getPropertyValue("stringProperty", root));
        Assert.assertEquals(77, BeanUtil.getPropertyValue("intProperty", root));
        Assert.assertEquals(777l, BeanUtil.getPropertyValue("longProperty", root));
        Assert.assertEquals(TestEnum.Seventh, BeanUtil.getPropertyValue("enumProperty", root));
View Full Code Here

        Assert.assertEquals(TestEnum.Seventh, BeanUtil.getPropertyValue("enumProperty", root));
    }

    @Test(groups="fast")
    public void testGetNestedProperties() throws Exception {
        TestBean root = new TestBean();
        TestBean nested = new TestBean();
        root.setNestedBean(nested);
        nested.setStringProperty("testValue");
        nested.setIntProperty(77);
        nested.setLongProperty(777l);
        nested.setEnumProperty(TestEnum.Seventh);

        Assert.assertEquals("testValue", BeanUtil.getPropertyValue("nestedBean.stringProperty", root));
        Assert.assertEquals(77, BeanUtil.getPropertyValue("nestedBean.intProperty", root));
        Assert.assertEquals(777l, BeanUtil.getPropertyValue("nestedBean.longProperty", root));
        Assert.assertEquals(TestEnum.Seventh, BeanUtil.getPropertyValue("nestedBean.enumProperty", root));
View Full Code Here

        Assert.assertEquals(TestEnum.Seventh, BeanUtil.getPropertyValue("nestedBean.enumProperty", root));
    }

    @Test(groups="fast")
    public void testGetNullProperties() throws Exception {
        TestBean root = new TestBean();

        // Test simple and nested props, leaving out primitives
        Assert.assertNull( BeanUtil.getPropertyValue("stringProperty" , root) );
        Assert.assertNull( BeanUtil.getPropertyValue("longProperty" , root) );
        Assert.assertNull( BeanUtil.getPropertyValue("enumProperty" , root) );
View Full Code Here

        Assert.assertNull( BeanUtil.getPropertyValue("stringMap", root));
    }

    @Test(groups="fast")
    public void testSetThenGetSimpleProperties() throws Exception {
        TestBean root = new TestBean();

        BeanUtil.setPropertyValue("stringProperty", root, "testValue");
        BeanUtil.setPropertyValue("intProperty",    root, 77);
        BeanUtil.setPropertyValue("longProperty",   root, 777l);
        BeanUtil.setPropertyValue("enumProperty",   root, TestEnum.Seventh);

        Assert.assertEquals("testValue", root.getStringProperty());
        Assert.assertEquals("testValue", BeanUtil.getPropertyValue("stringProperty", root));

        Assert.assertEquals(77, root.getIntProperty());
        Assert.assertEquals(77, BeanUtil.getPropertyValue("intProperty", root));

        Assert.assertEquals(new Long(777l), root.getLongProperty());
        Assert.assertEquals(777l, BeanUtil.getPropertyValue("longProperty", root));

        Assert.assertEquals(TestEnum.Seventh, root.getEnumProperty());
        Assert.assertEquals(TestEnum.Seventh, BeanUtil.getPropertyValue("enumProperty", root));

    }
View Full Code Here

    }

    @Test(groups="fast")
    public void testSetThenGetNestedProperties() throws Exception {
        TestBean root = new TestBean();

        BeanUtil.setPropertyValue("nestedBean.stringProperty", root, "testValue");
        BeanUtil.setPropertyValue("nestedBean.intProperty",    root, 77);
        BeanUtil.setPropertyValue("nestedBean.longProperty",   root, 777l);
        BeanUtil.setPropertyValue("nestedBean.enumProperty",   root, TestEnum.Seventh);

        Assert.assertEquals("testValue", root.getNestedBean().getStringProperty());
        Assert.assertEquals("testValue", BeanUtil.getPropertyValue("nestedBean.stringProperty", root));

        Assert.assertEquals(77, root.getNestedBean().getIntProperty());
        Assert.assertEquals(77, BeanUtil.getPropertyValue("nestedBean.intProperty", root));

        Assert.assertEquals(new Long(777l), root.getNestedBean().getLongProperty());
        Assert.assertEquals(777l, BeanUtil.getPropertyValue("nestedBean.longProperty", root));

        Assert.assertEquals(TestEnum.Seventh, root.getNestedBean().getEnumProperty());
        Assert.assertEquals(TestEnum.Seventh, BeanUtil.getPropertyValue("nestedBean.enumProperty", root));

        Assert.assertTrue(root.getNestedBean() == BeanUtil.getPropertyValue("nestedBean", root));
    }
View Full Code Here

TOP

Related Classes of net.sourceforge.stripes.test.TestBean

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.