Source Code Cross Referenced for AbstractBindingImplTest.java in  » ESB » celtix-1.0 » org » objectweb » celtix » bindings » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ESB » celtix 1.0 » org.objectweb.celtix.bindings 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.objectweb.celtix.bindings;
002:
003:        import java.io.IOException;
004:        import java.util.ArrayList;
005:        import java.util.List;
006:
007:        import javax.xml.ws.handler.Handler;
008:        import javax.xml.ws.handler.LogicalHandler;
009:        import javax.xml.ws.handler.MessageContext;
010:
011:        import junit.framework.TestCase;
012:
013:        import org.easymock.classextension.EasyMock;
014:        import org.easymock.classextension.IMocksControl;
015:        import org.objectweb.celtix.bus.jaxws.configuration.types.HandlerChainType;
016:        import org.objectweb.celtix.bus.jaxws.configuration.types.HandlerType;
017:        import org.objectweb.celtix.bus.jaxws.configuration.types.ObjectFactory;
018:        import org.objectweb.celtix.bus.jaxws.configuration.types.SystemHandlerChainType;
019:        import org.objectweb.celtix.common.injection.ResourceInjector;
020:        import org.objectweb.celtix.configuration.Configuration;
021:        import org.objectweb.celtix.context.InputStreamMessageContext;
022:        import org.objectweb.celtix.context.ObjectMessageContext;
023:        import org.objectweb.celtix.context.OutputStreamMessageContext;
024:        import org.objectweb.celtix.context.StreamMessageContext;
025:        import org.objectweb.celtix.handlers.HandlerInvoker;
026:        import org.objectweb.celtix.handlers.StreamHandler;
027:        import org.objectweb.celtix.handlers.SystemHandler;
028:
029:        import static org.easymock.EasyMock.expect;
030:
031:        public class AbstractBindingImplTest extends TestCase {
032:            private Handler lhs1;
033:            private Handler lhs2;
034:            private Handler lhs3;
035:            private Handler phs1;
036:            private Handler phs2;
037:            private Handler phs3;
038:
039:            private Handler lh2;
040:            private Handler lh1;
041:            private Handler ph2;
042:            private Handler ph1;
043:            private Handler sh1;
044:
045:            private List<Handler> userHandlers;
046:
047:            public void setUp() {
048:
049:                lhs1 = new TestLogicalSystemHandler();
050:                lhs2 = new TestLogicalSystemHandler();
051:                lhs3 = new TestLogicalSystemHandler();
052:                phs1 = new TestProtocolSystemHandler();
053:                phs2 = new TestProtocolSystemHandler();
054:                phs3 = new TestProtocolSystemHandler();
055:
056:                lh1 = new TestLogicalSystemHandler();
057:                lh2 = new TestLogicalSystemHandler();
058:                ph1 = new TestProtocolSystemHandler();
059:                ph2 = new TestProtocolSystemHandler();
060:                sh1 = new TestStreamHandler();
061:
062:                userHandlers = new ArrayList<Handler>();
063:                userHandlers.add(sh1);
064:                userHandlers.add(ph1);
065:                userHandlers.add(lh1);
066:                userHandlers.add(lh2);
067:                userHandlers.add(ph2);
068:            }
069:
070:            public void testSystemHandlerAccessors() {
071:                TestBinding b = new TestBinding();
072:
073:                List<Handler> preLogical = b.getPreLogicalSystemHandlers();
074:                assertEquals(0, preLogical.size());
075:                List<Handler> postLogical = b.getPostLogicalSystemHandlers();
076:                assertEquals(0, postLogical.size());
077:                List<Handler> preProtocol = b.getPreProtocolSystemHandlers();
078:                assertEquals(0, preProtocol.size());
079:                List<Handler> postProtocol = b.getPostProtocolSystemHandlers();
080:                assertEquals(0, postProtocol.size());
081:
082:                setSystemHandlers(b);
083:
084:                preLogical = b.getPreLogicalSystemHandlers();
085:                assertEquals(2, preLogical.size());
086:                postLogical = b.getPostLogicalSystemHandlers();
087:                assertEquals(1, postLogical.size());
088:                preProtocol = b.getPreProtocolSystemHandlers();
089:                assertEquals(1, preProtocol.size());
090:                postProtocol = b.getPostProtocolSystemHandlers();
091:                assertEquals(2, postProtocol.size());
092:            }
093:
094:            public void testGetHandlerChain() {
095:                TestBinding b = new TestBinding();
096:                List<Handler> handlers;
097:
098:                assertNull(b.getHandlerChain(false));
099:                assertEquals(0, b.getHandlerChain(true).size());
100:
101:                setSystemHandlers(b);
102:
103:                assertNull(b.getHandlerChain(false));
104:                handlers = b.getHandlerChain(true);
105:                assertEquals(6, handlers.size());
106:                assertTrue(lhs1 == handlers.get(0));
107:                assertTrue(lhs2 == handlers.get(1));
108:                assertTrue(lhs3 == handlers.get(2));
109:                assertTrue(phs1 == handlers.get(3));
110:                assertTrue(phs2 == handlers.get(4));
111:                assertTrue(phs3 == handlers.get(5));
112:
113:                b.setHandlerChain(userHandlers);
114:
115:                assertEquals(5, b.getHandlerChain(false).size());
116:                handlers = b.getHandlerChain(true);
117:                assertEquals(11, handlers.size());
118:                assertTrue(lhs1 == handlers.get(0));
119:                assertTrue(lhs2 == handlers.get(1));
120:                assertTrue(lh1 == handlers.get(2));
121:                assertTrue(lh2 == handlers.get(3));
122:                assertTrue(lhs3 == handlers.get(4));
123:                assertTrue(phs1 == handlers.get(5));
124:                assertTrue(ph1 == handlers.get(6));
125:                assertTrue(ph2 == handlers.get(7));
126:                assertTrue(phs2 == handlers.get(8));
127:                assertTrue(phs3 == handlers.get(9));
128:                assertTrue(sh1 == handlers.get(10));
129:            }
130:
131:            public void testConfigureSystemHandlers() {
132:                IMocksControl control = EasyMock.createControl();
133:                TestBinding b = new TestBinding();
134:                SystemHandlerChainType shc = null;
135:                Configuration c = control.createMock(Configuration.class);
136:                expect(c.getObject("systemHandlerChain")).andReturn(shc);
137:                control.replay();
138:
139:                b.configureSystemHandlers(c);
140:                assertEquals(0, b.getPreLogicalSystemHandlers().size());
141:                assertEquals(0, b.getPostLogicalSystemHandlers().size());
142:                assertEquals(0, b.getPreProtocolSystemHandlers().size());
143:                assertEquals(0, b.getPreProtocolSystemHandlers().size());
144:
145:                control.verify();
146:                control.reset();
147:
148:                shc = new ObjectFactory().createSystemHandlerChainType();
149:                c = control.createMock(Configuration.class);
150:                expect(c.getObject("systemHandlerChain")).andReturn(shc);
151:                control.replay();
152:
153:                b.configureSystemHandlers(c);
154:                assertEquals(0, b.getPreLogicalSystemHandlers().size());
155:                assertEquals(0, b.getPostLogicalSystemHandlers().size());
156:                assertEquals(0, b.getPreProtocolSystemHandlers().size());
157:                assertEquals(0, b.getPreProtocolSystemHandlers().size());
158:
159:                control.verify();
160:                control.reset();
161:
162:                shc = createSystemHandlerChain();
163:                c = control.createMock(Configuration.class);
164:                expect(c.getObject("systemHandlerChain")).andReturn(shc);
165:                control.replay();
166:
167:                b.configureSystemHandlers(c);
168:                assertEquals(2, b.getPreLogicalSystemHandlers().size());
169:                assertEquals(1, b.getPostLogicalSystemHandlers().size());
170:                assertEquals(1, b.getPreProtocolSystemHandlers().size());
171:                assertEquals(2, b.getPostProtocolSystemHandlers().size());
172:
173:                control.verify();
174:            }
175:
176:            public void testInjectSystemHandlers() {
177:                IMocksControl control = EasyMock.createControl();
178:                TestBinding b = new TestBinding();
179:                SystemHandlerChainType shc = createSystemHandlerChain();
180:                Configuration c = control.createMock(Configuration.class);
181:                expect(c.getObject("systemHandlerChain")).andReturn(shc);
182:                ResourceInjector ri = control
183:                        .createMock(ResourceInjector.class);
184:                ri.inject(EasyMock.isA(SystemHandler.class));
185:                EasyMock.expectLastCall().times(6);
186:                control.replay();
187:
188:                b.configureSystemHandlers(c);
189:                b.injectSystemHandlers(ri);
190:
191:                control.verify();
192:            }
193:
194:            private SystemHandlerChainType createSystemHandlerChain() {
195:                SystemHandlerChainType shc = new ObjectFactory()
196:                        .createSystemHandlerChainType();
197:                HandlerChainType hc = new ObjectFactory()
198:                        .createHandlerChainType();
199:                List<HandlerType> handlers = hc.getHandler();
200:                HandlerType h = new ObjectFactory().createHandlerType();
201:                h.setHandlerName("lhs1");
202:                h.setHandlerClass(TestLogicalSystemHandler.class.getName());
203:                handlers.add(h);
204:                h = new ObjectFactory().createHandlerType();
205:                h.setHandlerName("lhs2");
206:                h.setHandlerClass(TestLogicalSystemHandler.class.getName());
207:                handlers.add(h);
208:                shc.setPreLogical(hc);
209:
210:                hc = new ObjectFactory().createHandlerChainType();
211:                handlers = hc.getHandler();
212:                h = new ObjectFactory().createHandlerType();
213:                h.setHandlerName("lhs3");
214:                h.setHandlerClass(TestLogicalSystemHandler.class.getName());
215:                handlers.add(h);
216:                shc.setPostLogical(hc);
217:
218:                hc = new ObjectFactory().createHandlerChainType();
219:                handlers = hc.getHandler();
220:                h = new ObjectFactory().createHandlerType();
221:                h.setHandlerName("phs1");
222:                h.setHandlerClass(TestProtocolSystemHandler.class.getName());
223:                handlers.add(h);
224:                shc.setPreProtocol(hc);
225:
226:                hc = new ObjectFactory().createHandlerChainType();
227:                handlers = hc.getHandler();
228:                h = new ObjectFactory().createHandlerType();
229:                h.setHandlerName("phs2");
230:                h.setHandlerClass(TestProtocolSystemHandler.class.getName());
231:                handlers.add(h);
232:                h = new ObjectFactory().createHandlerType();
233:                h.setHandlerName("phs3");
234:                h.setHandlerClass(TestProtocolSystemHandler.class.getName());
235:                handlers.add(h);
236:                shc.setPostProtocol(hc);
237:
238:                return shc;
239:            }
240:
241:            private void setSystemHandlers(TestBinding b) {
242:                b.getPreLogicalSystemHandlers().add(lhs1);
243:                b.getPreLogicalSystemHandlers().add(lhs2);
244:                b.getPostLogicalSystemHandlers().add(lhs3);
245:                b.getPreProtocolSystemHandlers().add(phs1);
246:                b.getPostProtocolSystemHandlers().add(phs2);
247:                b.getPostProtocolSystemHandlers().add(phs3);
248:            }
249:
250:            static class TestBinding extends AbstractBindingImpl {
251:
252:                public MessageContext createBindingMessageContext(
253:                        MessageContext orig) {
254:                    return null;
255:                }
256:
257:                public HandlerInvoker createHandlerInvoker() {
258:                    return null;
259:                }
260:
261:                public void marshal(ObjectMessageContext objContext,
262:                        MessageContext context, DataBindingCallback callback) {
263:                }
264:
265:                public void marshalFault(ObjectMessageContext objContext,
266:                        MessageContext context, DataBindingCallback callback) {
267:                }
268:
269:                public void unmarshal(MessageContext context,
270:                        ObjectMessageContext objContext,
271:                        DataBindingCallback callback) {
272:                }
273:
274:                public void unmarshalFault(MessageContext context,
275:                        ObjectMessageContext objContext,
276:                        DataBindingCallback callback) {
277:                }
278:
279:                public void read(InputStreamMessageContext inContext,
280:                        MessageContext msgContext) throws IOException {
281:                }
282:
283:                public void write(MessageContext msgContext,
284:                        OutputStreamMessageContext outContext)
285:                        throws IOException {
286:                }
287:
288:                public boolean hasFault(MessageContext msgContext) {
289:                    return false;
290:                }
291:
292:                public void updateMessageContext(MessageContext msgContext) {
293:                }
294:
295:            }
296:
297:            public static class TestProtocolSystemHandler implements  Handler,
298:                    SystemHandler {
299:
300:                public void close(MessageContext arg0) {
301:                }
302:
303:                public boolean handleFault(MessageContext arg0) {
304:                    return false;
305:                }
306:
307:                public boolean handleMessage(MessageContext arg0) {
308:                    return false;
309:                }
310:
311:            }
312:
313:            public static class TestLogicalSystemHandler implements 
314:                    LogicalHandler, SystemHandler {
315:
316:                public void close(MessageContext arg0) {
317:                }
318:
319:                public boolean handleFault(MessageContext arg0) {
320:                    return false;
321:                }
322:
323:                public boolean handleMessage(MessageContext arg0) {
324:                    return false;
325:                }
326:            }
327:
328:            public static class TestStreamHandler implements  StreamHandler {
329:
330:                public void close(MessageContext arg0) {
331:                }
332:
333:                public boolean handleFault(StreamMessageContext arg0) {
334:                    return false;
335:                }
336:
337:                public boolean handleMessage(StreamMessageContext arg0) {
338:                    return false;
339:                }
340:
341:            }
342:
343:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.