01: /*
02: * User: Michael Rettig
03: * Date: Sep 7, 2002
04: * Time: 9:31:07 PM
05: */
06: package net.sourceforge.jaxor.example.tests;
07:
08: import net.sourceforge.jaxor.JaxorSession;
09: import net.sourceforge.jaxor.api.JaxorContext;
10: import net.sourceforge.jaxor.api.UnitOfWork;
11: import net.sourceforge.jaxor.example.domain.AddressFinder;
12: import net.sourceforge.jaxor.example.domain.AddressMetaRow;
13: import net.sourceforge.jaxor.example.domain.ObjectFactory;
14: import net.sourceforge.jaxor.example.domain.OrdersMetaRow;
15: import net.sourceforge.jaxor.example.simple.ContactMetaRow;
16: import net.sourceforge.jaxor.example.db.PostgresContextTestingFactory;
17:
18: import java.lang.reflect.Modifier;
19: import java.util.ArrayList;
20: import java.util.List;
21:
22: public class UnitOfWorkSerializationTest extends MultiTableTestCase {
23:
24: protected List getRows() {
25: List all = new ArrayList();
26: all.add(new AddressMetaRow());
27: all.add(new ContactMetaRow());
28: all.add(new OrdersMetaRow());
29: return all;
30: }
31:
32: public void testModifier() {
33: int mod = 0;
34: mod += Modifier.PUBLIC;
35: mod += Modifier.FINAL;
36: assertEquals("public final", Modifier.toString(mod));
37: }
38:
39: public void testSerializing() {
40: ObjectFactory.createAddress(new Long(2));
41: ObjectFactory.createOrder(new Long(1), new Long(2));
42: ContactFactory.createContact();
43: UnitOfWork work = JaxorSession.getJaxorContext()
44: .getUnitOfWork();
45:
46: assertEquals(work, work);
47: serialize(JaxorSession.getJaxorContext());
48: UnitOfWork newWork = (UnitOfWork) serialize(work);
49: assertEquals(work, newWork);
50: JaxorSession.begin(newWork, getTransaction());
51: commit();
52: assertNotNull(AddressFinder.selectByPrimaryKey(new Long(2)));
53: JaxorContext jaxor = JaxorSession.getJaxorContext();
54: serialize(jaxor);
55: }
56: }
|