Beispiel #1
0
  protected void setUp() throws Exception {
    super.setUp();

    String config = getClass().getResource(JDO_CONF_FILE).toString();
    JDOManager.loadConfiguration(config, getClass().getClassLoader());
    _jdo = JDOManager.createInstance(DATABASE_NAME);
  }
Beispiel #2
0
  protected void setUp() throws Exception {
    super.setUp();

    if (!_logHeader) {
      LOG.info(format("", "begin", "result", "iterate", "commit", "close"));
      _logHeader = true;
    }

    _jdo = JDOManager.createInstance(DATABASE_NAME);
  }
Beispiel #3
0
  public void testReadOnlyOidEmpty() throws Exception {
    long start = System.currentTimeMillis();

    _db = _jdo.getDatabase();
    _db.getCacheManager().expireCache();
    _db.begin();

    long begin = System.currentTimeMillis();

    OQLQuery query =
        _db.getOQLQuery(
            "CALL SQL select PTF_LOCKED.ID as ID "
                + "from PTF_LOCKED order by PTF_LOCKED.ID "
                + "AS ptf.jdo.rel1toN.OID");
    QueryResults results = query.execute(Database.ReadOnly);

    long result = System.currentTimeMillis();

    initIterateQueriesOID();

    int count = 0;
    while (results.hasMore()) {
      OID oid = (OID) results.next();
      iterateStatesOID(
          (Locked) _db.load(Locked.class, oid.getId(), Database.ReadOnly), Database.ReadOnly);

      count++;
    }

    long iterate = System.currentTimeMillis();

    _db.commit();

    long commit = System.currentTimeMillis();

    _db.close();

    long close = System.currentTimeMillis();

    LOG.info(
        format(
            "ReadOnlyOidEmpty",
            DF.format(begin - start),
            DF.format(result - begin),
            DF.format(iterate - result),
            DF.format(commit - iterate),
            DF.format(close - commit)));
  }
Beispiel #4
0
  public static Test suite() throws Exception {
    String config = TestRemove.class.getResource(JDO_CONF_FILE).toString();
    JDOManager.loadConfiguration(config, TestRemove.class.getClassLoader());

    TestSuite suite = new TestSuite("Remove ptf.jdo.rel1toN test objects");

    suite.addTest(new TestRemove("testRemoveService"));
    suite.addTest(new TestRemove("testRemoveEquipment"));
    suite.addTest(new TestRemove("testRemoveType"));
    suite.addTest(new TestRemove("testRemoveSupplier"));
    suite.addTest(new TestRemove("testRemoveReason"));
    suite.addTest(new TestRemove("testRemoveDepartment"));
    suite.addTest(new TestRemove("testRemoveState"));

    return suite;
  }
Beispiel #5
0
  public void testQueryEntity() throws Exception {
    Database db = _jdo.getDatabase();
    db.begin();

    OQLQuery query =
        db.getOQLQuery("SELECT entity FROM " + Entity.class.getName() + " entity WHERE id = $1");
    query.bind(new Integer(1));
    QueryResults results = query.execute();

    Entity entity = (Entity) results.next();

    assertNotNull(entity);
    assertEquals(new Integer(1), entity.getId());

    db.commit();
    db.close();
  }
Beispiel #6
0
  public void testReadWriteEmpty() throws Exception {
    long start = System.currentTimeMillis();

    _db = _jdo.getDatabase();
    _db.getCacheManager().expireCache();
    _db.begin();

    long begin = System.currentTimeMillis();

    OQLQuery query =
        _db.getOQLQuery("SELECT o FROM " + Locked.class.getName() + " o order by o.id");
    QueryResults results = query.execute();

    long result = System.currentTimeMillis();

    initIterateQueries();

    int count = 0;
    while (results.hasMore()) {
      iterateStates((Locked) results.next(), Database.Shared);

      count++;
    }

    long iterate = System.currentTimeMillis();

    _db.commit();

    long commit = System.currentTimeMillis();

    _db.close();

    long close = System.currentTimeMillis();

    LOG.info(
        format(
            "ReadWriteEmpty",
            DF.format(begin - start),
            DF.format(result - begin),
            DF.format(iterate - result),
            DF.format(commit - iterate),
            DF.format(close - commit)));
  }
Beispiel #7
0
  public void testReadOnlyOidOnly() throws Exception {
    long start = System.currentTimeMillis();

    _db = _jdo.getDatabase();
    _db.begin();

    long begin = System.currentTimeMillis();

    OQLQuery query =
        _db.getOQLQuery(
            "CALL SQL select PTF_LOCKED.ID as ID "
                + "from PTF_LOCKED order by PTF_LOCKED.ID "
                + "AS ptf.jdo.rel1toN.OID");
    QueryResults results = query.execute(Database.ReadOnly);

    long result = System.currentTimeMillis();

    int count = 0;
    while (results.hasMore()) {
      results.next();
      count++;
    }

    long iterate = System.currentTimeMillis();

    _db.commit();

    long commit = System.currentTimeMillis();

    _db.close();

    long close = System.currentTimeMillis();

    LOG.info(
        format(
            "ReadOnlyOidOnly",
            DF.format(begin - start),
            DF.format(result - begin),
            DF.format(iterate - result),
            DF.format(commit - iterate),
            DF.format(close - commit)));
  }
Beispiel #8
0
  public void testRemoveState() throws Exception {
    long time = System.currentTimeMillis();
    int count = 0;

    Database db = _jdo.getDatabase();
    db.begin();

    OQLQuery query = db.getOQLQuery("SELECT o FROM " + State.class.getName() + " o");
    QueryResults results = query.execute();
    while (results.hasMore()) {
      db.remove(results.next());
      count++;
    }

    db.commit();
    db.close();

    LOG.info(
        "Removed " + count + " state objects in " + (System.currentTimeMillis() - time) + "ms.");
  }
Beispiel #9
0
  public static Test suite() throws Exception {
    String config = TestLoadUni1toN.class.getResource(JDO_CONF_FILE).toString();
    JDOManager.loadConfiguration(config, TestLoadUni1toN.class.getClassLoader());

    TestSuite suite = new TestSuite("Test load 1:n with unidirectional mapping");

    suite.addTest(new TestLoadUni1toN("testReadWriteEmpty"));
    suite.addTest(new TestLoadUni1toN("testReadWriteCached"));
    suite.addTest(new TestLoadUni1toN("testReadWriteOidEmpty"));
    suite.addTest(new TestLoadUni1toN("testReadWriteOidCached"));

    suite.addTest(new TestLoadUni1toN("testReadOnlyEmpty"));
    suite.addTest(new TestLoadUni1toN("testReadOnlyCached"));
    suite.addTest(new TestLoadUni1toN("testReadOnlyOidEmpty"));
    suite.addTest(new TestLoadUni1toN("testReadOnlyOidCached"));

    suite.addTest(new TestLoadUni1toN("testReadOnlyOidOnly"));

    return suite;
  }
Beispiel #10
0
  protected void setUp() throws Exception {
    super.setUp();

    _jdo = JDOManager.createInstance(DATABASE_NAME);
  }