Package org.objectweb.speedo.pobjects.collection

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


    PersistenceManager pm = pmf.getPersistenceManager();
    pm.currentTransaction().begin();

        final Group group = new Group("Group One");

        final User user = new User("Tom");
        user.setE_mail("tom@example.com");
        group.getUsers().add(user);
    assertTrue("User already marked as persistent before the makePersitent action: ",
      !JDOHelper.isPersistent(user));
    assertTrue("Group already marked as persistent before the makePersitent action: ",
      !JDOHelper.isPersistent(group));
View Full Code Here


 
  public void testDeleteColElemWithoutRelation(boolean withEvictAll) {
      String gn = "group testDeleteColElemWithoutRelation" + withEvictAll;
      String un = "user testDeleteColElemWithoutRelation" + withEvictAll;
      Group group = new Group(gn);
      User user = new User(un);
      group.getUsers().add(user);
      PersistenceManager pm = pmf.getPersistenceManager();
      pm.currentTransaction().begin();
      pm.makePersistent(group);
      group = null;
      user = null;
      pm.currentTransaction().commit();
      if (withEvictAll) {
          pm.evictAll();
      }
      pm.currentTransaction().begin();
      user = (User) pm.getObjectById(
              pm.newObjectIdInstance(User.class, un), false);
      pm.deletePersistent(user);
      pm.currentTransaction().commit();
     
      pm.currentTransaction().begin();
      group = (Group) pm.getObjectById(
              pm.newObjectIdInstance(Group.class, gn), false);
      ArrayList al = new ArrayList();
      for(Iterator it = group.getUsers().iterator(); it.hasNext();) {
          user = (User) it.next();
          al.add(user.getName());
      }
      pm.deletePersistent(group);
      pm.currentTransaction().commit();
      pm.close();
      assertTrue("Group not empty: " + al, al.isEmpty());
View Full Code Here

        //creation of groups
        for(int i=0; i<NB_GROUP; i++) {
            Group g = new Group("group_" + i);
            Collection users = g.getUsers();
            for(int j=0; j<NB_USER_PER_GROUP; j++) {
                User u = new User("user_g" + i + "_u" + j);
                users.add(u);
            }
            pm.makePersistent(g);
        }
       
View Full Code Here

              (withBarrier ? "WithBarrier" : ""));
      final Waiter waiter = new Waiter(0, withBarrier);
      final Group group = new Group("TestThinLock.testGroupUser.group1");
      final User[] users = new User[NB];
      for(int i=0; i<NB; i++) {
          users[i] = new User("TestThinLock.testGroupUser.user" + i);
        group.getUsers().add(users[i]);
      }
      PersistenceManager pm = pmf.getPersistenceManager();
      pm.currentTransaction().begin();
      pm.makePersistent(group);
      pm.currentTransaction().commit();
      pm.close();
      Thread[] ths = new Thread[NB];
      for(int i=0; i<NB; i++) {
          ths[i] new Thread(new TestGroupUser(waiter, group, users[i],
                      new User("TestThinLock.testGroupUser.user" + (NB + i)),
                      pmf));
      }
      for(int i=0; i<NB; i++) {
          ths[i].start();
      }
View Full Code Here

        q.setOrdering("name ascending");
        q.setRange(0, 5);
        Collection c = (Collection) q.execute();
        ArrayList foundNames = new ArrayList();
        for (Iterator it = c.iterator(); it.hasNext();) {
            User u = (User) it.next();
            foundNames.add(u.getName());
        }
        q.closeAll();
        pm.currentTransaction().commit();
        pm.evictAll();
        assertEquals("not expected result", expectedNames.subList(0, 5), foundNames);

        pm.currentTransaction().begin();
        q = pm.newQuery(User.class);
        q.setOrdering("name ascending");
        q.setRange(2, 5);
        c = (Collection) q.execute();
        foundNames.clear();
        for (Iterator it = c.iterator(); it.hasNext();) {
            User u = (User) it.next();
            foundNames.add(u.getName());
        }
        q.closeAll();
        pm.currentTransaction().commit();
        pm.evictAll();
        assertEquals("not expected result", expectedNames.subList(2, 5), foundNames);

        pm.currentTransaction().begin();
        q = pm.newQuery(User.class);
        q.setOrdering("name ascending");
        c = (Collection) q.execute();
        foundNames.clear();
        for (Iterator it = c.iterator(); it.hasNext();) {
            User u = (User) it.next();
            foundNames.add(u.getName());
        }
        q.closeAll();
        pm.currentTransaction().commit();
        pm.evictAll();
        assertEquals("not expected result", expectedNames, foundNames);
View Full Code Here

TOP

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

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.