Package org.objectweb.speedo.pobjects.ref

Examples of org.objectweb.speedo.pobjects.ref.Group


    public void testCascadeDeleteOneToNone() {
      PersistenceManager pm = pmf.getPersistenceManager();
     
      // We create a group. A group can have a president and many members, but not this one.
      String gName = "SpeedoCascade";
      Group grp = new Group(gName);
     
      // We make the group persistant
        pm.makePersistent(grp);
       
        // Get the id
        Object gId = pm.getObjectId(grp);

        pm.close();

        grp = null;
       
        // Check the creation of the group
        pm = pmf.getPersistenceManager();
        grp = (Group) pm.getObjectById(gId, true);
    Assert.assertNotNull("null instance returned for group", grp);
    Assert.assertEquals("Bad group name", gName, grp.getName());
   
    /* Delete the group.
     */
    pm.currentTransaction().begin();
    pm.deletePersistent(grp);
 
View Full Code Here


      President pres = new President(pName);
     

      // A group
      String gName = "SpeedoCascade";
      Group grp = new Group(gName, pres);
      pres.setGroup(grp);
     
      // We make the group persistant
        pm.makePersistent(grp);
       
        // Get the ids
         Object gId = pm.getObjectId(grp);
        Object pId = pm.getObjectId(grp.getPresident());

        pm.close();

        grp = null;
        pres = null;
       
        // Check the creation of the group and its president
        pm = pmf.getPersistenceManager();
        grp = (Group) pm.getObjectById(gId, true);
        pres = (President) pm.getObjectById(pId, true);
    Assert.assertNotNull("null instance returned for group", grp);
    Assert.assertEquals("Bad group name", gName, grp.getName());
    Assert.assertNotNull("null instance returned for president", pres);
    Assert.assertEquals("Bad president name", pName, pres.getName());
   
    /* Delete the group :
     * this should delete the president.
View Full Code Here

    public void testCascadeDeleteOneToTwo() {
      PersistenceManager pm = pmf.getPersistenceManager();
     
      // A group
      String gName = "SpeedoCascade";
      Group grp = new Group(gName);
     
      // Two members
      String m1Name = "Jean";
      String m2Name = "Sophie";
      Member mem1 = new Member(m1Name, grp);
      Member mem2 = new Member(m2Name, grp);
     
      // We make the members persistant
        pm.makePersistent(mem1);
        pm.makePersistent(mem2);
       
        // Get the ids
        Object m1Id = pm.getObjectId(mem1);
        Object m2Id = pm.getObjectId(mem2);
        Object gId = pm.getObjectId(grp);

        pm.close();

        mem1 = null;
        mem2 = null;
        grp = null;
       
        // Check the creation of the group and its members
        pm = pmf.getPersistenceManager();
        mem1 = (Member) pm.getObjectById(m1Id, true);
        mem2 = (Member) pm.getObjectById(m2Id, true);
        grp = (Group) pm.getObjectById(gId, true);
    Assert.assertNotNull("null instance for the member 1", mem1);
    Assert.assertEquals("Bad member 1 name", m1Name, mem1.getName());
    Assert.assertNotNull("null instance for the member 2", mem2);
    Assert.assertEquals("Bad member 2 name", m2Name, mem2.getName());
    Assert.assertNotNull("null instance returned for group", grp);
    Assert.assertEquals("Bad group name", gName, grp.getName());
   
    /* Delete the group :
     * this should delete both members.
     */
    pm.currentTransaction().begin();
 
View Full Code Here

    public void testCascadeDeleteOneToMany() {
      PersistenceManager pm = pmf.getPersistenceManager();
     
      // A group
      String gName = "SpeedoCascade";
      Group grp = new Group(gName);
     
      // Two members
         String m1Name = "Jean";
      String m2Name = "Sophie";
         String m3Name = "Alain";
      String m4Name = "Sylvie";
         String m5Name = "Jeanne";
      String m6Name = "Rose";
         String m7Name = "Baptiste";
      String m8Name = "Alexandre";
         String m9Name = "Noemie";
      String m10Name = "Eve";
      Member mem1 = new Member(m1Name, grp);
      Member mem2 = new Member(m2Name, grp);
      Member mem3 = new Member(m3Name, grp);
      Member mem4 = new Member(m4Name, grp);
      Member mem5 = new Member(m5Name, grp);
      Member mem6 = new Member(m6Name, grp);
      Member mem7 = new Member(m7Name, grp);
      Member mem8 = new Member(m8Name, grp);
      Member mem9 = new Member(m9Name, grp);
      Member mem10 = new Member(m10Name, grp);
     
      // We make the members persistant
        pm.makePersistent(mem1);
        pm.makePersistent(mem2);
        pm.makePersistent(mem3);
        pm.makePersistent(mem4);
        pm.makePersistent(mem5);
        pm.makePersistent(mem6);
        pm.makePersistent(mem7);
        pm.makePersistent(mem8);
        pm.makePersistent(mem9);
        pm.makePersistent(mem10);
       
        // Get the ids
        Object m1Id = pm.getObjectId(mem1);
        Object m2Id = pm.getObjectId(mem2);
        Object m3Id = pm.getObjectId(mem3);
        Object m4Id = pm.getObjectId(mem4);
        Object m5Id = pm.getObjectId(mem5);
        Object m6Id = pm.getObjectId(mem6);
        Object m7Id = pm.getObjectId(mem7);
        Object m8Id = pm.getObjectId(mem8);
        Object m9Id = pm.getObjectId(mem9);
        Object m10Id = pm.getObjectId(mem10);
        Object gId = pm.getObjectId(grp);

        pm.close();

        mem1 = null;
        mem2 = null;
        mem3 = null;
        mem4 = null;
        mem5 = null;
        mem6 = null;
        mem7 = null;
        mem8 = null;
        mem9 = null;
        mem10 = null;
        grp = null;
       
        // Check the creation of the employee and the department
        pm = pmf.getPersistenceManager();
        mem1 = (Member) pm.getObjectById(m1Id, true);
        mem2 = (Member) pm.getObjectById(m2Id, true);
        mem3 = (Member) pm.getObjectById(m3Id, true);
        mem4 = (Member) pm.getObjectById(m4Id, true);
        mem5 = (Member) pm.getObjectById(m5Id, true);
        mem6 = (Member) pm.getObjectById(m6Id, true);
        mem7 = (Member) pm.getObjectById(m7Id, true);
        mem8 = (Member) pm.getObjectById(m8Id, true);
        mem9 = (Member) pm.getObjectById(m9Id, true);
        mem10 = (Member) pm.getObjectById(m10Id, true);
        grp = (Group) pm.getObjectById(gId, true);
    Assert.assertNotNull("null instance for the member 1", mem1);
    Assert.assertEquals("Bad member 1 name", m1Name, mem1.getName());
    Assert.assertNotNull("null instance for the member 2", mem2);
    Assert.assertEquals("Bad member 2 name", m2Name, mem2.getName());
    Assert.assertNotNull("null instance for the member 3", mem3);
    Assert.assertEquals("Bad member 3 name", m3Name, mem3.getName());
    Assert.assertNotNull("null instance for the member 4", mem4);
    Assert.assertEquals("Bad member 4 name", m4Name, mem4.getName());
    Assert.assertNotNull("null instance for the member 5", mem5);
    Assert.assertEquals("Bad member 5 name", m5Name, mem5.getName());
    Assert.assertNotNull("null instance for the member 6", mem6);
    Assert.assertEquals("Bad member 6 name", m6Name, mem6.getName());
    Assert.assertNotNull("null instance for the member 7", mem7);
    Assert.assertEquals("Bad member 7 name", m7Name, mem7.getName());
    Assert.assertNotNull("null instance for the member 8", mem8);
    Assert.assertEquals("Bad member 8 name", m8Name, mem8.getName());
    Assert.assertNotNull("null instance for the member 9", mem9);
    Assert.assertEquals("Bad member 9 name", m9Name, mem9.getName());
    Assert.assertNotNull("null instance for the member 10", mem10);
    Assert.assertEquals("Bad member 10 name", m10Name, mem10.getName());
    Assert.assertNotNull("null instance returned for group", grp);
    Assert.assertEquals("Bad group name", gName, grp.getName());
   
    /* Delete the group :
     * this should delete its members too.
     */
    pm.currentTransaction().begin();
 
View Full Code Here

    public void testCascadeDeleteMap() {
      PersistenceManager pm = pmf.getPersistenceManager();
     
      // A group
      String gName = "SpeedoCascade";
      Group grp = new Group(gName);
     
      // Five members
      Meeting m1 = new Meeting("Meeting1", "Topic1");
      Meeting m2 = new Meeting("Meeting2", "Topic2");
      Meeting m3 = new Meeting("Meeting3", "Topic3");
      Meeting m4 = new Meeting("Meeting4", "Topic4");
      Meeting m5 = new Meeting("Meeting5", "Topic5");
     
      // Add four meetings to the group
      grp.addMeeting(m1);
      grp.addMeeting(m2);
      grp.addMeeting(m3);
      grp.addMeeting(m4);
          
      //make the group persistent
      pm.makePersistent(grp);
      pm.makePersistent(m5);
      Object m1Id = pm.getObjectId(m1);
      Object m2Id = pm.getObjectId(m2);
      Object m3Id = pm.getObjectId(m3);
      Object m4Id = pm.getObjectId(m4);
      Object m5Id = pm.getObjectId(m5);
      Object gId = pm.getObjectId(grp);
      pm.close();
     
        m1 = null;
        m2 = null;
        m3 = null;
        m4 = null;
        m5 = null;
        grp = null;
       
        pm = pmf.getPersistenceManager();
       
        // Check the creation of the meetings
        m1 = (Meeting) pm.getObjectById(m1Id, true);
        m2 = (Meeting) pm.getObjectById(m2Id, true);
        m3 = (Meeting) pm.getObjectById(m3Id, true);
        m4 = (Meeting) pm.getObjectById(m4Id, true);
        m5 = (Meeting) pm.getObjectById(m5Id, true);
        grp = (Group) pm.getObjectById(gId, true);
       
    Assert.assertNotNull("null instance for the meeting 1", m1);
    Assert.assertNotNull("null instance for the meeting 2", m2);
    Assert.assertNotNull("null instance for the meeting 3", m3);
    Assert.assertNotNull("null instance for the meeting 4", m4);
    Assert.assertNotNull("null instance for the meeting 5", m5);
    Assert.assertNotNull("null instance returned for group", grp);
    Assert.assertEquals("Bad group name", gName, grp.getName());
   
    /* Delete the group :
     * this should delete its meetings too.
     */
    pm.currentTransaction().begin();
 
View Full Code Here

TOP

Related Classes of org.objectweb.speedo.pobjects.ref.Group

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.