public void testRemoveUsers() throws Exception {

    resetMeasure();

    int n = USER_NUM;

    String pfxUsr = "******" + worker_id + ".";
    String pfxGrp = "grpUre" + worker_id + ".";
    String pfxRol = "rolUre" + worker_id + ".";

    String ORGANIZATION = "ORGANIZATION";

    IdentitySession identitySession =
        identitySessionFactory.createIdentitySession("realm://JBossIdentityExample/SampleRealm");
    identitySession.beginTransaction();

    Group group =
        identitySession.getPersistenceManager().createGroup(pfxGrp + "GROUP" + n, ORGANIZATION);
    RoleType role = identitySession.getRoleManager().createRoleType(pfxRol + "manager");

    identitySession.getTransaction().commit();
    identitySession.close();

    identitySession.beginTransaction();

    for (int i = 0; i < n; i++) {

      User user = identitySession.getPersistenceManager().createUser(pfxUsr + i);
      if (triggerGc) {
        System.gc();
      }
    }

    identitySession.getTransaction().commit();
    identitySession.close();

    identitySession.beginTransaction();

    for (int i = 0; i < n; i++) {
      startStopwatch();
      identitySession.getPersistenceManager().removeUser(pfxUsr + i, true);
      stopStopwatch();
      storeStopwatch(i);
      if (triggerGc) {
        System.gc();
      }
    }

    identitySession.getTransaction().commit();
    identitySession.close();

    generateGraph(getGraphNamePfx() + ".testRemoveUsers()", this.getClass().getName());
  }
  public void testRemoveRoles() throws Exception {

    resetMeasure();

    int n = USER_NUM;

    String pfxUsr = "******" + worker_id + ".";
    String pfxGrp = "grpAsRRem" + worker_id + ".";
    String pfxRol = "rolAsRRem" + worker_id + ".";

    String ORGANIZATION = "ORGANIZATION";

    IdentitySession identitySession =
        identitySessionFactory.createIdentitySession("realm://JBossIdentityExample/SampleRealm");
    identitySession.beginTransaction();

    Group group =
        identitySession.getPersistenceManager().createGroup(pfxGrp + "GROUP" + n, ORGANIZATION);
    RoleType roleType = identitySession.getRoleManager().createRoleType(pfxRol + "manager");

    Collection<User> userList = new ArrayList<User>();

    for (int i = 0; i < n; i++) {
      User user = identitySession.getPersistenceManager().createUser(pfxUsr + i);
      userList.add(user);
    }

    identitySession.getTransaction().commit();
    identitySession.close();
    identitySession.beginTransaction();

    for (User user : userList) {
      identitySession.getRoleManager().createRole(roleType, user, group);
      if (triggerGc) {
        System.gc();
      }
    }

    int c = 0;
    for (User user : userList) {
      startStopwatch();
      identitySession.getRoleManager().removeRole(roleType, user, group);
      stopStopwatch();
      storeStopwatch(c++);
      if (triggerGc) {
        System.gc();
      }
    }

    identitySession.getTransaction().commit();
    identitySession.close();
    generateGraph(getGraphNamePfx() + ".testDisassociateRoles()", this.getClass().getName());
  }
Esempio n. 3
0
  @Test
  @Ignore
  public void testPopulateIdentity() throws Exception {

    resetMeasure();

    int n = 200;

    String pfxUsr = "******";
    String pfxGrp = "grpXtestPopulateIdentity";
    String pfxRol = "rolXtestPopulateIdentity";

    String ORGANIZATION = "ORGANIZATION";

    IdentitySession identitySession =
        identitySessionFactory.createIdentitySession("realm://JBossIdentityExample/SampleRealm");
    identitySession.beginTransaction();

    Group group =
        identitySession.getPersistenceManager().createGroup(pfxGrp + "GROUP" + n, ORGANIZATION);
    RoleType role = identitySession.getRoleManager().createRoleType(pfxRol + "manager");

    for (int i = 0; i < n; i++) {
      startStopwatch();
      createUser(pfxUsr, identitySession, group, role, i);
      stopStopwatch();
      storeStopwatch(i);
    }

    identitySession.getTransaction().commit();

    identitySession.close();

    generateGraph("populateIdentity", this.getClass().getName());
  }
Esempio n. 4
0
  @Test
  public void testAssociateUsersInManyTransactions() throws Exception {
    // logger = null;

    int n = 500;
    String pfxUsr = "******";
    String pfxGrp = "grpAsManytestAssociateUsersInManyTransactions";

    List<User> userList = new ArrayList<User>();

    String ORGANIZATION = "ORGANIZATION";

    IdentitySession identitySession =
        identitySessionFactory.createIdentitySession("realm://JBossIdentityExample/SampleRealm");

    identitySession.beginTransaction();
    Group group =
        identitySession.getPersistenceManager().createGroup(pfxGrp + "GROUP" + n, ORGANIZATION);
    identitySession.getTransaction().commit();
    identitySession.close();

    for (int i = 0; i < n; i++) {
      identitySession.beginTransaction();
      User user = identitySession.getPersistenceManager().createUser(pfxUsr + i);
      userList.add(user);
      identitySession.getTransaction().commit();
      identitySession.close();
    }
    identitySession.beginTransaction();

    System.gc();
    for (User u : userList) {
      identitySession =
          identitySessionFactory.createIdentitySession("realm://JBossIdentityExample/SampleRealm");
      identitySession.beginTransaction();
      identitySession.getRelationshipManager().associateUser(group, u);
      identitySession.getTransaction().commit();
      identitySession.close();
      System.gc();
    }

    identitySession.close();
  }
