コード例 #1
0
  @BeforeClass
  public static void setUp() {
    TestTools.createDb(DB_NAME);
    TestTools.defineSchema(DB_NAME, JB0.class);
    TestTools.defineSchema(DB_NAME, JB1.class);
    TestTools.defineSchema(DB_NAME, JB2.class);
    TestTools.defineSchema(DB_NAME, JB3.class);
    TestTools.defineSchema(DB_NAME, JB4.class);

    PersistenceManager pm = TestTools.openPM();
    pm.currentTransaction().begin();

    for (int i = 1; i <= COUNT; i++) {
      JB0 jb;
      jb = new JB4(4, 4, i, 4, 4);
      pm.makePersistent(jb);
      jb = new JB3(3, 3, i, 3);
      pm.makePersistent(jb);
      jb = new JB2(2, 2, i);
      pm.makePersistent(jb);
      jb = new JB1(1, 2);
      pm.makePersistent(jb);
      jb = new JB0(0);
      pm.makePersistent(jb);
    }

    pm.currentTransaction().commit();
    TestTools.closePM(pm);
  }
コード例 #2
0
ファイル: IskPubPerYear.java プロジェクト: NickCharsley/zoodb
 @BeforeClass
 public static void beforeClass() {
   TestTools.removeDb();
   TestTools.createDb();
   TestTools.defineSchema(ComplexHolder0.class, ComplexHolder1.class, ComplexHolder2.class);
   TestTools.defineIndex(ComplexHolder0.class, "id", false);
 }
コード例 #3
0
 @Before
 public void before() {
   TestTools.createDb();
   TestTools.defineSchema(TestClass.class);
   pm = TestTools.openPM();
   pm.currentTransaction().begin();
 }
コード例 #4
0
  /**
   * Test serialisation.
   *
   * <p>If a transaction has only new objects (no modified objects) and if the new objects have
   * other persistent capable objects referenced (but no have called makePersistent() on them) and
   * if we are not in the first transaction in a session, then we get the following NPE. See issue
   * #57.
   */
  @Test
  public void testSerialization() {
    TestTools.defineSchema(ProjectPC.class, CoordinatePC.class);
    PersistenceManager pm = TestTools.openPM();
    pm.currentTransaction().begin();

    CoordinatePC x = new CoordinatePC();
    pm.makePersistent(x);

    pm.currentTransaction().commit();
    pm.currentTransaction().begin();

    ProjectPC s = new ProjectPC(new ProjectPC(null));
    pm.makePersistent(s);
    Object oid = pm.getObjectId(s);
    pm.currentTransaction().commit();
    TestTools.closePM();

    pm = TestTools.openPM();
    pm.currentTransaction().begin();
    ProjectPC s2 = (ProjectPC) pm.getObjectById(oid);
    assertNotNull(s2);
    pm.currentTransaction().commit();
    pm.close();
  }
コード例 #5
0
  /** Test import of ZooDB 0.3 xml files. */
  @Test
  public void testImport0_3() {
    String path = Test_014_XmlImportExport.class.getResource("XmlComplexTest.xml").getPath();

    // import to DB
    TestTools.defineSchema(TestSerializer.class, TestSuper.class, DBLargeVector.class);
    ZooXmlImport.main(new String[] {TestTools.getDbName(), path});

    // check target
    PersistenceManager pm2 = TestTools.openPM();
    pm2.currentTransaction().begin();

    // Check for content in target
    Extent<TestSerializer> ext = pm2.getExtent(TestSerializer.class);
    TestSerializer ts2 = ext.iterator().next();
    ts2.check(false);
    pm2.currentTransaction().rollback();
    TestTools.closePM();
  }
コード例 #6
0
  private void populateSimple() {
    TestTools.defineSchema(TestClass.class);
    PersistenceManager pm = TestTools.openPM();
    pm.currentTransaction().begin();

    pm.newQuery(TestClass.class).deletePersistentAll();

    TestClass tc1 = new TestClass();
    tc1.setData(
        1, false, 'c', (byte) 127, (short) 32000, 1234567890L, "xyz", new byte[] {1, 2}, -1.1f, 35);
    pm.makePersistent(tc1);
    tc1 = new TestClass();
    tc1.setData(
        12,
        false,
        'd',
        (byte) 127,
        (short) 32000,
        1234567890L,
        "xyz",
        new byte[] {1, 2},
        -0.1f,
        34);
    pm.makePersistent(tc1);
    tc1 = new TestClass();
    tc1.setData(
        123,
        false,
        'e',
        (byte) 127,
        (short) 32000,
        1234567890L,
        "xyz",
        new byte[] {1, 2},
        0.1f,
        3.0);
    pm.makePersistent(tc1);
    tc1 = new TestClass();
    tc1.setData(
        1234,
        false,
        'f',
        (byte) 127,
        (short) 32000,
        1234567890L,
        "xyz",
        new byte[] {1, 2},
        1.1f,
        -0.01);
    pm.makePersistent(tc1);
    tc1 = new TestClass();
    tc1.setData(
        12345,
        false,
        'g',
        (byte) 127,
        (short) 32000,
        1234567890L,
        "xyz",
        new byte[] {1, 2},
        11.1f,
        -35);
    pm.makePersistent(tc1);

    pm.currentTransaction().commit();
    TestTools.closePM();
    ;
  }
