Package net.sourceforge.stripes.mock

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


    @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);
View Full Code Here


    @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);
    }

    @Validate(required=true, on="validatePublicField")
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);
    }

    public Integer shouldBeDoubled;
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

        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 {
View Full Code Here

     */
    @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

    }

    protected void runValidationTests(Class<? extends BaseActionBean<User>> type) throws Exception {
        // Trigger the validation errors
        MockRoundtrip trip = new MockRoundtrip(StripesTestFixture.getServletContext(), type);
        trip.execute("login");
        ValidationErrors errors = trip.getValidationErrors();
        Assert.assertNotNull(errors, "Expected validation errors but got none");
        Assert.assertFalse(errors.isEmpty(), "Expected validation errors but got none");
        Assert.assertEquals(errors.size(), 2, "Expected two validation errors but got " + errors.size());
View Full Code Here

        Assert.assertEquals(errors.size(), 2, "Expected two validation errors but got " + errors.size());

        // Now add the required parameters and make sure the validation errors don't happen
        trip.addParameter("model.username", "Scooby");
        trip.addParameter("model.password", "Shaggy");
        trip.execute("login");
        errors = trip.getValidationErrors();
        Assert.assertTrue(errors == null || errors.isEmpty(), "Got unexpected validation errors");

        BaseActionBean<User> bean = trip.getActionBean(type);
        Assert.assertNotNull(bean);
View Full Code Here

    @Test(groups="fast")
    public void testListOfLong() throws Exception {
        MockRoundtrip trip = new MockRoundtrip(StripesTestFixture.getServletContext(), getClass());
        trip.addParameter("numbers", "123 456 789");
        trip.execute();
        OneToManyTypeConverterTest bean = trip.getActionBean(getClass());
        List<Long> numbers = bean.getNumbers();
        Assert.assertEquals(numbers, Literal.list(123l, 456l, 789l));
    }
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.