Examples of TestClassA


Examples of org.apache.ojb.odmg.shared.TestClassA

        return oldAddresses;
    }

    private void clearTestData() throws LockingException
    {
        TestClassA a = generateTestData();
        TestClassB b2 = generateAnotherB();
        Transaction tx = _kit.getTransaction(_conn);
        tx.begin();
        Identity oid = _conn.getIdentity(a);
        Identity oidb = _conn.getIdentity(a.getB());
        Identity oidb2 = _conn.getIdentity(b2);
        TestClassA a1 = (TestClassA) _conn.getObjectByIdentity(oid);
        if (a1 != null)
        {
            _conn.deletePersistent(a1);
        }
        TestClassB b1 = (TestClassB) _conn.getObjectByIdentity(oidb);
View Full Code Here

Examples of org.apache.ojb.odmg.shared.TestClassA

        tx.commit();
    }

    private TestClassA generateTestData()
    {
        TestClassA tca = new TestClassA();
        tca.setOid("someoid");
        tca.setValue1("abc");
        tca.setValue2("123");
        tca.setValue3(5);
        TestClassB tcb = new TestClassB();
        tcb.setOid("boid");
        tcb.setValue1("hi there");
        tca.setB(tcb);
        return tca;
    }
View Full Code Here

Examples of org.apache.ojb.odmg.shared.TestClassA

    }

   public void testSwizzle3() throws TransactionException, LockingException, PBFactoryException, PersistenceBrokerException
    {
        clearTestData();
        TestClassA a = generateTestData();
        Transaction tx = _kit.getTransaction(_conn);
        tx.begin();
        _conn.makePersistent(a.getB());
        _conn.makePersistent(a);
    TestClassB b = a.getB();
        tx.commit();
        /**
        * clear to start test
        */
        _conn.invalidateAll();
        tx = _kit.getTransaction(_conn);
        tx.begin();
        /**
     * load B
     */
    Identity oidb = _conn.getIdentity(b);
        TestClassB b1 = (TestClassB) _conn.getObjectByIdentity(oidb);
        assertTrue(b1 != null);
    /**
     * load A
      */
    Identity oida = _conn.getIdentity(a);
    TestClassA a1 = (TestClassA) _conn.getObjectByIdentity(oida);

    /**
     * B, as navigated from A, should be the same as B gotten directly.
     */
    assertTrue(a1.getB().equals(b1));
        tx.commit();

    /**
     * clear
     */
 
View Full Code Here

Examples of org.apache.ojb.odmg.shared.TestClassA

    }

    public void testSwizzle2() throws TransactionException, LockingException, PBFactoryException, PersistenceBrokerException
    {
        clearTestData();
        TestClassA a = generateTestData();
        Transaction tx = _kit.getTransaction(_conn);
        tx.begin();
        _conn.makePersistent(a.getB());
        _conn.makePersistent(a);
        tx.commit();
        /**
        * clear to start test
        */
        _conn.invalidateAll();
        /**
        * get A to make it and the related B in cache
        */
        tx = _kit.getTransaction(_conn);
        tx.begin();
        Identity oid = _conn.getIdentity(a);
        TestClassA a1 = (TestClassA) _conn.getObjectByIdentity(oid);
        assertTrue(a1.getB() != null);
        assertTrue(a1.getB().getValue1().equals("hi there"));
        /**
        * everything is good, update b
        */
        tx.commit();

        /**
        * now get B and update it, do NOT get it by traversing A
        */
        tx = _kit.getTransaction(_conn);
        tx.begin();
        Identity boid = _conn.getIdentity(a.getB());
        TestClassB b1 = (TestClassB) _conn.getObjectByIdentity(boid);
        assertTrue(b1 != null);
        assertTrue(b1.getValue1().equals("hi there"));
        /**
        * everything is good, update b
        */
        _conn.lockForWrite(b1);
        b1.setValue1("goodbye there");
        tx.commit();
        /**
        * make sure b was updated
        */
        tx = _kit.getTransaction(_conn);
        tx.begin();
        boid = _conn.getIdentity(a.getB());
        b1 = (TestClassB) _conn.getObjectByIdentity(boid);
        assertTrue(b1 != null);
        assertTrue(b1.getValue1().equals("goodbye there"));
        tx.commit();

        /**
        * now get A again and make sure the related B is updated to reflect
        * the new value.
        */
        tx = _kit.getTransaction(_conn);
        tx.begin();
        TestClassA a2 = (TestClassA) _conn.getObjectByIdentity(oid);
        assertTrue(a2.getB() != null);
        assertTrue(a2.getB().getValue1().equals("goodbye there"));
        tx.commit();
        clearTestData();
    }
View Full Code Here

