Examples of MockContext


Examples of org.apache.click.MockContext

     * 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

Examples of org.apache.click.MockContext

     * readonly attribute.
     *
     * CLK-751
     */
    public void testReadonly() {
        MockContext context = MockContext.initContext();
        CheckList cl = new CheckList("cl");
        cl.setReadonly(true);
        int[] in = {1,2,3,4,5,6};
        List<Option> ol = createOptionsList(in);
        cl.setOptionList(ol);
View Full Code Here

Examples of org.apache.click.MockContext

            "three",
            "3.1"};
    }
   
    private void assertExpandOrCollapse(Tree tree, String[] nodeIds, boolean expected) {
        MockContext context = (MockContext) MockContext.getThreadLocalContext();
        for(int i = 0; i < nodeIds.length; i++) {
            TreeNode node = tree.find(nodeIds[i]);
            assertTrue("IsExpanded must be " + expected,node.isExpanded() == expected);
        }
        tree.onProcess();
        context.executeActionListeners();
        for(int i = 0; i < nodeIds.length; i++) {
            TreeNode node = tree.find(nodeIds[i]);
            assertTrue("IsExpanded must be " + !expected,node.isExpanded() == !expected);
        }
    }
View Full Code Here

Examples of org.apache.click.MockContext

            assertTrue("IsExpanded must be " + !expected,node.isExpanded() == !expected);
        }
    }

    private void assertSelectOrDeselect(Tree tree, String[] nodeIds, boolean expected) {
        MockContext context = (MockContext) MockContext.getThreadLocalContext();
        for(int i = 0; i < nodeIds.length; i++) {
            TreeNode node = tree.find(nodeIds[i]);
            assertTrue("IsExpanded must be " + expected,node.isSelected() == expected);
        }
        tree.onProcess();
        context.executeActionListeners();
        for(int i = 0; i < nodeIds.length; i++) {
            TreeNode node = tree.find(nodeIds[i]);
            assertTrue("IsExpanded must be " + !expected,node.isSelected() == !expected);
        }
    }
View Full Code Here

Examples of org.apache.click.MockContext

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

Examples of org.apache.click.MockContext

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

        TabbedPanel tabbedPanel = new TabbedPanel("tabbedPanel");

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

        tabbedPanel.add(new Panel("panel1"));
        tabbedPanel.add(new Panel("panel2"));
        tabbedPanel.onInit();
        String activePanelName = tabbedPanel.getActivePanel().getName();
View Full Code Here

Examples of org.apache.click.MockContext

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

        TabbedPanel tabbedPanel = new TabbedPanel("tabbedPanel");

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

        tabbedPanel.add(new Panel("panel1"));
        tabbedPanel.add(new Panel("panel2"));
        tabbedPanel.onInit();
        String activePanelName = tabbedPanel.getActivePanel().getName();
View Full Code Here

Examples of org.apache.click.MockContext

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

        TabbedPanel tabbedPanel = new TabbedPanel("tabbedPanel");

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

        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

Examples of org.apache.click.MockContext

    /**
     * Test TextField onProcess behavior.
     */
    public void testOnProcess() {
        MockContext context = MockContext.initContext();
        MockRequest request = context.getMockRequest();
       
        TextField textField = new TextField("text");
        assertEquals("text", textField.getName());
       
        request.getParameterMap().put("text", "textvalue");
View Full Code Here

Examples of org.apache.click.MockContext

     * Checks that Click vetoes the addition of a Container to itself.
     *
     * CLK-414.
     */
    public void testAddContainerToItself() {
        MockContext context = MockContext.initContext();
        try {
            Form form = new Form("form");
            form.add(form);
            Assert.assertFalse("Cannot add container to itself", true);
        } catch (RuntimeException expected) {
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.