KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jcorporate > expresso > core > registry > TestExpressoThread


1 package com.jcorporate.expresso.core.registry;
2
3 import com.jcorporate.expresso.core.security.SuperUser;
4 import com.jcorporate.expresso.services.test.TestSystemInitializer;
5 import junit.framework.TestCase;
6
7 /**
8  * Test case to make sure Expresso credentials are properly getting
9  * 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 JavaDoc {
18         super.setUp();
19         expressoThread = new ExpressoThread();
20         //Increase credentials for the test.
21
RequestRegistry.superUser(SuperUser.SUPER_USER);
22     }
23
24     protected void tearDown() throws Exception JavaDoc {
25         expressoThread = null;
26         //Reduce credentials for the test.
27
RequestRegistry.revertUser();
28         super.tearDown();
29     }
30
31     public void testExpressoThreadRequestRegistry()
32             throws InterruptedException JavaDoc {
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(),
43                 model.getDataContext());
44
45         assertEquals(SuperUser.SUPER_USER, model.getUser());
46     }
47
48 }
49
Popular Tags