PageRenderTime 10ms CodeModel.GetById 1ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/tests_bugs/com/google/appengine/datanucleus/bugs/jdo/Issue73Test.java

http://datanucleus-appengine.googlecode.com/
Java | 40 lines | 32 code | 6 blank | 2 comment | 0 complexity | bd0f17156eba9fffc2786a3edf2aabc3 MD5 | raw file
 1package com.google.appengine.datanucleus.bugs.jdo;
 2
 3import com.google.appengine.datanucleus.bugs.jdo.JDOBugTestCase;
 4import com.google.appengine.datanucleus.bugs.test.Issue73Child;
 5import com.google.appengine.datanucleus.bugs.test.Issue73Parent;
 6
 7public class Issue73Test extends JDOBugTestCase {
 8
 9  public void testMultipleOneToOne() {
10    Issue73Parent p = new Issue73Parent();
11    p.setName("First Parent");
12    Issue73Child c1 = new Issue73Child();
13    c1.setName("Child 1");
14    p.setChild1(c1);
15    Issue73Child c2 = new Issue73Child();
16    c2.setName("Child 2");
17    p.setChild1(c2);
18
19    // Persist parent with 2 children
20    Object id = null;
21    beginTxn();
22    pm.makePersistent(p);
23    commitTxn();
24    id = pm.getObjectId(p);
25    pm.close();
26
27    // Retrieve and check the results
28    pm = pmf.getPersistenceManager();
29    beginTxn();
30    Issue73Parent p1 = (Issue73Parent)pm.getObjectById(id);
31    Issue73Child c1a = p1.getChild1();
32    Issue73Child c2a = p1.getChild2();
33    assertNotNull(c1a);
34    assertNotNull(c2a);
35    assertEquals("Child 1", c1a.getName());
36    assertEquals("Child 2", c2a.getName());
37
38    commitTxn();
39  }
40}