PageRenderTime 29ms CodeModel.GetById 14ms RepoModel.GetById 0ms 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
Possible License(s): Apache-2.0
  1. package com.google.appengine.datanucleus.bugs.jdo;
  2. import com.google.appengine.datanucleus.bugs.jdo.JDOBugTestCase;
  3. import com.google.appengine.datanucleus.bugs.test.Issue73Child;
  4. import com.google.appengine.datanucleus.bugs.test.Issue73Parent;
  5. public class Issue73Test extends JDOBugTestCase {
  6. public void testMultipleOneToOne() {
  7. Issue73Parent p = new Issue73Parent();
  8. p.setName("First Parent");
  9. Issue73Child c1 = new Issue73Child();
  10. c1.setName("Child 1");
  11. p.setChild1(c1);
  12. Issue73Child c2 = new Issue73Child();
  13. c2.setName("Child 2");
  14. p.setChild1(c2);
  15. // Persist parent with 2 children
  16. Object id = null;
  17. beginTxn();
  18. pm.makePersistent(p);
  19. commitTxn();
  20. id = pm.getObjectId(p);
  21. pm.close();
  22. // Retrieve and check the results
  23. pm = pmf.getPersistenceManager();
  24. beginTxn();
  25. Issue73Parent p1 = (Issue73Parent)pm.getObjectById(id);
  26. Issue73Child c1a = p1.getChild1();
  27. Issue73Child c2a = p1.getChild2();
  28. assertNotNull(c1a);
  29. assertNotNull(c2a);
  30. assertEquals("Child 1", c1a.getName());
  31. assertEquals("Child 2", c2a.getName());
  32. commitTxn();
  33. }
  34. }