1 4 package org.oddjob.framework; 5 6 import java.io.Serializable ; 7 8 import junit.framework.TestCase; 9 10 import org.apache.commons.beanutils.DynaBean; 11 import org.oddjob.Helper; 12 13 public class SerializableWrapperTest extends TestCase { 14 15 public static class Test1 implements Runnable , Serializable { 16 private static final long serialVersionUID = 20051231; 17 private String check="hello"; 18 19 public void run() {} 20 public String getCheck() { return check; } 21 } 22 23 public static class Test2 implements Runnable { 24 public void run() {} 25 } 26 27 public void testSimple() throws Exception { 28 Runnable test = new Test1(); 29 Object wrapper = RunnableWrapper.wrapperFor(test); 30 DynaBean copy = (DynaBean) Helper.copy(wrapper); 31 assertEquals("hello", copy.get("check")); 32 } 33 34 public void testNotSerializable () throws Exception { 35 Runnable test = new Test2(); 36 Object wrapper = RunnableWrapper.wrapperFor(test); 37 assertTrue(wrapper instanceof Transient); 38 } 39 } 40 | Popular Tags |