Source Code Cross Referenced for CounterRepositoryTest.java in  » Web-Services-apache-cxf-2.0.1 » management » org » apache » cxf » management » counters » 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 » Web Services apache cxf 2.0.1 » management » org.apache.cxf.management.counters 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Licensed to the Apache Software Foundation (ASF) under one
003:         * or more contributor license agreements. See the NOTICE file
004:         * distributed with this work for additional information
005:         * regarding copyright ownership. The ASF licenses this file
006:         * to you under the Apache License, Version 2.0 (the
007:         * "License"); you may not use this file except in compliance
008:         * with the License. You may obtain a copy of the License at
009:         *
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         * Unless required by applicable law or agreed to in writing,
013:         * software distributed under the License is distributed on an
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         * KIND, either express or implied. See the License for the
016:         * specific language governing permissions and limitations
017:         * under the License.
018:         */package org.apache.cxf.management.counters;
019:
020:        import javax.management.ObjectName;
021:
022:        import org.apache.cxf.Bus;
023:        import org.apache.cxf.management.InstrumentationManager;
024:        import org.easymock.classextension.EasyMock;
025:        import org.junit.Assert;
026:        import org.junit.Before;
027:        import org.junit.Test;
028:
029:        public class CounterRepositoryTest extends Assert {
030:            private Bus bus;
031:            //private InstrumentationManager im;
032:            private ObjectName serviceCounter;
033:            private ObjectName operationCounter;
034:
035:            @Before
036:            public void setUp() throws Exception {
037:
038:                serviceCounter = new ObjectName(
039:                        "tandoori:type=counter,service=help");
040:                operationCounter = new ObjectName(
041:                        "tandoori:type=counter,service=help,operation=me");
042:                bus = EasyMock.createMock(Bus.class);
043:                bus.getExtension(InstrumentationManager.class);
044:                EasyMock.expectLastCall().andReturn(null).anyTimes();
045:                EasyMock.replay(bus);
046:            }
047:
048:            @Test
049:            public void testIncreaseOneWayResponseCounter() throws Exception {
050:
051:                CounterRepository cr = new CounterRepository();
052:                cr.setBus(bus);
053:                //cr.createCounter(operationCounter, true);
054:                MessageHandlingTimeRecorder mhtr = EasyMock
055:                        .createMock(MessageHandlingTimeRecorder.class);
056:                EasyMock.expect(mhtr.isOneWay()).andReturn(true).anyTimes();
057:                EasyMock.expect(mhtr.getEndTime()).andReturn((long) 100000000)
058:                        .anyTimes();
059:                EasyMock.expect(mhtr.getHandlingTime()).andReturn((long) 1000)
060:                        .anyTimes();
061:
062:                EasyMock.replay(mhtr);
063:                cr.increaseCounter(serviceCounter, mhtr);
064:                cr.increaseCounter(operationCounter, mhtr);
065:                ResponseTimeCounter opCounter = (ResponseTimeCounter) cr
066:                        .getCounter(operationCounter);
067:                ResponseTimeCounter sCounter = (ResponseTimeCounter) cr
068:                        .getCounter(serviceCounter);
069:
070:                assertEquals("The operation counter isn't increased", opCounter
071:                        .getNumInvocations(), 1);
072:                assertEquals("The Service counter isn't increased", sCounter
073:                        .getNumInvocations(), 1);
074:
075:                EasyMock.verify(bus);
076:                EasyMock.verify(mhtr);
077:            }
078:
079:            @Test
080:            public void testIncreaseOneWayNoResponseCounter() throws Exception {
081:
082:                CounterRepository cr = new CounterRepository();
083:                cr.setBus(bus);
084:                //cr.createCounter(operationCounter, true);
085:                MessageHandlingTimeRecorder mhtr = EasyMock
086:                        .createMock(MessageHandlingTimeRecorder.class);
087:                EasyMock.expect(mhtr.isOneWay()).andReturn(true).anyTimes();
088:                EasyMock.expect(mhtr.getEndTime()).andReturn((long) 0)
089:                        .anyTimes();
090:                EasyMock.replay(mhtr);
091:                cr.increaseCounter(serviceCounter, mhtr);
092:                cr.increaseCounter(operationCounter, mhtr);
093:                ResponseTimeCounter opCounter = (ResponseTimeCounter) cr
094:                        .getCounter(operationCounter);
095:                ResponseTimeCounter sCounter = (ResponseTimeCounter) cr
096:                        .getCounter(serviceCounter);
097:
098:                assertEquals("The operation counter isn't increased", opCounter
099:                        .getNumInvocations(), 1);
100:                assertEquals("The Service counter isn't increased", sCounter
101:                        .getNumInvocations(), 1);
102:
103:                EasyMock.verify(bus);
104:                EasyMock.verify(mhtr);
105:            }
106:
107:            @Test
108:            public void testIncreaseResponseCounter() throws Exception {
109:                CounterRepository cr = new CounterRepository();
110:                cr.setBus(bus);
111:
112:                MessageHandlingTimeRecorder mhtr1 = EasyMock
113:                        .createMock(MessageHandlingTimeRecorder.class);
114:                EasyMock.expect(mhtr1.isOneWay()).andReturn(false).anyTimes();
115:                EasyMock.expect(mhtr1.getHandlingTime()).andReturn((long) 1000)
116:                        .anyTimes();
117:                EasyMock.replay(mhtr1);
118:                cr.createCounter(operationCounter, mhtr1);
119:                cr.increaseCounter(serviceCounter, mhtr1);
120:                cr.increaseCounter(operationCounter, mhtr1);
121:                ResponseTimeCounter opCounter = (ResponseTimeCounter) cr
122:                        .getCounter(operationCounter);
123:                ResponseTimeCounter sCounter = (ResponseTimeCounter) cr
124:                        .getCounter(serviceCounter);
125:
126:                assertEquals("The operation counter isn't increased", opCounter
127:                        .getNumInvocations(), 1);
128:                assertEquals(
129:                        "The operation counter's AvgResponseTime is wrong ",
130:                        opCounter.getAvgResponseTime(), 1000);
131:                assertEquals(
132:                        "The operation counter's MaxResponseTime is wrong ",
133:                        opCounter.getMaxResponseTime(), (long) 1000);
134:                assertEquals(
135:                        "The operation counter's MinResponseTime is wrong ",
136:                        opCounter.getMinResponseTime(), (long) 1000);
137:                assertEquals("The Service counter isn't increased", sCounter
138:                        .getNumInvocations(), 1);
139:
140:                MessageHandlingTimeRecorder mhtr2 = EasyMock
141:                        .createMock(MessageHandlingTimeRecorder.class);
142:                EasyMock.expect(mhtr2.isOneWay()).andReturn(false).anyTimes();
143:                EasyMock.expect(mhtr2.getHandlingTime()).andReturn((long) 2000)
144:                        .anyTimes();
145:                EasyMock.replay(mhtr2);
146:                cr.increaseCounter(serviceCounter, mhtr2);
147:                cr.increaseCounter(operationCounter, mhtr2);
148:                assertEquals("The operation counter isn't increased", opCounter
149:                        .getNumInvocations(), 2);
150:                assertEquals(
151:                        "The operation counter's AvgResponseTime is wrong ",
152:                        opCounter.getAvgResponseTime(), 1500);
153:                assertEquals(
154:                        "The operation counter's MaxResponseTime is wrong ",
155:                        opCounter.getMaxResponseTime(), (long) 2000);
156:                assertEquals(
157:                        "The operation counter's MinResponseTime is wrong ",
158:                        opCounter.getMinResponseTime(), (long) 1000);
159:                assertEquals("The Service counter isn't increased", sCounter
160:                        .getNumInvocations(), 2);
161:
162:                EasyMock.verify(bus);
163:                EasyMock.verify(mhtr1);
164:                EasyMock.verify(mhtr2);
165:            }
166:
167:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.