001: /*
002: * Copyright 2005-2007 The Kuali Foundation.
003: *
004: *
005: * Licensed under the Educational Community License, Version 1.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.opensource.org/licenses/ecl1.php
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package edu.iu.uis.eden.test.stress;
018:
019: import java.util.ArrayList;
020: import java.util.Collections;
021: import java.util.List;
022:
023: import edu.iu.uis.eden.clientapp.vo.UserIdVO;
024:
025: public class TestInfo {
026:
027: private static List routeHeaderIds = Collections
028: .synchronizedList(new ArrayList());
029: private static List users = Collections
030: .synchronizedList(new ArrayList());
031: private static long serverCalls;
032: private static long documentApprovals;
033: private static long documentAcks;
034: private static long documentFYIs;
035:
036: public static long getDocumentAcks() {
037: return documentAcks;
038: }
039:
040: public static long getDocumentApprovals() {
041: return documentApprovals;
042: }
043:
044: public static long getDocumentFYIs() {
045: return documentFYIs;
046: }
047:
048: public static List getRouteHeaderIds() {
049: return routeHeaderIds;
050: }
051:
052: public static void addRouteHeaderId(Long routeHeaderId) {
053: routeHeaderIds.add(routeHeaderId);
054: }
055:
056: public static void addUser(UserIdVO user) {
057: users.add(user);
058: }
059:
060: public static long getServerCalls() {
061: return serverCalls;
062: }
063:
064: public static void setServerCalls(long serverCalls) {
065: TestInfo.serverCalls = serverCalls;
066: }
067:
068: public static Long getRandomRouteHeaderId() {
069: if (routeHeaderIds.isEmpty()) {
070: return null;
071: }
072: Long routeHeaderId = null;
073: synchronized (routeHeaderIds) {
074: routeHeaderId = (Long) StressTestUtils
075: .getRandomListObject(routeHeaderIds);
076: routeHeaderIds.remove(routeHeaderId);
077: }
078: return routeHeaderId;
079: }
080:
081: public static UserIdVO getRandomUser() {
082: if (users.isEmpty()) {
083: return null;
084: }
085: return (UserIdVO) StressTestUtils.getRandomListObject(users);
086: }
087:
088: public synchronized static void markCallToServer() {
089: serverCalls++;
090: }
091:
092: public synchronized static void markDocumentAcks() {
093: documentAcks++;
094: }
095:
096: public synchronized static void markDocumentApprovals() {
097: documentApprovals++;
098: }
099:
100: public synchronized static void markDocumentFYIs() {
101: TestInfo.documentFYIs++;
102: }
103: }
|