Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NewObject.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NewObject.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NewObject.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NoReference.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NoReference.java?rev=733503&view=auto
==============================================================================
--- 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NoReference.java
 (added)
+++ 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NoReference.java
 Sun Jan 11 11:51:40 2009
@@ -0,0 +1,13 @@
+package org.apache.commons.javaflow.rewrite;
+
+import org.apache.commons.javaflow.Continuation;
+
+
+public final class NoReference implements Runnable {
+
+  public void run() {
+    new Object();
+    Continuation.suspend();
+  }
+
+}
\ No newline at end of file

Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NoReference.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NoReference.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NoReference.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NullVariableMethodFlow.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NullVariableMethodFlow.java?rev=733503&view=auto
==============================================================================
--- 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NullVariableMethodFlow.java
 (added)
+++ 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NullVariableMethodFlow.java
 Sun Jan 11 11:51:40 2009
@@ -0,0 +1,33 @@
+package org.apache.commons.javaflow.rewrite;
+
+import java.util.Properties;
+
+/**
+ * A regression test case for handling null in the local variables.
+ *
+ * @author Kohsuke Kawaguchi
+ */
+public class NullVariableMethodFlow implements Runnable {
+
+    public void run() {
+        getLocalAddress(System.getProperties());
+    }
+
+    public static String getLocalAddress(Properties session) {
+        String x = null, y;
+
+        // when javaflow generates the store/load code around this invocation,
+        // x is of the type 'null'. we have to restore the local variable
+        // in the correct type (in particular not java/lang/Object, but "null")
+        // or otherwise VerifyError occurs.
+        y = session.getProperty("a");
+        if (y == null) {
+            x = session.getProperty("b");
+        }
+
+        if (y == null)
+            y = x;
+
+        return y;
+    }
+}

Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NullVariableMethodFlow.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NullVariableMethodFlow.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NullVariableMethodFlow.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/RewriteBugs.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/RewriteBugs.java?rev=733503&view=auto
==============================================================================
--- 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/RewriteBugs.java
 (added)
+++ 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/RewriteBugs.java
 Sun Jan 11 11:51:40 2009
