Package org.objectweb.speedo.pobjects.collection

Examples of org.objectweb.speedo.pobjects.collection.Employee


    return LOG_NAME + ".rt.collection.POBuilder";
  }

    public void testCreateEmployee() {
        logger.log(BasicLevel.DEBUG, "Start testCreateEmployee");
        Employee e = new Employee(EMPLOYEE_NAME, null);

        PersistenceManager pm = pmf.getPersistenceManager();
        pm.makePersistent(e);
        Employee[] es = new Employee[NB_ELEMENTS];
        for(int i=0; i<NB_ELEMENTS; i++) {
            es[i]= new Employee(getName(i));
            e.addFriend(es[i]);
            e.addInt(i);
        }
        Assert.assertEquals("Bad sise:" , NB_ELEMENTS, e.friends.size());

        Collection elems = e.friends;
        Assert.assertNotNull("Null collection field", elems);
View Full Code Here


        pm.close();
    }

    public void testSetCollection() {
        logger.log(BasicLevel.DEBUG, "Start testSetCollection");
        Employee e = new Employee(EMPLOYEE_NAME2, null);

        PersistenceManager pm = pmf.getPersistenceManager();
        pm.currentTransaction().begin();
        pm.makePersistent(e);
        pm.currentTransaction().commit();

        ArrayList es = new ArrayList();

        pm.currentTransaction().begin();
        for(int i=0; i<NB_ELEMENTS2; i++) {
            es.add(new Employee(getName2(i)));
        }
        e.setFriends(es);

        Collection elems = e.friends;
        Assert.assertNotNull("Null collection field", elems);
        Iterator elemIt = elems.iterator();
        Assert.assertNotNull("Null iterator over elements", elemIt);
View Full Code Here

  }

  public void testCreation1() {
        logger.log(BasicLevel.DEBUG, "Start testCreation1");
        logger.log(BasicLevel.DEBUG, "Create Employee");
        Employee e1 = new Employee("e1");
        Employee e2 = new Employee("e2");
        e1.setBoss(e2);

        PersistenceManager pm = pmf.getPersistenceManager();
        pm.makePersistent(e1);
        Object eId = pm.getObjectId(e1);
View Full Code Here

  }

    public void testCreation2() {
        logger.log(BasicLevel.DEBUG, "Start testCreation2");
        logger.log(BasicLevel.DEBUG, "Create Employee");
        Employee e1 = new Employee("e1");
        e1.setBoss(e1);

        PersistenceManager pm = pmf.getPersistenceManager();
        pm.makePersistent(e1);
        Object eId = pm.getObjectId(e1);
        Assert.assertNotNull("null object identifier", eId);
        pm.close();

        e1 = null;
        pm = pmf.getPersistenceManager();
        e1 = (Employee) pm.getObjectById(eId, true);
        Assert.assertNotNull("null instance returned by getObjectById", e1);
        Assert.assertEquals("Bad employee name", "e1", e1.getName());
        Assert.assertNotNull("null instance returned by getObjectById", e1.getBoss());
        Assert.assertEquals("Bad boss", e1, e1.getBoss());
        pm.currentTransaction().begin();
        pm.deletePersistent(e1);
        pm.currentTransaction().commit();
        pm.close();
    }
