Package org.objectweb.speedo.pobjects.basic

Examples of org.objectweb.speedo.pobjects.basic.BasicA


  public void testCreateObjects(int NBOBJ) {
    logger.log(BasicLevel.WARN, "Creating " + NBOBJ + " objects ...");
    PersistenceManager pm = pmf.getPersistenceManager();
    pm.currentTransaction().begin();
    for(int i=0; i<NBOBJ; i++) {
      BasicA ba = new BasicA();
      ba.writeF1("testBigExtent_" + NBOBJ);
      pm.makePersistent(ba);
    }
    pm.currentTransaction().commit();
    pm.evictAll();
    pm.close();
View Full Code Here


    long t = Calendar.getInstance().getTimeInMillis();
    Extent e = pm.getExtent(BasicA.class, false);
    Iterator it = e.iterator();
    int i= 0;
    while(it.hasNext()) {
      BasicA ba = (BasicA) it.next();
      logger.log(BasicLevel.DEBUG, ba.readF1());
    }
    e.closeAll();
    pm.close();
    t = Calendar.getInstance().getTimeInMillis() - t;
    logger.log(BasicLevel.WARN, "Time: " + t + "ms");
View Full Code Here

    Iterator it = e.iterator();
    int i= 0;
    while(it.hasNext()) {
      assertTrue("More object than expected, expected="
        + NBOBJ + ", found " + (i + 1), i < NBOBJ);
      BasicA ba = (BasicA) it.next();
      pm.deletePersistent(ba);
      logger.log(BasicLevel.DEBUG, ba.readF1());
      i++;
    }
    e.closeAll();
    pm.currentTransaction().commit();
    pm.close();
View Full Code Here

        }
  }

  public void testRollBackTxSamePM() {
    logger.log(BasicLevel.DEBUG, "testRollBackTxSamePM");
    BasicA ba = new BasicA();
    ba.writeF1("testRollBack1");
    ba.writeF2(2);
    PersistenceManager pm = pmf.getPersistenceManager();

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

        pm.currentTransaction().begin();
    ba.writeF2(3);
        Assert.assertEquals("Bad f2 value before roolback", 3, ba.readF2());
        pm.currentTransaction().rollback();
        Assert.assertEquals("Bad f2 value after roolback", 2, ba.readF2());

        pm.currentTransaction().begin();
        pm.deletePersistent(ba);
        pm.currentTransaction().commit();
        pm.close();
View Full Code Here

        pm.close();
  }

    public void testRollBack2() {
        logger.log(BasicLevel.DEBUG, "testRollBack2");
        BasicA ba = new BasicA();
        ba.writeF1("testRollBack1");
        ba.writeF2(2);
        PersistenceManager pm = pmf.getPersistenceManager();

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

        pm.currentTransaction().begin();
        ba.writeF2(3);
        Assert.assertEquals("Bad f2 value before roolback", 3, ba.readF2());
        pm.currentTransaction().rollback();
        Assert.assertEquals("Bad f2 value after roolback", 2, ba.readF2());
        ba.writeF2(4);
        Assert.assertEquals("Bad f2 value after roolback", 4, ba.readF2());
        pm.close();

        pm = pmf.getPersistenceManager();
        Assert.assertEquals("Bad f2 value after roolback", 4, ba.readF2());
       
        pm.currentTransaction().begin();
        pm.deletePersistent(ba);
        pm.currentTransaction().commit();
        pm.close();
View Full Code Here

      testBasicType(0);
    }

  public void testSerialization() {
    logger.log(BasicLevel.DEBUG, "testSerialization");
    BasicA ba = new BasicA();
    ba.writeF1("testSerialization");
    ba.writeF2(5);
    Locale l = new Locale("en"); //Examples: "en", "de_DE", "_GB", "en_US_WIN", "de__POSIX", "fr__MAC"
    ba.setLocale(l);
    PersistenceManager pm = pmf.getPersistenceManager();

    pm.currentTransaction().begin();
    pm.makePersistent(ba);
    Object oid = pm.getObjectId(ba);
    pm.currentTransaction().commit();
    pm.close();
    File f = new File(new File(new File("output"),"test"), "testSerialization");
    if (f.exists()) {
      f.delete();
    }
    try {
      ObjectOutputStream oos = new ObjectOutputStream(
          new FileOutputStream(f));
      oos.writeObject(ba);
      oos.close();

      ba = null;
      ObjectInputStream ois = new ObjectInputStream(
          new FileInputStream(f));
      ba = (BasicA) ois.readObject();
      ois.close();
      ba.readF1_F2();
      assertEquals("Bad locale language value", l.getLanguage(), ba.getLocale().getLanguage());
      assertEquals("Bad locale country value", l.getCountry(), ba.getLocale().getCountry());
      assertEquals("Bad locale variant value", l.getVariant(), ba.getLocale().getVariant());
     
    } catch (Exception e) {
      logger.log(BasicLevel.ERROR, "testSerialization fails: ", e);
      fail(e.getMessage());
    } finally {
View Full Code Here

  public void testStaticFinder() {
    logger.log(BasicLevel.DEBUG, "testStaticFinder");
    ArrayList oids = new ArrayList();
    PersistenceManager pm = pmf.getPersistenceManager();
    for(int i =0; i<50; i++) {
      BasicA ba = new BasicA();
      ba.writeF1("testStaticFinder" + i);
      ba.writeF2(i);
      pm.makePersistent(ba);
      oids.add(pm.getObjectId(ba));
    }
    pm.close();
    try {
View Full Code Here

    }
  }

  public void testNonNullField() {
    logger.log(BasicLevel.DEBUG, "testNonNullField");
    BasicA ba = new BasicA();
    ba.writeF1("testNonNullField");
    PersistenceManager pm = pmf.getPersistenceManager();
    pm.currentTransaction().begin();
    pm.makePersistent(ba);
    pm.currentTransaction().commit();
    pm.currentTransaction().begin();
    ba.setNonullField(null);
    try {
      pm.currentTransaction().commit();
      fail("no exception thrown when a null value try to be store for a persistent field marked as non null");
    } catch (JDOUserException e) {
    } catch (Exception e) {
View Full Code Here

      pm.close();
    }
  }
  public void testRefresh() {
    logger.log(BasicLevel.DEBUG, "testRefresh");
    BasicA ba = new BasicA();
    ba.writeF1("testRefresh");
    ba.writeF2(2);
    PersistenceManager pm = pmf.getPersistenceManager();
    pm.currentTransaction().begin();
    pm.makePersistent(ba);
        pm.currentTransaction().commit();
       
    pm.currentTransaction().begin();
    pm.refresh(ba);
    int f2 = ba.readF2();
    assertTrue("bad F2 value:" + f2, f2 < 4);
        pm.currentTransaction().commit();
       
    pm.currentTransaction().begin();
    pm.deletePersistent(ba);
View Full Code Here

        pm.close();
  }

  public void testRefreshDirty() {
    logger.log(BasicLevel.DEBUG, "testRefreshDirty");
    BasicA ba = new BasicA();
    ba.writeF1("testRefreshDirty");
    ba.writeF2(2);
    PersistenceManager pm = pmf.getPersistenceManager();
    pm.currentTransaction().begin();
    pm.makePersistent(ba);
        pm.currentTransaction().commit();
       
    pm.currentTransaction().begin();
    ba.writeF2(4);
    pm.refresh(ba);
    int f2 = ba.readF2();
    assertTrue("bad F2 value:" + f2, f2 < 4);
        pm.currentTransaction().commit();
       
    pm.currentTransaction().begin();
    pm.deletePersistent(ba);
View Full Code Here

TOP

Related Classes of org.objectweb.speedo.pobjects.basic.BasicA

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.