01: package org.objectweb.celtix.bus.context;
02:
03: import javax.xml.ws.handler.MessageContext;
04:
05: import junit.framework.TestCase;
06:
07: public abstract class AbstractMessageContextTestBase extends TestCase {
08:
09: private MessageContext ctx;
10:
11: protected abstract MessageContext getMessageContext();
12:
13: public void setUp() {
14: ctx = getMessageContext();
15: }
16:
17: public void testGetDefaultScope() {
18:
19: final String name = "foo.bar";
20: ctx.put(name, "prop-value");
21: assertTrue(ctx.containsKey(name));
22: assertEquals(MessageContext.Scope.HANDLER, ctx.getScope(name));
23: }
24:
25: public void testGetSetScope() {
26:
27: final String name = "foo.bar";
28: ctx.put(name, "prop-value");
29: ctx.setScope(name, MessageContext.Scope.APPLICATION);
30: assertEquals(MessageContext.Scope.APPLICATION, ctx
31: .getScope(name));
32: }
33:
34: public void testGetScopeBadScope() {
35:
36: try {
37: ctx.getScope("foo.bar.wibble.bad.property");
38: fail("did not get expected IllegalArgumentException");
39: } catch (IllegalArgumentException ex) {
40: // ok
41: }
42:
43: }
44:
45: public void testSetScopeBadScope() {
46:
47: try {
48: ctx.setScope("foo.bar.wibble.bad.property",
49: MessageContext.Scope.APPLICATION);
50: fail("did not get expected IllegalArgumentException");
51: } catch (IllegalArgumentException ex) {
52: // ok
53: }
54: }
55: }
|