@@ -0,0 +1,150 @@
+package org.apache.commons.javaflow.rewrite;
+
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+public class RewriteBugs
+{
+
+       /**
+        * 
+        * ASM rewriting BUG!
+        * 
+        *  Calculate the cartesian product of parameters.
+        *  Example: names = {"a", "b"}, values = {{"1", "2"}, {"3", "4"}}
+        *               result = {{"a"="1", "b"="3"}, {"a"="2", "b"="3"}, 
{"a"="1", "b"="4"}, {"a=2", b="4"}}
+        *  @param names The names.
+        *  @param values The values (must be some form of collection, i.e. 
array, list, iterator etc.)
+        */
+       public static List calculateCartesianProduct(String[] names, Object[] 
values)
+       {
+               //ArrayList ret = SCollection.createArrayList();
+               ArrayList ret = new ArrayList();
+               if(names==null || values==null)
+                       return ret;
+               if(names.length!=values.length)
+                       throw new IllegalArgumentException("Must have same 
length: "+names.length+" "+values.length);
+               
+               //HashMap binding = SCollection.createHashMap();
+               HashMap binding = new HashMap();
+               Iterator[] iters = new Iterator[values.length];
+               
+               for(int i=0; i<values.length; i++)
+               {
+                       // When one collection is empty -> no binding at all.
+                       // First binding consists of all first elements.
+                       //iters[i] = SReflect.getIterator(values[i]);
+                       iters[i] = RewriteBugs.getIterator(values[i]);
+                       if(!iters[i].hasNext())
+                       {
+                               return ret;
+                       }
+                       else
+                       {
+                               binding.put(names[i], iters[i].next());
+                       }
+               }
+               ret.add(binding);
+               
+               // Iterate through binding sets for subsequent bindings.
+               while(true)
+               {
+                       // Calculate next binding.
+                       // Copy old binding and change one value.
+                       binding = (HashMap)binding.clone();
+                       int i = 0;
+                       for(; i<values.length && !iters[i].hasNext(); i++)
+                       {
+                               // Overflow: Re-init iterator.
+                               //iters[i] = SReflect.getIterator(values[i]);
+                               iters[i] = RewriteBugs.getIterator(values[i]);
+                               binding.put(names[i], iters[i].next());
+                       }
+                       if(i<iters.length)
+                       {
+                               binding.put(names[i], iters[i].next());
+                       }
+                       else
+                       {
+                               // Overflow in last iterator: done.
+                               // Hack: Unnecessarily re-inits all iterators 
before break ?
+                               break;
+                       }
+                       ret.add(binding);
+               }
+               
+               return ret;
+       }
+       
+       
+       
+       // 
+       // ---- helper methods -- copied from jadex utility classes -----
+       //
+       
+       /**
+        *  Get an iterator for an arbitrary collection object.
+        *  Supports iterators, enumerations, java.util.Collections,
+        *  java.util.Maps, arrays. Null is converted to empty iterator.
+        *  @param collection   The collection object.
+        *  @return An iterator over the collection.
+        *  @throws IllegalArgumentException when argument is not
+        *              one of (Iterator, Enumeration, Collection, Map, Array).
+        */
+       public static Iterator  getIterator(Object collection)
+       {
+               if(collection==null)
+               {
+                       return Collections.EMPTY_LIST.iterator();
+               }
+               else if(collection instanceof Iterator)
+               {
+                       return (Iterator)collection;
+               }
+               else if(collection instanceof Enumeration)
+               {
+                       // Return enumeration wrapper.
+                       final Enumeration eoc   = (Enumeration)collection;
+                       return new Iterator()
+                       {
+                               public boolean  hasNext()       {return 
eoc.hasMoreElements();}
+                               public Object   next()  {return 
eoc.nextElement();}
+                               public void     remove(){throw new 
UnsupportedOperationException(
+                                       "remove() not supported for 
enumerations");}
+                       };
+               }
+               else if(collection instanceof Collection)
+               {
+                       return ((Collection)collection).iterator();
+               }
+               else if(collection instanceof Map)
+               {
+                       return ((Map)collection).values().iterator();
+               }
+               else if(collection!=null && collection.getClass().isArray())
+               {
+                       // Return array wrapper.
+                       final Object array      = collection;
+                       return new Iterator()
+                       {
+                               int i=0;
+                               public boolean  hasNext()       {return 
i<Array.getLength(array);}
+                               public Object   next()  {return 
Array.get(array, i++);}
+                               public void     remove()        {throw new 
UnsupportedOperationException(
+                                       "remove() not supported for arrays");}
+                       };
+               }
+               else
+               {
+                       throw new IllegalArgumentException("Cannot iterate over 
"+collection);
+               }
+       }
+       
+}
\ No newline at end of file

Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/RewriteBugs.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/RewriteBugs.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/RewriteBugs.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/Simple.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/Simple.java?rev=733503&view=auto
==============================================================================
--- 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/Simple.java
 (added)
+++ 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/Simple.java
 Sun Jan 11 11:51:40 2009
@@ -0,0 +1,22 @@
+package org.apache.commons.javaflow.rewrite;
+
+import org.apache.commons.javaflow.Continuation;
+
+public final class Simple implements Runnable {
+
+    public int g = -1; // global count throughout all continuations
+    public int l = -1; // local count mapped to a global variable so
+                       // we can access is
+    
+    public void run() {
+        int local = -1;
+        ++g; l=++local;
+        Continuation.suspend();
+        ++g; l=++local;
+        Continuation.suspend();
+        ++g; l=++local;
+        Continuation.suspend();
+        ++g; l=++local;
+    }
+
+}
\ No newline at end of file

Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/Simple.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/Simple.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/Simple.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/SimpleSerializable.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/SimpleSerializable.java?rev=733503&view=auto
==============================================================================
--- 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/SimpleSerializable.java
 (added)
+++ 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/SimpleSerializable.java
 Sun Jan 11 11:51:40 2009
@@ -0,0 +1,26 @@
+package org.apache.commons.javaflow.rewrite;
+
+import java.io.Serializable;
+import org.apache.commons.javaflow.Continuation;
+
+
+public final class SimpleSerializable implements Runnable, Serializable {
+    private static final long serialVersionUID = 1L;
+    
+    public int g = -1; // global count throughout all continuations
+    public int l = -1; // local count mapped to a global variable so
+                       // we can access is
+    
+    public void run() {
+        int local = -1;
+        ++g; l=++local;
+        Continuation.suspend();
+        ++g; l=++local;
+        Continuation.suspend();
+        ++g; l=++local;
+        Continuation.suspend();
+        ++g; l=++local;
+    }
+
+}
+

Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/SimpleSerializable.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/SimpleSerializable.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/SimpleSerializable.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/SimpleSynchronized.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/SimpleSynchronized.java?rev=733503&view=auto
==============================================================================
--- 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/SimpleSynchronized.java
 (added)
+++ 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/SimpleSynchronized.java
 Sun Jan 11 11:51:40 2009
@@ -0,0 +1,30 @@
+package org.apache.commons.javaflow.rewrite;
+
+import org.apache.commons.javaflow.Continuation;
+
+public final class SimpleSynchronized implements Runnable {
+
+       public boolean a = false;
+       public boolean b = false;
+       public boolean c = false;
+       public boolean d = false;
+       public boolean e = false;
+       public boolean f = false;
+
+       private Object o = new Object();
+       
+       public void run() {             
+               a = true;
+               Continuation.suspend();
+               b = true;
+               synchronized(o) {
+                       c = true;
+                       Continuation.suspend();
+                       d = true;
+               }
+               e = true;
+               Continuation.suspend();
+               f = true;               
+    }
+
+}
\ No newline at end of file

Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/SimpleSynchronized.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/SimpleSynchronized.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/SimpleSynchronized.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/SimpleTryCatch.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/SimpleTryCatch.java?rev=733503&view=auto
==============================================================================
--- 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/SimpleTryCatch.java
 (added)
+++ 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/SimpleTryCatch.java
 Sun Jan 11 11:51:40 2009
@@ -0,0 +1,39 @@
+package org.apache.commons.javaflow.rewrite;
+
+import org.apache.commons.javaflow.Continuation;
+
+public final class SimpleTryCatch implements Runnable {
+
+       public boolean a = false;
+       public boolean b = false;
+       public boolean c = false;
+       public boolean d = false;
+       public boolean e = false;
+       public boolean f = false;
+
+       private final boolean throwException;
+       
+       public SimpleTryCatch(final boolean pThrowException) {
+               throwException = pThrowException;
+       }
+       
+       public void run() {
+       try {
+               a = true;
+               Continuation.suspend();
+               if (throwException) {
+                       throw new Exception("exception");
+               }
+               b = true;
+       } catch(Exception e) {
+               c = true;
+               Continuation.suspend();
+               d = true;
+       } finally {
+               e = true;
+               Continuation.suspend();
+               f = true;
+       }       
+    }
+
+}
\ No newline at end of file

Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/SimpleTryCatch.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/SimpleTryCatch.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/SimpleTryCatch.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/Stack.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/Stack.java?rev=733503&view=auto
==============================================================================
--- 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/Stack.java
 (added)
+++ 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/Stack.java
 Sun Jan 11 11:51:40 2009
@@ -0,0 +1,35 @@
+package org.apache.commons.javaflow.rewrite;
+
+/**
+ * Regression test case.
+ *
+ * <p>
+ * When the stack size reaches the maximum in a constructor method invocation,
+ * there was a bug where we failed to expand the stack size appropriately.
+ *
+ * This is a regression test for that case.
+ *
+ *
+ * @author Kohsuke Kawaguchi
+ */
+public final class Stack implements Runnable {
+    public void run() {
+        final Object o = foo("abc","def");
+    }
+
+    private Object foo(String a, String b) {
+        return new StrStr(a,b);
+    }
+
+    private static final class StrStr {
+        private final String value;
+
+        public StrStr(String a, String b) {
+            value = a+b;
+        }
+
+        public String toString() {
+            return value;
+        }
+    }
+}

Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/Stack.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/Stack.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/Stack.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/suite/SerializationTestCase.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/suite/SerializationTestCase.java?rev=733503&view=auto
==============================================================================
--- 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/suite/SerializationTestCase.java
 (added)
+++ 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/suite/SerializationTestCase.java
 Sun Jan 11 11:51:40 2009
@@ -0,0 +1,128 @@
+package org.apache.commons.javaflow.suite;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamClass;
+import java.lang.reflect.Proxy;
+
+import junit.framework.TestCase;
+import junitx.util.PrivateAccessor;
+
+import org.apache.commons.javaflow.Continuation;
+import org.apache.commons.javaflow.bytecode.StackRecorder;
+import org.apache.commons.javaflow.rewrite.Invoker;
+import org.apache.commons.javaflow.rewrite.Simple;
+import org.apache.commons.javaflow.rewrite.SimpleSerializable;
+
+public class SerializationTestCase extends TestCase {
+
+    private File output;
+
+
+    public void testSuspend() throws Exception {
+        final SimpleSerializable r = new SimpleSerializable();
+        assertTrue(r.g == -1);
+        assertTrue(r.l == -1);
+        Continuation c1 = Continuation.startWith(r);
+        assertTrue(r.g == 0);
+        assertTrue(r.l == 0);
+        
+        output = File.createTempFile("continuation", "xml");
+        output.deleteOnExit();
+
+        saveJDK(c1, output);
+        
+    }
+
+    public class ObjectInputStreamExt extends ObjectInputStream {
+
+        private ClassLoader classloader;
+
+        public ObjectInputStreamExt(InputStream in, ClassLoader loader) throws 
IOException {
+            super(in);
+            this.classloader = loader;
+        }
+
+        protected Class resolveClass(ObjectStreamClass classDesc) throws 
IOException, ClassNotFoundException {
+
+               return Class.forName(classDesc.getName(), true, classloader);
+        }
+
+        protected Class resolveProxyClass(String[] interfaces) throws 
IOException, ClassNotFoundException {
+            Class[] cinterfaces = new Class[interfaces.length];
+            for (int i = 0; i < interfaces.length; i++) {
+               cinterfaces[i] = Class.forName(interfaces[i], true, 
classloader);
+            }
+            
+            try {
+                return Proxy.getProxyClass(classloader, cinterfaces);
+            } catch (IllegalArgumentException e) {
+                throw new ClassNotFoundException(null, e);
+            }
+        }
+    }
+    
+    
+    private void saveJDK(final Object c1, final File output) throws 
IOException {
+       final ObjectOutputStream oos = new ObjectOutputStream(new 
FileOutputStream(output));            
+       oos.writeObject(c1); 
+       oos.close(); 
+    }
+
+    private Object loadJDK(final File input) throws IOException, 
ClassNotFoundException {
+       final ObjectInputStream ois = new ObjectInputStreamExt(new 
FileInputStream(input), this.getClass().getClassLoader());
+       final Object o = ois.readObject();
+       ois.close();
+       return o;
+    }
+    
+    public void testResume() throws Exception {
+        testSuspend();
+        assertTrue("suspend must succeed to create the output first", output 
!= null);
+
+        assertEquals(output.length(), 562);
+        
+        final Object o = loadJDK(output);
+        
+        assertTrue(o instanceof Continuation);
+        final Continuation c1 = (Continuation) o;
+        final StackRecorder sr1 = (StackRecorder) 
PrivateAccessor.getField(c1,"stackRecorder");
+        final Runnable r1 = (Runnable) PrivateAccessor.getField(sr1, 
"runnable");
+        assertEquals(SimpleSerializable.class.getName(), 
r1.getClass().getName());
+        
+        final SimpleSerializable ss1 = (SimpleSerializable)r1;
+        assertTrue(ss1.g == 0);
+        assertTrue(ss1.l == 0);
+        final Continuation c2 = Continuation.continueWith(c1);
+        final StackRecorder sr2 = (StackRecorder) 
PrivateAccessor.getField(c2,"stackRecorder");
+        final Runnable r2 = (Runnable) PrivateAccessor.getField(sr2, 
"runnable");
+        assertEquals(SimpleSerializable.class.getName(), 
r2.getClass().getName());
+        final SimpleSerializable ss2 = (SimpleSerializable)r2;
+        assertTrue(ss2.g == 1);
+        assertTrue(ss2.l == 1);
+        assertTrue(r1 == r2);
+    }
+
+
+    public void testSerializableCheck() throws Exception {
+        final Runnable r1 = new Simple();
+        Continuation c1 = Continuation.startWith(r1);
+        assertTrue(c1 != null);
+        assertTrue(!c1.isSerializable());
+
+        final Runnable r2 = new SimpleSerializable();
+        Continuation c2 = Continuation.startWith(r2);
+        assertTrue(c2 != null);
+        assertTrue(c2.isSerializable());
+
+        final Runnable r3 = new SimpleSerializable();
+        Continuation c3 = Continuation.startWith(new Invoker(r3));
+        assertTrue(c3 != null);
+        assertTrue(c3.isSerializable());
+    }
+}

Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/suite/SerializationTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/suite/SerializationTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/suite/SerializationTestCase.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/suite/VerificationTestCase.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/suite/VerificationTestCase.java?rev=733503&view=auto
==============================================================================
--- 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/suite/VerificationTestCase.java
 (added)
+++ 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/suite/VerificationTestCase.java
 Sun Jan 11 11:51:40 2009
@@ -0,0 +1,251 @@
+package org.apache.commons.javaflow.suite;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.javaflow.Continuation;
+import org.apache.commons.javaflow.rewrite.BlackRed;
+import org.apache.commons.javaflow.rewrite.ClassAccess1;
+import org.apache.commons.javaflow.rewrite.ClassAccess2;
+import org.apache.commons.javaflow.rewrite.CounterFlow;
+import org.apache.commons.javaflow.rewrite.DefaultConstructor;
+import org.apache.commons.javaflow.rewrite.Invoker;
+import org.apache.commons.javaflow.rewrite.NewObject;
+import org.apache.commons.javaflow.rewrite.NoReference;
+import org.apache.commons.javaflow.rewrite.RewriteBugs;
+import org.apache.commons.javaflow.rewrite.Simple;
+import org.apache.commons.javaflow.rewrite.SimpleSerializable;
+import org.apache.commons.javaflow.rewrite.SimpleSynchronized;
+import org.apache.commons.javaflow.rewrite.SimpleTryCatch;
+import org.apache.commons.javaflow.rewrite.Stack;
+
+public class VerificationTestCase extends TestCase {
+
+    public void testBlackRed2() {
+        final Runnable r = new BlackRed();
+        final Continuation c1 = Continuation.startWith(r);
+        assertTrue(c1 != null);
+        final Continuation c2 = Continuation.continueWith(c1);
+        assertTrue(c2 == null);
+    }
+
+    public void testClassAccess1() throws Exception {
+        final ClassAccess1 r = new ClassAccess1();
+        final Continuation c = Continuation.startWith(r);
+        assertTrue(c != null);
+    }
+    
+    public void testClassAccess2() throws Exception {
+        final ClassAccess2 r = new ClassAccess2();
+        final Continuation c = Continuation.startWith(r);
+        assertTrue(c != null);
+    }
+
+    public void testCounter() {
+        final int count = 5;
+        final Runnable r = new CounterFlow(count);
+        int i = 0;
+        Continuation c = Continuation.startWith(r);
+        while (c != null) {
+            c = Continuation.continueWith(c);
+            i++;
+        }
+        assertTrue(i == count);
+    }
+
+    public void testInvoker() {
+        Runnable o = new DefaultConstructor();
+        Continuation c = Continuation.startWith(o);
+        assertTrue(c == null);
+    }
+
+    public void testInvoker2() {
+        final Runnable r = new Simple();
+        final Runnable o = new Invoker(r);
+        final Continuation c = Continuation.startWith(o);
+        assertNotNull(c);
+    }
+
+    public void testNewObject() throws Exception {
+        final Runnable r = new NewObject();
+        final Continuation c = Continuation.startWith(r);
+        assertTrue(c == null);
+    }
+
+    public void testNoReference() throws Exception {
+        final Runnable r = new NoReference();
+        final Continuation c = Continuation.startWith(r);
+        assertTrue(c != null);
+    }
+    public void testSimpleSuspendResume() throws Exception {
+        final SimpleSerializable r = new SimpleSerializable();
+        assertTrue(r.g == -1);
+        assertTrue(r.l == -1);
+        Continuation c1 = Continuation.startWith(r);
+        assertNotNull(c1);
+        assertTrue(r.g == 0);
+        assertTrue(r.l == 0);
+        Continuation c2 = Continuation.continueWith(c1);
+        assertNotNull(c2);
+        assertTrue(r.g == 1);
+        assertTrue(r.l == 1);
+        Continuation c3 = Continuation.continueWith(c2);
+        assertNotNull(c3);
+        assertTrue(r.g == 2);
+        assertTrue(r.l == 2);
+    }
+
+
+    public void testContinuationBranching() throws Exception {
+        final SimpleSerializable r = new SimpleSerializable();
+        assertTrue(r.g == -1);
+        assertTrue(r.l == -1);
+        Continuation c1 = Continuation.startWith(r);
+        assertNotNull(c1);
+        assertTrue(r.g == 0);
+        assertTrue(r.l == 0);
+        Continuation c2 = Continuation.continueWith(c1);
+        assertNotNull(c2);
+        assertTrue(r.g == 1);
+        assertTrue(r.l == 1);
+        Continuation c31 = Continuation.continueWith(c2);
+        assertNotNull(c31);
+        assertTrue(r.g == 2);
+        assertTrue(r.l == 2);
+        Continuation c32 = Continuation.continueWith(c2);
+        assertNotNull(c32);
+        assertTrue(r.g == 3);
+        assertTrue(r.l == 2);
+    }
+
+    public void testASMRewriteBug() throws Exception {
+        //final RewriteBugs r = new RewriteBugs();
+        RewriteBugs.calculateCartesianProduct(new String[]{"a","b"}, new 
Object[]{"1","2"});
+    }
+    public void testSimpleSuspend() throws Exception {
+        final Simple r = new Simple();
+        final Continuation c = Continuation.startWith(r);
+        assertTrue(c != null);
+    }
+
+    public void testSimpleTryCatchWithoutException() throws Exception {
+        final SimpleTryCatch r = new SimpleTryCatch(false);
+        Continuation c;
+
+        c = Continuation.startWith(r);
+        assertTrue(c != null);
+        assertTrue(r.a);
+        assertFalse(r.b);
+        assertFalse(r.c);
+        assertFalse(r.d);
+        assertFalse(r.e);
+        assertFalse(r.f);
+
+        c = Continuation.continueWith(c);
+        assertTrue(c == null);
+        assertTrue(r.a);
+        assertTrue(r.b);
+        assertFalse(r.c);
+        assertFalse(r.d);
+        assertTrue(r.e);
+        assertFalse(r.f);
+
+        c = Continuation.continueWith(c);
+        assertTrue(c != null);
+        assertTrue(r.a);
+        assertFalse(r.b);
+        assertTrue(r.c);
+        assertTrue(r.d);
+        assertTrue(r.e);
+        assertFalse(r.f);    
+
+
+        c = Continuation.continueWith(c);
+        assertTrue(c == null);
+        assertTrue(r.a);
+        assertFalse(r.b);
+        assertTrue(r.c);
+        assertTrue(r.d);
+        assertTrue(r.e);
+        assertTrue(r.f);    
+    }
+
+    public void testSimpleTryCatchWithException() throws Exception {
+        final SimpleTryCatch r = new SimpleTryCatch(true);
+        Continuation c;
+
+        c = Continuation.startWith(r);
+        assertTrue(c != null);
+        assertTrue(r.a);
+        assertFalse(r.b);
+        assertFalse(r.c);
+        assertFalse(r.d);
+        assertFalse(r.e);
+        assertFalse(r.f);
+
+        c = Continuation.continueWith(c);
+        assertTrue(c != null);
+        assertTrue(r.a);
+        assertFalse(r.b);
+        assertTrue(r.c);
+        assertFalse(r.d);
+        assertFalse(r.e);
+        assertFalse(r.f);
+
+        c = Continuation.continueWith(c);
+        assertTrue(c != null);
+        assertTrue(r.a);
+        assertTrue(r.b);
+        assertFalse(r.c);
+        assertFalse(r.d);
+        assertTrue(r.e);
+        assertTrue(r.f);    
+    }
+
+    public void testSimpleSynchronized() throws Exception {
+        final SimpleSynchronized r = new SimpleSynchronized();
+        Continuation c;
+
+        c = Continuation.startWith(r);
+        assertTrue(c != null);
+        assertTrue(r.a);
+        assertFalse(r.b);
+        assertFalse(r.c);
+        assertFalse(r.d);
+        assertFalse(r.e);
+        assertFalse(r.f);
+
+        c = Continuation.continueWith(c);
+        assertTrue(c == null);
+        assertTrue(r.a);
+        assertTrue(r.b);
+        assertTrue(r.c);
+        assertFalse(r.d);
+        assertFalse(r.e);
+        assertFalse(r.f);
+
+        c = Continuation.continueWith(c);
+        assertTrue(c != null);
+        assertTrue(r.a);
+        assertTrue(r.b);
+        assertTrue(r.c);
+        assertTrue(r.d);
+        assertTrue(r.e);
+        assertFalse(r.f);
+
+        c = Continuation.continueWith(c);
+        assertTrue(c != null);
+        assertTrue(r.a);
+        assertTrue(r.b);
+        assertTrue(r.c);
+        assertTrue(r.d);
+        assertTrue(r.e);
+        assertTrue(r.f);
+    }
+
+    public void testStack() throws Exception {
+        final Runnable r = new Stack();
+        final Continuation c = Continuation.startWith(r);
+        assertNotNull(c);
+    }
+
+}

Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/suite/VerificationTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/suite/VerificationTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: 
commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/suite/VerificationTestCase.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain


Reply via email to