Examples of MockContainer


Examples of com.calclab.suco.testing.ioc.MockContainer

     * We want to verify that a component always call "getMessage" on its
     * service when we call the getMessage method on the component
     */
    @Test
    public void componentShouldCallServiceWhenGetMessage() {
  final MockContainer container = new MockContainer();
  final Component component = container.create(Component.class);
  final Service mockedService = container.getInstance(Service.class);
  // perform the call
  component.getMessage();
  // verify that component called the getMessage method on the mock
  // see mockito (mockito.googlecode.com) for more info about how mockito
  // works
View Full Code Here

Examples of com.opensymphony.xwork2.mock.MockContainer

    }

    public void testSerialization() throws Exception {
        // given
        DefaultActionInvocation actionInvocation = new DefaultActionInvocation(new HashMap<String, Object>(), false);
        actionInvocation.setContainer(new MockContainer());

        // when
        DefaultActionInvocation serializable = (DefaultActionInvocation) actionInvocation.serialize();

        // then
View Full Code Here

Examples of com.opensymphony.xwork2.mock.MockContainer

    }

    public void testDeserialization() throws Exception {
        // given
        DefaultActionInvocation actionInvocation = new DefaultActionInvocation(new HashMap<String, Object>(), false);
        MockContainer mockContainer = new MockContainer();
        ActionContext.getContext().setContainer(mockContainer);

        // when
        DefaultActionInvocation deserializable = (DefaultActionInvocation) actionInvocation.deserialize(ActionContext.getContext());
View Full Code Here

Examples of com.opensymphony.xwork2.mock.MockContainer

    }

    public void testSerialization() throws Exception {
        // given
        DefaultActionInvocation actionInvocation = new DefaultActionInvocation(new HashMap<String, Object>(), false);
        actionInvocation.setContainer(new MockContainer());

        // when
        DefaultActionInvocation serializable = (DefaultActionInvocation) actionInvocation.serialize();

        // then
View Full Code Here

Examples of com.opensymphony.xwork2.mock.MockContainer

    }

    public void testDeserialization() throws Exception {
        // given
        DefaultActionInvocation actionInvocation = new DefaultActionInvocation(new HashMap<String, Object>(), false);
        MockContainer mockContainer = new MockContainer();
        ActionContext.getContext().setContainer(mockContainer);

        // when
        DefaultActionInvocation deserializable = (DefaultActionInvocation) actionInvocation.deserialize(ActionContext.getContext());
View Full Code Here

Examples of org.apache.click.MockContainer

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

Examples of org.apache.click.MockContainer

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

Examples of org.apache.click.MockContainer

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

Examples of org.apache.click.MockContainer

        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

Examples of org.apache.click.MockContainer

        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
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.