Esempio n. 5
0
  @Test
  @Ignore
  public void testCreateUsersInManyTransactions() throws Exception {
    // logger.info("testCreateUsersInManyTransactions");
    resetMeasure();

    int n = USER_NUM;
    String pfxUsr = "******";
    String pfxGrp = "grpCrManytestCreateUsersInManyTransactions";
    String pfxRol = "rolCrManytestCreateUsersInManyTransactions";

    String ORGANIZATION = "ORGANIZATION";

    IdentitySession identitySession =
        identitySessionFactory.createIdentitySession("realm://JBossIdentityExample/SampleRealm");

    identitySession.beginTransaction();
    identitySession.getPersistenceManager().createGroup(pfxGrp + "GROUP" + n, ORGANIZATION);
    identitySession.getRoleManager().createRoleType(pfxRol + "managerMany");
    identitySession.getTransaction().commit();
    identitySession.close();

    for (int i = 0; i < n; i++) {

      identitySession.beginTransaction();

      startStopwatch();
      identitySession.getPersistenceManager().createUser(pfxUsr + i);
      stopStopwatch();
      storeStopwatch(i);

      identitySession.getTransaction().commit();
      identitySession.close();
    }

    generateGraph("testCreateUsersInManyTransactions", this.getClass().getName());
  }
Esempio n. 6
0
  @Test
  @Ignore
  public void testPopulateAndassociateIdentity1() throws Exception {
    String pfxUsr = "******";
    String pfxGrp = "grpXtestPopulateAndassociateIdentity1";
    String pfxRol = "rolXtestPopulateAndassociateIdentity1";

    String ORGANIZATION = "ORGANIZATION";

    IdentitySession identitySession =
        identitySessionFactory.createIdentitySession("realm://JBossIdentityExample/SampleRealm");
    identitySession.beginTransaction();

    //   logger.info("start creating first group!");
    Group group =
        identitySession.getPersistenceManager().createGroup(pfxGrp + "GROUP", ORGANIZATION);
    //   logger.info("stop creating first group!");

    // RoleType role = identitySession.getRoleManager().createRoleType(pfxRol+"manager");

    //    logger.info("start creating first user!");
    User user1 =
        identitySession
            .getPersistenceManager()
            .createUser("FirsttestPopulateAndassociateIdentity1User");
    //    logger.info("------------------");
    User user2 =
        identitySession
            .getPersistenceManager()
            .createUser("SecondtestPopulateAndassociateIdentity1User");
    //    logger.info("------------------");
    User user3 =
        identitySession
            .getPersistenceManager()
            .createUser("ThirdtestPopulateAndassociateIdentity1User");
    //    logger.info("stop creating first user!");

    //    logger.info("start associating first user!");
    identitySession.getRelationshipManager().associateUser(group, user1);
    //    logger.info("------------------");
    identitySession.getRelationshipManager().associateUser(group, user2);
    //     logger.info("------------------");
    identitySession.getRelationshipManager().associateUser(group, user3);
    //    logger.info("stop associating first user!");
    identitySession.getTransaction().commit();

    identitySession.close();
  }
  public void testRemoveGroups() throws Exception {

    resetMeasure();

    int n = USER_NUM;

    String pfxUsr = "******" + worker_id + ".";
    String pfxGrp = "grpGrpRem" + worker_id + ".";
    String pfxRol = "rolGrpRem" + worker_id + ".";

    String ORGANIZATION = "ORGANIZATION";

    IdentitySession identitySession =
        identitySessionFactory.createIdentitySession("realm://JBossIdentityExample/SampleRealm");
    identitySession.beginTransaction();

    Collection<Group> groupCol = new ArrayList<Group>();

    for (int i = 0; i < n; i++) {
      Group group =
          identitySession.getPersistenceManager().createGroup(pfxGrp + "GROUP" + i, ORGANIZATION);
      groupCol.add(group);
    }

    int c = 0;
    for (Group group : groupCol) {
      startStopwatch();
      identitySession.getPersistenceManager().removeGroup(group, true);
      stopStopwatch();
      storeStopwatch(c++);
      if (triggerGc) {
        System.gc();
      }
    }

    identitySession.getTransaction().commit();

    identitySession.close();

    generateGraph(getGraphNamePfx() + ".testRemoveGroups()", this.getClass().getName());
  }