Examples of org.apache.ojb.odmg.shared.TestClassA

    }

    public void testSwizzleNto1() throws Exception
    {
        clearTestData();
        TestClassA a = generateTestData();
        TestClassB b2 = generateAnotherB();
        Transaction tx = _kit.getTransaction(_conn);
        tx.begin();
        _conn.makePersistent(a.getB());
        _conn.makePersistent(a);
        tx.commit();
        /**
         * change B
         */
        tx = _kit.getTransaction(_conn);
        tx.begin();
        Identity oid = _conn.getIdentity(a);
        TestClassA a1 = (TestClassA) _conn.getObjectByIdentity(oid);
        _conn.makePersistent(b2);
        a1.setB(b2);
        tx.commit();

        tx = _kit.getTransaction(_conn);
        tx.begin();
        a = (TestClassA) _conn.getObjectByIdentity(oid);
View Full Code Here

Examples of org.apache.ojb.odmg.shared.TestClassA

    }

   public void testSwizzle4() throws TransactionException, LockingException, PBFactoryException, PersistenceBrokerException
    {
        clearTestData();
        TestClassA a = generateTestData();
    TestClassB b = a.getB();
        Transaction tx = _kit.getTransaction(_conn);

        tx.begin();
        _conn.makePersistent(b);
        _conn.makePersistent(a);
        b.setA(a);
        tx.commit();
        /**
        * clear to start test
        */
        _conn.invalidateAll();
        tx = _kit.getTransaction(_conn);
        tx.begin();
        /**
     * load B
     */
    Identity oidb = _conn.getIdentity(b);
        TestClassB b1 = (TestClassB) _conn.getObjectByIdentity(oidb);
    /**
     * load A
      */
    Identity oida = _conn.getIdentity(a);
    TestClassA a1 = (TestClassA) _conn.getObjectByIdentity(oida);
    assertTrue(a1 != null);
    assertTrue(a1.getB().equals(b1));
    assertTrue(b1.getA().equals(a1));
        /**
     * update B
     */
        a.setValue1("a");
        _conn.makePersistent(a);

    /**
     * B, as navigated from A, should be the same as B gotten directly.
     */
    assertTrue(a1.getValue1().equals(a.getValue1()));
        tx.commit();

    /**
     * clear
     */
 
View Full Code Here

Examples of org.apache.ojb.odmg.shared.TestClassA

        return oldAddresses;
    }

    private void clearTestData() throws LockingException
    {
        TestClassA a = generateTestData();
        TestClassB b2 = generateAnotherB();
        Transaction tx = _kit.getTransaction(_conn);
        tx.begin();
        Identity oid = _conn.getIdentity(a);
        Identity oidb = _conn.getIdentity(a.getB());
        Identity oidb2 = _conn.getIdentity(b2);
        TestClassA a1 = (TestClassA) _conn.getObjectByIdentity(oid);
        if (a1 != null)
        {
            _conn.deletePersistent(a1);
        }
        TestClassB b1 = (TestClassB) _conn.getObjectByIdentity(oidb);
View Full Code Here

Examples of org.apache.ojb.odmg.shared.TestClassA

        tx.commit();
    }

    private TestClassA generateTestData()
    {
        TestClassA tca = new TestClassA();
        tca.setOid("someoid");
        tca.setValue1("abc");
        tca.setValue2("123");
        tca.setValue3(5);
        TestClassB tcb = new TestClassB();
        tcb.setOid("boid");
        tcb.setValue1("hi there");
        tca.setB(tcb);
        return tca;
    }
View Full Code Here

Examples of org.apache.ojb.odmg.shared.TestClassA

  public void testOrReferenceOnDifferentTables() throws Exception
  {
        deleteData(TestClassA.class);
        deleteData(TestClassB.class);

    TestClassA a1 = new TestClassA();
    TestClassA a2 = new TestClassA();

    TestClassB b1 = new TestClassB();
    TestClassB b2 = new TestClassB();
    a1.setB(b1);
    a2.setB(b2);

    Transaction tx = odmg.newTransaction();
    tx.begin();
    database.makePersistent(a1);
    database.makePersistent(a2);
    database.makePersistent(b1);
    database.makePersistent(b2);
    tx.commit();
    tx = odmg.newTransaction();
    tx.begin();
    // get the right values
    OQLQuery query = odmg.newOQLQuery();
    query.create("select a from " + TestClassA.class.getName());
    List As = (List) query.execute();
    Iterator asIterator = As.iterator();
    TestClassA temp = null;

    temp = (TestClassA) asIterator.next();
    String bID1 = temp.getB().getOid();
    temp = (TestClassA) asIterator.next();
    String bID2 = temp.getB().getOid();

    query = odmg.newOQLQuery();
    query.create("select a from " + TestClassA.class.getName() +
           " where (b.oid=$1 or b.oid=$2)");
    query.bind(bID1);
View Full Code Here

Examples of org.apache.ojb.odmg.shared.TestClassA

    protected void setUp() throws Exception
    {
      super.setUp();

      m_a = new TestClassA();
      m_b = new TestClassB();

      // init a
      m_a.setValue1("A.One");
      m_a.setValue2("B.Two");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.