Package org.apache.cocoon.components.flow.java

Examples of org.apache.cocoon.components.flow.java.Continuation


    }

    public static void testSimpleContinuable() throws Exception {
        ContinuationClassLoader cl = new ContinuationClassLoader(Thread
                .currentThread().getContextClassLoader());
        Continuation continuation = new Continuation(null);
        continuation.registerThread();
        Class clazz = cl.loadClass("org.apache.cocoon.components.flow.java.test.SimpleContinuable");
        Object object = clazz.newInstance();
        clazz.getMethod("suspend", null).invoke(object, null);
        if (continuation.isCapturing())
            continuation.getStack().popReference();
        continuation = new Continuation(continuation, null);
        continuation.registerThread();
        clazz.getMethod("suspend", null).invoke(object, null);
    }
View Full Code Here


    }

    public static void testWrapperContinuable() throws Exception {
        ContinuationClassLoader cl = new ContinuationClassLoader(Thread
                .currentThread().getContextClassLoader());
        Continuation continuation = new Continuation(null);
        continuation.registerThread();
        Class clazz = cl.loadClass("org.apache.cocoon.components.flow.java.test.WrapperContinuable");
        Object object = clazz.newInstance();
        clazz.getMethod("test", null).invoke(object, null);
        if (continuation.isCapturing())
            continuation.getStack().popReference();
        continuation = new Continuation(continuation, null);
        continuation.registerThread();
        clazz.getMethod("test", null).invoke(object, null);
    }
View Full Code Here

    }

    public static void testExtendedContinuable() throws Exception {
        ContinuationClassLoader cl = new ContinuationClassLoader(Thread
                .currentThread().getContextClassLoader());
        Continuation continuation = new Continuation(null);
        continuation.registerThread();
        Class clazz = cl.loadClass("org.apache.cocoon.components.flow.java.test.ExtendedContinuable");
        Object object = clazz.newInstance();
        clazz.getMethod("test", null).invoke(object, null);
        if (continuation.isCapturing())
            continuation.getStack().popReference();
        continuation = new Continuation(continuation, null);
        continuation.registerThread();
        clazz.getMethod("test", null).invoke(object, null);
    }
View Full Code Here

    }

    public static void testSimpleContinuable() throws Exception {
        ContinuationClassLoader cl = new ContinuationClassLoader(Thread
                .currentThread().getContextClassLoader());
        Continuation continuation = new Continuation("suspend", null);
        continuation.registerThread();
        Class clazz = cl.loadClass("org.apache.cocoon.components.flow.java.test.SimpleContinuable");
        Object object = clazz.newInstance();
        clazz.getMethod("suspend", null).invoke(object, null);
        if (continuation.isCapturing())
            continuation.getStack().popReference();
        continuation = new Continuation(continuation, null);
        continuation.registerThread();
        clazz.getMethod("suspend", null).invoke(object, null);
    }
View Full Code Here

    }

    public static void testWrapperContinuable() throws Exception {
        ContinuationClassLoader cl = new ContinuationClassLoader(Thread
                .currentThread().getContextClassLoader());
        Continuation continuation = new Continuation("test", null);
        continuation.registerThread();
        Class clazz = cl.loadClass("org.apache.cocoon.components.flow.java.test.WrapperContinuable");
        Object object = clazz.newInstance();
        clazz.getMethod("test", null).invoke(object, null);
        if (continuation.isCapturing())
            continuation.getStack().popReference();
        continuation = new Continuation(continuation, null);
        continuation.registerThread();
        clazz.getMethod("test", null).invoke(object, null);
    }
View Full Code Here

    }

    public static void testExtendedContinuable() throws Exception {
        ContinuationClassLoader cl = new ContinuationClassLoader(Thread
                .currentThread().getContextClassLoader());
        Continuation continuation = new Continuation("test", null);
        continuation.registerThread();
        Class clazz = cl.loadClass("org.apache.cocoon.components.flow.java.test.ExtendedContinuable");
        Object object = clazz.newInstance();
        clazz.getMethod("test", null).invoke(object, null);
        if (continuation.isCapturing())
            continuation.getStack().popReference();
        continuation = new Continuation(continuation, null);
        continuation.registerThread();
        clazz.getMethod("test", null).invoke(object, null);
    }
View Full Code Here

        Class clazz = loader.loadClass("org.apache.cocoon.components.flow.java.test.SimpleFlow");
        Continuable flow = (Continuable) clazz.newInstance();

        Method method = clazz.getMethod("run", new Class[0]);

        Continuation c = new Continuation(method.getName(), context);
        assertTrue(!c.isRestoring());
        assertTrue(!c.isCapturing());

        System.out.println("*** start flow");
        c.registerThread();
        method.invoke(flow, new Object[0]);
        if (c.isCapturing())
            c.getStack().popReference();
        c.deregisterThread();
        System.out.println("*** return from flow");

        assertTrue(!c.isRestoring());
        assertTrue(c.isCapturing());

        //System.out.println("request=" + request);
        request.addParameter("a", "2.3");
        redirector.reset();
        c = new Continuation(c, context);

        assertTrue(c.isRestoring());
        assertTrue(!c.isCapturing());

        System.out.println("*** resume flow");
        c.registerThread();
        method.invoke(flow, new Object[0]);
        if (c.isCapturing())
            c.getStack().popReference();
        c.deregisterThread();
        System.out.println("*** return from flow");

        assertTrue(!c.isRestoring());
        assertTrue(!c.isCapturing());

        VarMap map = (VarMap)FlowHelper.getContextObject(objectmodel);
       
        assertEquals(((Float)map.getMap().get("result")).floatValue(), 3.3f, 0.1f);

