Revision 9537
Added by Jing Tao over 8 years ago
test/edu/ucsb/nceas/metacat/dataone/D1NodeVersionCheckerTest.java | ||
---|---|---|
186 | 186 |
Settings.getConfiguration().setProperty("D1Client.CN_URL", "https://cn.dataone.org/cn"); |
187 | 187 |
node.setValue("urn:node:KNB"); |
188 | 188 |
checker = new D1NodeVersionChecker(node); |
189 |
assertTrue(checker.getVersion("MNReplication").equals("v1"));
|
|
189 |
assertTrue(checker.getVersion("MNReplication").equals("v2"));
|
|
190 | 190 |
node.setValue("urn:node:CN"); |
191 | 191 |
checker = new D1NodeVersionChecker(node); |
192 | 192 |
assertTrue(checker.getVersion("MNReplication") == null); |
test/edu/ucsb/nceas/metacattest/AuthLdapTest.java | ||
---|---|---|
76 | 76 |
{ |
77 | 77 |
try |
78 | 78 |
{ |
79 |
String lterUser = PropertyService.getProperty("test.lterUser"); |
|
79 |
//String lterUser = PropertyService.getProperty("test.lterUser");
|
|
80 | 80 |
//System.out.println("before initilizing authldap object"); |
81 | 81 |
AuthLdap ldap = new AuthLdap(); |
82 | 82 |
//System.out.println("after initilizing authldap object"); |
... | ... | |
87 | 87 |
if ( response != null) |
88 | 88 |
{ |
89 | 89 |
assertTrue("Couldn't find user "+anotheruser,response.indexOf(anotheruser) != -1); |
90 |
assertTrue("Couldn't find user "+lterUser,response.indexOf(lterUser) != -1); |
|
90 |
//assertTrue("Couldn't find user "+lterUser,response.indexOf(lterUser) != -1);
|
|
91 | 91 |
} |
92 | 92 |
else |
93 | 93 |
{ |
test/edu/ucsb/nceas/metacattest/LTERAccountTest.java | ||
---|---|---|
1 |
/** |
|
2 |
* '$RCSfile$' |
|
3 |
* Copyright: 2000 Regents of the University of California and the |
|
4 |
* National Center for Ecological Analysis and Synthesis |
|
5 |
* Purpose: To test the MetaCatURL class by JUnit |
|
6 |
* Authors: Jing Tao |
|
7 |
* |
|
8 |
* '$Author: tao $' |
|
9 |
* '$Date: 2014-03-04 09:48:15 -0800 (Tue, 04 Mar 2014) $' |
|
10 |
* '$Revision: 8695 $' |
|
11 |
* |
|
12 |
* This program is free software; you can redistribute it and/or modify |
|
13 |
* it under the terms of the GNU General Public License as published by |
|
14 |
* the Free Software Foundation; either version 2 of the License, or |
|
15 |
* (at your option) any later version. |
|
16 |
* |
|
17 |
* This program is distributed in the hope that it will be useful, |
|
18 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 |
* GNU General Public License for more details. |
|
21 |
* |
|
22 |
* You should have received a copy of the GNU General Public License |
|
23 |
* along with this program; if not, write to the Free Software |
|
24 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
25 |
*/ |
|
26 |
package edu.ucsb.nceas.metacattest; |
|
27 |
|
|
28 |
import edu.ucsb.nceas.metacat.AuthLdap; |
|
29 |
import edu.ucsb.nceas.metacat.properties.PropertyService; |
|
30 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
|
31 |
import junit.framework.Test; |
|
32 |
import junit.framework.TestSuite; |
|
33 |
|
|
34 |
|
|
35 |
/** |
|
36 |
* The reason to add this specific test for a LTER account is LTET ldap server is not working right |
|
37 |
* now. We centralize all tests of LTER acounts here in order to simplify the management |
|
38 |
* @author tao |
|
39 |
* |
|
40 |
*/ |
|
41 |
public class LTERAccountTest extends MetaCatServletTest{ |
|
42 |
/** |
|
43 |
* Constructor to build the test |
|
44 |
* |
|
45 |
* @param name |
|
46 |
* the name of the test method |
|
47 |
*/ |
|
48 |
public LTERAccountTest(String name) { |
|
49 |
super(name); |
|
50 |
|
|
51 |
} |
|
52 |
|
|
53 |
/** |
|
54 |
* Establish a testing framework by initializing appropriate objects |
|
55 |
*/ |
|
56 |
public void setUp() { |
|
57 |
super.setUp(); |
|
58 |
} |
|
59 |
|
|
60 |
/** |
|
61 |
* Release any objects after tests are complete |
|
62 |
*/ |
|
63 |
public void tearDown() { |
|
64 |
} |
|
65 |
|
|
66 |
/** |
|
67 |
* Create a suite of tests to be run together |
|
68 |
*/ |
|
69 |
public static Test suite() { |
|
70 |
double number = 0; |
|
71 |
|
|
72 |
TestSuite suite = new TestSuite(); |
|
73 |
suite.addTest(new LTERAccountTest("testGetPrincipals")); |
|
74 |
suite.addTest(new LTERAccountTest("testLterReferralLogin")); |
|
75 |
suite.addTest(new LTERAccountTest("testLterReferralLoginFail")); |
|
76 |
return suite; |
|
77 |
} |
|
78 |
|
|
79 |
public void testGetPrincipals() |
|
80 |
{ |
|
81 |
try |
|
82 |
{ |
|
83 |
String lterUser = PropertyService.getProperty("test.lterUser"); |
|
84 |
//System.out.println("before initilizing authldap object"); |
|
85 |
AuthLdap ldap = new AuthLdap(); |
|
86 |
//System.out.println("after initilizing authldap object"); |
|
87 |
|
|
88 |
//System.out.println("before calling the getPrincipals method"); |
|
89 |
String response = ldap.getPrincipals(username, password); |
|
90 |
//System.out.println("after calling the getPrincipals method \n"+response); |
|
91 |
if ( response != null) |
|
92 |
{ |
|
93 |
//assertTrue("Couldn't find user "+anotheruser,response.indexOf(anotheruser) != -1); |
|
94 |
assertTrue("Couldn't find user "+lterUser,response.indexOf(lterUser) != -1); |
|
95 |
} |
|
96 |
else |
|
97 |
{ |
|
98 |
fail("the response is null in getPrincipal method"); |
|
99 |
} |
|
100 |
} |
|
101 |
catch (Exception e) |
|
102 |
{ |
|
103 |
//System.out.println("Error to get principals "+e.getMessage()); |
|
104 |
fail("There is an exception in getPrincipals "+e.getMessage()); |
|
105 |
} |
|
106 |
|
|
107 |
} |
|
108 |
|
|
109 |
/** |
|
110 |
* Test the login to lter succesfully |
|
111 |
*/ |
|
112 |
public void testLterReferralLogin() { |
|
113 |
debug("\nRunning: testLterReferralLogin test"); |
|
114 |
String user = null; |
|
115 |
String passwd = null; |
|
116 |
try { |
|
117 |
user = PropertyService.getProperty("test.lterUser"); |
|
118 |
passwd = PropertyService.getProperty("test.lterPassword"); |
|
119 |
} catch (PropertyNotFoundException pnfe) { |
|
120 |
fail("Could not find property: " + pnfe.getMessage()); |
|
121 |
} |
|
122 |
|
|
123 |
debug("Logging into lter: " + user + " : " + passwd); |
|
124 |
assertTrue(logIn(user, passwd)); |
|
125 |
this.testLogOut(); |
|
126 |
|
|
127 |
|
|
128 |
} |
|
129 |
|
|
130 |
/** |
|
131 |
* Test the login to lter failed |
|
132 |
*/ |
|
133 |
public void testLterReferralLoginFail() { |
|
134 |
debug("\nRunning: testLterReferralLoginFail test"); |
|
135 |
String user = null; |
|
136 |
String passwd = "wrong"; |
|
137 |
try { |
|
138 |
user = PropertyService.getProperty("test.lterUser"); |
|
139 |
} catch (PropertyNotFoundException pnfe) { |
|
140 |
fail("Could not find property: " + pnfe.getMessage()); |
|
141 |
} |
|
142 |
assertTrue(!logIn(user, passwd)); |
|
143 |
// assertTrue( withProtocol.getProtocol().equals("http")); |
|
144 |
this.testLogOut(); |
|
145 |
|
|
146 |
} |
|
147 |
} |
test/edu/ucsb/nceas/metacattest/MetaCatServletTest.java | ||
---|---|---|
110 | 110 |
|
111 | 111 |
TestSuite suite = new TestSuite(); |
112 | 112 |
suite.addTest(new MetaCatServletTest("initialize")); |
113 |
suite.addTest(new MetaCatServletTest("testLterReferralLogin")); |
|
114 |
suite.addTest(new MetaCatServletTest("testLterReferralLoginFail")); |
|
113 |
//suite.addTest(new MetaCatServletTest("testLterReferralLogin"));
|
|
114 |
//suite.addTest(new MetaCatServletTest("testLterReferralLoginFail"));
|
|
115 | 115 |
suite.addTest(new MetaCatServletTest("testOtherReferralLogin")); |
116 | 116 |
suite.addTest(new MetaCatServletTest("testOtherReferralLoginFail")); |
117 | 117 |
suite.addTest(new MetaCatServletTest("testNCEASLoginFail")); |
... | ... | |
194 | 194 |
/** |
195 | 195 |
* Test the login to lter succesfully |
196 | 196 |
*/ |
197 |
public void testLterReferralLogin() { |
|
197 |
/*public void testLterReferralLogin() {
|
|
198 | 198 |
debug("\nRunning: testLterReferralLogin test"); |
199 | 199 |
String user = null; |
200 | 200 |
String passwd = null; |
... | ... | |
210 | 210 |
this.testLogOut(); |
211 | 211 |
|
212 | 212 |
|
213 |
} |
|
213 |
}*/
|
|
214 | 214 |
|
215 | 215 |
/** |
216 | 216 |
* Test the login to lter failed |
217 | 217 |
*/ |
218 |
public void testLterReferralLoginFail() { |
|
218 |
/*public void testLterReferralLoginFail() {
|
|
219 | 219 |
debug("\nRunning: testLterReferralLoginFail test"); |
220 | 220 |
String user = null; |
221 | 221 |
String passwd = "wrong"; |
... | ... | |
228 | 228 |
// assertTrue( withProtocol.getProtocol().equals("http")); |
229 | 229 |
this.testLogOut(); |
230 | 230 |
|
231 |
} |
|
231 |
}*/
|
|
232 | 232 |
|
233 | 233 |
/** |
234 | 234 |
* Test the login to Other succesfully |
Also available in: Unified diff
1. Set knb to version 2.
2. Centralize the lter tests into one class.