Project

General

Profile

« Previous | Next » 

Revision 8420

Added by Jing Tao over 10 years ago

Add a junit test for the AuthFile

View differences:

test/edu/ucsb/nceas/metacat/authentication/AuthFileTest.java
1
/**  '$RCSfile$'
2
 *  Copyright: 2010 Regents of the University of California and the
3
 *              National Center for Ecological Analysis and Synthesis
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation; either version 2 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
 */
19
package edu.ucsb.nceas.metacat.authentication;
20

  
21
import junit.framework.Test;
22
import junit.framework.TestSuite;
23
import edu.ucsb.nceas.MCTestCase;
24

  
25

  
26
public class AuthFileTest extends MCTestCase {
27
    private static final String PASSWORDFILEPATH = "build/password";
28
    private static final String GROUPNAME = "nceas-dev";
29
    /**
30
     * consstructor for the test
31
     */
32
     public AuthFileTest(String name)
33
     {
34
         super(name);
35
     }
36
   
37
     /**
38
      * Establish a testing framework by initializing appropriate objects
39
      */
40
     public void setUp() throws Exception 
41
     {
42
         super.setUp();
43
     }
44

  
45
     /**
46
      * Release any objects after tests are complete
47
      */
48
     public void tearDown() 
49
     {
50
     }
51

  
52
     /**
53
      * Create a suite of tests to be run together
54
      */
55
     public static Test suite() 
56
     {
57
         TestSuite suite = new TestSuite();
58
         //suite.addTest(new AuthFileTest(""));
59
         suite.addTest(new AuthFileTest("testAddGroup"));
60
         return suite;
61
     }
62
     
63
     /**
64
      * Test the addGroup method
65
      * @throws Exception
66
      */
67
     public void testAddGroup() throws Exception{
68
         AuthFile authFile = AuthFile.getInstance(PASSWORDFILEPATH);
69
         authFile.addGroup(GROUPNAME);
70
         try {
71
             authFile.addGroup(GROUPNAME);
72
             assertTrue("We can't reach here since we can't add the group twice", false);
73
         } catch (AuthenticationException e) {
74
             
75
         }
76
         
77
     }
78
}

Also available in: Unified diff