Package org.apache.click

Examples of org.apache.click.MockContext


   
    /**
     * Radio Submit onProcess behavior.
     */
    public void testOnProcess() {
        MockContext context = MockContext.initContext();
        MockRequest request = context.getMockRequest();
       
        Radio button = new Radio("value", "label", "button");
        assertEquals("button", button.getName());
       
        assertTrue(button.onProcess());
       
        request.setParameter("button", "true");
        assertTrue(button.onProcess());
       
        Listener l = new Listener();
        button.setActionListener(l);

        // No request param -> no action listener executed
        request.removeParameter("button");
        assertTrue(button.onProcess());
        context.executeActionListeners();
        assertFalse(l.fired);

        // No request param -> no action listener executed
        request.setParameter("button", "value");
        assertTrue(button.onProcess());
        context.executeActionListeners();
        assertTrue(button.isChecked());
        assertTrue(l.fired);

        // Disabled button with request param
        request.setParameter("button", "true");
View Full Code Here


    /**
     * Test that the request parameter <tt>tabPanelIndex</tt> sets the new
     * active panel correctly.
     */
    public void testTabPanelIndexParameter() {
        MockContext context = MockContext.initContext();

        // Since tabbedPanel is zero index based, setting tabPanelIndex to 1
        // should set the active panel to panel2
        context.getMockRequest().setParameter("tabPanelIndex", "1");

        TabbedPanel tabbedPanel = new TabbedPanel("tabbedPanel");
        tabbedPanel.add(new Panel("panel1"));
        tabbedPanel.add(new Panel("panel2"));
        tabbedPanel.onInit();
View Full Code Here

    /**
     * Test that if user selects panel2, panel2 becomes the active panel.
     */
    public void testTabLinkClicked() {
        MockContext context = MockContext.initContext();

        // Simulate user selecting panel2
        context.getMockRequest().setParameter(ActionLink.ACTION_LINK, "tabLink");
        context.getMockRequest().setParameter(ActionLink.VALUE, "panel2");

        TabbedPanel tabbedPanel = new TabbedPanel("tabbedPanel");
        tabbedPanel.add(new Panel("panel1"));
        tabbedPanel.add(new Panel("panel2"));
        tabbedPanel.onInit();
View Full Code Here

     * Test that registered tab listener is fired.
     *
     * CLK-432.
     */
    public void testTabListenerFired() {
        MockContext context = MockContext.initContext();

        // Simulate user selecting panel2
        context.getMockRequest().setParameter(ActionLink.ACTION_LINK, "tabLink");
        context.getMockRequest().setParameter(ActionLink.VALUE, "panel2");

        TabbedPanel tabbedPanel = new TabbedPanel("tabbedPanel");
        tabbedPanel.add(new Panel("panel1"));
        tabbedPanel.add(new Panel("panel2"));

        tabbedPanel.setTabListener(new ActionListener() {
            private static final long serialVersionUID = 1L;

            public boolean onAction(Control source) {
                return false;
            }
        });

        tabbedPanel.onInit();
        tabbedPanel.onProcess();
        // Simulate ClickServlet triggering all action events
        boolean actionResult = context.executeActionListeners();

        // If tab listener was triggered the actionResult should be false
        assertFalse(actionResult);
    }
View Full Code Here

     * Check that required CheckList is valid if at least one checkbox is checked.
     *
     * CLK-722
     */
    public void testRequiredValid() {
        MockContext context = MockContext.initContext();
        context.getMockRequest().setParameter("cl", "1");
        CheckList cl = new CheckList("cl");
        cl.setRequired(true);
        int[] in = {1,2,3,4,5,6};
        List<Option> ol = createOptionsList(in);
        cl.setOptionList(ol);
View Full Code Here

import org.apache.click.servlet.MockRequest;

public class IntegerFieldTest extends TestCase {
   
    public void testOnProcess() {
        MockContext mockContext = MockContext.initContext();
        MockRequest request = mockContext.getMockRequest();
       
        IntegerField intField = new IntegerField("id");
        assertEquals("id", intField.getName());
       
        request.getParameterMap().put("id", "1234");
View Full Code Here

    protected void tearDown() throws Exception {
        Locale.setDefault(defaultLocale);
    }

    public void testOnProcess() {
        MockContext mockContext = MockContext.initContext();
        MockRequest request = mockContext.getMockRequest();

        DoubleField doubleField = new DoubleField("id");
        assertEquals("id", doubleField.getName());
       
        assertEquals(new Double(Double.POSITIVE_INFINITY), new Double(doubleField.getMaxValue()));
View Full Code Here

        assertEquals("-20.1", doubleField.getValue());
        assertEquals(new Double(-20.1), doubleField.getValueObject());
    }

    public void testLocaleServerENClientDE() {
        MockContext mockContext = MockContext.initContext(Locale.GERMANY);
        MockRequest request = mockContext.getMockRequest();

        DoubleField doubleField = new DoubleField("id");

        // German uses ',' as the decimal separator
        // German 123,4 => double 123.4
View Full Code Here

* Provides DateField JUnit TestCase.
*/
public class DateFieldTest extends TestCase {

    public void testNullParameter() {
        MockContext mockContext = MockContext.initContext();
        MockRequest request = mockContext.getMockRequest();

        DateField dateField = new DateField("dateField");
        assertEquals("dateField", dateField.getName());
       
        request.getParameterMap().put("dateField", "");       
View Full Code Here

     * value each time.
     *
     * CLK-316
     */
    public void testIntegerCacheValue() {
        MockContext mockContext = MockContext.initContext();
        MockRequest request = mockContext.getMockRequest();
        mockContext.setLocale(Locale.US);
       
        DateField dateField = new DateField("dateField");
        dateField.setFormatPattern("dd MMM yyyy H m s S");
        String requestParam = "06 Oct 2008 2 30 59 999";
        request.getParameterMap().put("dateField", requestParam);
View Full Code Here

TOP

Related Classes of org.apache.click.MockContext

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.