Source Code Cross Referenced for InstrumentationManagerTest.java in  » ESB » celtix-1.0 » org » objectweb » celtix » bus » management » 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.bus.management 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.objectweb.celtix.bus.management;
002:
003:        import java.util.List;
004:        import junit.framework.TestCase;
005:
006:        import org.easymock.classextension.EasyMock;
007:        import org.objectweb.celtix.Bus;
008:        import org.objectweb.celtix.BusException;
009:        import org.objectweb.celtix.bus.busimpl.ComponentCreatedEvent;
010:        import org.objectweb.celtix.bus.busimpl.ComponentRemovedEvent;
011:
012:        import org.objectweb.celtix.bus.management.jmx.export.AnnotationTestInstrumentation;
013:        import org.objectweb.celtix.bus.transports.http.HTTPClientTransport;
014:        import org.objectweb.celtix.bus.transports.jms.JMSClientTransport;
015:        import org.objectweb.celtix.bus.workqueue.WorkQueueInstrumentation;
016:        import org.objectweb.celtix.bus.workqueue.WorkQueueManagerImpl;
017:        import org.objectweb.celtix.management.Instrumentation;
018:        import org.objectweb.celtix.management.InstrumentationManager;
019:
020:        public class InstrumentationManagerTest extends TestCase {
021:            Bus bus;
022:            InstrumentationManager im;
023:
024:            public void setUp() throws Exception {
025:                bus = Bus.init();
026:                im = bus.getInstrumentationManager();
027:            }
028:
029:            public void tearDown() throws Exception {
030:                //test case had done the bus.shutdown         
031:            }
032:
033:            // try to get WorkQueue information
034:            public void testWorkQueueInstrumentation() throws BusException {
035:                //im.getAllInstrumentation();
036:                WorkQueueManagerImpl wqm = new WorkQueueManagerImpl(bus);
037:                bus.sendEvent(new ComponentCreatedEvent(wqm));
038:                bus.sendEvent(new ComponentCreatedEvent(wqm));
039:                //NOTE: now the bus WorkQueueManager is lazy load , if WorkQueueManager 
040:                //create with bus , this test could be failed.
041:                List<Instrumentation> list = im.getAllInstrumentation();
042:                //NOTE: change for the BindingManager and TransportFactoryManager instrumentation 
043:                // create with the bus.
044:                assertEquals("Too many instrumented items", 4, list.size());
045:                Instrumentation it1 = list.get(2);
046:                Instrumentation it2 = list.get(3);
047:                assertTrue("Item 1 not a WorkQueueInstrumentation",
048:                        WorkQueueInstrumentation.class.isAssignableFrom(it1
049:                                .getClass()));
050:                assertTrue("Item 2 not a WorkQueueInstrumentation",
051:                        WorkQueueInstrumentation.class.isAssignableFrom(it2
052:                                .getClass()));
053:
054:                // not check for the instrumentation unique name
055:                // sleep for the MBServer connector thread startup 
056:                try {
057:                    Thread.sleep(100);
058:                } catch (InterruptedException e) {
059:                    // do nothing
060:                }
061:                bus.sendEvent(new ComponentRemovedEvent(wqm));
062:                assertEquals("Instrumented stuff not removed from list", 2,
063:                        list.size());
064:                bus.shutdown(true);
065:                assertEquals("Instrumented stuff not removed from list", 0,
066:                        list.size());
067:            }
068:
069:            public void testMoreInstrumentation() throws BusException {
070:                //im.getAllInstrumentation();
071:                WorkQueueManagerImpl wqm = new WorkQueueManagerImpl(bus);
072:                bus.sendEvent(new ComponentCreatedEvent(wqm));
073:
074:                JMSClientTransport jct = EasyMock
075:                        .createMock(JMSClientTransport.class);
076:                bus.sendEvent(new ComponentCreatedEvent(jct));
077:
078:                HTTPClientTransport hct = EasyMock
079:                        .createMock(HTTPClientTransport.class);
080:                bus.sendEvent(new ComponentCreatedEvent(hct));
081:
082:                // TODO should test for the im getInstrumentation 
083:                List<Instrumentation> list = im.getAllInstrumentation();
084:                assertEquals("Too many instrumented items", 5, list.size());
085:                // sleep for the MBServer connector thread startup 
086:                try {
087:                    Thread.sleep(100);
088:                } catch (InterruptedException e) {
089:                    // do nothing
090:                }
091:
092:                bus.sendEvent(new ComponentRemovedEvent(wqm));
093:                bus.sendEvent(new ComponentRemovedEvent(jct));
094:                bus.sendEvent(new ComponentRemovedEvent(hct));
095:                assertEquals("Instrumented stuff not removed from list", 2,
096:                        list.size());
097:                bus.shutdown(true);
098:                assertEquals("Instrumented stuff not removed from list", 0,
099:                        list.size());
100:            }
101:
102:            public void testCustemerInstrumentationByEvent()
103:                    throws BusException {
104:                AnnotationTestInstrumentation ati = new AnnotationTestInstrumentation();
105:                bus.sendEvent(new ComponentCreatedEvent(ati));
106:
107:                List<Instrumentation> list = im.getAllInstrumentation();
108:                assertEquals("Not exactly the number of instrumented item", 3,
109:                        list.size());
110:
111:                // get the ati for more assert
112:                Instrumentation instr = list.get(2);
113:                assertEquals(
114:                        "Not exactly the name of AnnotationTestInstrumentation",
115:                        "AnnotationTestInstrumentation", instr
116:                                .getInstrumentationName());
117:                bus.sendEvent(new ComponentRemovedEvent(ati));
118:                assertEquals(
119:                        "AnnotationTestInstrumented stuff not removed from list",
120:                        2, list.size());
121:                bus.shutdown(true);
122:                assertEquals("Instrumented stuff not removed from list", 0,
123:                        list.size());
124:
125:            }
126:
127:            public void testCustemerInstrumentationByInstrumentationManager()
128:                    throws BusException {
129:                AnnotationTestInstrumentation ati = new AnnotationTestInstrumentation();
130:                im.register(ati);
131:
132:                List<Instrumentation> list = im.getAllInstrumentation();
133:                assertEquals("Not exactly the number of instrumented item", 3,
134:                        list.size());
135:
136:                // get the ati for more assert
137:                Instrumentation instr = list.get(2);
138:                assertEquals(
139:                        "Not exactly the name of AnnotationTestInstrumentation",
140:                        "AnnotationTestInstrumentation", instr
141:                                .getInstrumentationName());
142:                im.unregister(ati);
143:                assertEquals(
144:                        "AnnotationTestInstrumented stuff not removed from list",
145:                        2, list.size());
146:                bus.shutdown(true);
147:                assertEquals("Instrumented stuff not removed from list", 0,
148:                        list.size());
149:            }
150:
151:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.