Esempio n. 1
0
 public void testAddGroupToRole() {
   createRole();
   try {
     roleDAO.addGroupToRole(group, role);
     assertTrue(roleDAO.getRolesForGroupName(group.getGroupName()).contains(role));
   } catch (DataAccessException e) {
     rollback();
   }
   rollback();
 }
Esempio n. 2
0
  public void testRemoveGroupFromRole() {
    System.out.println("one");
    createRole();

    try {
      roleDAO.addGroupToRole(group, role);
      assertTrue(roleDAO.getRolesForGroupName(group.getGroupName()).contains(role));
      roleDAO.removeGroupFromRole(group, role);
      assertFalse(roleDAO.getRolesForGroupName(group.getGroupName()).contains(role));
    } catch (DataAccessException e) {
      e.printStackTrace();
      rollback();
      fail();
    }
    rollback();
  }
Esempio n. 3
0
 /** Roll back if role was added */
 private void rollback() {
   try {
     roleDAO.remove(role);
   } catch (DataAccessException e) {
     e.printStackTrace();
     fail();
   }
 }
Esempio n. 4
0
 public void testGetRolesForGroupName() {
   try {
     assertTrue(
         roleDAO.getRolesForGroupName("Everyone").contains(new RoleTO("Authenticated_users")));
   } catch (DataAccessException e) {
     e.printStackTrace();
     fail();
   }
 }
Esempio n. 5
0
  public void testGetAllRoles() {
    try {

      assertNotNull(roleDAO.getAllRoles());
    } catch (DataAccessException e) {
      e.printStackTrace();
      fail();
    }
  }
Esempio n. 6
0
 /** Utility method for adding a user */
 private void createRole() {
   try {
     roleDAO.create(role);
   } catch (DataAccessException e) {
     rollback();
     e.printStackTrace();
     fail();
   }
 }
Esempio n. 7
0
  public void testCreateAndRemove() {

    createRole();
    try {
      assertTrue(roleDAO.getAllRoles().contains(role));
    } catch (DataAccessException e) {
      e.printStackTrace();
    }
    rollback();
  }