0001: package hero.client.test;
0002:
0003: /*
0004: *
0005: * NodeTests.java -
0006: * Copyright (C) 2002 Ecoo Team
0007: * charoy@loria.fr
0008: *
0009: *
0010: * This program is free software; you can redistribute it and/or
0011: * modify it under the terms of the GNU Lesser General Public License
0012: * as published by the Free Software Foundation; either version 2
0013: * of the License, or (at your option) any later version.
0014: *
0015: * This program is distributed in the hope that it will be useful,
0016: * but WITHOUT ANY WARRANTY; without even the implied warranty of
0017: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0018: * GNU Lesser General Public License for more details.
0019: *
0020: * You should have received a copy of the GNU Lesser General Public License
0021: * along with this program; if not, write to the Free Software
0022: * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
0023: */
0024:
0025: import javax.security.auth.login.LoginContext;
0026:
0027: import hero.interfaces.BnNodeLightValue;
0028: import hero.interfaces.BnNodeValue;
0029: import hero.interfaces.BnProject;
0030: import hero.interfaces.BnProjectHome;
0031: import hero.interfaces.BnProjectUtil;
0032: import hero.interfaces.BnUserHome;
0033: import hero.interfaces.BnUserPropertyValue;
0034: import hero.interfaces.Constants;
0035: import hero.interfaces.ProjectSession;
0036: import hero.interfaces.ProjectSessionHome;
0037: import hero.interfaces.ProjectSessionUtil;
0038: import hero.interfaces.UserSession;
0039: import hero.interfaces.UserSessionHome;
0040: import hero.interfaces.UserSessionUtil;
0041: import hero.util.HeroException;
0042:
0043: import java.util.Collection;
0044: import java.util.Hashtable;
0045: import java.util.Iterator;
0046:
0047: import org.apache.axis.client.Call;
0048: import org.apache.axis.client.Service;
0049:
0050: import junit.framework.TestCase;
0051: import junit.framework.TestSuite;
0052:
0053: import hero.interfaces.UserRegistration;
0054: import hero.interfaces.UserRegistrationHome;
0055: import hero.interfaces.UserRegistrationUtil;
0056:
0057: public class UserSessionTests extends TestCase {
0058:
0059: private BnProjectHome projecth;
0060: private ProjectSessionHome projectsesh;
0061: private BnUserHome userh;
0062: private UserSessionHome usersessionh;
0063:
0064: public UserSessionTests(String testname) {
0065: super (testname);
0066: }
0067:
0068: public static TestSuite suite() {
0069: return new TestSuite(UserSessionTests.class);
0070: }
0071:
0072: public void setUp() throws Exception {
0073: }
0074:
0075: public void testGetProjectListSession() throws Exception {
0076: projectsesh = ProjectSessionUtil.getHome();
0077: ProjectSession p = projectsesh.create();
0078: p.initProject("Failure");
0079: p.addNode("t1", 1);
0080: p.addNode("t2", 1);
0081: p.addEdge("t1", "t2");
0082: usersessionh = UserSessionUtil.getHome();
0083: UserSession usersession = usersessionh.create();
0084: ProjectSession lproj1 = projectsesh.create();
0085: lproj1.initProject("p1SS");
0086: ProjectSession lproj2 = projectsesh.create();
0087: lproj2.initProject("p2SS");
0088: System.out.println("usersession home ?" + usersessionh);
0089:
0090: System.out.println("usersession ?" + usersession);
0091: Collection c = usersession.getProjectList();
0092: assertTrue("getProjectList Error", c.size() != 0);
0093: Collection c2 = usersession.getToDoList("p1SS");
0094: Collection c3 = usersession.getToDoList("p2SS");
0095: usersession.startActivity("Failure", "t1");
0096: usersession.startActivity("Failure", "t2");
0097: usersession.terminateActivity("Failure", "t1");
0098: }
0099:
0100: public void testGetProjectList() throws Exception {
0101: projectsesh = ProjectSessionUtil.getHome();
0102: usersessionh = UserSessionUtil.getHome();
0103: UserSession usersession = usersessionh.create();
0104: ProjectSession lproj1 = projectsesh.create();
0105: lproj1.initProject("p1");
0106: ProjectSession lproj2 = projectsesh.create();
0107: lproj2.initProject("p2");
0108: System.out.println("usersession home ?" + usersessionh);
0109:
0110: System.out.println("usersession ?" + usersession);
0111: Collection c = usersession.getProjectList();
0112: assertTrue("getProjectList Error", c.size() != 0);
0113: }
0114:
0115: // getToDoList test method in order to verify user ready activities
0116:
0117: public void testGetToDoList1() throws Exception {
0118: projectsesh = ProjectSessionUtil.getHome();
0119: usersessionh = UserSessionUtil.getHome();
0120: ProjectSession proj = projectsesh.create();
0121: proj.initProject("p3");
0122:
0123: proj.addNode("name1", Constants.Nd.AND_JOIN_NODE);
0124: proj.setUserRole("admin", "InitialRole");
0125:
0126: UserSession usersession = usersessionh.create();
0127: Collection c = usersession.getToDoList("p3");
0128: Iterator i = c.iterator();
0129: assertTrue("getToDoList Error", ((String) i.next())
0130: .equals("name1"));
0131: }
0132:
0133: public void testGetToDoList2() throws Exception {
0134: projectsesh = ProjectSessionUtil.getHome();
0135: usersessionh = UserSessionUtil.getHome();
0136: ProjectSession proj = projectsesh.create();
0137: proj.initProject("p4");
0138:
0139: proj.addNode("name1", Constants.Nd.AND_JOIN_NODE);
0140: proj.addNode("name2", Constants.Nd.AND_JOIN_NODE);
0141:
0142: proj.setUserRole("admin", "InitialRole");
0143:
0144: UserSession usersession = usersessionh.create();
0145: Collection c = usersession.getToDoList("p4");
0146: Iterator i = c.iterator();
0147: String node1 = (String) i.next();
0148: String node2 = (String) i.next();
0149:
0150: assertTrue("getToDoList Error", node1.equals("name1")
0151: || node1.equals("name2"));
0152: assertTrue("getToDoList Error", node2.equals("name1")
0153: || node2.equals("name2"));
0154: }
0155:
0156: // getActivityList test method in order to verify startActivity method
0157: // and obtain new executing users activities
0158:
0159: public void testGetActivityList() throws Exception {
0160: projectsesh = ProjectSessionUtil.getHome();
0161: usersessionh = UserSessionUtil.getHome();
0162: ProjectSession proj = projectsesh.create();
0163: proj.initProject("p5");
0164:
0165: proj.addNode("NodeExecuting", Constants.Nd.AND_JOIN_NODE);
0166:
0167: proj.setUserRole("admin", "InitialRole");
0168:
0169: UserSession usersession = usersessionh.create();
0170: Collection c = usersession.getActivityList("p5");
0171: assertTrue("getActivityList Error", c.size() == 0);
0172: usersession.startActivity("p5", "NodeExecuting");
0173: c = usersession.getActivityList("p5");
0174: Iterator i = c.iterator();
0175: assertTrue("getActivityList Error", ((String) i.next())
0176: .equals("NodeExecuting"));
0177: }
0178:
0179: public void testGetNode() throws Exception {
0180: projectsesh = ProjectSessionUtil.getHome();
0181: usersessionh = UserSessionUtil.getHome();
0182: ProjectSession proj = projectsesh.create();
0183: proj.initProject("testgetnode");
0184: proj.addNode("pouet", Constants.Nd.AND_JOIN_NODE);
0185: UserSession usr = usersessionh.create();
0186: try {
0187: BnNodeValue nv = usr.getNode("testgetnode", "pouet");
0188: } catch (HeroException h) {
0189: assertTrue("Should be a success", false);
0190: }
0191: }
0192:
0193: public void testProperty() throws Exception {
0194: usersessionh = UserSessionUtil.getHome();
0195: UserSession usr = usersessionh.create();
0196:
0197: usr.setUserProperty("prop1", "val1");
0198: usr.setUserProperty("prop2", "val2");
0199: usr.setUserProperty("prop3", "val3");
0200:
0201: }
0202:
0203: public void testDeleteProperty() throws Exception {
0204: usersessionh = UserSessionUtil.getHome();
0205: UserSession usr = usersessionh.create();
0206: usr.deleteUserProperty("prop2");
0207: usr.deleteUserProperty("prop3");
0208: }
0209:
0210: public void testGetProperties() throws Exception {
0211: usersessionh = UserSessionUtil.getHome();
0212: UserSession usr = usersessionh.create();
0213:
0214: Collection c = usr.getUserProperties();
0215:
0216: for (Iterator i = c.iterator(); i.hasNext();) {
0217: BnUserPropertyValue p = (BnUserPropertyValue) i.next();
0218: String key = p.getTheKey();
0219: String value = p.getTheValue();
0220: assertTrue("Get Properties", key.equalsIgnoreCase("prop1"));
0221:
0222: }
0223: }
0224:
0225: public void testSpeedCheckOneCallRMI() throws Exception {
0226: usersessionh = UserSessionUtil.getHome();
0227: UserSession usr = usersessionh.create();
0228: usr.getUser();
0229: usr.getUserPassword();
0230:
0231: }
0232:
0233: public void testSpeedCheckTenCallRMI() throws Exception {
0234: usersessionh = UserSessionUtil.getHome();
0235: UserSession usr = usersessionh.create();
0236: for (int i = 0; i < 10; i++) {
0237: usr.getUser();
0238: usr.getUserPassword();
0239: }
0240: }
0241:
0242: public void testSpeedCheckOneCallSOAP() throws Exception {
0243: String endpoint = System.getProperty("bonita.host")
0244: + "/bonita_ws/services/UserSession";
0245:
0246: Service service = new Service();
0247: Call call = (Call) service.createCall();
0248:
0249: call.setTargetEndpointAddress(new java.net.URL(endpoint));
0250:
0251: call.setMaintainSession(true);
0252: call.setUsername("admin");
0253: call.setPassword("toto");
0254:
0255: call.setOperationName("getUser");
0256: String resp = (String) call.invoke(new Object[] {});
0257: call.setOperationName("getUserPassword");
0258: String ret2 = (String) call.invoke(new Object[] {});
0259:
0260: }
0261:
0262: public void testSpeedCheckTenCallSOAP() throws Exception {
0263: String endpoint = System.getProperty("bonita.host")
0264: + "/bonita_ws/services/UserSession";
0265:
0266: Service service = new Service();
0267: Call call = (Call) service.createCall();
0268:
0269: call.setTargetEndpointAddress(new java.net.URL(endpoint));
0270:
0271: call.setMaintainSession(true);
0272: call.setUsername("admin");
0273: call.setPassword("toto");
0274:
0275: for (int i = 0; i < 10; i++) {
0276: call.setOperationName("getUser");
0277: String resp = (String) call.invoke(new Object[] {});
0278: call.setOperationName("getUserPassword");
0279: String ret2 = (String) call.invoke(new Object[] {});
0280: }
0281: }
0282:
0283: public void testGetProjectInstances() throws Exception {
0284: projectsesh = ProjectSessionUtil.getHome();
0285: ProjectSession p = projectsesh.create();
0286: p.initModel("GPI");
0287: p.initModel("GPIGPI");
0288:
0289: String name1 = p.instantiateProject("GPI");
0290: String name2 = p.instantiateProject("GPI");
0291:
0292: usersessionh = UserSessionUtil.getHome();
0293: UserSession usr = usersessionh.create();
0294:
0295: Collection instances = usr.getProjectInstancesNames("GPI");
0296: assertTrue("getProjectInstances Error", instances.size() == 2);
0297: }
0298:
0299: public void testInstancesByProperty() throws Exception {
0300: ProjectSessionHome projectSessionh = ProjectSessionUtil
0301: .getHome();
0302: ProjectSession ps = projectSessionh.create();
0303: ps.initModel("instProp");
0304:
0305: ProjectSession ps2 = projectSessionh.create();
0306: ps2.initModel("instProp2");
0307:
0308: ProjectSession ps3 = projectSessionh.create();
0309: ps3.initModel("instProp3");
0310:
0311: ps.setProperty("id", "1234");
0312: ps2.setProperty("id", "1234");
0313: ps3.setProperty("id2", "1234");
0314:
0315: UserSessionHome uHome = UserSessionUtil.getHome();
0316: UserSession usersession = uHome.create();
0317: Collection names = usersession.getInstancesByPropertyNames(
0318: "id", "1234");
0319:
0320: assertTrue("Error in Instances by Property. Project error",
0321: names.size() == 0);
0322: String prop1 = ps.instantiateProject("instProp");
0323: String prop2 = ps2.instantiateProject("instProp2");
0324: String prop3 = ps3.instantiateProject("instProp3");
0325: ps.setProperty("id", "1234");
0326: ps2.setProperty("id", "1234");
0327: ps3.setProperty("id2", "1234");
0328: names = usersession.getInstancesByPropertyNames("id", "1234");
0329: assertTrue("Error in Instances by Property. Instance error",
0330: names.size() == 2);
0331: }
0332:
0333: public void testProjectsByProperty() throws Exception {
0334: ProjectSessionHome projectSessionh = ProjectSessionUtil
0335: .getHome();
0336: ProjectSession ps = projectSessionh.create();
0337: ps.initModel("projProp");
0338:
0339: ProjectSession ps2 = projectSessionh.create();
0340: ps2.initModel("projProp2");
0341:
0342: ps.setProperty("id", "123");
0343: ps2.setProperty("id", "123");
0344:
0345: UserSessionHome uHome = UserSessionUtil.getHome();
0346: UserSession usersession = uHome.create();
0347: Collection names = usersession.getProjectsByPropertyNames("id",
0348: "123");
0349:
0350: assertTrue("Error in Projects by Property", names.size() == 2);
0351: String prop1 = ps.instantiateProject("projProp");
0352: String prop2 = ps2.instantiateProject("projProp2");
0353: ps.setProperty("id", "123");
0354: ps2.setProperty("id", "123");
0355: names = usersession.getProjectsByPropertyNames("id", "123");
0356: assertTrue("Error in Projects by Property", names.size() == 2);
0357: }
0358:
0359: public void testGetInstancesList() throws Exception {
0360: UserRegistrationHome urHome = UserRegistrationUtil.getHome();
0361: UserRegistration userReg = urHome.create();
0362: userReg.userCreate("GetInst", "GetInst",
0363: "miguel.valdes-faura@bull.net");
0364:
0365: ProjectSessionHome projectSessionh = ProjectSessionUtil
0366: .getHome();
0367: ProjectSession ps = projectSessionh.create();
0368: ps.initModel("GetInstancesList");
0369: ps.addNode("node1", 1);
0370: ps.addUser("GetInst");
0371: ps.setNodeRole("node1", "GetInst");
0372:
0373: ProjectSession ps2 = projectSessionh.create();
0374: ps2.initModel("GetInstancesList2");
0375:
0376: ProjectSession ps3 = projectSessionh.create();
0377: ps3.initModel("GetInstancesList3");
0378: ps3.addNode("node1", 1);
0379: ps3.addUser("GetInst");
0380: ps3.setNodeRole("node1", "GetInst");
0381:
0382: SimpleCallbackHandler handler = new SimpleCallbackHandler(
0383: "GetInst", "GetInst".toCharArray());
0384: LoginContext lc = new LoginContext("TestClient", handler);
0385: lc.login();
0386:
0387: UserSessionHome uHome = UserSessionUtil.getHome();
0388: UserSession usersession = uHome.create();
0389:
0390: Collection names = usersession.getInstancesListNames();
0391: assertTrue("Error in getInstancesList. GetInstancesListNames",
0392: names.size() == 0);
0393:
0394: names = usersession.getProjectListNames();
0395: assertTrue("Error in getInstancesList. GetProjectListNames",
0396: names.size() == 2);
0397:
0398: names = usersession.getInstancesList();
0399: assertTrue("Error in getInstancesList. GetInstancesList", names
0400: .size() == 0);
0401:
0402: names = usersession.getProjectList();
0403: assertTrue("Error in getInstancesList. GetProjectList", names
0404: .size() == 2);
0405:
0406: ps.instantiateProject("GetInstancesList");
0407: ps.instantiateProject("GetInstancesList3");
0408:
0409: names = usersession.getInstancesListNames();
0410: assertTrue("Error in getInstancesList. GetInstancesListNames",
0411: names.size() == 2);
0412:
0413: names = usersession.getProjectListNames();
0414: assertTrue("Error in getInstancesList. GetProjectListNames",
0415: names.size() == 4);
0416:
0417: names = usersession.getInstancesList();
0418: assertTrue("Error in getInstancesList. GetInstancesList", names
0419: .size() == 2);
0420:
0421: names = usersession.getProjectList();
0422: assertTrue("Error in getInstancesList. GetProjectList", names
0423: .size() == 4);
0424:
0425: char[] password2 = { 't', 'o', 't', 'o' };
0426: handler = new SimpleCallbackHandler("admin", password2);
0427: lc = new LoginContext("TestClient", handler);
0428: lc.login();
0429: }
0430:
0431: public void testGetTodoListAllInstances() throws Exception {
0432: UserRegistrationHome urHome = UserRegistrationUtil.getHome();
0433: UserRegistration userReg = urHome.create();
0434: userReg.userCreate("tdai", "tdai",
0435: "miguel.valdes-faura@bull.net");
0436:
0437: ProjectSessionHome projectSessionh = ProjectSessionUtil
0438: .getHome();
0439: ProjectSession ps = projectSessionh.create();
0440: ps.initModel("TDAI");
0441: ps.addNode("node1", 1);
0442: ps.addNode("node2", 1);
0443: ps.addUser("tdai");
0444: ps.setNodeRole("node1", "tdai");
0445:
0446: ProjectSession ps2 = projectSessionh.create();
0447: ps2.initModel("TDAI2");
0448: ps2.addNode("node2", 1);
0449:
0450: ProjectSession ps3 = projectSessionh.create();
0451: ps3.initModel("TDAI3");
0452: ps3.addNode("node1", 1);
0453: ps3.addNode("node2", 1);
0454: ps3.addUser("tdai");
0455: ps3.setNodeRole("node1", "tdai");
0456:
0457: ProjectSession ps4 = projectSessionh.create();
0458: ps4.initProject("TDAI4");
0459: ps4.addNode("node1", 1);
0460: ps4.addUser("tdai");
0461: ps4.setNodeRole("node1", "tdai");
0462:
0463: SimpleCallbackHandler handler = new SimpleCallbackHandler(
0464: "tdai", "tdai".toCharArray());
0465: LoginContext lc = new LoginContext("TestClient", handler);
0466: lc.login();
0467:
0468: ps.instantiateProject("TDAI");
0469: ps2.instantiateProject("TDAI2");
0470: ps3.instantiateProject("TDAI3");
0471:
0472: UserSessionHome uHome = UserSessionUtil.getHome();
0473: UserSession usersession = uHome.create();
0474:
0475: Collection names = usersession.getToDoListAllInstances();
0476: assertTrue("Error in getTodoListAllInstances",
0477: names.size() == 3);
0478:
0479: char[] password2 = { 't', 'o', 't', 'o' };
0480: handler = new SimpleCallbackHandler("admin", password2);
0481: lc = new LoginContext("TestClient", handler);
0482: lc.login();
0483: }
0484:
0485: public void testGetActivityListAllInstances() throws Exception {
0486: UserRegistrationHome urHome = UserRegistrationUtil.getHome();
0487: UserRegistration userReg = urHome.create();
0488: userReg.userCreate("taai", "taai",
0489: "miguel.valdes-faura@bull.net");
0490:
0491: ProjectSessionHome projectSessionh = ProjectSessionUtil
0492: .getHome();
0493: ProjectSession ps = projectSessionh.create();
0494: ps.initModel("TAAI");
0495: ps.addNode("node1", 1);
0496: ps.addNode("node2", 1);
0497: ps.addUser("taai");
0498: ps.setNodeRole("node1", "taai");
0499:
0500: ProjectSession ps2 = projectSessionh.create();
0501: ps2.initModel("TAAI2");
0502: ps2.addNode("node2", 1);
0503:
0504: ProjectSession ps3 = projectSessionh.create();
0505: ps3.initModel("TAAI3");
0506: ps3.addNode("node1", 1);
0507: ps3.addNode("node2", 1);
0508: ps3.addUser("taai");
0509: ps3.setNodeRole("node1", "taai");
0510:
0511: SimpleCallbackHandler handler = new SimpleCallbackHandler(
0512: "taai", "taai".toCharArray());
0513: LoginContext lc = new LoginContext("TestClient", handler);
0514: lc.login();
0515:
0516: String name1 = ps.instantiateProject("TAAI");
0517: String name2 = ps2.instantiateProject("TAAI2");
0518: String name3 = ps3.instantiateProject("TAAI3");
0519:
0520: UserSessionHome uHome = UserSessionUtil.getHome();
0521: UserSession usersession = uHome.create();
0522:
0523: Collection names = usersession.getActivityListAllInstances();
0524: assertTrue("Error in getActivityAllInstancesList.1 ", names
0525: .size() == 0);
0526:
0527: usersession.startActivity(name1, "node1");
0528:
0529: names = usersession.getActivityListAllInstances();
0530: assertTrue("Error in getActivityAllInstancesList.2 ", names
0531: .size() == 1);
0532:
0533: usersession.startActivity(name3, "node1");
0534:
0535: names = usersession.getActivityListAllInstances();
0536: assertTrue("Error in getActivityAllInstancesList.3 ", names
0537: .size() == 2);
0538:
0539: usersession.terminateActivity(name3, "node1");
0540:
0541: names = usersession.getActivityListAllInstances();
0542: assertTrue("Error in getActivityAllInstancesList.4 ", names
0543: .size() == 1);
0544:
0545: char[] password2 = { 't', 'o', 't', 'o' };
0546: handler = new SimpleCallbackHandler("admin", password2);
0547: lc = new LoginContext("TestClient", handler);
0548: lc.login();
0549: }
0550:
0551: public void testGetTodoListByProperty() throws Exception {
0552: UserRegistrationHome urHome = UserRegistrationUtil.getHome();
0553: UserRegistration userReg = urHome.create();
0554: userReg
0555: .userCreate("tdp", "tdp",
0556: "miguel.valdes-faura@bull.net");
0557:
0558: ProjectSessionHome projectSessionh = ProjectSessionUtil
0559: .getHome();
0560: ProjectSession ps = projectSessionh.create();
0561: ps.initModel("TDP");
0562: ps.addNode("node1", 1);
0563: ps.setProperty("test", "111");
0564: ps.setNodeProperty("node1", "test", "111");
0565: ps.setNodeProperty("node1", "test", "1112");
0566: ps.addNode("node2", 1);
0567: ps.addUser("tdp");
0568: ps.setNodeRole("node1", "tdp");
0569: ps.setNodeRole("node2", "tdp");
0570:
0571: ProjectSession ps2 = projectSessionh.create();
0572: ps2.initModel("TDP2");
0573: ps2.addNode("node2", 1);
0574:
0575: ProjectSession ps3 = projectSessionh.create();
0576: ps3.initModel("TDP3");
0577: ps3.addNode("node1", 1);
0578: ps3.setNodeProperty("node1", "test", "111");
0579: ps3.addNode("node2", 1);
0580: ps3.setNodeProperty("node2", "test3", "111");
0581: ps3.addUser("tdp");
0582: ps3.setNodeRole("node1", "tdp");
0583:
0584: SimpleCallbackHandler handler = new SimpleCallbackHandler(
0585: "tdp", "tdp".toCharArray());
0586: LoginContext lc = new LoginContext("TestClient", handler);
0587: lc.login();
0588:
0589: String name = ps.instantiateProject("TDP");
0590: ps.setNodeProperty("node2", "test", "111");
0591: ps.setProperty("test", "111");
0592: ps2.instantiateProject("TDP2");
0593: ps3.instantiateProject("TDP3");
0594:
0595: UserSessionHome uHome = UserSessionUtil.getHome();
0596: UserSession usersession = uHome.create();
0597:
0598: Collection names = usersession.getToDoListByProperty("test",
0599: "111");
0600: assertTrue("Error in getTodoListByProperty.1",
0601: names.size() == 2);
0602:
0603: ps.setNodeProperty("node1", "test", "111");
0604: ps.setNodeProperty("node2", "test3", "11122");
0605:
0606: ps.setProperty("test", "111");
0607: ps.setProperty("test3", "11122");
0608:
0609: names = usersession.getToDoListByProperty("test", "111");
0610: assertTrue("Error in getTodoListByProperty.2",
0611: names.size() == 2);
0612:
0613: names = usersession.getToDoListByProperty("test", "1111");
0614: assertTrue("Error in getTodoListByProperty.3",
0615: names.size() == 0);
0616:
0617: usersession.startActivity(name, "node1");
0618:
0619: names = usersession.getToDoListByProperty("test", "111");
0620: assertTrue("Error in getTodoListByProperty.4",
0621: names.size() == 1);
0622:
0623: char[] password2 = { 't', 'o', 't', 'o' };
0624: handler = new SimpleCallbackHandler("admin", password2);
0625: lc = new LoginContext("TestClient", handler);
0626: lc.login();
0627: }
0628:
0629: public void testGetTodoListByPropertiesAND() throws Exception {
0630: UserRegistrationHome urHome = UserRegistrationUtil.getHome();
0631: UserRegistration userReg = urHome.create();
0632: userReg.userCreate("tdtp", "tdtp",
0633: "miguel.valdes-faura@bull.net");
0634:
0635: ProjectSessionHome projectSessionh = ProjectSessionUtil
0636: .getHome();
0637: ProjectSession ps = projectSessionh.create();
0638: ps.initModel("TDTP");
0639: ps.addNode("node1", 1);
0640: ps.setProperty("test", "111");
0641: ps.setNodeProperty("node1", "test", "111");
0642: ps.setProperty("testTwo", "1112");
0643: ps.addNode("node2", 1);
0644: ps.addUser("tdtp");
0645: ps.setNodeRole("node1", "tdtp");
0646: ps.setNodeRole("node2", "tdtp");
0647:
0648: ProjectSession ps2 = projectSessionh.create();
0649: ps2.initModel("TDTP2");
0650: ps2.addNode("node2", 1);
0651:
0652: ProjectSession ps3 = projectSessionh.create();
0653: ps3.initModel("TDTP3");
0654: ps3.addNode("node1", 1);
0655: ps3.setNodeProperty("node1", "test", "111");
0656: ps3.addNode("node2", 1);
0657: ps3.setNodeProperty("node2", "test3", "111");
0658: ps3.addUser("tdtp");
0659: ps3.setNodeRole("node1", "tdtp");
0660:
0661: SimpleCallbackHandler handler = new SimpleCallbackHandler(
0662: "tdtp", "tdtp".toCharArray());
0663: LoginContext lc = new LoginContext("TestClient", handler);
0664: lc.login();
0665:
0666: String name = ps.instantiateProject("TDTP");
0667: ps.setNodeProperty("node2", "test", "111");
0668: ps.setProperty("test", "111");
0669: ps2.instantiateProject("TDTP2");
0670: ps3.instantiateProject("TDTP3");
0671:
0672: UserSessionHome uHome = UserSessionUtil.getHome();
0673: UserSession usersession = uHome.create();
0674:
0675: Hashtable prop = new Hashtable();
0676: prop.put("test", "111");
0677:
0678: Collection names = usersession.getToDoListByProperties(
0679: Constants.AND, prop);
0680: assertTrue("Error in getTodoListByProperties.0",
0681: names.size() == 2);
0682:
0683: prop.put("testTwo", "1112");
0684:
0685: names = usersession
0686: .getToDoListByProperties(Constants.AND, prop);
0687: assertTrue("Error in getTodoListByProperties.1",
0688: names.size() == 2);
0689:
0690: ps.setNodeProperty("node1", "test", "111");
0691: ps.setNodeProperty("node2", "test3", "11122");
0692:
0693: ps2.setProperty("test", "111");
0694: ps2.setProperty("testTwo", "1112");
0695: ps2.setProperty("testThree", "1113");
0696: ps3.setProperty("test", "111");
0697: ps3.setProperty("testTwo", "1112");
0698: ps3.setProperty("testThree", "1113");
0699:
0700: names = usersession
0701: .getToDoListByProperties(Constants.AND, prop);
0702: assertTrue("Error in getTodoListByProperties.2",
0703: names.size() == 3);
0704:
0705: prop.put("testTwo", "1114");
0706:
0707: names = usersession
0708: .getToDoListByProperties(Constants.AND, prop);
0709: assertTrue("Error in getTodoListByProperties.3",
0710: names.size() == 0);
0711:
0712: usersession.startActivity(name, "node1");
0713:
0714: prop.put("testTwo", "1112");
0715: prop.put("testThree", "1113");
0716:
0717: names = usersession
0718: .getToDoListByProperties(Constants.AND, prop);
0719: assertTrue("Error in getTodoListByProperties.4",
0720: names.size() == 1);
0721:
0722: char[] password2 = { 't', 'o', 't', 'o' };
0723: handler = new SimpleCallbackHandler("admin", password2);
0724: lc = new LoginContext("TestClient", handler);
0725: lc.login();
0726: }
0727:
0728: public void testGetTodoListByPropertiesOR() throws Exception {
0729: UserRegistrationHome urHome = UserRegistrationUtil.getHome();
0730: UserRegistration userReg = urHome.create();
0731: userReg.userCreate("tdtpor", "tdtpor",
0732: "miguel.valdes-faura@bull.net");
0733:
0734: ProjectSessionHome projectSessionh = ProjectSessionUtil
0735: .getHome();
0736: ProjectSession ps = projectSessionh.create();
0737: ps.initModel("TDTPOR");
0738: ps.addNode("node1", 1);
0739: ps.setProperty("test", "111");
0740: ps.setNodeProperty("node1", "test", "111");
0741: ps.setProperty("testTwo", "1112");
0742: ps.addNode("node2", 1);
0743: ps.addUser("tdtpor");
0744: ps.setNodeRole("node1", "tdtpor");
0745: ps.setNodeRole("node2", "tdtpor");
0746:
0747: ProjectSession ps2 = projectSessionh.create();
0748: ps2.initModel("TDTP2OR");
0749: ps2.addNode("node2", 1);
0750:
0751: ProjectSession ps3 = projectSessionh.create();
0752: ps3.initModel("TDTP3OR");
0753: ps3.addNode("node1", 1);
0754: ps3.setNodeProperty("node1", "test", "111");
0755: ps3.addNode("node2", 1);
0756: ps3.setNodeProperty("node2", "test3", "111");
0757: ps3.addUser("tdtpor");
0758: ps3.setNodeRole("node1", "tdtpor");
0759:
0760: SimpleCallbackHandler handler = new SimpleCallbackHandler(
0761: "tdtpor", "tdtpor".toCharArray());
0762: LoginContext lc = new LoginContext("TestClient", handler);
0763: lc.login();
0764:
0765: String name = ps.instantiateProject("TDTPOR");
0766: ps.setNodeProperty("node2", "test", "111");
0767: ps.setProperty("test", "111");
0768: ps2.instantiateProject("TDTP2OR");
0769: ps3.instantiateProject("TDTP3OR");
0770: ps3.setProperty("testTwo", "1112");
0771:
0772: UserSessionHome uHome = UserSessionUtil.getHome();
0773: UserSession usersession = uHome.create();
0774:
0775: Hashtable prop = new Hashtable();
0776: prop.put("test", "111");
0777:
0778: Collection names = usersession.getToDoListByProperties(
0779: Constants.OR, prop);
0780: assertTrue("Error in getTodoListByProperties.0",
0781: names.size() == 2);
0782:
0783: prop.put("testTwo", "1112");
0784:
0785: names = usersession.getToDoListByProperties(Constants.OR, prop);
0786: assertTrue("Error in getTodoListByProperties.1-> "
0787: + names.size(), names.size() == 3);
0788:
0789: ps.setNodeProperty("node1", "test", "111");
0790: ps.setNodeProperty("node2", "test3", "11122");
0791:
0792: ps2.setProperty("test", "111");
0793: ps2.setProperty("testTwo", "1112");
0794: ps2.setProperty("testThree", "1113");
0795: ps3.setProperty("test", "111");
0796: ps3.setProperty("testTwo", "1112");
0797: ps3.setProperty("testThree", "1113");
0798:
0799: names = usersession.getToDoListByProperties(Constants.OR, prop);
0800: assertTrue("Error in getTodoListByProperties.2",
0801: names.size() == 3);
0802:
0803: prop.put("testThree", "1113");
0804:
0805: names = usersession.getToDoListByProperties(Constants.OR, prop);
0806: assertTrue("Error in getTodoListByProperties.3",
0807: names.size() == 3);
0808:
0809: prop.put("testFour", "1114");
0810: try {
0811: names = usersession.getToDoListByProperties(Constants.OR,
0812: prop);
0813: assertTrue(
0814: "Error in getToDoListByProperties.4, operation should be failed",
0815: false);
0816: } catch (Exception e) {
0817: }
0818:
0819: char[] password2 = { 't', 'o', 't', 'o' };
0820: handler = new SimpleCallbackHandler("admin", password2);
0821: lc = new LoginContext("TestClient", handler);
0822: lc.login();
0823: }
0824:
0825: public void testActivityListByProperty() throws Exception {
0826: UserRegistrationHome urHome = UserRegistrationUtil.getHome();
0827: UserRegistration userReg = urHome.create();
0828: userReg
0829: .userCreate("alp", "alp",
0830: "miguel.valdes-faura@bull.net");
0831:
0832: ProjectSessionHome projectSessionh = ProjectSessionUtil
0833: .getHome();
0834: ProjectSession ps = projectSessionh.create();
0835: ps.initModel("ALP");
0836: ps.addNode("node1", 1);
0837: ps.setProperty("test", "111");
0838: ps.setNodeProperty("node1", "test", "111");
0839: ps.setNodeProperty("node1", "test", "1112");
0840: ps.addNode("node2", 1);
0841: ps.addUser("alp");
0842: ps.setNodeRole("node1", "alp");
0843: ps.setNodeRole("node2", "alp");
0844:
0845: ProjectSession ps2 = projectSessionh.create();
0846: ps2.initModel("ALP2");
0847: ps2.addNode("node2", 1);
0848:
0849: ProjectSession ps3 = projectSessionh.create();
0850: ps3.initModel("ALP3");
0851: ps3.addNode("node1", 1);
0852: ps3.setNodeProperty("node1", "test", "111");
0853: ps3.setProperty("test", "111");
0854: ps3.setProperty("test", "111");
0855: ps3.setNodeProperty("node1", "test", "111");
0856: ps3.addNode("node2", 1);
0857: ps3.setNodeProperty("node2", "test3", "111");
0858: ps3.addUser("alp");
0859: ps3.setNodeRole("node1", "alp");
0860:
0861: SimpleCallbackHandler handler = new SimpleCallbackHandler(
0862: "alp", "alp".toCharArray());
0863: LoginContext lc = new LoginContext("TestClient", handler);
0864: lc.login();
0865:
0866: String name = ps.instantiateProject("ALP");
0867: ps.setProperty("test", "111");
0868: ps.setNodeProperty("node2", "test", "111");
0869: ps2.instantiateProject("ALP2");
0870: ps3.instantiateProject("ALP3");
0871:
0872: UserSessionHome uHome = UserSessionUtil.getHome();
0873: UserSession usersession = uHome.create();
0874:
0875: Collection names = usersession.getActivityListByProperty(
0876: "test", "111");
0877: assertTrue("Error in getActivityListByProperty.1",
0878: names.size() == 0);
0879:
0880: usersession.startActivity(name, "node2");
0881:
0882: names = usersession.getActivityListByProperty("test", "111");
0883: assertTrue("Error in getActivityListByProperty.2",
0884: names.size() == 1);
0885:
0886: ps.setNodeProperty("node1", "test", "111");
0887: ps.setNodeProperty("node2", "test3", "11122");
0888: ps.setProperty("test", "111");
0889: ps.setProperty("test3", "11122");
0890:
0891: names = usersession.getActivityListByProperty("test", "111");
0892: assertTrue("Error in getActivityListByProperty.2",
0893: names.size() == 1);
0894:
0895: names = usersession.getToDoListByProperty("test", "1111");
0896: assertTrue("Error in getActivityListByProperty.3",
0897: names.size() == 0);
0898:
0899: usersession.terminateActivity(name, "node2");
0900:
0901: names = usersession.getActivityListByProperty("test", "111");
0902: assertTrue("Error in getActivityListByProperty.4",
0903: names.size() == 0);
0904:
0905: char[] password2 = { 't', 'o', 't', 'o' };
0906: handler = new SimpleCallbackHandler("admin", password2);
0907: lc = new LoginContext("TestClient", handler);
0908: lc.login();
0909: }
0910:
0911: public void testGetTodoListByActivityProperty() throws Exception {
0912: ProjectSessionHome projectSessionh = ProjectSessionUtil
0913: .getHome();
0914: ProjectSession ps = projectSessionh.create();
0915: ps.initModel("instActProp");
0916:
0917: ProjectSession ps2 = projectSessionh.create();
0918: ps2.initModel("instActProp2");
0919:
0920: ProjectSession ps3 = projectSessionh.create();
0921: ps3.initModel("instActProp3");
0922:
0923: ps.setProperty("id", "1234");
0924: ps2.setProperty("id", "1234");
0925: ps3.setProperty("id2", "1234");
0926:
0927: UserSessionHome uHome = UserSessionUtil.getHome();
0928: UserSession usersession = uHome.create();
0929: Collection names = usersession.getToDoListByActivityProperty(
0930: "id", "1234");
0931:
0932: assertTrue("Error in Instances by Property. Project error",
0933: names.size() == 0);
0934: String prop1 = ps.instantiateProject("instProp");
0935: String prop2 = ps2.instantiateProject("instProp2");
0936: String prop3 = ps3.instantiateProject("instProp3");
0937: ps.setProperty("id", "1234");
0938: ps2.setProperty("id", "1234");
0939: ps3.setProperty("id2", "1234");
0940: names = usersession.getToDoListByActivityProperty("id", "1234");
0941: assertTrue("Error in Instances by Property. Instance error",
0942: names.size() == 0);
0943:
0944: ps.addNode("node1", 1);
0945: ps.setNodeRole("node1", "admin");
0946: ps.setNodeProperty("node1", "test", "ok", true);
0947: ps2.addNode("node2", 1);
0948: ps2.setNodeRole("node2", "admin");
0949: ps2.setNodeProperty("node2", "test", "nok", true);
0950: prop1 = ps.instantiateProject("instProp");
0951: prop2 = ps2.instantiateProject("instProp2");
0952: prop3 = ps3.instantiateProject("instProp3");
0953:
0954: names = usersession.getToDoListByActivityProperty("test", "ok");
0955: assertTrue(
0956: "Error in Instances by ActivityProperty. Instance error",
0957: names.size() == 1);
0958: }
0959:
0960: public void testGetTodoListByActivityPropertyTwoUsers()
0961: throws Exception {
0962: UserRegistrationHome urHome = UserRegistrationUtil.getHome();
0963: UserRegistration userReg = urHome.create();
0964: userReg.userCreate("tdptu", "tdptu",
0965: "miguel.valdes-faura@bull.net");
0966:
0967: ProjectSessionHome projectSessionh = ProjectSessionUtil
0968: .getHome();
0969: ProjectSession ps = projectSessionh.create();
0970: ps.initModel("TDPTU");
0971: ps.addNode("node1", 1);
0972: ps.setNodeProperty("node1", "testtu", "111");
0973: ps.addNode("node2", 1);
0974: ps.addUser("tdptu");
0975: ps.setNodeRole("node1", "tdptu");
0976: ps.setNodeRole("node2", "tdptu");
0977:
0978: ProjectSession ps2 = projectSessionh.create();
0979: ps2.initModel("TDPTU2");
0980: ps2.addNode("node2", 1);
0981: ps2.setNodeProperty("node2", "testtu", "111");
0982:
0983: ProjectSession ps3 = projectSessionh.create();
0984: ps3.initModel("TDPTU3");
0985: ps3.addNode("node1", 1);
0986: ps3.setNodeProperty("node1", "testtu", "111");
0987: ps3.addNode("node2", 1);
0988: ps3.setNodeProperty("node2", "test3", "111");
0989: ps3.addUser("tdptu");
0990: ps3.setNodeRole("node1", "tdptu");
0991:
0992: SimpleCallbackHandler handler = new SimpleCallbackHandler(
0993: "tdptu", "tdptu".toCharArray());
0994: LoginContext lc = new LoginContext("TestClient", handler);
0995: lc.login();
0996:
0997: String name = ps.instantiateProject("TDPTU");
0998: ps2.instantiateProject("TDPTU2");
0999: ps3.instantiateProject("TDPTU3");
1000:
1001: UserSessionHome uHome = UserSessionUtil.getHome();
1002: UserSession usersession = uHome.create();
1003:
1004: Collection names = usersession.getToDoListByActivityProperty(
1005: "testtu", "111");
1006: java.util.Iterator i = names.iterator();
1007: BnNodeValue nd = null;
1008: while (i.hasNext()) {
1009: nd = (BnNodeValue) i.next();
1010: }
1011:
1012: assertTrue("Error in getTodoListByProperty.1: " + nd.getName()
1013: + "+" + nd.getBnProject().getName(), names.size() == 2);
1014:
1015: ps3.setNodeProperty("node1", "testtu", "1112");
1016: ps3.setNodeProperty("node2", "test3", "11122");
1017:
1018: names = usersession.getToDoListByActivityProperty("testtu",
1019: "111");
1020: assertTrue("Error in getTodoListByActivityProperty.2: "
1021: + names.size(), names.size() == 1);
1022:
1023: usersession.startActivity(name, "node1");
1024:
1025: names = usersession.getToDoListByActivityProperty("testtu",
1026: "111");
1027: assertTrue("Error in getTodoListByActivityProperty.4: "
1028: + names.size(), names.size() == 0);
1029:
1030: char[] password2 = { 't', 'o', 't', 'o' };
1031: handler = new SimpleCallbackHandler("admin", password2);
1032: lc = new LoginContext("TestClient", handler);
1033: lc.login();
1034: }
1035:
1036: public void testFindModels() throws Exception {
1037: UserSessionHome uHome = UserSessionUtil.getHome();
1038: UserSession usersession = uHome.create();
1039: Collection names = usersession.getModels();
1040: assertTrue("Error in findModels", names.size() > 0);
1041: }
1042:
1043: public void testModelInstancesActivities() throws Exception {
1044: UserSessionHome uHome = UserSessionUtil.getHome();
1045: UserRegistrationHome urHome = UserRegistrationUtil.getHome();
1046: UserRegistration userReg = urHome.create();
1047: userReg.userCreate("demandeur1", "toto",
1048: "miguel.valdes-faura@bull.net");
1049: userReg.userCreate("approbateur1", "toto",
1050: "miguel.valdes-faura@bull.net");
1051:
1052: ProjectSessionHome projectSessionh = ProjectSessionUtil
1053: .getHome();
1054: ProjectSession ps = projectSessionh.create();
1055: ps.initModel("demande_de_conges");
1056: ps.addNode("demande", 1);
1057: ps.addNode("approbation", 1);
1058: ps.addEdge("demande", "approbation");
1059: ps.addRole("demandeur", "demandeur");
1060: ps.addRole("approbateur", "approbateur");
1061: ps.setNodeRole("demande", "demandeur");
1062: ps.setNodeRole("approbation", "approbateur");
1063: ps.addUser("approbateur1");
1064: ps.setUserRole("approbateur1", "approbateur");
1065:
1066: ps.addRoleMapper("demandeur", "mapperTest",
1067: Constants.Mapper.PROPERTIES);
1068:
1069: ProjectSession psh = projectSessionh.create();
1070: psh.initModel("demande_habilitation");
1071: psh.addNode("demande", 1);
1072: psh.addNode("acceptation", 1);
1073: psh.addEdge("demande", "acceptation");
1074: psh.addRole("demandeur", "demandeur");
1075: psh.addRole("approbateur", "approbateur");
1076: psh.setNodeRole("demande", "demandeur");
1077: psh.setNodeRole("acceptation", "approbateur");
1078: psh.addUser("approbateur1");
1079: psh.setUserRole("approbateur1", "approbateur");
1080: psh.addRoleMapper("demandeur", "mapperTest2",
1081: Constants.Mapper.PROPERTIES);
1082:
1083: SimpleCallbackHandler handler = new SimpleCallbackHandler(
1084: "demandeur1", "toto".toCharArray());
1085: LoginContext lc = new LoginContext("TestClient", handler);
1086: lc.login();
1087:
1088: UserSession usersession1 = uHome.create();
1089: ProjectSession ps2 = projectSessionh.create();
1090: String instName1 = ps2.instantiateProject("demande_de_conges");
1091:
1092: Collection names = usersession1
1093: .getModelInstancesTodoList("demande_de_conges");
1094: assertTrue("Error in getModelInstancesTodoList.1: "
1095: + names.size(), names.size() == 1);
1096: Iterator i = names.iterator();
1097: assertTrue("Error in getModelInstancesTodoList.2: ",
1098: ((String) i.next()).equals("demande"));
1099:
1100: String instName2 = ps2.instantiateProject("demande_de_conges");
1101:
1102: names = usersession1
1103: .getModelInstancesTodoList("demande_de_conges");
1104: assertTrue("Error in getModelInstancesTodoList.3: "
1105: + names.size(), names.size() == 1);
1106:
1107: handler = new SimpleCallbackHandler("approbateur1", "toto"
1108: .toCharArray());
1109: lc = new LoginContext("TestClient", handler);
1110: lc.login();
1111:
1112: UserSession usersession2 = uHome.create();
1113: names = usersession2
1114: .getModelInstancesTodoList("demande_de_conges");
1115: assertTrue("Error in getModelInstancesTodoList.4: "
1116: + names.size(), names.size() == 0);
1117:
1118: handler = new SimpleCallbackHandler("demandeur1", "toto"
1119: .toCharArray());
1120: lc = new LoginContext("TestClient", handler);
1121: lc.login();
1122:
1123: names = usersession1.getInstancesActivityTodoList(
1124: "demande_de_conges", "demande");
1125: assertTrue("Error in getInstancesActivityTodoList.1: "
1126: + names.size(), names.size() == 2);
1127:
1128: usersession1.startActivity(instName1, "demande");
1129: usersession1.terminateActivity(instName1, "demande");
1130: names = usersession1
1131: .getModelInstancesTerminated("demande_de_conges");
1132: assertTrue("Error in getModelInstancesTerminated.1: "
1133: + names.size(), names.size() == 1);
1134: i = names.iterator();
1135: assertTrue("Error in getModelInstancesTerminated.2: ",
1136: ((String) i.next()).equals("demande"));
1137:
1138: names = usersession1.getInstancesActivityTerminated(
1139: "demande_de_conges", "demande");
1140: assertTrue("Error in getInstancesActivityTerminated.1: "
1141: + names.size(), names.size() == 1);
1142:
1143: usersession1.startActivity(instName2, "demande");
1144: usersession1.terminateActivity(instName2, "demande");
1145:
1146: names = usersession1
1147: .getModelInstancesTerminated("demande_de_conges");
1148: assertTrue("Error in getModelInstancesTerminated.3: "
1149: + names.size(), names.size() == 1);
1150:
1151: names = usersession1.getInstancesActivityTerminated(
1152: "demande_de_conges", "demande");
1153: assertTrue("Error in getInstancesActivityTerminated.2: "
1154: + names.size(), names.size() == 2);
1155:
1156: handler = new SimpleCallbackHandler("approbateur1", "toto"
1157: .toCharArray());
1158: lc = new LoginContext("TestClient", handler);
1159: lc.login();
1160:
1161: names = usersession2
1162: .getModelInstancesTodoList("demande_de_conges");
1163: assertTrue("Error in getModelInstancesTodoList.5: "
1164: + names.size(), names.size() == 1);
1165:
1166: names = usersession2.getInstancesActivityTodoList(
1167: "demande_de_conges", "demande");
1168: assertTrue("Error in getInstancesActivityTodoList.2: "
1169: + names.size(), names.size() == 0);
1170:
1171: names = usersession2.getInstancesActivityTodoList(
1172: "demande_de_conges", "approbation");
1173: assertTrue("Error in getInstancesActivityTodoList.2: "
1174: + names.size(), names.size() == 2);
1175:
1176: usersession2.startActivity(instName1, "approbation");
1177: usersession2.terminateActivity(instName1, "approbation");
1178:
1179: names = usersession2.getInstancesActivityTodoList(
1180: "demande_de_conges", "approbation");
1181: assertTrue("Error in getInstancesActivityTodoList.3: "
1182: + names.size(), names.size() == 1);
1183:
1184: names = usersession2
1185: .getModelInstancesTerminated("demande_de_conges");
1186: assertTrue("Error in getModelInstancesTerminated.4: "
1187: + names.size(), names.size() == 0);
1188:
1189: names = usersession2.getInstancesActivityTerminated(
1190: "demande_de_conges", "approbation");
1191: assertTrue("Error in getInstancesActivityTerminated.3: "
1192: + names.size(), names.size() == 0);
1193:
1194: usersession2.startActivity(instName2, "approbation");
1195: usersession2.terminateActivity(instName2, "approbation");
1196:
1197: names = usersession2.getInstancesActivityTodoList(
1198: "demande_de_conges", "approbation");
1199: assertTrue("Error in getInstancesActivityTodoList.4: "
1200: + names.size(), names.size() == 0);
1201:
1202: names = usersession2
1203: .getModelInstancesTerminated("demande_de_conges");
1204: assertTrue("Error in getModelInstancesTerminated.5: "
1205: + names.size(), names.size() == 0);
1206:
1207: names = usersession2.getInstancesActivityTerminated(
1208: "demande_de_conges", "approbation");
1209: assertTrue("Error in getInstancesActivityTerminated.4: "
1210: + names.size(), names.size() == 0);
1211:
1212: handler = new SimpleCallbackHandler("demandeur1", "toto"
1213: .toCharArray());
1214: lc = new LoginContext("TestClient", handler);
1215: lc.login();
1216:
1217: UserSession usersession3 = uHome.create();
1218: ProjectSession ps3 = projectSessionh.create();
1219:
1220: instName1 = ps3.instantiateProject("demande_habilitation");
1221:
1222: names = usersession3
1223: .getModelInstancesTodoList("demande_habilitation");
1224: assertTrue("Error in getModelInstancesTodoList.5: "
1225: + names.size(), names.size() == 1);
1226:
1227: names = usersession3
1228: .getModelInstancesTodoList("demande_de_conges");
1229: assertTrue("Error in getModelInstancesTodoList.6: "
1230: + names.size(), names.size() == 0);
1231:
1232: usersession1.startActivity(instName1, "demande");
1233: usersession1.terminateActivity(instName1, "demande");
1234:
1235: handler = new SimpleCallbackHandler("approbateur1", "toto"
1236: .toCharArray());
1237: lc = new LoginContext("TestClient", handler);
1238: lc.login();
1239:
1240: names = usersession2.getInstancesActivityTodoList(
1241: "demande_de_conges", "approbation");
1242: assertTrue("Error in getInstancesActivityTodoList.5: "
1243: + names.size(), names.size() == 0);
1244:
1245: names = usersession2
1246: .getModelInstancesTerminated("demande_de_conges");
1247: assertTrue("Error in getModelInstancesTerminated.6: "
1248: + names.size(), names.size() == 0);
1249:
1250: names = usersession2.getInstancesActivityTerminated(
1251: "demande_de_conges", "approbation");
1252: assertTrue("Error in getInstancesActivityTerminated.5: "
1253: + names.size(), names.size() == 0);
1254:
1255: names = usersession2
1256: .getModelInstancesTodoList("demande_habilitation");
1257: assertTrue("Error in getModelInstancesTodoList.6: "
1258: + names.size(), names.size() == 1);
1259:
1260: names = usersession2.getInstancesActivityTodoList(
1261: "demande_habilitation", "acceptation");
1262: assertTrue("Error in getInstancesActivityTodoList.6: "
1263: + names.size(), names.size() == 1);
1264:
1265: char[] password2 = { 't', 'o', 't', 'o' };
1266: handler = new SimpleCallbackHandler("admin", password2);
1267: lc = new LoginContext("TestClient", handler);
1268: lc.login();
1269: }
1270:
1271: public void testMyInstances() throws Exception {
1272: UserSessionHome uHome = UserSessionUtil.getHome();
1273: UserRegistrationHome urHome = UserRegistrationUtil.getHome();
1274: UserRegistration userReg = urHome.create();
1275: userReg.userCreate("demandeur2", "toto",
1276: "miguel.valdes-faura@bull.net");
1277: userReg.userCreate("approbateur2", "toto",
1278: "miguel.valdes-faura@bull.net");
1279:
1280: ProjectSessionHome projectSessionh = ProjectSessionUtil
1281: .getHome();
1282: ProjectSession ps = projectSessionh.create();
1283: ps.initModel("followup1");
1284: ps.addNode("demande", 1);
1285: ps.addNode("approbation", 1);
1286: ps.addEdge("demande", "approbation");
1287: ps.addRole("demandeur", "demandeur");
1288: ps.addRole("approbateur", "approbateur");
1289: ps.setNodeRole("demande", "demandeur");
1290: ps.setNodeRole("approbation", "approbateur");
1291: ps.addUser("approbateur2");
1292: ps.setUserRole("approbateur2", "approbateur");
1293: ps.addRoleMapper("demandeur", "mapperTest",
1294: Constants.Mapper.PROPERTIES);
1295:
1296: SimpleCallbackHandler handler = new SimpleCallbackHandler(
1297: "demandeur2", "toto".toCharArray());
1298: LoginContext lc = new LoginContext("TestClient", handler);
1299: lc.login();
1300:
1301: UserSession usersession1 = uHome.create();
1302: ProjectSession ps2 = projectSessionh.create();
1303: String instName1 = ps2.instantiateProject("followup1");
1304:
1305: Collection names = usersession1.getUserInstancesProject();
1306: assertTrue("Error in getUserInstancesProject.1: "
1307: + names.size(), names.size() == 1);
1308:
1309: names = usersession1.getUserInstancesProjectNodes("followup1");
1310: assertTrue("Error in getUserInstancesProjectNodes.1: "
1311: + names.size(), names.size() == 1);
1312:
1313: usersession1.startActivity(instName1, "demande");
1314:
1315: names = usersession1.getUserInstancesProjectNodes("followup1");
1316: assertTrue("Error in getUserInstancesProjectNodes.2: "
1317: + names.size(), names.size() == 2);
1318:
1319: usersession1.terminateActivity(instName1, "demande");
1320:
1321: names = usersession1.getUserInstancesProjectNodes("followup1");
1322: assertTrue("Error in getUserInstancesProjectNodes.3: "
1323: + names.size(), names.size() == 1);
1324:
1325: handler = new SimpleCallbackHandler("approbateur2", "toto"
1326: .toCharArray());
1327: lc = new LoginContext("TestClient", handler);
1328: lc.login();
1329:
1330: UserSession usersession2 = uHome.create();
1331: ProjectSession ps3 = projectSessionh.create();
1332:
1333: names = usersession2.getUserInstancesProject();
1334: assertTrue("Error in getUserInstancesProject.2: "
1335: + names.size(), names.size() == 0);
1336:
1337: names = usersession2.getUserInstancesProjectNodes("followup1");
1338: assertTrue("Error in getUserInstancesProjectNodes.4: "
1339: + names.size(), names.size() == 0);
1340:
1341: ps3.instantiateProject("followup1");
1342:
1343: names = usersession2.getUserInstancesProject();
1344: assertTrue("Error in getUserInstancesProject.3: "
1345: + names.size(), names.size() == 1);
1346:
1347: names = usersession2.getUserInstancesProjectNodes("followup1");
1348: assertTrue("Error in getUserInstancesProjectNodes.5: "
1349: + names.size(), names.size() == 1);
1350:
1351: handler = new SimpleCallbackHandler("demandeur2", "toto"
1352: .toCharArray());
1353: lc = new LoginContext("TestClient", handler);
1354: lc.login();
1355:
1356: String instName2 = ps2.instantiateProject("followup1");
1357:
1358: names = usersession1.getUserInstancesProject();
1359: assertTrue("Error in getUserInstancesProject.4: "
1360: + names.size(), names.size() == 1);
1361:
1362: names = usersession1.getUserInstancesProjectNodes("followup1");
1363: assertTrue("Error in getUserInstancesProjectNodes.6: "
1364: + names.size(), names.size() == 2);
1365:
1366: char[] password2 = { 't', 'o', 't', 'o' };
1367: handler = new SimpleCallbackHandler("admin", password2);
1368: lc = new LoginContext("TestClient", handler);
1369: lc.login();
1370: }
1371:
1372: public void testSubProcessesAutoDelete() throws Exception {
1373: projectsesh = ProjectSessionUtil.getHome();
1374:
1375: ProjectSession lproj1 = projectsesh.create();
1376: lproj1.initModel("Approval_Workflow");
1377: lproj1.addNode("Approval", Constants.Nd.AND_JOIN_NODE);
1378: lproj1.setNodeRole("Approval", "admin");
1379: lproj1.addNode("Reject", Constants.Nd.AND_JOIN_AUTOMATIC_NODE);
1380: lproj1.addNode("Accept", Constants.Nd.AND_JOIN_AUTOMATIC_NODE);
1381: lproj1.addEdge("Approval", "Reject");
1382: lproj1.addEdge("Approval", "Accept");
1383:
1384: ProjectSession p = projectsesh.create();
1385: p.initModel("TestSubProcessesAuto");
1386: p.addNode("testAct", Constants.Nd.AND_JOIN_AUTOMATIC_NODE);
1387: p.addNodeSubProcess("Approval", "Approval_Workflow");
1388: p.addEdge("testAct", "Approval");
1389:
1390: String instName = p.instantiateProject("TestSubProcessesAuto");
1391:
1392: usersessionh = UserSessionUtil.getHome();
1393: UserSession usersession = usersessionh.create();
1394: Collection acts = usersession.getInstancesActivityTodoList(
1395: "Approval_Workflow", "Approval");
1396: Iterator i = acts.iterator();
1397: while (i.hasNext()) {
1398: BnNodeLightValue nd = (BnNodeLightValue) i.next();
1399: usersession.startActivity(nd.getBnProject().getName(), nd
1400: .getName());
1401: usersession.terminateActivity(nd.getBnProject().getName(),
1402: nd.getName());
1403: }
1404: try {
1405: BnProjectHome pHome = BnProjectUtil.getHome();
1406: BnProject pr = pHome.findByName(instName);
1407: assertTrue(
1408: "Should have throw EJBException, auto delete instance operations has failed",
1409: false);
1410: } catch (Exception e) {
1411: //expected behavior
1412: }
1413: }
1414: }
|