Package org.apache.click

Examples of org.apache.click.MockContainer$CleanRuntimeException


    /**
     * Test Google App Engine (GAE) MemoryFileItem support.
     */
    public void testMemoryFileItem() {
        MockContainer container = new MockContainer("web");
        container.start();

        String firstname = "Steve";
        String lastname = "Jones";

        // Lookup path to files
        String file1Path = container.getServletContext().getRealPath("upload1.txt");
        String file2Path = container.getServletContext().getRealPath("upload2.txt");

        File upload1 = new File(file1Path);
        File upload2 = new File(file2Path);
        MockRequest request = container.getRequest();

        // Add couple of files to be uploaded
        request.addFile("upload1", upload1, "utf-8");
        request.addFile("upload2", upload2, "utf-8");

        // Set firstname and lastname request parameters
        request.setParameter("firstname", firstname);
        request.setParameter("lastname", lastname);

        // Set FORM_NAME parameter to ensure Form is submitted
        request.setParameter(Form.FORM_NAME, "form");

        MemoryFileItemUploadPage page = (MemoryFileItemUploadPage) container.testPage(MemoryFileItemUploadPage.class);

        // Check that field parameters were processed
        assertEquals(firstname, page.getForm().getFieldValue("firstname"));
        assertEquals(lastname, page.getForm().getFieldValue("lastname"));

        // Check that file field parameters were processed
        FileField fileField1 = (FileField) page.getForm().getField("upload1");
        FileField fileField2 = (FileField) page.getForm().getField("upload2");
        assertEquals("upload1 success", fileField1.getFileItem().getString());
        assertEquals("upload2 success", fileField2.getFileItem().getString());

        container.stop();
    }
View Full Code Here


import org.apache.click.MockContext;

public class TabbedFormTest extends TestCase {

    public void testGetHtmlImport() {
        MockContainer container = new MockContainer("web");
        container.start();

        // MockContext is created when a container tests a page. There
        // are no pages to test here so we manually create a MockContext,
        // but reuse the Mock Servlet objects created in the container.
        MockContext.initContext(container.getServletConfig(), container.getRequest(), container.getResponse(), container.getClickServlet());

        TabbedForm form = new TabbedForm("form");

        assertTrue(form.toString().indexOf("<form") > 0);
        assertTrue(form.getHtmlImports().indexOf("/control.js") > 0);
        assertTrue(form.getHtmlImports().indexOf("/control.css") > 0);
        assertTrue(form.getHtmlImports().indexOf("/extras-control.css") > 0);
       
        container.stop();
    }
View Full Code Here

import org.apache.click.MockContext;

public class TabbedFormTest extends TestCase {

    public void testGetHeadElements() {
        MockContainer container = new MockContainer("web");
        container.start();

        // MockContext is created when a container tests a page. There
        // are no pages to test here so we manually create a MockContext,
        // but reuse the Mock Servlet objects created in the container.
        MockContext.initContext(container.getServletConfig(),
            container.getRequest(), container.getResponse(), container.getClickServlet());

        TabbedForm form = new TabbedForm("form");

        assertTrue(form.toString().indexOf("<form") > 0);
        assertTrue(form.getHeadElements().toString().indexOf("/control.js") > 0);
        assertTrue(form.getHeadElements().toString().indexOf("/control.css") > 0);
        assertTrue(form.getHeadElements().toString().indexOf("/extras-control.css") > 0);
       
        container.stop();
    }
View Full Code Here

        pstr.println("<click-app charset='UTF-8'>");
        pstr.println(" <pages package='org.apache.click.pages'/>");
        pstr.println("</click-app>");
        pstr.close();

        MockContainer container = new MockContainer(tmpdir.getAbsolutePath());
        container.start();
        ConfigService config = ClickUtils.getConfigService(container.getServletContext());

        assertEquals(ErrorPage.class, config.getErrorPageClass());
        assertEquals(Page.class, config.getNotFoundPageClass());
        assertEquals("development", config.getApplicationMode());
        assertEquals("UTF-8", config.getCharset());
        assertEquals(false, config.isProductionMode());
        assertEquals(false, config.isProfileMode());
        assertEquals(Format.class, config.createFormat().getClass());
        assertEquals(AutoBinding.DEFAULT, config.getAutoBindingMode());
        assertEquals(null, config.getLocale());
        assertEquals(Collections.EMPTY_LIST, config.getPageClassList());
        // Check deployed resource
        assertTrue(new File(tmpdir, "click/control.css").exists());

