Package org.apache.struts.mock

Examples of org.apache.struts.mock.MockFormBean


    }

    // -- public Object lookup(PageContext pageContext, String name, String scopeName)
    // lookup with null scope
    public void test_Object_lookup_PageContext_String__String1() {
        pageContext.setAttribute("bean", new MockFormBean());

        try {
            Object val = tagutils.lookup(pageContext, "bean", null);

            assertNotNull((val));
View Full Code Here


        }
    }

    // lookup with page scope
    public void test_Object_lookup_PageContext_String__String2() {
        pageContext.setAttribute("bean", new MockFormBean());

        try {
            Object val = tagutils.lookup(pageContext, "bean", "page");

            assertNotNull((val));
View Full Code Here

    }

    // lookup with invalid scope
    // -- (where an exception is thrown)
    public void test_Object_lookup_PageContext_String__String3() {
        pageContext.setAttribute("bean", new MockFormBean());

        Object val = null;

        try {
            val = tagutils.lookup(pageContext, "bean", "invalid");
View Full Code Here

        //        }
    }

    // try to get the call to throw an IllegalArgumentException
    public void test_Object_lookup_PageContext_String_String_String2() {
        pageContext.setAttribute("bean", new MockFormBean());

        Object val = null;

        try {
            val = tagutils.lookup(pageContext, "bean", "doesNotExistMethod",
View Full Code Here

        }
    }

    // try to get the call to throw an NoSuchMethodException
    public void test_Object_lookup_PageContext_String_String_String3() {
        pageContext.setAttribute("bean", new MockFormBean());

        Object val = null;

        try {
            val = tagutils.lookup(pageContext, "bean", "doesNotExistMethod");
View Full Code Here

    public void testMultipartVisibility() throws Exception {

        String mockMappingName = "mockMapping";
        String stringValue     = "Test";

        MockFormBean  mockForm = new MockFormBean();
        ActionMapping mapping  = new ActionMapping();
        mapping.setName(mockMappingName);

        // Set up the mock HttpServletRequest
        request.setMethod("POST");
        request.setContentType("multipart/form-data");
        request.setAttribute(Globals.MULTIPART_KEY, MockMultipartRequestHandler.class.getName());
        request.setAttribute(Globals.MAPPING_KEY, mapping);

        request.addParameter("stringProperty", stringValue);
        request.addParameter("multipartRequestHandler.mapping.name", "Bad");

        // Check the Mapping/ActionForm before
        assertNull("Multipart Handler already set",    mockForm.getMultipartRequestHandler());
        assertEquals("Mapping name not set correctly", mockMappingName, mapping.getName());

        // Try to populate
        try {
            RequestUtils.populate(mockForm, request);
        } catch(ServletException se) {
            // Expected BeanUtils.populate() to throw a NestedNullException
            // which gets wrapped in RequestUtils in a ServletException
            assertEquals("Unexpected type of Exception thrown", "BeanUtils.populate", se.getMessage());
        }

        // Check the Mapping/ActionForm after
        assertNotNull("Multipart Handler Missing", mockForm.getMultipartRequestHandler());
        assertEquals("Mapping name has been modified", mockMappingName, mapping.getName());

    }
View Full Code Here


    // Single parameter -- scope + name + property
    public void testComputeParameters1c() {

        request.setAttribute("attr", new MockFormBean("bar"));

        Map map = null;
        try {
            map = RequestUtils.computeParameters
                (page, "foo", "attr", "stringProperty", "request",
View Full Code Here


    // Provided map -- scope + name + property
    public void testComputeParameters2c() {

        request.setAttribute("attr", new MockFormBean());

        Map map = null;
        try {
            map = RequestUtils.computeParameters
                (page, null, null, null, null,
View Full Code Here


    // Kitchen sink combination of parameters with a merge
    public void testComputeParameters3a() {

        request.setAttribute("attr", new MockFormBean("bar3"));
        session.setAttribute(Globals.TRANSACTION_TOKEN_KEY, "token");

        Map map = null;
        try {
            map = RequestUtils.computeParameters
View Full Code Here


    // Single parameter -- scope + name + property
    public void testComputeParameters1c() {

        request.setAttribute("attr", new MockFormBean("bar"));

        Map map = null;
        try {
            map = RequestUtils.computeParameters
                (page, "foo", "attr", "stringProperty", "request",
View Full Code Here

TOP

Related Classes of org.apache.struts.mock.MockFormBean

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.