View Full Code Here

    }

    public void testCreation3() {
        logger.log(BasicLevel.DEBUG, "Start testCreation3");
        logger.log(BasicLevel.DEBUG, "Create Employee");
        Employee e1 = new Employee("e1", null);
        Employee e2 = new Employee("e2");

        e1.addFriend(e2);
        Assert.assertEquals("Bad friends set size", e1.getFriendsCol().size(), 1);
        Assert.assertTrue("Bad friends set content", e1.getFriendsCol().contains(e2));
View Full Code Here

    }

    public void testCreation4() {
        logger.log(BasicLevel.DEBUG, "Start testCreation4");
        logger.log(BasicLevel.DEBUG, "Create Employee");
        Employee e1 = new Employee("e1", null);

        PersistenceManager pm = pmf.getPersistenceManager();
        pm.makePersistent(e1);
        Object eId = pm.getObjectId(e1);
        Assert.assertNotNull("null object identifier", eId);

        Employee e2 = new Employee("e2");

        e1.addFriend(e2);
        Assert.assertEquals("Bad friends set size", e1.getFriendsCol().size(), 1);
        Assert.assertTrue("Bad friends set content", e1.getFriendsCol().contains(e2));

        e1.addInt(1);
        Assert.assertEquals("Bad ints set size", e1.getIntsCol().size(), 1);
        Assert.assertTrue("Bad ints set content", e1.getIntsCol().contains(new Integer(1)));

        pm.close();

        e1 = null;
        pm = pmf.getPersistenceManager();
        e1 = (Employee) pm.getObjectById(eId, true);
        Assert.assertNotNull("null instance returned by getObjectById", e1);
        Assert.assertEquals("Bad employee name", "e1", e1.getName());

        Assert.assertNotNull("null collection returned by getObjectById", e1.getFriendsCol());
        Assert.assertEquals("Bad friends set size", e1.getFriendsCol().size(), 1);
        Assert.assertTrue("Bad friends set content", e1.getFriendsCol().iterator().hasNext());
        Assert.assertNotNull("Bad friends set content", e1.getFriendsCol().iterator().next());
        Assert.assertEquals("Bad friends set content", ((Employee) e1.getFriendsCol().iterator().next()).getName(), "e2");

        Assert.assertNotNull("null collection returned by getObjectById", e1.getIntsCol());
        Assert.assertEquals("Bad ints set size", e1.getIntsCol().size(), 1);
        Assert.assertTrue("Bad ints set content", e1.getIntsCol().iterator().hasNext());
        Assert.assertNotNull("Bad ints set content", e1.getIntsCol().iterator().next());
        Assert.assertTrue("Bad ints set content", e1.getIntsCol().contains(new Integer(1)));
        Object o = e2.getName();
        pm.currentTransaction().begin();
        pm.deletePersistent(e1);
        pm.deletePersistent(e2);
        pm.currentTransaction().commit();
        pm.close();
View Full Code Here

        Object o = it.next();
        q.closeAll();

        Assert.assertNotNull("Null object returned by the iterator", o);
        Assert.assertEquals("bad object type", Employee.class, o.getClass());
        Employee e = (Employee) o;
        Collection elems = e.getFriendsCol();
        Assert.assertNotNull("Null collection field", elems);
        Iterator elemIt = elems.iterator();
        Assert.assertNotNull("Null iterator over elements", elemIt);
        ArrayList elemNames = new ArrayList();
        while(elemIt.hasNext()) {
View Full Code Here

        Object o = it.next();
        q.closeAll();

        Assert.assertNotNull("Null object returned by the iterator", o);
        Assert.assertEquals("bad object type", Employee.class, o.getClass());
        Employee e = (Employee) o;
        Collection elems = e.getFriendsCol();
        Assert.assertNotNull("Null collection field", elems);
        Iterator elemIt = elems.iterator();
        Assert.assertNotNull("Null iterator over elements", elemIt);
        ArrayList elemNames = new ArrayList();
        while(elemIt.hasNext()) {
View Full Code Here

    pm.close();

  }
 
  public void testColModifNSet() {
        Employee e1 = new Employee("e1");
        Employee e2 = new Employee("e2");
        Employee e3 = new Employee("e3");
    PersistenceManager pm = pmf.getPersistenceManager();
    pm.currentTransaction().begin();
        pm.makePersistent(e1);
        Object oid1 = pm.getObjectId(e1);
        pm.makePersistent(e2);
View Full Code Here

TOP

Related Classes of org.objectweb.speedo.pobjects.collection.Employee

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.