Package org.agilewiki.jactor.iteratorTest

Source Code of org.agilewiki.jactor.iteratorTest.SimpleFactorialTest

package org.agilewiki.jactor.iteratorTest;

import junit.framework.TestCase;
import org.agilewiki.jactor.JAIterator;
import org.agilewiki.jactor.RP;

/**
* Test code.
*/
public class SimpleFactorialTest extends TestCase {
    public void testFactorial() throws Exception {
        final int max = 5;
        RP printResult = new RP() {
            public void processResponse(Object rsp) {
                System.out.println(rsp);
            }
        };

        (new JAIterator() {
            int i;
            int r = 1;

            public void process(RP rp) throws Exception {
                if (i >= max) rp.processResponse(new Integer(r));
                else {
                    i += 1;
                    r = r * i;
                    rp.processResponse(null);
                }
            }
        }).iterate(printResult);
    }
}
TOP

Related Classes of org.agilewiki.jactor.iteratorTest.SimpleFactorialTest

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.