1 4 package org.oddjob.persist; 5 6 import junit.framework.TestCase; 7 8 import org.apache.commons.beanutils.PropertyUtils; 9 import org.oddjob.arooa.registry.ComponentRegistry; 10 import org.oddjob.framework.RunnableWrapper; 11 import org.oddjob.jobs.EchoJob; 12 13 public class PersisterBaseTest extends TestCase { 14 15 class MockPersister extends PersisterBase { 16 String id; 17 Object component; 18 public void persist(String id, Object component) { 19 this.id = id; 20 this.component = component; 21 } 22 public Object restore(String id) { 23 return null; 24 } 25 public void remove(String id) { 26 } 27 } 28 29 public void test1() throws Exception { 30 MockPersister test = new MockPersister(); 31 32 Object j = RunnableWrapper.wrapperFor(new EchoJob()); 33 PropertyUtils.setProperty(j, "text", "Hello"); 34 test.setRoot(j); 35 36 ComponentRegistry registry = new ComponentRegistry(); 37 registry.register("foo", j); 38 39 test.initialise(registry); 40 41 assertEquals("foo", test.id); 42 assertEquals(j, test.component); 43 44 test.id = null; 45 test.component = null; 46 47 ((Runnable ) j).run(); 48 49 assertEquals("foo", test.id); 50 assertEquals(j, test.component); 51 } 52 } 53 | Popular Tags |