|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| package org.globus.cas.impl.databaseAccess; |
|
12 |
| |
|
13 |
| import junit.framework.Test; |
|
14 |
| import junit.framework.TestCase; |
|
15 |
| import junit.framework.TestSuite; |
|
16 |
| |
|
17 |
| import org.globus.cas.types.TrustAnchorData; |
|
18 |
| |
|
19 |
| import org.apache.commons.logging.Log; |
|
20 |
| import org.apache.commons.logging.LogFactory; |
|
21 |
| |
|
22 |
| public class TestTrustAnchorData extends TestCase { |
|
23 |
| |
|
24 |
| static Log logger = |
|
25 |
| LogFactory.getLog(TestTrustAnchorData.class.getName()); |
|
26 |
| |
|
27 |
0
| public TestTrustAnchorData(String name){
|
|
28 |
0
| super(name);
|
|
29 |
| } |
|
30 |
| |
|
31 |
0
| public static Test suite() {
|
|
32 |
0
| return new TestSuite(TestTrustAnchorData.class);
|
|
33 |
| } |
|
34 |
| |
|
35 |
0
| public void testTrustAnchorData() throws Exception {
|
|
36 |
| |
|
37 |
0
| String nickname = "nickname" + System.currentTimeMillis();
|
|
38 |
0
| String authMethod = "authMethod";
|
|
39 |
0
| String authData ="authData";
|
|
40 |
| |
|
41 |
| |
|
42 |
0
| TrustAnchorData trustAnchor = new TrustAnchorData();
|
|
43 |
0
| trustAnchor.setNickname(nickname);
|
|
44 |
0
| trustAnchor.setAuthMethod(authMethod);
|
|
45 |
0
| trustAnchor.setAuthData(authData);
|
|
46 |
0
| TrustAnchorDataHandler.storeObject(trustAnchor);
|
|
47 |
0
| logger.debug("Store object went through " + trustAnchor.toString());
|
|
48 |
| |
|
49 |
| |
|
50 |
0
| String[] trustAnchorList = TrustAnchorDataHandler.list();
|
|
51 |
0
| assertTrue(trustAnchorList!=null);
|
|
52 |
0
| logger.debug("Trust anchor list is " + trustAnchorList);
|
|
53 |
| |
|
54 |
| |
|
55 |
0
| TrustAnchorData retrieveAnchorData =
|
|
56 |
| (TrustAnchorData)TrustAnchorDataHandler.retrieveObject(nickname); |
|
57 |
0
| assertTrue(retrieveAnchorData!=null);
|
|
58 |
0
| logger.debug("Retrieved trust anchor " + retrieveAnchorData.toString());
|
|
59 |
0
| assertTrue(retrieveAnchorData.equals(trustAnchor));
|
|
60 |
| |
|
61 |
| |
|
62 |
0
| String retrievedNick = TrustAnchorDataHandler.getNickname(authData,
|
|
63 |
| authMethod); |
|
64 |
0
| assertTrue(retrievedNick.equals(nickname));
|
|
65 |
| |
|
66 |
0
| TrustAnchorDataHandler.deleteObject(nickname);
|
|
67 |
0
| TrustAnchorData deletedData =
|
|
68 |
| (TrustAnchorData)TrustAnchorDataHandler.retrieveObject(nickname); |
|
69 |
0
| assertTrue(deletedData == null);
|
|
70 |
| } |
|
71 |
| } |