Package org.apache.commons.chain

Examples of org.apache.commons.chain.Context


    public void testAlternateContext() throws Exception {
        TestAlternateContextCommand test = new TestAlternateContextCommand();

        test.setMethod("foo");
        Context context = new ContextBase();
        assertNull(context.get("elephant"));
        boolean result = test.execute(context);
        assertTrue(result);
        assertNotNull(context.get("elephant"));
        assertEquals("elephant", context.get("elephant"));


    }
View Full Code Here


            System.setProperty("logback.configurationFile", "logback-cli.xml");

            String uri = command.getOptionValue("cli");
            Repository repository = JcrUtils.getRepository(uri);

            Context context = new ContextBase();
            CommandHelper.setRepository(context, repository, uri);
            try {
                Session session = repository.login();
                CommandHelper.setSession(context, session);
                CommandHelper.setCurrentNode(context, session.getRootNode());
View Full Code Here

        // Compare to self
        assertTrue(context.equals(context));
        assertTrue(context.hashCode() == context.hashCode());

        // Compare to equivalent instance
        Context other = createContext();
        assertTrue(context.equals(other));
        assertTrue(context.hashCode() == other.hashCode());

        // Compare to non-equivalent instance - other modified
        other.put("bop", "bop value");
        assertTrue(!context.equals(other));
        assertTrue(context.hashCode() != other.hashCode());

        // Compare to non-equivalent instance - self modified
        other = createContext(); // reset to equivalence
        context.put("bop", "bop value");
        assertTrue(!context.equals(other));
        assertTrue(context.hashCode() != other.hashCode());

    }
View Full Code Here

        // Compare to self
        assertTrue(context.equals(context));
        assertTrue(context.hashCode() == context.hashCode());

        // Compare to equivalent instance
        Context other = new ServletWebContext(scontext, request, response);
        // assertTrue(context.equals(other));
        assertTrue(context.hashCode() == other.hashCode());

        // Compare to non-equivalent instance - other modified
        other.put("bop", "bop value");
        // assertTrue(!context.equals(other));
        assertTrue(context.hashCode() != other.hashCode());

        // Compare to non-equivalent instance - self modified
        other = new ServletWebContext(scontext, request, response);
        context.put("bop", "bop value");
        // assertTrue(!context.equals(other));
        assertTrue(context.hashCode() != other.hashCode());

    }       
View Full Code Here

        // Compare to self
        assertTrue(context.equals(context));
        assertTrue(context.hashCode() == context.hashCode());

        // Compare to equivalent instance
        Context other = new PortletWebContext(pcontext, request, response);
        // assertTrue(context.equals(other));
        assertTrue(context.hashCode() == other.hashCode());

        // Compare to non-equivalent instance - other modified
        other.put("bop", "bop value");
        // assertTrue(!context.equals(other));
        assertTrue(context.hashCode() != other.hashCode());

        // Compare to non-equivalent instance - self modified
        other = new PortletWebContext(pcontext, request, response);
        context.put("bop", "bop value");
        // assertTrue(!context.equals(other));
        assertTrue(context.hashCode() != other.hashCode());

    }       
View Full Code Here

    public void testMethodDispatch() throws Exception {
        TestCommand test = new TestCommand();

        test.setMethod("testMethod");
        Context context = new ContextBase();
        assertNull(context.get("foo"));
        boolean result = test.execute(context);
        assertTrue(result);
        assertNotNull(context.get("foo"));
        assertEquals("foo", context.get("foo"));


    }
View Full Code Here

    public void testMethodKeyDispatch() throws Exception {
        TestCommand test = new TestCommand();

        test.setMethodKey("foo");
        Context context = new ContextBase();
        context.put("foo", "testMethodKey");
        assertNull(context.get("bar"));
        boolean result = test.execute(context);
        assertFalse(result);
        assertNotNull(context.get("bar"));
        assertEquals("bar", context.get("bar"));


    }
View Full Code Here

    public void testAlternateContext() throws Exception {
        TestAlternateContextCommand test = new TestAlternateContextCommand();

        test.setMethod("foo");
        Context context = new ContextBase();
        assertNull(context.get("elephant"));
        boolean result = test.execute(context);
        assertTrue(result);
        assertNotNull(context.get("elephant"));
        assertEquals("elephant", context.get("elephant"));


    }
View Full Code Here

                                 HttpServletRequest request,
                                 HttpServletResponse response)
        throws Exception {

        // Set up a context for this request
        Context context = new ServletWebContext
            (getServlet().getServletContext(), request, response);
        context.put("mapping", mapping);
        context.put("form", form);

        // Delegate to the specified command
        String name = mapping.getParameter();
        Command command = getCatalog().getCommand(request.getParameter(name));
        command.execute(context); // Ignore return state

        // Return results as appropriate
        Exception exception = null;
        try {
            exception = (Exception) context.get("exception");
            if (exception != null) {
                throw exception;
            }
        } catch (ClassCastException e) {
            ; // It is not an Exception
        }
        ActionForward forward = null;
        try {
            forward = (ActionForward) context.get("forward");
        } catch (ClassCastException e) {
            forward = null; // It is not an ActionForward
        }
        return forward;
View Full Code Here

                                 HttpServletRequest request,
                                 HttpServletResponse response)
        throws Exception {

        // Set up a context for this request
        Context context = new ServletWebContext
            (getServlet().getServletContext(), request, response);
        context.put("mapping", mapping);
        context.put("form", form);

        // Delegate to the specified command
        Command command = getCatalog().getCommand(mapping.getParameter());
        command.execute(context); // Ignore return state

        // Return results as appropriate
        Exception exception = null;
        try {
            exception = (Exception) context.get("exception");
            if (exception != null) {
                throw exception;
            }
        } catch (ClassCastException e) {
            ; // It is not an Exception
        }
        ActionForward forward = null;
        try {
            forward = (ActionForward) context.get("forward");
        } catch (ClassCastException e) {
            forward = null; // It is not an ActionForward
        }
        return forward;
View Full Code Here

TOP

Related Classes of org.apache.commons.chain.Context

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.