Project

General

Profile

« Previous | Next » 

Revision 8428

Added by Jing Tao almost 11 years ago

Add method to test the getusers method.

View differences:

test/edu/ucsb/nceas/metacat/authentication/AuthFileTest.java
60 60
         suite.addTest(new AuthFileTest("testAddGroup"));
61 61
         suite.addTest(new AuthFileTest("testAddUser"));
62 62
         suite.addTest(new AuthFileTest("testAuthenticate"));
63
         suite.addTest(new AuthFileTest("testGetUsers"));
63 64
         return suite;
64 65
     }
65 66
     
......
115 116
             assertTrue("The authentication should NOT succeed.", false);
116 117
         }
117 118
     }
119
     
120
     /**
121
      * Test the getUsers method
122
      * @throws Exception
123
      */
124
     public void testGetUsers() throws Exception {
125
         AuthFile authFile = AuthFile.getInstance(PASSWORDFILEPATH);
126
         String[][] users = authFile.getUsers(null, null);
127
         assertTrue("The file should have one user "+USERNAME, users[0][0].equals(USERNAME));
128
         String[]userInGroup = authFile.getUsers(null, null, GROUPNAME);
129
         assertTrue("There should be at least one user in the group "+GROUPNAME, userInGroup[0].equals(USERNAME));
130
         userInGroup = authFile.getUsers(null, null, "group1");
131
         assertTrue("There shouldn't have any users in the group1 ", userInGroup==null);
132
     }
118 133
}

Also available in: Unified diff