View Full Code Here

        Class clazz = loader.loadClass("org.apache.cocoon.components.flow.java.test.SimpleFlow");
        Continuable flow = (Continuable) clazz.newInstance();

        Method method = clazz.getMethod("testCatch", new Class[0]);

        Continuation c = new Continuation(method.getName(), context);
        assertTrue(!c.isRestoring());
        assertTrue(!c.isCapturing());

        System.out.println("*** start flow");
        c.registerThread();
        method.invoke(flow, new Object[0]);
        if (c.isCapturing())
            c.getStack().popReference();
        c.deregisterThread();
        System.out.println("*** return from flow");

        assertTrue(!c.isRestoring());
        assertTrue(c.isCapturing());

        assertEquals(redirector.getRedirect(), "cocoon:/getNumberA");

        request.addParameter("a", "bla");
        redirector.reset();
        c = new Continuation(c, context);

        assertTrue(c.isRestoring());
        assertTrue(!c.isCapturing());

        System.out.println("*** resume flow");
        c.registerThread();
        method.invoke(flow, new Object[0]);
        if (c.isCapturing())
            c.getStack().popReference();
        c.deregisterThread();
        System.out.println("*** return from flow");

        assertTrue(!c.isRestoring());
        assertTrue(c.isCapturing());

        assertEquals(redirector.getRedirect(), "cocoon:/error");

        redirector.reset();
        c = new Continuation(c, context);

        assertTrue(c.isRestoring());
        assertTrue(!c.isCapturing());

        System.out.println("*** resume flow");
        c.registerThread();
        method.invoke(flow, new Object[0]);
        if (c.isCapturing())
            c.getStack().popReference();
        c.deregisterThread();
        System.out.println("*** return from flow");

        assertTrue(!c.isRestoring());
        assertTrue(!c.isCapturing());

        assertEquals(redirector.getRedirect(), "cocoon:/result");
    }
View Full Code Here

        Class clazz = loader.loadClass("org.apache.cocoon.components.flow.java.test.SimpleFlow");
        Continuable flow = (Continuable) clazz.newInstance();

        Method method = clazz.getMethod("testAbstract", new Class[0]);

        Continuation c = new Continuation(method.getName(), context);
        assertTrue(!c.isRestoring());
        assertTrue(!c.isCapturing());

        System.out.println("*** start flow");
        c.registerThread();
        method.invoke(flow, new Object[0]);
        if (c.isCapturing())
            c.getStack().popReference();
        c.deregisterThread();
        System.out.println("*** return from flow");

        assertTrue(!c.isRestoring());
        assertTrue(c.isCapturing());

        assertEquals(redirector.getRedirect(), "cocoon:/parent");
    }
View Full Code Here

        Class clazz = loader.loadClass("org.apache.cocoon.components.flow.java.test.SimpleFlow");
        Continuable flow = (Continuable) clazz.newInstance();

        Method method = clazz.getMethod("testDelegate", new Class[0]);

        Continuation c = new Continuation(method.getName(), context);
        assertTrue(!c.isRestoring());
        assertTrue(!c.isCapturing());

        System.out.println("*** start flow");
        c.registerThread();
        method.invoke(flow, new Object[0]);
        if (c.isCapturing())
            c.getStack().popReference();
        c.deregisterThread();
        System.out.println("*** return from flow");
        System.out.println();

        assertTrue(!c.isRestoring());
        assertTrue(c.isCapturing());

        assertEquals(redirector.getRedirect(), "cocoon:/page/getNumberA");

        request.addParameter("a", "2");
        redirector.reset();
        c = new Continuation(c, context);

        assertTrue(c.isRestoring());
        assertTrue(!c.isCapturing());

        System.out.println();
        System.out.println("*** resume flow");
        c.registerThread();
        method.invoke(flow, new Object[0]);
        if (c.isCapturing())
            c.getStack().popReference();
        c.deregisterThread();
        System.out.println("*** return from flow");
        System.out.println();

        assertTrue(!c.isRestoring());
        assertTrue(c.isCapturing());

        assertEquals(redirector.getRedirect(), "cocoon:/page/getNumberB");

        request.addParameter("b", "2");
        redirector.reset();
        c = new Continuation(c, context);

        assertTrue(c.isRestoring());
        assertTrue(!c.isCapturing());

        System.out.println();
        System.out.println("*** resume flow");
        c.registerThread();
        method.invoke(flow, new Object[0]);
        if (c.isCapturing())
            c.getStack().popReference();
        c.deregisterThread();
        System.out.println("*** return from flow");
        System.out.println();

        assertTrue(!c.isRestoring());
        assertTrue(c.isCapturing());

        assertEquals(redirector.getRedirect(), "cocoon:/page/getOperator");
       
        request.addParameter("operator", "plus");
        redirector.reset();
        c = new Continuation(c, context);

        assertTrue(c.isRestoring());
        assertTrue(!c.isCapturing());

        System.out.println();
        System.out.println("*** resume flow");
        c.registerThread();
        method.invoke(flow, new Object[0]);
        if (c.isCapturing())
            c.getStack().popReference();
        c.deregisterThread();
        System.out.println("*** return from flow");
        System.out.println();

        assertTrue(!c.isRestoring());
        assertTrue(!c.isCapturing());

        assertEquals(redirector.getRedirect(), "cocoon:/page/displayResult");
    }
View Full Code Here

TOP

Related Classes of org.apache.cocoon.components.flow.java.Continuation

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.