KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hero > client > test > performance > PerformanceTests


1 /**
2  *
3  * Bonita
4  * Copyright (C) 1999 Bull S.A.
5  * Bull 68 route de versailles 78434 Louveciennes Cedex France
6  * Further information: bonita@objectweb.org
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21  * USA
22  *
23  *
24 --------------------------------------------------------------------------
25  * $Id: PerformanceTests.java,v 1.1 2004/07/30 14:57:58 mvaldes Exp $
26  *
27 --------------------------------------------------------------------------
28  */

29
30
31 package hero.client.test.performance;
32
33 /*
34 *
35 * PerformanceTests.java -
36 * Copyright (C) 2003 Ecoo Team
37 * valdes@loria.fr
38 *
39 *
40 * This program is free software; you can redistribute it and/or
41 * modify it under the terms of the GNU Lesser General Public License
42 * as published by the Free Software Foundation; either version 2
43 * of the License, or (at your option) any later version.
44 *
45 * This program is distributed in the hope that it will be useful,
46 * but WITHOUT ANY WARRANTY; without even the implied warranty of
47 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48 * GNU Lesser General Public License for more details.
49 *
50 * You should have received a copy of the GNU Lesser General Public License
51 * along with this program; if not, write to the Free Software
52 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
53 */

54
55 import hero.interfaces.UserSession;
56 import hero.interfaces.UserSessionHome;
57 import hero.interfaces.UserSessionUtil;
58 import hero.interfaces.ProjectSession;
59 import hero.interfaces.ProjectSessionHome;
60 import hero.interfaces.ProjectSessionUtil;
61 import junit.framework.TestCase;
62 import junit.framework.TestSuite;
63 import javax.security.auth.login.LoginContext JavaDoc;
64 import hero.client.test.SimpleCallbackHandler;
65 import java.util.Collection JavaDoc;
66 import java.util.Iterator JavaDoc;
67
68 public class PerformanceTests extends TestCase {
69  
70     public PerformanceTests(String JavaDoc testname) {
71     super(testname);
72     }
73     
74     public static TestSuite suite() {
75     return new TestSuite(PerformanceTests.class);
76     }
77
78     public void setUp() throws Exception JavaDoc {
79     }
80     
81     public void testUsersInteraction() throws Exception JavaDoc {
82     int i=0;
83     UserSessionHome uHome = UserSessionUtil.getHome();
84     for (i=0;i<15;i++)
85     {
86         String JavaDoc uName= "user"+i;
87         char[] password=uName.toCharArray();
88         SimpleCallbackHandler handler = new SimpleCallbackHandler(uName,password);
89         LoginContext JavaDoc lc = new LoginContext JavaDoc("TestClient", handler);
90         lc.login();
91         UserSession us = uHome.create();
92         Collection JavaDoc instances = us.getProjectListNames();
93         Iterator JavaDoc index = instances.iterator();
94         while (index.hasNext())
95         {
96             String JavaDoc name = (String JavaDoc)index.next();
97             if (name.matches("Stress.*"))
98             {
99                 ProjectSessionHome pHome = ProjectSessionUtil.getHome();
100                 ProjectSession ps = pHome.create();
101                 ps.initProject(name);
102                 ps.setUserRole("user"+i,"InitialRole");
103                 Collection JavaDoc task = us.getToDoList(name);
104                 Iterator JavaDoc tsk = task.iterator();
105                 while (tsk.hasNext())
106                 {
107                     us.startActivity(name,(String JavaDoc)tsk.next());
108                     task = us.getToDoList(name);
109                     tsk = task.iterator();
110                 }
111                 ps.remove();
112             }
113         }
114         us.remove();
115      }
116         
117     }
118 }
119
Popular Tags