Package org.objectweb.speedo.pobjects.basic

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


      }
      assertEquals("Bad content", expected, found);
      final Class superClass = JDOImplHelper.getInstance().getPersistenceCapableSuperclass(BasicA.class);
      assertNull("Bad super class name", superClass);
     
    BasicA ba = new BasicA();
    ba.writeF1("testPONEICompatible");
    ba.writeF2(23242);
    PersistenceManager pm = pmf.getPersistenceManager();
    pm.currentTransaction().begin();
    pm.makePersistent(ba);
        pm.currentTransaction().commit();
       
View Full Code Here


   
   
    //test delete and make an object persistent in the same transaction
    public void testDeleteRollback() {
       logger.log(BasicLevel.DEBUG, "testDeleteRollBack");
         BasicA ba = new BasicA();
         ba.writeF1("testDeleteRollBack");
         ba.writeF2(2);
         PersistenceManager pm = pmf.getPersistenceManager();

         pm.currentTransaction().begin();
         pm.makePersistent(ba);
         pm.currentTransaction().commit();
        
         pm.currentTransaction().begin();
         pm.deletePersistent(ba);
         pm.currentTransaction().rollback();
        
         pm.currentTransaction().begin();
         assertTrue("The object should be persistent", JDOHelper.isPersistent(ba));
         assertEquals("F2 should be 2", 2, ba.readF2());
         pm.deletePersistent(ba);
         pm.currentTransaction().commit();

         pm.close();
  }
View Full Code Here

         pm.close();
  }
  public void testDeleteAndUse() {
    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();
    pm.deletePersistent(ba);
    assertEquals("bad F2 value after delete:", 2, ba.readF2());
        ba.writeF2(3);
    assertEquals("bad F2 value after delete and set:", 3, ba.readF2());
        pm.currentTransaction().commit();
    assertEquals("bad F2 value after commit:", 3, ba.readF2());
        ba.writeF2(4);
    assertEquals("bad F2 value after commit and set:", 4, ba.readF2());
        pm.close();
    assertEquals("bad F2 value after close:", 4, ba.readF2());
        ba.writeF2(5);
    assertEquals("bad F2 value after close and set:", 5, ba.readF2());
  }
View Full Code Here

        };
        PersistenceManager pm = pmf.getPersistenceManager();
        for (int i = 0; i < listeners.length; i++) {
            pmf.addInstanceLifecycleListener(listeners[i], new Class[]{BasicA.class});
        }
        BasicA ba = new BasicA();
        assertEquals("unexpect event on create ", 0, nbEvent[0]);
        ba.writeF1("testInstanceLifecycleListener_1");
        assertEquals("unexpect event on write ", 0, nbEvent[0]);
        pm.currentTransaction().begin();
        pm.makePersistent(ba);
        assertEquals("Bad event number on make persistent: ", 1, nbEvent[0]);
        ba.writeF1("testInstanceLifecycleListener_1");
        assertEquals("Bad event number on make persistent after write: ", 3, nbEvent[0]);
        assertNotNull("Not postCreate event", marks[InstanceLifecycleEvent.CREATE][POST]);
        assertTrue("Bad source ", marks[InstanceLifecycleEvent.CREATE][POST].getSource() == ba);

        clear(nbEvent, marks);
        pm.currentTransaction().commit();
        pm.currentTransaction().begin();
        assertTrue("Bad event number on commit: " + nbEvent[0], 2 == nbEvent[0] | 3 ==nbEvent[0]);
        assertNotNull("Not preStore event", marks[InstanceLifecycleEvent.STORE][PRE]);
        assertTrue("Bad source on preStore", marks[InstanceLifecycleEvent.STORE][PRE].getSource() == ba);
        assertNotNull("Not postStore event", marks[InstanceLifecycleEvent.STORE][POST]);
        assertTrue("Bad source on postStore", marks[InstanceLifecycleEvent.STORE][POST].getSource() == ba);
        pm.currentTransaction().commit();
       
        pm.evict(ba);
       
        pm.currentTransaction().begin();
        clear(nbEvent, marks);
        assertEquals("Bad f1 value" , "testInstanceLifecycleListener_1", ba.readF1());
        assertTrue("Bad event number on load: ", 2 == nbEvent[0] || 1 == nbEvent[0]);
        assertNotNull("Not postStore event", marks[InstanceLifecycleEvent.LOAD][POST]);
        assertTrue("Bad source on postStore", marks[InstanceLifecycleEvent.LOAD][POST].getSource() == ba);
