commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tcu...@apache.org
Subject svn commit: r411779 [2/2] - in /jakarta/commons/sandbox/javaflow/trunk: ./ src/java/org/apache/commons/javaflow/bytecode/ src/java/org/apache/commons/javaflow/bytecode/transformation/asm/ src/test/org/apache/commons/javaflow/bytecode/transformation/ sr...
Date Mon, 05 Jun 2006 13:08:22 GMT
Added: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/rewrite/SimpleSerializable.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/rewrite/SimpleSerializable.java?rev=411779&view=auto
==============================================================================
--- jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/rewrite/SimpleSerializable.java
(added)
+++ jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/rewrite/SimpleSerializable.java
Mon Jun  5 06:08:19 2006
@@ -0,0 +1,26 @@
+package org.apache.commons.javaflow.bytecode.transformation.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: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/rewrite/SimpleSerializable.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/rewrite/Stack.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/rewrite/Stack.java?rev=411779&view=auto
==============================================================================
--- jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/rewrite/Stack.java
(added)
+++ jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/rewrite/Stack.java
Mon Jun  5 06:08:19 2006
@@ -0,0 +1,35 @@
+package org.apache.commons.javaflow.bytecode.transformation.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: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/rewrite/Stack.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractBlackRedTestCase.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractBlackRedTestCase.java?rev=411779&view=auto
==============================================================================
--- jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractBlackRedTestCase.java
(added)
+++ jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractBlackRedTestCase.java
Mon Jun  5 06:08:19 2006
@@ -0,0 +1,16 @@
+package org.apache.commons.javaflow.bytecode.transformation.tests;
+
+import org.apache.commons.javaflow.Continuation;
+import org.apache.commons.javaflow.bytecode.transformation.AbstractTransformerTestCase;
+import org.apache.commons.javaflow.bytecode.transformation.rewrite.BlackRed;
+
+public abstract class AbstractBlackRedTestCase extends AbstractTransformerTestCase {
+
+    public void testBlackRed() {
+        final Runnable r = new BlackRed();
+        final Continuation c1 = Continuation.startWith(r);
+        assertTrue(c1 != null);
+        final Continuation c2 = Continuation.continueWith(c1);
+        assertTrue(c2 == null);
+    }
+}

Propchange: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractBlackRedTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractBlackRedTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractClassAccessTestCase.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractClassAccessTestCase.java?rev=411779&view=auto
==============================================================================
--- jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractClassAccessTestCase.java
(added)
+++ jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractClassAccessTestCase.java
Mon Jun  5 06:08:19 2006
@@ -0,0 +1,21 @@
+package org.apache.commons.javaflow.bytecode.transformation.tests;
+
+import org.apache.commons.javaflow.Continuation;
+import org.apache.commons.javaflow.bytecode.transformation.AbstractTransformerTestCase;
+import org.apache.commons.javaflow.bytecode.transformation.rewrite.ClassAccess1;
+import org.apache.commons.javaflow.bytecode.transformation.rewrite.ClassAccess2;
+
+public abstract class AbstractClassAccessTestCase extends AbstractTransformerTestCase {
+
+    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);
+    }
+}

Propchange: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractClassAccessTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractClassAccessTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractCounterTestCase.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractCounterTestCase.java?rev=411779&view=auto
==============================================================================
--- jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractCounterTestCase.java
(added)
+++ jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractCounterTestCase.java
Mon Jun  5 06:08:19 2006
@@ -0,0 +1,20 @@
+package org.apache.commons.javaflow.bytecode.transformation.tests;
+
+import org.apache.commons.javaflow.Continuation;
+import org.apache.commons.javaflow.bytecode.transformation.AbstractTransformerTestCase;
+import org.apache.commons.javaflow.bytecode.transformation.rewrite.CounterFlow;
+
+public abstract class AbstractCounterTestCase extends AbstractTransformerTestCase {
+
+    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);
+    }
+}

