01: package org.objectweb.celtix.bus.context;
02:
03: import javax.xml.ws.handler.MessageContext;
04: import junit.framework.TestCase;
05: import org.objectweb.celtix.context.GenericMessageContext;
06: import org.objectweb.celtix.context.WebServiceContextImpl;
07:
08: public class WebServiceContextImplTest extends TestCase {
09:
10: public void tearDown() {
11: WebServiceContextImpl.clear();
12: }
13:
14: public void testConstructor() {
15:
16: GenericMessageContext gmc = new GenericMessageContext();
17: WebServiceContextImpl ctx = new WebServiceContextImpl(gmc);
18: assertSame(gmc, ctx.getMessageContext());
19: }
20:
21: public void testGetSetMessageContext() {
22:
23: WebServiceContextImpl wsci = new WebServiceContextImpl();
24: assertNull(wsci.getMessageContext());
25:
26: final MessageContext ctx = new GenericMessageContext();
27: WebServiceContextImpl.setMessageContext(ctx);
28:
29: assertSame(ctx, wsci.getMessageContext());
30:
31: Thread t = new Thread() {
32: public void run() {
33: WebServiceContextImpl threadLocalWSCI = new WebServiceContextImpl();
34:
35: assertNull(threadLocalWSCI.getMessageContext());
36:
37: MessageContext threadLocalCtx = new GenericMessageContext();
38: WebServiceContextImpl.setMessageContext(threadLocalCtx);
39:
40: assertSame(threadLocalCtx, threadLocalWSCI
41: .getMessageContext());
42: assertTrue(ctx != threadLocalWSCI.getMessageContext());
43:
44: }
45: };
46:
47: t.start();
48:
49: try {
50: t.join();
51: } catch (InterruptedException e) {
52: e.printStackTrace();
53: }
54:
55: }
56: }
|