/*
        nbEvent[0] = 0;
View Full Code Here

  public void testGetObjectId() {
    logger.log(BasicLevel.INFO, "testGetObjectId");
    try {
      Transaction tx = pm.currentTransaction();
      tx.begin();
      BasicA nba1 = new BasicA();
      pm.makePersistent(nba1);     

      Object p2 = JDOHelper.getObjectId(nba1);
      tx.commit();
     
View Full Code Here

   
    Object results = query.execute(new String(""), new java.lang.Integer(0));

    // check query result
    Collection expected = new ArrayList();
    Object p3 = new BasicA();
    expected.add(p3);
/*
    insertExpected(expected);

   
 
View Full Code Here

    tx = getPM().currentTransaction();
    logger.log(BasicLevel.DEBUG, "begin initData");
    tx.begin();
    tx2.begin();

    BasicA ba11 = new BasicA();
    ba11.writeF1("ba11");
    BasicA ba12 = new BasicA();
    ba11.writeF1("ba12");

    getPM().makePersistent(ba11);
    getPM().makePersistent(ba12);

    BasicA ba21 = new BasicA();
    ba11.writeF1("ba21");
    BasicA ba22 = new BasicA();
    ba11.writeF1("ba22");

    pm2.makePersistent(ba21);
    pm2.makePersistent(ba22);

    tx.commit();
    tx2.commit();

    logger.log(BasicLevel.DEBUG, "begin test");
    tx.begin();
    tx2.begin();

    BasicA ba11a = findBasicA(pm, "ba11");
    Assert.assertEquals(ba11a, ba11);

    BasicA ba21a = findBasicA(pm2, "ba21");
    Assert.assertEquals(ba21a, ba21);

    tx.commit();
    tx2.commit();
View Full Code Here

    Query q = pm.newQuery(BasicA.class);
    q.declareParameters("String param");
    q.setFilter("(param == f1)");
    Collection results = (Collection) q.execute(param);
    Iterator it = results.iterator();
    BasicA ret = (BasicA) it.next();
    return ret;
  }
View Full Code Here

    Assert.assertTrue("same persistence manager", !pm1.equals(pm2));

    try {

      pm1.currentTransaction().begin();
      ba1 = new BasicA();
      ba2 = new BasicA();
      ba3 = new BasicA();
      ba4 = new BasicA();
      ba5 = new BasicA();

      pm1.makePersistent(ba1);
      pm1.makePersistent(ba2);
      pm1.makePersistent(ba3);
      pm1.makePersistent(ba4);
View Full Code Here

    tx = getPM().currentTransaction();
    //tx.setRetainValues(false);
    tx.setRestoreValues(false);

    tx.begin();
    BasicA ba11 = new BasicA();
    ba11.writeF1("ba11");
    getPM().makePersistent(ba11);
    tx.commit();

    tx.begin();
    Object p1Id = getPM().getObjectId(ba11);
    BasicA ba11a = (BasicA) getPM().getObjectById(p1Id, true);
    BasicA ba11c = findBasicA(getPM(), "ba11");
    tx.commit();
    closePM();

    Assert.assertEquals("Assertion A5.4-2 failed; getObjectById results differ", ba11a, ba11);
    Assert.assertEquals("Assertion A5.4-2 failed; query results differ", ba11c, ba11);
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.