001: package org.objectweb.celtix.bus.context;
002:
003: import java.util.HashMap;
004: import java.util.Map;
005:
006: import javax.xml.ws.handler.MessageContext;
007:
008: import org.objectweb.celtix.context.GenericMessageContext;
009: import org.objectweb.celtix.context.MessageContextWrapper;
010:
011: public class MessageContextWrapperTest extends
012: AbstractMessageContextTestBase {
013:
014: private GenericMessageContext wrapped;
015: private MessageContextWrapper wrapper;
016:
017: @Override
018: protected MessageContext getMessageContext() {
019: wrapped = new GenericMessageContext();
020: wrapper = new MessageContextWrapper(wrapped);
021: return wrapper;
022: }
023:
024: /*
025: * Test method for 'org.objectweb.celtix.bus.context.MessageContextWrapper.size()'
026: */
027: public void testSize() {
028:
029: assertEquals(wrapped.size(), wrapper.size());
030: wrapper.put("foo", "bar");
031: assertEquals(wrapped.size(), wrapper.size());
032: }
033:
034: /*
035: * Test method for 'org.objectweb.celtix.bus.context.MessageContextWrapper.isEmpty()'
036: */
037: public void testIsEmpty() {
038:
039: assertEquals(wrapped.isEmpty(), wrapper.isEmpty());
040: wrapper.put("foo", "bar");
041: assertEquals(wrapped.isEmpty(), wrapper.isEmpty());
042: }
043:
044: /*
045: * Test method for 'org.objectweb.celtix.bus.context.MessageContextWrapper.containsKey(Object)'
046: */
047: public void testContainsKey() {
048:
049: assertEquals(wrapped.containsKey("foo"), wrapper
050: .containsKey("foo"));
051: wrapper.put("foo", "bar");
052: assertEquals(wrapped.containsKey("foo"), wrapper
053: .containsKey("foo"));
054: }
055:
056: /*
057: * Test method for 'org.objectweb.celtix.bus.context.MessageContextWrapper.containsValue(Object)'
058: */
059: public void testContainsValue() {
060:
061: assertEquals(wrapped.containsValue("bar"), wrapper
062: .containsValue("bar"));
063: wrapper.put("foo", "bar");
064: assertEquals(wrapped.containsValue("bar"), wrapper
065: .containsValue("bar"));
066:
067: }
068:
069: /*
070: * Test method for 'org.objectweb.celtix.bus.context.MessageContextWrapper.get(Object)'
071: */
072: public void testGetPut() {
073: assertEquals(wrapped.get("foo"), wrapper.get("foo"));
074: wrapper.put("foo", "bar");
075: assertEquals(wrapped.get("foo"), wrapper.get("foo"));
076: }
077:
078: /*
079: * Test method for 'org.objectweb.celtix.bus.context.MessageContextWrapper.remove(Object)'
080: */
081: public void testRemove() {
082:
083: wrapper.put("foo", "bar");
084: wrapper.remove("foo");
085: assertEquals(wrapped.containsKey("foo"), wrapper
086: .containsKey("foo"));
087: }
088:
089: /*
090: * Test method for 'org.objectweb.celtix.bus.context.MessageContextWrapper.
091: * putAll(Map<? extends String, ? extends Object>)'
092: */
093: public void testPutAll() {
094: Map<String, Object> map = new HashMap<String, Object>();
095: map.put("foo", "bar");
096: wrapper.putAll(map);
097:
098: assertTrue(wrapper.containsKey("foo"));
099: assertTrue(wrapper.containsValue("bar"));
100: assertTrue(wrapped.containsKey("foo"));
101: assertTrue(wrapped.containsValue("bar"));
102: }
103:
104: /*
105: * Test method for 'org.objectweb.celtix.bus.context.MessageContextWrapper.clear()'
106: */
107: public void testClear() {
108:
109: wrapper.put("foo", "bar");
110: wrapper.clear();
111: assertTrue(wrapper.isEmpty());
112: assertTrue(wrapped.isEmpty());
113: }
114:
115: /*
116: * Test method for 'org.objectweb.celtix.bus.context.MessageContextWrapper.keySet()'
117: */
118: public void testKeySet() {
119: wrapper.put("foo", "bar");
120: assertEquals(1, wrapper.keySet().size());
121: assertTrue(wrapper.keySet().contains("foo"));
122:
123: assertEquals(1, wrapped.keySet().size());
124: assertTrue(wrapped.keySet().contains("foo"));
125: }
126:
127: /*
128: * Test method for 'org.objectweb.celtix.bus.context.MessageContextWrapper.values()'
129: */
130: public void testValues() {
131: wrapper.put("foo", "bar");
132: assertEquals(1, wrapper.values().size());
133: assertTrue(wrapper.values().contains("bar"));
134:
135: assertEquals(1, wrapped.values().size());
136: assertTrue(wrapped.values().contains("bar"));
137:
138: }
139:
140: /*
141: * Test method for 'org.objectweb.celtix.bus.context.MessageContextWrapper.entrySet()'
142: */
143: public void testEntrySet() {
144:
145: wrapper.put("foo", "bar");
146: assertEquals(wrapped.entrySet(), wrapper.entrySet());
147: }
148:
149: }
|