|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| package org.globus.cas.impl.databaseAccess; |
|
12 |
| |
|
13 |
| import org.globus.cas.types.ServiceTypeData; |
|
14 |
| |
|
15 |
| import org.globus.cas.utils.CasStringUtils; |
|
16 |
| |
|
17 |
| import junit.framework.Test; |
|
18 |
| import junit.framework.TestCase; |
|
19 |
| import junit.framework.TestSuite; |
|
20 |
| |
|
21 |
| import org.apache.commons.logging.Log; |
|
22 |
| import org.apache.commons.logging.LogFactory; |
|
23 |
| |
|
24 |
| public class TestServiceTypeAction extends TestCase { |
|
25 |
| |
|
26 |
| static Log logger = |
|
27 |
| LogFactory.getLog(TestServiceTypeAction.class.getName()); |
|
28 |
| |
|
29 |
0
| public TestServiceTypeAction(String name){
|
|
30 |
0
| super(name);
|
|
31 |
| } |
|
32 |
| |
|
33 |
0
| public static Test suite() {
|
|
34 |
0
| return new TestSuite(TestServiceTypeAction.class);
|
|
35 |
| } |
|
36 |
| |
|
37 |
0
| public void testServiceTypeAction() throws Exception {
|
|
38 |
| |
|
39 |
0
| String serviceTypeName = "serviceTypeName";
|
|
40 |
0
| ServiceTypeData serviceTypeData = new ServiceTypeData();
|
|
41 |
0
| serviceTypeData.setName(serviceTypeName);
|
|
42 |
0
| String serviceId = ServiceTypeDataHandler.storeObject(serviceTypeData);
|
|
43 |
0
| assertTrue(serviceId!=null);
|
|
44 |
0
| logger.debug("Store service type data went through");
|
|
45 |
| |
|
46 |
0
| String actionName1 = "actionName1";
|
|
47 |
0
| String actionName2 = "actionName2";
|
|
48 |
| |
|
49 |
0
| String actionId1 =
|
|
50 |
| ServiceTypeActionHandler.addServiceActionMapping(serviceTypeName, |
|
51 |
| actionName1); |
|
52 |
0
| assertTrue(actionId1!=null);
|
|
53 |
0
| logger.debug("actionName1 added");
|
|
54 |
0
| String actionId2 =
|
|
55 |
| ServiceTypeActionHandler.addServiceActionMapping(serviceTypeName, |
|
56 |
| actionName2); |
|
57 |
0
| assertTrue(actionId2!=null);
|
|
58 |
0
| logger.debug("actionName2 added");
|
|
59 |
| |
|
60 |
| |
|
61 |
0
| String[] serviceActionMapping =
|
|
62 |
| ServiceTypeActionHandler.retrieveServiceActionMappings( |
|
63 |
| serviceTypeName); |
|
64 |
0
| assertTrue(serviceActionMapping!=null);
|
|
65 |
0
| logger.debug("mappings retrived for assertions");
|
|
66 |
0
| assertTrue(CasStringUtils.stringInArray(serviceActionMapping,
|
|
67 |
| actionName1)); |
|
68 |
0
| assertTrue(CasStringUtils.stringInArray(serviceActionMapping,
|
|
69 |
| actionName2)); |
|
70 |
| |
|
71 |
| |
|
72 |
0
| String list[] = ServiceTypeActionHandler.listServiceActionMappings();
|
|
73 |
0
| assertTrue(list != null);
|
|
74 |
0
| assertTrue(CasStringUtils.stringInArray(list, serviceTypeName + "/"
|
|
75 |
| + actionName1)); |
|
76 |
0
| assertTrue(CasStringUtils.stringInArray(list, serviceTypeName + "/"
|
|
77 |
| + actionName2)); |
|
78 |
| |
|
79 |
| |
|
80 |
0
| ServiceTypeActionHandler.removeServiceActionMapping(serviceTypeName,
|
|
81 |
| actionName2); |
|
82 |
0
| serviceActionMapping =
|
|
83 |
| ServiceTypeActionHandler.retrieveServiceActionMappings( |
|
84 |
| serviceTypeName); |
|
85 |
0
| assertTrue(serviceActionMapping!=null);
|
|
86 |
0
| assertTrue(!CasStringUtils.stringInArray(serviceActionMapping,
|
|
87 |
| actionName2)); |
|
88 |
0
| logger.debug("actionName2 removed");
|
|
89 |
| |
|
90 |
0
| String serviceGpName = "serviceGroupName";
|
|
91 |
0
| ServiceTypeActionHandler.createServiceActionGroup(serviceGpName);
|
|
92 |
0
| logger.debug("created action group");
|
|
93 |
| |
|
94 |
0
| ServiceTypeActionHandler.addServiceActionGpEntry(serviceGpName,
|
|
95 |
| serviceTypeName, |
|
96 |
| actionName1); |
|
97 |
0
| ServiceTypeActionHandler.addServiceActionMapping(serviceTypeName,
|
|
98 |
| actionName2); |
|
99 |
0
| ServiceTypeActionHandler.addServiceActionGpEntry(serviceGpName,
|
|
100 |
| serviceTypeName, |
|
101 |
| actionName2); |
|
102 |
| |
|
103 |
0
| String groupEntries[] =
|
|
104 |
| ServiceTypeActionHandler.retrieveServiceActionGpEntries( |
|
105 |
| serviceGpName); |
|
106 |
0
| assertTrue(groupEntries!=null);
|
|
107 |
0
| assertTrue(CasStringUtils.stringInArray(groupEntries, serviceTypeName
|
|
108 |
| + "/" + actionName1)); |
|
109 |
0
| assertTrue(CasStringUtils.stringInArray(groupEntries, serviceTypeName
|
|
110 |
| + "/" + actionName2)); |
|
111 |
| |
|
112 |
| |
|
113 |
| |
|
114 |
0
| String serviceGpName1 = "serviceGroupName1";
|
|
115 |
0
| ServiceTypeActionHandler.createServiceActionGroup(serviceGpName1);
|
|
116 |
| |
|
117 |
0
| ServiceTypeActionHandler.addServiceActionGpEntry(serviceGpName1,
|
|
118 |
| serviceTypeName, |
|
119 |
| actionName1); |
|
120 |
| |
|
121 |
| |
|
122 |
0
| String[] actionIdGroups
|
|
123 |
| = ServiceTypeActionHandler.retrieveServiceActionGroups(actionId1); |
|
124 |
0
| assertTrue(actionIdGroups != null);
|
|
125 |
0
| assertTrue(CasStringUtils.stringInArray(actionIdGroups,
|
|
126 |
| serviceGpName)); |
|
127 |
0
| assertTrue(CasStringUtils.stringInArray(actionIdGroups,
|
|
128 |
| serviceGpName1)); |
|
129 |
| |
|
130 |
| |
|
131 |
0
| list = ServiceTypeActionHandler.listServiceActionGroups();
|
|
132 |
0
| assertTrue(list != null);
|
|
133 |
0
| assertTrue(CasStringUtils.stringInArray(list, serviceGpName));
|
|
134 |
0
| assertTrue(CasStringUtils.stringInArray(list, serviceGpName1));
|
|
135 |
| |
|
136 |
| |
|
137 |
0
| ServiceTypeActionHandler.removeServiceActionGpEntry(serviceGpName,
|
|
138 |
| serviceTypeName, |
|
139 |
| actionName2); |
|
140 |
0
| ServiceTypeActionHandler.removeServiceActionMapping(serviceTypeName,
|
|
141 |
| actionName2); |
|
142 |
| |
|
143 |
0
| groupEntries =
|
|
144 |
| ServiceTypeActionHandler.retrieveServiceActionGpEntries( |
|
145 |
| serviceGpName); |
|
146 |
0
| assertTrue(!CasStringUtils.stringInArray(groupEntries, serviceTypeName
|
|
147 |
| + "/" + actionName2)); |
|
148 |
| |
|
149 |
0
| ServiceTypeActionHandler.removeServiceActionGpEntry(serviceGpName,
|
|
150 |
| serviceTypeName, |
|
151 |
| actionName1); |
|
152 |
| |
|
153 |
0
| ServiceTypeActionHandler.removeServiceActionGpEntry(serviceGpName1,
|
|
154 |
| serviceTypeName, |
|
155 |
| actionName1); |
|
156 |
0
| ServiceTypeActionHandler.removeServiceActionMapping(serviceTypeName,
|
|
157 |
| actionName1); |
|
158 |
| |
|
159 |
0
| ServiceTypeActionHandler.deleteServiceActionGroup(serviceGpName1);
|
|
160 |
0
| ServiceTypeActionHandler.deleteServiceActionGroup(serviceGpName);
|
|
161 |
0
| ServiceTypeDataHandler.deleteObject(serviceTypeName);
|
|
162 |
| } |
|
163 |
| } |