Propchange: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractCounterTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractCounterTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractDefaultConstructorTestCase.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractDefaultConstructorTestCase.java?rev=411779&view=auto
==============================================================================
--- jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractDefaultConstructorTestCase.java
(added)
+++ jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractDefaultConstructorTestCase.java
Mon Jun  5 06:08:19 2006
@@ -0,0 +1,14 @@
+package org.apache.commons.javaflow.bytecode.transformation.tests;
+
+import junit.framework.TestCase;
+import org.apache.commons.javaflow.Continuation;
+import org.apache.commons.javaflow.bytecode.transformation.rewrite.DefaultConstructor;
+
+public abstract class AbstractDefaultConstructorTestCase extends TestCase {
+
+    public void testInvoker() {
+        Runnable o = new DefaultConstructor();
+        Continuation c = Continuation.startWith(o);
+        assertTrue(c == null);
+    }
+}

Propchange: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractDefaultConstructorTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractDefaultConstructorTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractInvokerTestCase.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractInvokerTestCase.java?rev=411779&view=auto
==============================================================================
--- jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractInvokerTestCase.java
(added)
+++ jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractInvokerTestCase.java
Mon Jun  5 06:08:19 2006
@@ -0,0 +1,15 @@
+package org.apache.commons.javaflow.bytecode.transformation.tests;
+
+import org.apache.commons.javaflow.Continuation;
+import org.apache.commons.javaflow.bytecode.transformation.AbstractTransformerTestCase;
+import org.apache.commons.javaflow.bytecode.transformation.Invoker;
+
+public abstract class AbstractInvokerTestCase extends AbstractTransformerTestCase {
+
+    public void testInvoker() {
+        Runnable r = new Thread();
+        Runnable o = new Invoker(r);
+        Continuation c = Continuation.startWith(o);
+        assertTrue(c != null);
+    }
+}

Propchange: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractInvokerTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractInvokerTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractNewObjectTestCase.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractNewObjectTestCase.java?rev=411779&view=auto
==============================================================================
--- jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractNewObjectTestCase.java
(added)
+++ jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractNewObjectTestCase.java
Mon Jun  5 06:08:19 2006
@@ -0,0 +1,14 @@
+package org.apache.commons.javaflow.bytecode.transformation.tests;
+
+import org.apache.commons.javaflow.Continuation;
+import org.apache.commons.javaflow.bytecode.transformation.AbstractTransformerTestCase;
+import org.apache.commons.javaflow.bytecode.transformation.rewrite.NewObject;
+
+public abstract class AbstractNewObjectTestCase extends AbstractTransformerTestCase {
+
+    public void testNewObject() throws Exception {
+        final Runnable r = new NewObject();
+        final Continuation c = Continuation.startWith(r);
+        assertTrue(c == null);
+    }
+}

Propchange: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractNewObjectTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractNewObjectTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractNoReferenceTestCase.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractNoReferenceTestCase.java?rev=411779&view=auto
==============================================================================
--- jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractNoReferenceTestCase.java
(added)
+++ jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractNoReferenceTestCase.java
Mon Jun  5 06:08:19 2006
@@ -0,0 +1,14 @@
+package org.apache.commons.javaflow.bytecode.transformation.tests;
+
+import org.apache.commons.javaflow.Continuation;
+import org.apache.commons.javaflow.bytecode.transformation.AbstractTransformerTestCase;
+import org.apache.commons.javaflow.bytecode.transformation.rewrite.NoReference;
+
+public abstract class AbstractNoReferenceTestCase extends AbstractTransformerTestCase {
+
+    public void testNoReference() throws Exception {
+        final Runnable r = new NoReference();
+        final Continuation c = Continuation.startWith(r);
+        assertTrue(c != null);
+    }
+}

Propchange: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractNoReferenceTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractNoReferenceTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractResumeTestCase.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractResumeTestCase.java?rev=411779&view=auto
==============================================================================
--- jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractResumeTestCase.java
(added)
+++ jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractResumeTestCase.java
Mon Jun  5 06:08:19 2006
@@ -0,0 +1,49 @@
+package org.apache.commons.javaflow.bytecode.transformation.tests;
+
+import org.apache.commons.javaflow.Continuation;
+import org.apache.commons.javaflow.bytecode.transformation.AbstractTransformerTestCase;
+import org.apache.commons.javaflow.bytecode.transformation.rewrite.SimpleSerializable;
+
+public abstract class AbstractResumeTestCase extends AbstractTransformerTestCase {
+
+    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);
+    }
+}