コード例 #7
0
  @Test
  public void testComplexClass() {
    // populate
    Object oid = null;
    TestTools.defineSchema(TestSerializer.class, TestSuper.class, DBLargeVector.class);
    PersistenceManager pm = TestTools.openPM();
    pm.currentTransaction().begin();
    TestSerializer ts1 = new TestSerializer();
    ts1.init();
    ts1.check(true);
    pm.makePersistent(ts1);
    oid = pm.getObjectId(ts1);
    pm.currentTransaction().commit();
    TestTools.closePM();
    pm = null;

    TestSerializer.resetStatic();

    // export to XML
    StringWriter out = new StringWriter();
    ZooXmlExport ex = new ZooXmlExport(out);
    ex.writeDB(TestTools.getDbName());
    System.out.println(out.getBuffer());
    Scanner sc = new Scanner(new StringReader(out.getBuffer().toString()));
    ZooXmlImport im = new ZooXmlImport(sc);

    // import to new DB
    DataStoreManager dsm = ZooHelper.getDataStoreManager();
    if (dsm.dbExists(DB2)) {
      dsm.removeDb(DB2);
    }
    dsm.createDb(DB2);
    TestTools.defineSchema(DB2, TestSerializer.class, TestSuper.class, DBLargeVector.class);
    im.readDB(DB2);

    // check target
    PersistenceManager pm2 = TestTools.openPM(DB2);
    pm2.currentTransaction().begin();

    // Check for content in target
    TestSerializer ts2 = (TestSerializer) pm2.getObjectById(oid, true);
    ts2.check(false);
    pm2.currentTransaction().rollback();
    TestTools.closePM();

    TestSerializer.resetStatic();

    // Now try the same thing again, this time with an existing object.
    pm2 = TestTools.openPM(DB2);
    pm2.currentTransaction().begin();

    TestSerializer ts3 = (TestSerializer) pm2.getObjectById(oid);
    ts3.check(false);
    // mark dirty to enforce rewrite.
    ts3.markDirtyTS();
    pm2.currentTransaction().commit();
    TestTools.closePM();

    TestSerializer.resetStatic();
    // Check target
    pm2 = TestTools.openPM(DB2);
    pm2.currentTransaction().begin();

    TestSerializer ts4 = (TestSerializer) pm2.getObjectById(oid, true);
    ts4.check(false);
    pm2.currentTransaction().rollback();
    TestTools.closePM();
  }
コード例 #8
0
 @Before
 public void beforeTest() {
   TestTools.createDb();
   TestTools.defineSchema(TestClass.class, TestClassTiny.class, TestClassTiny2.class);
 }
コード例 #9
0
 @BeforeClass
 public static void setUp() {
   TestTools.createDb();
   TestTools.defineSchema(TestClass.class, TestClassTiny.class, TestClassTiny2.class);
 }
コード例 #10
0
 @BeforeClass
 public static void setUp() {
   TestTools.createDb();
   TestTools.defineSchema(JB0.class, JB1.class, JB2.class, JB3.class, JB4.class, JdoTree.class);
 }
コード例 #11
0
 @BeforeClass
 public static void setUp() {
   TestTools.createDb();
   TestTools.defineSchema(
       TestPostLoad.class, TestPreStore.class, TestPreClear.class, TestPreDelete.class);
 }
コード例 #12
0
ファイル: DBArrayListTest.java プロジェクト: jonasnick/zoodb
 @BeforeClass
 public static void setUpClass() {
   TestTools.createDb(DB_NAME);
   TestTools.defineSchema(DB_NAME, PersistentDummyImpl.class);
 }
コード例 #13
0
 @Before
 public void before() {
   TestTools.createDb();
   TestTools.defineSchema(TestClass.class);
 }