Package org.objectweb.speedo.pobjects.relations

Examples of org.objectweb.speedo.pobjects.relations.C


      pm.close();
    }
    }

    public void testManyMany() { // tests on active persistent objects
        C c1 = new C("testManyMany_c1");
        C c2 = new C("testManyMany_c2");
        C c3 = new C("testManyMany_c3");

        D d1 = new D("testManyMany_d1");
        D d2 = new D("testManyMany_d2");
        D d3 = new D("testManyMany_d3");

        PersistenceManager pm = pmf.getPersistenceManager();
        pm.makePersistent(c1);
        pm.makePersistent(c2);
        pm.makePersistent(c3);
        pm.makePersistent(d1);
        pm.makePersistent(d2);
        pm.makePersistent(d3);
        pm.close();

        try {
            pm = pmf.getPersistenceManager();
            c1.getDs().add(d1);
            assertTrue(d1.getCs().contains(c1));
            c1.getDs().add(d2);
            assertTrue(d2.getCs().contains(c1));

            c2.getDs().add(d1);
            assertTrue(d1.getCs().contains(c2));
            c2.getDs().add(d2);
            assertTrue(d2.getCs().contains(c2));
            c2.getDs().add(d3);
            assertTrue(d3.getCs().contains(c2));

            c3.getDs().add(d2);
            assertTrue(d2.getCs().contains(c3));
            c3.getDs().add(d3);
            assertTrue(d3.getCs().contains(c3));

            c1.getDs().add(d3);
            assertTrue(d3.getCs().contains(c1));

            c1.getDs().remove(d1);
            assertTrue(!d1.getCs().contains(c1));

            d2.getCs().remove(c2);
            assertTrue(!c2.getDs().contains(d2));

            c1.setDs(c2.getDs());
            // reload objects before testing effects of the above assignement
            pm.close();
            pm = pmf.getPersistenceManager();
            assertTrue(c1.getDs().contains(d1));
            assertTrue(!c1.getDs().contains(d2));
            assertTrue(c1.getDs().contains(d3));

            assertTrue(c2.getDs().contains(d1));
            assertTrue(!c2.getDs().contains(d2));
            assertTrue(c2.getDs().contains(d3));

            assertTrue(!c3.getDs().contains(d1));
            assertTrue(c3.getDs().contains(d2));
            assertTrue(c3.getDs().contains(d3));

            assertTrue(d1.getCs().contains(c1));
            assertTrue(d1.getCs().contains(c2));
            assertTrue(!d1.getCs().contains(c3));
View Full Code Here


            pm.close();
        }
    }

    public void testManyMany2() { // tests on non persistent objects
        C c1 = new C("testManyMany2_c1");
        C c2 = new C("testManyMany2_c2");
        C c3 = new C("testManyMany2_c3");

        D d1 = new D("testManyMany2_d1");
        D d2 = new D("testManyMany2_d2");
        D d3 = new D("testManyMany2_d3");

        PersistenceManager pm = pmf.getPersistenceManager();

        c1.getDs().add(d1);
        c1.getDs().add(d2);

        c2.getDs().add(d1);
        c2.getDs().add(d2);
        c2.getDs().add(d3);

        c3.getDs().add(d2);
        c3.getDs().add(d3);

        pm.makePersistent(c1);
        pm.makePersistent(c2);
        pm.makePersistent(c3);
        pm.close();

        try {
            pm = pmf.getPersistenceManager();
            assertTrue(d1.getCs().contains(c1));
            assertTrue(d2.getCs().contains(c1));

            assertTrue(d1.getCs().contains(c2));
            assertTrue(d2.getCs().contains(c2));
            assertTrue(d3.getCs().contains(c2));

            assertTrue(d2.getCs().contains(c3));
            assertTrue(d3.getCs().contains(c3));

            Collection c = new ArrayList();
            c.addAll(c2.getDs());
            c1.setDs(c);

            pm.close();

            pm = pmf.getPersistenceManager();
            assertTrue(c1.getDs().contains(d1));
            assertTrue(c1.getDs().contains(d2));
            assertTrue(c1.getDs().contains(d3));

            assertTrue(c2.getDs().contains(d1));
            assertTrue(c2.getDs().contains(d2));
            assertTrue(c2.getDs().contains(d3));

            assertTrue(!c3.getDs().contains(d1));
            assertTrue(c3.getDs().contains(d2));
            assertTrue(c3.getDs().contains(d3));

            assertTrue(d1.getCs().contains(c1));
            assertTrue(d1.getCs().contains(c2));
            assertTrue(!d1.getCs().contains(c3));
View Full Code Here

            pm.close();
        }
    }

    public void testManyMany3() { // tests with manually managed consistency
        C c1 = new C("testManyMany3_c1");
        C c2 = new C("testManyMany3_c2");
        C c3 = new C("testManyMany3_c3");

        D d1 = new D("testManyMany3_d1");
        D d2 = new D("testManyMany3_d2");
        D d3 = new D("testManyMany3_d3");

        PersistenceManager pm = pmf.getPersistenceManager();

        c1.setDs(Arrays.asList(new Object[] { d1, d2 }));
        c2.setDs(Arrays.asList(new Object[] { d1, d2, d3 }));
        c3.setDs(Arrays.asList(new Object[] { d2, d3 }));

        d1.setCs(Arrays.asList(new Object[] { c1, c2 }));
        d2.setCs(Arrays.asList(new Object[] { c1, c2, c3 }));
        d3.setCs(Arrays.asList(new Object[] { c2, c3 }));

        pm.makePersistent(c1);
        pm.makePersistent(c2);
        pm.makePersistent(c3);
        pm.close();

        try {
            pm = pmf.getPersistenceManager();
            assertTrue(c1.getDs().size() == 2);
            assertTrue(c1.getDs().contains(d1));
            assertTrue(c1.getDs().contains(d2));

            assertTrue(c2.getDs().size() == 3);
            assertTrue(c2.getDs().contains(d1));
            assertTrue(c2.getDs().contains(d2));
            assertTrue(c2.getDs().contains(d3));

            assertTrue(c3.getDs().size() == 2);
            assertTrue(c3.getDs().contains(d2));
            assertTrue(c3.getDs().contains(d3));

            assertTrue(d1.getCs().size() == 2);
            assertTrue(d1.getCs().contains(c1));
            assertTrue(d1.getCs().contains(c2));
View Full Code Here

            pm.close();
        }
    }

    public void testManyManyDelete() {
      C c1 = new C("testManyManyDelete_c1");
      C c2 = new C("testManyManyDelete_c2");
      C c3 = new C("testManyManyDelete_c3");

      D d1 = new D("testManyManyDelete_d1");
      D d2 = new D("testManyManyDelete_d2");
      D d3 = new D("testManyManyDelete_d3");
     
      PersistenceManager pm = pmf.getPersistenceManager();
      pm.makePersistent(c1);
      pm.makePersistent(c2);
      pm.makePersistent(c3);
      pm.makePersistent(d1);
      pm.makePersistent(d2);
      pm.makePersistent(d3);
      logger.log(BasicLevel.DEBUG, "testManyManyDelete:after makePersistent");
      pm.close();
      logger.log(BasicLevel.DEBUG, "testManyManyDelete:after close");

      try {
        pm = pmf.getPersistenceManager();

        c1.getDs().add(d1);

        c1.getDs().add(d2);

        c2.getDs().add(d1);
        c2.getDs().add(d2);
        c2.getDs().add(d3);

        c3.getDs().add(d2);
        c3.getDs().add(d3);
       
        logger.log(BasicLevel.DEBUG, "testManyManyDelete:after ad collection content");

        pm.close();
        logger.log(BasicLevel.DEBUG, "testManyManyDelete:after close");
       
        pm = pmf.getPersistenceManager();
        pm.currentTransaction().begin();
        assertTrue(d1.getCs().contains(c1));
        assertTrue(d2.getCs().contains(c1));
        assertTrue(d1.getCs().contains(c2));
        assertTrue(d2.getCs().contains(c2));
        assertTrue(d3.getCs().contains(c2));
        assertTrue(d2.getCs().contains(c3));
        assertTrue(d3.getCs().contains(c3));
       
        pm.deletePersistent(d2);
        logger.log(BasicLevel.DEBUG, "testManyManyDelete:after delete d2");
        pm.currentTransaction().commit();
        pm.close();
        logger.log(BasicLevel.DEBUG, "testManyManyDelete:after close");
       
        pm = pmf.getPersistenceManager();

        assertTrue(c1.getDs().size() == 1);
        logger.log(BasicLevel.DEBUG, "testManyManyDelete:c1.nds.size()==1 : " + (c1.getDs().size()==1));
        assertTrue(c1.getDs().contains(d1));
        logger.log(BasicLevel.DEBUG, "testManyManyDelete:c1.nds.contains(d1) : " + (c1.getDs().contains(d1)));
       
        assertTrue(c2.getDs().size() == 2);
        logger.log(BasicLevel.DEBUG, "testManyManyDelete:c2.nds.size()==1 : " + (c2.getDs().size()==1));
        assertTrue(c2.getDs().contains(d1));
        logger.log(BasicLevel.DEBUG, "testManyManyDelete:c2.nds.contains(d1) : " + (c2.getDs().contains(d1)));
        assertTrue(c2.getDs().contains(d3));
        logger.log(BasicLevel.DEBUG, "testManyManyDelete:c2.nds.contains(d3) : " + (c2.getDs().contains(d3)));
       
        assertTrue(c3.getDs().size() == 1);
        logger.log(BasicLevel.DEBUG, "testManyManyDelete:c3.nds.size()==1 : " + (c3.getDs().size()==1));
        assertTrue(c3.getDs().contains(d3));
        logger.log(BasicLevel.DEBUG, "testManyManyDelete:c3.nds.contains(d3) : " + (c3.getDs().contains(d3)));
       
        assertTrue(d1.getCs().contains(c1));
        logger.log(BasicLevel.DEBUG, "testManyManyDelete:d1.cs.contains(c1) : " + (d1.getCs().contains(c1)));
        assertTrue(d1.getCs().contains(c2));
        logger.log(BasicLevel.DEBUG, "testManyManyDelete:d1.cs.contains(c2) : " + (d1.getCs().contains(c2)));
View Full Code Here

TOP

Related Classes of org.objectweb.speedo.pobjects.relations.C

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.