Package net.sourceforge.stripes.mock

Examples of net.sourceforge.stripes.mock.MockRoundtrip


    }

    @Test(groups="fast")
    public void bindPublicPropertyWithoutMethods() throws Exception {
        // Should be able to set it just fine
        MockRoundtrip trip = getRoundtrip();
        trip.addParameter("publicLong", "12345");
        trip.execute();

        TestActionBean bean = trip.getActionBean(TestActionBean.class);
        Assert.assertEquals(new Long(12345), bean.publicLong);
    }
View Full Code Here


    }

    @Test(groups="fast")
    public void attemptToBindIntoActionBeanContext() throws Exception {
        // Should be able to set it just fine
        MockRoundtrip trip = getRoundtrip();
        trip.addParameter("context.eventName", "woohaa!");
        trip.addParameter(" context.eventName", "woohaa!");
        trip.execute();

        TestActionBean bean = trip.getActionBean(TestActionBean.class);
        ActionBeanContext context = bean.getContext();
        Assert.assertFalse("woohaa!".equals(context.getEventName()));
    }
View Full Code Here

    }

    @Test(groups="fast")
    public void attemptToBindIntoActionBeanContextII() throws Exception {
        // Should be able to set it just fine
        MockRoundtrip trip = getRoundtrip();
        trip.addParameter("Context.eventName", "woohaa!");
        trip.addParameter(" Context.eventName", "woohaa!");
        trip.execute();

        TestActionBean bean = trip.getActionBean(TestActionBean.class);
        ActionBeanContext context = bean.getContext();
        Assert.assertFalse("woohaa!".equals(context.getEventName()));
    }
View Full Code Here

    }

    @Test(groups="fast")
    public void bindArrayOfEnums() throws Exception {
        // Should be able to set it just fine
        MockRoundtrip trip = getRoundtrip();
        trip.addParameter("colors", "Red", "Green", "Blue");
        trip.execute();

        TestActionBean bean = trip.getActionBean(TestActionBean.class);
        TestActionBean.Color[] colors = bean.getColors();
        Assert.assertNotNull(colors);
        Assert.assertEquals(colors.length, 3);
        Assert.assertEquals(colors[0], TestActionBean.Color.Red);
        Assert.assertEquals(colors[1], TestActionBean.Color.Green);
View Full Code Here

        Assert.assertEquals(colors[2], TestActionBean.Color.Blue);
    }

    @Test(groups="fast")
    public void testBindingToSubclassOfDeclaredType() throws Exception {
        MockRoundtrip trip = getRoundtrip();
        trip.addParameter("item.id", "1000000");
        trip.execute();

        TestActionBean bean = trip.getActionBean(TestActionBean.class);
        TestActionBean.PropertyLess item = bean.getItem();
        Assert.assertEquals(item.getClass(), TestActionBean.Item.class);
        Assert.assertEquals( ((TestActionBean.Item) item).getId(), new Long(1000000l));
    }
View Full Code Here

     *
     * @see http://www.stripesframework.org/jira/browse/STS-600
     */
    @Test(groups="fast")
    public void testValidateRequiredAndIgnored() throws Exception {
        MockRoundtrip trip = new MockRoundtrip(StripesTestFixture.getServletContext(), getClass());
        trip.execute("validateRequiredAndIgnored");
        ActionBean actionBean = trip.getActionBean(getClass());
        Assert.assertEquals(actionBean.getContext().getValidationErrors().size(), 0);
    }
View Full Code Here

     *
     * @see http://www.stripesframework.org/jira/browse/STS-604
     */
    @Test(groups="fast")
    public void testValidatePublicField() throws Exception {
        MockRoundtrip trip = new MockRoundtrip(StripesTestFixture.getServletContext(), getClass());
        trip.execute("validatePublicField");
        ActionBean actionBean = trip.getActionBean(getClass());
        Assert.assertEquals(actionBean.getContext().getValidationErrors().size(), 1);
    }
View Full Code Here

     * @see http://www.stripesframework.org/jira/browse/STS-610
     */
    @Test(groups="extensions")
    @SuppressWarnings({ "unchecked", "rawtypes" })
    public void testValidateTypeConverterExtendsStock() throws Exception {
        MockRoundtrip trip = new MockRoundtrip(StripesTestFixture.getServletContext(), getClass());
        Locale locale = trip.getRequest().getLocale();
        TypeConverterFactory factory = StripesFilter.getConfiguration().getTypeConverterFactory();
        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 {
            Class<? extends TypeConverter> tcType = tc == null ? null : tc.getClass();
View Full Code Here

    public void testValidateTypeConverterDoesNotExtendStock() throws Exception {
        TypeConverterFactory factory = StripesFilter.getConfiguration().getTypeConverterFactory();
        Class<? extends TypeConverter> oldtc = factory.getTypeConverter(//
                String.class, Locale.getDefault()).getClass();
        try {
            MockRoundtrip trip = new MockRoundtrip(StripesTestFixture.getServletContext(), 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 {
            factory.add(String.class, (Class<? extends TypeConverter<?>>) oldtc);
View Full Code Here

     *
     * @see http://www.stripesframework.org/jira/browse/STS-521
     */
    @Test(groups="fast")
    public void testValidateEncryptedEmptyString() throws Exception {
        MockRoundtrip trip = new MockRoundtrip(StripesTestFixture.getServletContext(), getClass());
        trip.addParameter("encryptedParam", CryptoUtil.encrypt(""));
        trip.execute("validateEncrypted");
        ValidationAnnotationsTest actionBean = trip.getActionBean(getClass());
        Assert.assertNull(actionBean.encryptedParam);
    }
View Full Code Here

TOP

Related Classes of net.sourceforge.stripes.mock.MockRoundtrip

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.