Package org.objectweb.speedo.pobjects.collection

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


  public void testReachability() {
    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


      testDeleteColElemWithoutRelation(false);
 
  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();
View Full Code Here

        pm.makePersistentAll(r2);
        pm.makePersistentAll(bs);
       
        //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

   */
  public void testGroupUser(final int NB, final boolean withBarrier) {
      logger.log(BasicLevel.INFO, "testGroupUser" + NB +
              (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();
      }
      Collection threads = Arrays.asList(ths);
      List res = waiter.nextAction(threads, 1000);
      assertTrue("Thread blocked on first point: " + res, res.isEmpty());
      res = waiter.nextAction(threads, 1000);
      if (!res.isEmpty()) {
        for(int i=0; i<ths.length; i++) {
            if (ths[i].isAlive()) {
                ths[i].interrupt();
            }
        }
      }
      assertTrue("Thread blocked on second point: " + res, res.isEmpty());
      res = waiter.nextAction(threads, 1000);
      for(int i=0; i<ths.length; i++) {
          if (ths[i].isAlive()) {
              try {
                    ths[i].join(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
          }
      }
      pm = pmf.getPersistenceManager();
      int size = group.getUsers().size();
      pm.currentTransaction().begin();
      pm.deletePersistentAll(group.getUsers());
      pm.deletePersistent(group);
      pm.currentTransaction().commit();
      pm.close();
      assertEquals("Bad number of users", NB, size);
  }
View Full Code Here

        q.declareVariables("User u");
        q.setFilter("!(this.users.contains(u)) && (u.name == p1)");
        Collection c = (Collection) q.execute("user_g0_u0");
        Collection founds = new ArrayList(c.size());
        for (Iterator iter = c.iterator(); iter.hasNext();) {
            Group g = (Group) iter.next();
            founds.add(g.getName());
        }
        q.closeAll();
        pm.close();
        assertSameCollection("Bad group found",
                Arrays.asList(new String[]{"group_1", "group_2"}),
View Full Code Here

        q.declareVariables("User u1 ; User u2");
        q.setFilter("((this.users.contains(u1)) && (u1.name == p1)) && ((this.users.contains(u2)) && (u2.name == p2))");
        Collection c = (Collection) q.execute("user_g0_u0", "user_g0_u1");
        Collection founds = new ArrayList(c.size());
        for (Iterator iter = c.iterator(); iter.hasNext();) {
            Group g = (Group) iter.next();
            founds.add(g.getName());
        }
        q.closeAll();
        pm.close();
        assertSameCollection("Bad group found",
                Arrays.asList(new String[]{"group_0"}),
View Full Code Here

TOP

Related Classes of org.objectweb.speedo.pobjects.collection.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.