01: package com.jcorporate.expresso.core.registry;
02:
03: import com.jcorporate.expresso.core.security.SuperUser;
04: import com.jcorporate.expresso.services.test.TestSystemInitializer;
05: import junit.framework.TestCase;
06:
07: /**
08: * Test case to make sure Expresso credentials are properly getting
09: * sent between threads in classes derived from ExpressoThread.
10: *
11: * @author Michael Rimov
12: * @version $Revision: 1.2 $ on $Date: 2004/11/17 20:48:23 $
13: */
14: public class TestExpressoThread extends TestCase {
15: private ExpressoThread expressoThread = null;
16:
17: protected void setUp() throws Exception {
18: super .setUp();
19: expressoThread = new ExpressoThread();
20: //Increase credentials for the test.
21: RequestRegistry.super User(SuperUser.SUPER_USER);
22: }
23:
24: protected void tearDown() throws Exception {
25: expressoThread = null;
26: //Reduce credentials for the test.
27: RequestRegistry.revertUser();
28: super .tearDown();
29: }
30:
31: public void testExpressoThreadRequestRegistry()
32: throws InterruptedException {
33: ExpressoThreadTestModel model = new ExpressoThreadTestModel();
34: model.start();
35: model.join(5000); //Wait up to five seconds.
36: //Bail if we don't get there
37: //by then.
38: if (model.isAlive()) {
39: fail("Test Thread Model didn't end in 5 seconds");
40: }
41:
42: assertEquals(TestSystemInitializer.getTestContext(), model
43: .getDataContext());
44:
45: assertEquals(SuperUser.SUPER_USER, model.getUser());
46: }
47:
48: }
|