001: /*
002: * Danet GmbH
003: * Beratung und Software-Entwicklung
004: * Geschäftstelle AN
005: *
006: * $Id: Rms.java,v 1.2 2005/08/18 14:49:12 drmlipp Exp $
007: *
008: * $Log: Rms.java,v $
009: * Revision 1.2 2005/08/18 14:49:12 drmlipp
010: * Removed staffmgmt dependend test cases.
011: *
012: * Revision 1.1.1.2 2003/12/19 13:01:52 drmlipp
013: * Updated to 1.1rc1
014: *
015: * Revision 1.23 2003/10/21 21:00:45 lipp
016: * Moved EJBClientTest to new junit sub-package.
017: *
018: * Revision 1.22 2003/10/08 11:52:55 huaiyang
019: * make test weblogic compatible.
020: *
021: * Revision 1.21 2003/10/02 13:00:39 lipp
022: * Interface improvements.
023: *
024: * Revision 1.20 2003/05/23 15:42:41 lipp
025: * Fixed deployment unit dependencies.
026: *
027: * Revision 1.19 2003/04/26 16:46:55 lipp
028: * Made unittests and systemtests coexist in eclipse.
029: *
030: * Revision 1.18 2003/04/16 19:25:04 lipp
031: * Adapted to jdk 1.4
032: *
033: * Revision 1.17 2003/01/13 20:29:42 lipp
034: * Classpath fixes.
035: *
036: * Revision 1.16 2002/12/19 21:37:42 lipp
037: * Reorganized interfaces.
038: *
039: * Revision 1.15 2002/08/30 13:37:05 lipp
040: * Using Workflow engine facade now.
041: *
042: * Revision 1.14 2002/06/27 10:48:36 lipp
043: * Adapted to change in RAS/RMS interface.
044: *
045: * Revision 1.13 2002/02/03 21:41:42 lipp
046: * Cleaned up unittests.
047: *
048: * Revision 1.12 2002/01/09 14:00:01 lipp
049: * Cleaned up relation between wfcore, resource assignment and resource
050: * management service.
051: *
052: * Revision 1.11 2002/01/09 10:23:37 lipp
053: * Removed no longer needed newRMSFactory.
054: *
055: * Revision 1.10 2001/12/19 09:04:26 robert
056: * added self configuration for the test case
057: *
058: * Revision 1.9 2001/12/18 16:11:03 robert
059: * added test case for authorizers method
060: *
061: * Revision 1.8 2001/12/18 15:50:06 robert
062: * Redesign the test cases.
063: *
064: * Revision 1.7 2001/12/18 13:08:10 robert
065: * modify to new constructors and methods of the Resource class.
066: *
067: * Revision 1.6 2001/12/17 15:22:15 robert
068: * test case for resourceByKey
069: *
070: * Revision 1.5 2001/12/17 12:14:04 lipp
071: * Adapted to configurable ResourceManagement/AssignmentServices.
072: *
073: * Revision 1.4 2001/12/13 16:19:59 robert
074: * Temporary test method for resource management service.
075: *
076: * Revision 1.3 2001/12/13 12:20:08 robert
077: * Introduced security and added JNDI test case
078: *
079: * Revision 1.2 2001/12/06 10:55:46 robert
080: * changed to correct class cast
081: *
082: * Revision 1.1 2001/12/05 13:58:44 robert
083: * basically test cases for ResourceManagementServiceFactory and
084: * ResourceManagementService
085: *
086: *
087: *
088: */
089: package rms;
090:
091: import java.util.Collection;
092: import java.util.Iterator;
093:
094: import javax.security.auth.login.LoginException;
095:
096: import de.danet.an.util.EJBUtil;
097: import de.danet.an.util.junit.EJBClientTest;
098:
099: // import de.danet.an.staffmgmt.domain.DuplicateGroupNameException;
100: // import de.danet.an.staffmgmt.domain.StaffDirectory;
101: // import de.danet.an.staffmgmt.domain.StaffGroup;
102: // import de.danet.an.staffmgmt.ejbs.StaffDirectoryHome;
103: // import de.danet.an.staffmgmt.resource.Resource;
104: import de.danet.an.workflow.spis.ras.ResourceAssignmentService;
105: import de.danet.an.workflow.spis.ras.ResourceAssignmentServiceFactory;
106: import de.danet.an.workflow.spis.rms.ResourceManagementService;
107: import de.danet.an.workflow.spis.rms.ResourceManagementServiceFactory;
108: import de.danet.an.workflow.spis.rms.ResourceNotFoundException;
109:
110: import junit.framework.*;
111:
112: import common.UTLoginContext;
113:
114: /**
115: * Zusammenstellung aller RmsObjectTests.
116: */
117: public class Rms extends TestCase {
118: private static UTLoginContext plc = null;
119: static {
120: try {
121: plc = new UTLoginContext();
122: plc.login();
123: } catch (LoginException e) {
124: throw new IllegalStateException(e.getMessage());
125: }
126: }
127:
128: /**
129: * Konstruktor zum Erzeugen eines TestCase
130: */
131: public Rms(String name) {
132: super (name);
133: }
134:
135: /**
136: * Stellt diese TestSuite zusammen.
137: */
138: public static Test suite() {
139: TestSuite suite = new TestSuite();
140: suite.addTest(new Rms("rms"));
141: return new EJBClientTest(plc, suite);
142: }
143:
144: // Lookup as service in JARs
145: public void rms() throws Exception {
146:
147: // ResourceManagementServiceFactory rmsf
148: // = ResourceManagementServiceFactory.newInstance();
149:
150: // testRMSServices(rmsf);
151: }
152:
153: private void testRMSServices(ResourceManagementServiceFactory rmsf)
154: throws Exception {
155: // StaffDirectory sd = createStaffDirectory();
156:
157: // // +++ create needed configuration +++
158: // StaffGroup testGroup = null;
159: // boolean toRemove = true;
160: // try {
161: // testGroup = sd.createStaffGroup("dfowempaffj");
162: // } catch (DuplicateGroupNameException de) {
163: // toRemove = false;
164: // }
165: // assertTrue (testGroup != null);
166: // StaffGroup adminGroup = sd.findStaffGroupByKey("0");
167: // adminGroup.addMember(testGroup);
168: // // addMember not need catch for RecursiveMembershipException
169: // // +++ end of configuration +++
170:
171: // ResourceAssignmentServiceFactory rasf
172: // = ResourceAssignmentServiceFactory.newInstance();
173: // ResourceAssignmentService ras
174: // = rasf.newResourceAssignmentService();
175:
176: // rmsf.setResourceAssignmentService (ras);
177: // ResourceManagementService rms
178: // = rmsf.newResourceManagementService();
179:
180: // // -------------- asResource ----------------
181: // // ???
182:
183: // // -------------- authorizers ----------------
184: // // StaffMember
185: // Resource mr = new Resource(ras, sd.findStaffMemberByKey("0"));
186: // Collection v = rms.authorizers(mr);
187: // boolean test = false;
188: // for (Iterator it = v.iterator(); it.hasNext(); ) {
189: // Resource authMr = (Resource)it.next();
190: // test = test || (authMr.resourceName().equals("Administratoren"));
191: // }
192: // assertTrue(test);
193: // // StaffGroup
194: // Resource gr = new Resource(ras, testGroup);
195: // v = rms.authorizers(gr);
196: // test = false;
197: // for (Iterator it = v.iterator(); it.hasNext(); ) {
198: // Resource authGr = (Resource)it.next();
199: // test = test || (authGr.resourceName().equals("Administratoren"));
200: // }
201: // assertTrue(test);
202: // // the group Administratoren retrieves an empty result.
203: // gr = new Resource(ras, sd.findStaffGroupByKey("0"));
204: // v = rms.authorizers(gr);
205: // test = false;
206: // for (Iterator it = v.iterator(); it.hasNext(); ) {
207: // Resource authGr = (Resource)it.next();
208: // test = test || (authGr.resourceName().equals("Administratoren"));
209: // }
210: // assertTrue(!test);
211:
212: // // -------------- resourceByKey ----------------
213: // Resource r = (Resource)rms.resourceByKey ("M0");
214: // assertTrue(r.resourceName().startsWith("Administrator"));
215: // r = (Resource)rms.resourceByKey ("G0");
216: // assertTrue(r.resourceName().startsWith("Administrator"));
217: // try {
218: // r = (Resource)rms.resourceByKey ("G999");
219: // } catch (ResourceNotFoundException rnfe) {
220: // assertTrue(true);
221: // }
222: // assertTrue(r.resourceName().startsWith("Administrator"));
223: // try {
224: // r = (Resource)rms.resourceByKey ("falscher Key");
225: // } catch (IllegalArgumentException iae) {
226: // assertTrue(true);
227: // }
228:
229: // // -------------- listResources ----------------
230: // v = rms.listResources();
231: // test = false;
232: // for (Iterator it = v.iterator(); it.hasNext(); ) {
233: // Resource res = (Resource)it.next();
234: // test = test || (res.resourceName().equals("Administratoren"));
235: // }
236: // assertTrue(test);
237:
238: // // +++ cleanup configuration +++
239: // if(toRemove) {
240: // sd.removeStaffGroup(testGroup.key());
241: // }
242: }
243:
244: // private StaffDirectory createStaffDirectory() throws Exception {
245: // return ((StaffDirectoryHome)EJBUtil.lookupEJBHome
246: // (StaffDirectoryHome.class,
247: // "de.danet.an.workflow.StaffDirectory")).create();
248: // }
249: }
|