01: /*
02: * Copyright 2007 The Kuali Foundation
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.rice.test;
17:
18: import junit.framework.Assert;
19:
20: public class TestUtilities {
21:
22: private static Thread exceptionThreader;
23:
24: /**
25: * Waits "indefinately" for the exception routing thread to terminate.
26: *
27: * This actually doesn't wait forever but puts an upper bound of 5 minutes
28: * on the time to wait for the exception routing thread to complete. If a
29: * document cannot go into exception routing within 5 minutes then we got
30: * problems.
31: */
32: public static void waitForExceptionRouting() {
33: waitForExceptionRouting(5 * 60 * 1000);
34: }
35:
36: public static void waitForExceptionRouting(long milliseconds) {
37: try {
38: getExceptionThreader().join(milliseconds);
39: } catch (InterruptedException e) {
40: Assert
41: .fail("This thread was interuppted while waiting for exception routing.");
42: }
43: if (getExceptionThreader().isAlive()) {
44: Assert
45: .fail("Document was not put into exception routing within the specified amount of time "
46: + milliseconds);
47: }
48: }
49:
50: public static Thread getExceptionThreader() {
51: return exceptionThreader;
52: }
53:
54: public static void setExceptionThreader(Thread exceptionThreader) {
55: TestUtilities.exceptionThreader = exceptionThreader;
56: }
57:
58: }
|