Package net.sourceforge.stripes.test

Examples of net.sourceforge.stripes.test.TestBean


        Assert.assertNull(root.getStringList().get(1));
    }

    @Test(groups="fast")
    public void testSetNullPrimitives() throws Exception {
        TestBean root = new TestBean();
        root.setBooleanProperty(true);
        root.setIntProperty(77);

        Assert.assertEquals(77, root.getIntProperty());
        Assert.assertEquals(true, root.isBooleanProperty());

        BeanUtil.setPropertyToNull("intProperty", root);
        BeanUtil.setPropertyToNull("booleanProperty", root);

        Assert.assertEquals(0, root.getIntProperty());
        Assert.assertEquals(false, root.isBooleanProperty());
    }
View Full Code Here


     * would not fall back to looking at instance information to figure out the type info.
     */
    @Test(groups="fast")
    public void testFallBackToInstanceInfo() throws Exception {
        Map<String,TestBean> map = new HashMap<String,TestBean>();
        map.put("foo", new TestBean());
        map.get("foo").setStringProperty("bar");
        Map.Entry<String,TestBean> entry = map.entrySet().iterator().next();
        String value = (String) BeanUtil.getPropertyValue("value.stringProperty", entry);
        Assert.assertEquals(value, "bar");
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    @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

*/
public class BeanComparatorTest {
    @Test(groups="fast")
    public void testSimplePropertySort() throws Exception {
        List<TestBean> beans = new ArrayList<TestBean>();
        beans.add(new TestBean());
        beans.get(beans.size()-1).setStringProperty("hello");
        beans.add(new TestBean());
        beans.get(beans.size()-1).setStringProperty("goodbye");
        beans.add(new TestBean());
        beans.get(beans.size()-1).setStringProperty("whatever");
        beans.add(new TestBean());
        beans.get(beans.size()-1).setStringProperty("huh?");
        beans.add(new TestBean());
        beans.get(beans.size()-1).setStringProperty("no way!");

        Collections.sort(beans, new BeanComparator("stringProperty"));
        Assert.assertEquals(beans.get(0).getStringProperty(), "goodbye");
        Assert.assertEquals(beans.get(1).getStringProperty(), "hello");
View Full Code Here

    }

    @Test(groups="fast")
    public void testSimpleMultiPropertySort() throws Exception {
        List<TestBean> beans = new ArrayList<TestBean>();
        beans.add(new TestBean());
        beans.get(beans.size()-1).setLongProperty(2l);
        beans.get(beans.size()-1).setStringProperty("hello");
        beans.add(new TestBean());
        beans.get(beans.size()-1).setLongProperty(2l);
        beans.get(beans.size()-1).setStringProperty("goodbye");
        beans.add(new TestBean());
        beans.get(beans.size()-1).setLongProperty(1l);
        beans.get(beans.size()-1).setStringProperty("whatever");
        beans.add(new TestBean());
        beans.get(beans.size()-1).setLongProperty(1l);
        beans.get(beans.size()-1).setStringProperty("huh?");
        beans.add(new TestBean());
        beans.get(beans.size()-1).setLongProperty(3l);
        beans.get(beans.size()-1).setStringProperty("no way!");

        Collections.sort(beans, new BeanComparator("longProperty", "stringProperty"));
        Assert.assertEquals(beans.get(0).getStringProperty(), "huh?");
View Full Code Here

    }

    @Test(groups="fast")
    public void testNullPropertySort() throws Exception {
        List<TestBean> beans = new ArrayList<TestBean>();
        beans.add(new TestBean());
        beans.get(beans.size()-1).setStringProperty("hello");
        beans.add(new TestBean());
        beans.get(beans.size()-1).setStringProperty(null);
        beans.add(new TestBean());
        beans.get(beans.size()-1).setStringProperty("whatever");

        Collections.sort(beans, new BeanComparator("stringProperty"));
        Assert.assertEquals(beans.get(0).getStringProperty(), "hello");
        Assert.assertEquals(beans.get(1).getStringProperty(), "whatever");
View Full Code Here

    }

    @Test(groups="fast")
    public void testNullPropertySort2() throws Exception {
        List<TestBean> beans = new ArrayList<TestBean>();
        beans.add(new TestBean());
        beans.get(beans.size()-1).setStringProperty(null);
        beans.add(new TestBean());
        beans.get(beans.size()-1).setStringProperty(null);
        beans.add(new TestBean());
        beans.get(beans.size()-1).setStringProperty("whatever");

        Collections.sort(beans, new BeanComparator("stringProperty"));
        Assert.assertEquals(beans.get(0).getStringProperty(), "whatever");
        Assert.assertEquals(beans.get(1).getStringProperty(), null);
View Full Code Here

    }

    @Test(groups="fast")
    public void testNestedPropertySort() throws Exception {
        List<TestBean> beans = new ArrayList<TestBean>();
        beans.add(new TestBean());
        beans.get(beans.size()-1).setNestedBean(new TestBean());
        beans.get(beans.size()-1).getNestedBean().setEnumProperty(TestEnum.Fourth);
        beans.add(new TestBean());
        beans.get(beans.size()-1).setNestedBean(new TestBean());
        beans.get(beans.size()-1).getNestedBean().setEnumProperty(TestEnum.Second);
        beans.add(new TestBean());
        beans.get(beans.size()-1).setNestedBean(new TestBean());
        beans.get(beans.size()-1).getNestedBean().setEnumProperty(TestEnum.Ninth);
        beans.add(new TestBean());
        beans.get(beans.size()-1).setNestedBean(new TestBean());
        beans.get(beans.size()-1).getNestedBean().setEnumProperty(TestEnum.Eight);
        beans.add(new TestBean());
        beans.get(beans.size()-1).setNestedBean(new TestBean());
        beans.get(beans.size()-1).getNestedBean().setEnumProperty(TestEnum.First);

        Collections.sort(beans, new BeanComparator("nestedBean.enumProperty"));
        Assert.assertEquals(beans.get(0).getNestedBean().getEnumProperty(), TestEnum.First);
        Assert.assertEquals(beans.get(1).getNestedBean().getEnumProperty(), TestEnum.Second);
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.