        container.stop();

        deleteDir(tmpdir);
    }
View Full Code Here

        pstr.println(" <pages package='org.apache.click.pages'/>");
        //pstr.println(" <mode value='trace'/>");
        pstr.println("</click-app>");
        pstr.close();

        MockContainer container = new MockContainer(tmpdir.getAbsolutePath());
        container.start();
        ConfigService config = ClickUtils.getConfigService(container.getServletContext());

        assertEquals(Locale.UK, config.getLocale());
        assertEquals("iso8859-1", config.getCharset());

        container.stop();

        deleteDir(tmpdir);
    }
View Full Code Here

        PrintStream f = new PrintStream(makeFile(tmpdir, "BinaryPage.htm"));
        f.print("template");
        f.close();

        MockContainer container = new MockContainer(tmpdir.getAbsolutePath());
        container.start();
        ConfigService config = ClickUtils.getConfigService(container.getServletContext());

        Class<? extends Page> pageClass = config.getPageClass("/BinaryPage.htm");
        assertFalse(BinaryPage.class.isAssignableFrom(pageClass));

        container.testPage("/BinaryPage.htm");
        assertEquals("template", container.getResponse().getDocument());

        container.stop();

        deleteDir(tmpdir);
    }
View Full Code Here

        pstr.println(" <pages package='org.apache.click.pages'/>");
        pstr.println(" <mode value='production'/>");
        pstr.println("</click-app>");
        pstr.close();

        MockContainer container = new MockContainer(tmpdir.getAbsolutePath());
        container.start();
        ConfigService config = ClickUtils.getConfigService(container.getServletContext());

        assertEquals(true, config.isProductionMode());
        assertEquals(false, config.isProfileMode());

        container.stop();

        deleteDir(tmpdir);
    }
View Full Code Here

        pstr.println(" <pages package='org.apache.click.pages'/>");
        pstr.println(" <mode value='profile'/>");
        pstr.println("</click-app>");
        pstr.close();

        MockContainer container = new MockContainer(tmpdir.getAbsolutePath());
        container.start();
        ConfigService config = ClickUtils.getConfigService(container.getServletContext());

        assertEquals(false, config.isProductionMode());
        assertEquals(true, config.isProfileMode());

        container.stop();

        deleteDir(tmpdir);
    }
View Full Code Here

        pstr.println(" <pages package='org.apache.click.pages'/>");
        pstr.println(" <mode value='debug'/>");
        pstr.println("</click-app>");
        pstr.close();

        MockContainer container = new MockContainer(tmpdir.getAbsolutePath());
        container.start();
        ConfigService config = ClickUtils.getConfigService(container.getServletContext());

        assertEquals(false, config.isProductionMode());
        assertEquals(false, config.isProfileMode());

        container.stop();

        deleteDir(tmpdir);
    }
View Full Code Here

        PrintStream f = new PrintStream(makeFile(tmpdir, "BinaryPage.htm"));
        f.println("template");
        f.close();

        MockContainer container = new MockContainer(tmpdir.getAbsolutePath());
        container.start();
        ConfigService config = ClickUtils.getConfigService(container.getServletContext());

        assertSame(BinaryPage.class, config.getPageClass("/BinaryPage.htm"));
        assertEquals(3, config.getPageHeaders("/BinaryPage.htm").size());

        assertNull(config.getPageClass("/UnknownPage.htm"));
        assertNull(config.getPageHeaders("/UnknownPage.htm"));

        ArrayList<Class<? extends Page>> list = new ArrayList<Class<? extends Page>>();
        list.add(org.apache.click.pages.BinaryPage.class);
        assertEquals(list, config.getPageClassList());

        container.stop();

        deleteDir(tmpdir);
    }
View Full Code Here

TOP

Related Classes of org.apache.click.MockContainer$CleanRuntimeException

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.