Package org.apache.click

Examples of org.apache.click.MockContext


import org.apache.click.servlet.MockRequest;

public class LongFieldTest extends TestCase {
   
    public void testOnProcess() {
        MockContext mockContext = MockContext.initContext();
        MockRequest request = mockContext.getMockRequest();
       
        LongField longField = new LongField("id");
        assertEquals("id", longField.getName());

        request.getParameterMap().put("id", "1234");
View Full Code Here


            "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

            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

        germanF.setValue("3.456,134");
        assertEquals(3456.134f, germanF.getNumber().floatValue(),0);
    }
   
    public void testOnProcess() {
        MockContext mockContext = MockContext.initContext(Locale.US);
        MockRequest req = mockContext.getMockRequest();
        Map<String, Object> params = req.getParameterMap();
       
        NumberField engF = new NumberField("en");
        engF.setPattern("#,##0.00");
       
View Full Code Here

        assertNull(engF.getNumber());
        assertEquals("some value", req.getParameter(engF.getName()));
    }
   
    public void testValidate() {
        MockContext mockContext = MockContext.initContext(Locale.US);
        MockRequest req = mockContext.getMockRequest();
        Map<String, Object> params = req.getParameterMap();
       
        NumberField engF = new NumberField("en");
        engF.setPattern("0");
       
View Full Code Here

        assertFalse(pat.matcher("#A2A2A").matches());
        assertFalse(pat.matcher("#1234").matches());
    }
   
    public void testValidate() {
        MockContext mockContext = MockContext.initContext();
        MockRequest mr = mockContext.getMockRequest();
        Map<String, Object> params = mr.getParameterMap();
       
        ColorPicker cp = new ColorPicker("color");
       
        params.put("color","#fff");
View Full Code Here

        menu.setRoles(Collections.singletonList(role));

        RoleAccessController controller = new RoleAccessController();
        menu.setAccessController(controller);

        MockContext context = MockContext.initContext();
        MockPrincipal principal = new MockPrincipal("bob", role);
        context.getMockRequest().setUserPrincipal(principal);

        // Perform tests
        assertTrue(menu.isUserInRoles());
    }
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.