Propchange: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractResumeTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractResumeTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractSerializationTestCase.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractSerializationTestCase.java?rev=411779&view=auto
==============================================================================
--- jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractSerializationTestCase.java
(added)
+++ jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractSerializationTestCase.java
Mon Jun  5 06:08:19 2006
@@ -0,0 +1,147 @@
+package org.apache.commons.javaflow.bytecode.transformation.tests;
+
+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 junitx.util.PrivateAccessor;
+
+import org.apache.commons.javaflow.Continuation;
+import org.apache.commons.javaflow.bytecode.StackRecorder;
+import org.apache.commons.javaflow.bytecode.transformation.AbstractTransformerTestCase;
+import org.apache.commons.javaflow.bytecode.transformation.Invoker;
+import org.apache.commons.javaflow.bytecode.transformation.rewrite.Simple;
+import org.apache.commons.javaflow.bytecode.transformation.rewrite.SimpleSerializable;
+
+public abstract class AbstractSerializationTestCase extends AbstractTransformerTestCase {
+
+    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);
+        
+    }
+
+//    private void saveXStream(final Object c1, final File output) throws IOException {
+//        final XStream xstream = new XStream(new DomDriver());
+//        final String xml = xstream.toXML(c1);
+//        final FileOutputStream fos = new FileOutputStream(output);
+//        fos.write(xml.getBytes());
+//        fos.close();
+//    }
+//
+//    private Object loadXStream(final File input) throws IOException {
+//        final String xml = FileUtils.readFully(new FileReader(input));
+//        final XStream xstream = new XStream(new DomDriver());
+//        xstream.setClassLoader(getClass().getClassLoader());
+//        final Object o = xstream.fromXML(xml);
+//    	return o;
+//    }
+    
+    
+    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);
+        	//return classloader.loadClass(classDesc.getName());
+        }
+
+        protected Class resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException
{
+            Class[] cinterfaces = new Class[interfaces.length];
+            for (int i = 0; i < interfaces.length; i++) {
+//                cinterfaces[i] = classloader.loadClass(interfaces[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);
+
+        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());
+        
+        System.out.println(AbstractSerializationTestCase.class.getName() + "@" + AbstractSerializationTestCase.class.getClassLoader());
+        System.out.println(SimpleSerializable.class.getName() + "@" + SimpleSerializable.class.getClassLoader());
+        System.out.println(r1.getClass().getName() + "@" + r1.getClass().getClassLoader());
+        
+        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: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractSerializationTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractSerializationTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractSimpleTestCase.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractSimpleTestCase.java?rev=411779&view=auto
==============================================================================
--- jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractSimpleTestCase.java
(added)
+++ jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractSimpleTestCase.java
Mon Jun  5 06:08:19 2006
@@ -0,0 +1,14 @@
+package org.apache.commons.javaflow.bytecode.transformation.tests;
+
+import org.apache.commons.javaflow.Continuation;
+import org.apache.commons.javaflow.bytecode.transformation.AbstractTransformerTestCase;
+import org.apache.commons.javaflow.bytecode.transformation.rewrite.Simple;
+
+public abstract class AbstractSimpleTestCase extends AbstractTransformerTestCase {
+
+    public void testSimpleSuspend() throws Exception {
+        final Runnable r = new Simple();
+        final Continuation c = Continuation.startWith(r);
+        assertTrue(c != null);
+    }
+}

Propchange: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractSimpleTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractSimpleTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractStackTestCase.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractStackTestCase.java?rev=411779&view=auto
==============================================================================
--- jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractStackTestCase.java
(added)
+++ jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractStackTestCase.java
Mon Jun  5 06:08:19 2006
@@ -0,0 +1,14 @@
+package org.apache.commons.javaflow.bytecode.transformation.tests;
+
+import org.apache.commons.javaflow.Continuation;
+import org.apache.commons.javaflow.bytecode.transformation.AbstractTransformerTestCase;
+import org.apache.commons.javaflow.bytecode.transformation.rewrite.Stack;
+
+public abstract class AbstractStackTestCase extends AbstractTransformerTestCase {
+
+    public void testStack() throws Exception {
+        final Runnable r = new Stack();
+        final Continuation c = Continuation.startWith(r);
+        assertTrue(c == null);
+    }
+}

Propchange: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractStackTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractStackTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message