Source Code Cross Referenced for ProxyTest.java in  » Profiler » JMeasurement » de » mcs » jmeasurement » test » proxy » 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 » Profiler » JMeasurement » de.mcs.jmeasurement.test.proxy 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * MCS Media Computer Software Copyright (c) 2006 by MCS
003:         * -------------------------------------- Created on 26.07.2006 by W.Klaas
004:         * 
005:         * Licensed under the Apache License, Version 2.0 (the "License"); you may not
006:         * use this file except in compliance with the License. You may obtain a copy of
007:         * the License at
008:         * 
009:         * http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
013:         * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
014:         * License for the specific language governing permissions and limitations under
015:         * the License. $Id$
016:         */
017:        /**
018:         * 
019:         */package de.mcs.jmeasurement.test.proxy;
020:
021:        import java.io.IOException;
022:
023:        import org.xml.sax.SAXException;
024:
025:        import de.mcs.jmeasurement.DefaultMeasurePoint;
026:        import de.mcs.jmeasurement.DefaultMonitor;
027:        import de.mcs.jmeasurement.MeasureFactory;
028:        import de.mcs.jmeasurement.MeasurementException;
029:        import de.mcs.jmeasurement.Monitor;
030:        import de.mcs.jmeasurement.test.MCSTestCase;
031:
032:        /**
033:         * @author W.Klaas
034:         * @version $Revision
035:         */
036:        public class ProxyTest extends MCSTestCase {
037:
038:            private static final int LOOP_COUNT_PROXY = 2;
039:
040:            private static final int LOOP_COUNT = 100000;
041:
042:            private static final String TEST_STRING = "Das ist das Haus vom Nikolaus..."
043:                    + "Das ist das Haus vom Nikolaus..."
044:                    + "Das ist das Haus vom Nikolaus..."
045:                    + "Das ist das Haus vom Nikolaus..."
046:                    + "Das ist das Haus vom Nikolaus..."
047:                    + "Das ist das Haus vom Nikolaus..."
048:                    + "Das ist das Haus vom Nikolaus..."
049:                    + "Das ist das Haus vom Nikolaus...";
050:
051:            /**
052:             * testing the proxy functionality of JMeasurement.
053:             * 
054:             * @throws Exception
055:             */
056:            public void testProxy() throws Exception {
057:                System.out
058:                        .println("testing proxy functionality of JMeasurement.");
059:                MeasureFactory.setApplicationName("ProxyTest");
060:                MeasureFactory.clear();
061:                ITestProxy testProxy = (ITestProxy) MeasureFactory
062:                        .registerInterface(new CTestProxy(), true, true);
063:
064:                for (int i = 0; i < LOOP_COUNT_PROXY; i++) {
065:                    testProxy.echoNow("echo now: This is my line.");
066:                    String org = "echo: This is my line.";
067:                    String line = testProxy.echo(org);
068:                    assertEquals(org, line);
069:                    try {
070:                        testProxy.exceptionNow();
071:                        fail("ProxyException expected");
072:                    } catch (Exception e) {
073:                    }
074:                }
075:                System.out.println(MeasureFactory.asString());
076:
077:                Long value = (Long) ((DefaultMeasurePoint) MeasureFactory
078:                        .getMeasurePoint("de.mcs.jmeasurement.test.proxy.CTestProxy#echo"))
079:                        .getData("averageMSec").getValue();
080:
081:                assertBetween(CTestProxy.waitEcho - 10,
082:                        CTestProxy.waitEcho + 10, value.intValue());
083:
084:                value = (Long) ((DefaultMeasurePoint) MeasureFactory
085:                        .getMeasurePoint("de.mcs.jmeasurement.test.proxy.CTestProxy#echo"))
086:                        .getData("accessCount").getValue();
087:
088:                assertEquals(LOOP_COUNT_PROXY, value.intValue());
089:
090:                value = (Long) ((DefaultMeasurePoint) MeasureFactory
091:                        .getMeasurePoint("de.mcs.jmeasurement.test.proxy.CTestProxy#echoNow"))
092:                        .getData("averageMSec").getValue();
093:
094:                assertBetween(CTestProxy.waitEchoNow - 10,
095:                        CTestProxy.waitEchoNow + 10, value.intValue());
096:
097:                value = (Long) ((DefaultMeasurePoint) MeasureFactory
098:                        .getMeasurePoint("de.mcs.jmeasurement.test.proxy.CTestProxy#echoNow"))
099:                        .getData("accessCount").getValue();
100:
101:                assertEquals(LOOP_COUNT_PROXY, value.intValue());
102:
103:                value = (Long) ((DefaultMeasurePoint) MeasureFactory
104:                        .getMeasurePoint("de.mcs.jmeasurement.test.proxy.CTestProxy#exceptionNow"))
105:                        .getData("averageMSec").getValue();
106:
107:                assertBetween(CTestProxy.waitException - 10,
108:                        CTestProxy.waitException + 10, value.intValue());
109:
110:                value = (Long) ((DefaultMeasurePoint) MeasureFactory
111:                        .getMeasurePoint("de.mcs.jmeasurement.test.proxy.CTestProxy#exceptionNow"))
112:                        .getData("accessCount").getValue();
113:
114:                assertEquals(LOOP_COUNT_PROXY, value.intValue());
115:            }
116:
117:            /**
118:             * testing the proxy functionality of JMeasurement.
119:             * 
120:             * @throws Exception
121:             */
122:            public void testProxyMethodNames() throws Exception {
123:                System.out
124:                        .println("testing proxy functionality with method names of JMeasurement.");
125:                MeasureFactory.setApplicationName("ProxyTest");
126:                MeasureFactory.clear();
127:                ITestProxy testProxy = (ITestProxy) MeasureFactory
128:                        .registerInterface(new CTestProxy(), true, true,
129:                                new String[] { "echo" });
130:
131:                for (int i = 0; i < LOOP_COUNT_PROXY; i++) {
132:                    testProxy.echoNow("echo now: This is my line.");
133:                    String org = "echo: This is my line.";
134:                    String line = testProxy.echo(org);
135:                    assertEquals(org, line);
136:                    try {
137:                        testProxy.exceptionNow();
138:                        fail("ProxyException expected");
139:                    } catch (Exception e) {
140:                    }
141:                }
142:                System.out.println(MeasureFactory.asString());
143:
144:                Long value = (Long) ((DefaultMeasurePoint) MeasureFactory
145:                        .getMeasurePoint("de.mcs.jmeasurement.test.proxy.CTestProxy#echo"))
146:                        .getData("averageMSec").getValue();
147:
148:                assertBetween(CTestProxy.waitEcho - 10,
149:                        CTestProxy.waitEcho + 10, value.intValue());
150:
151:                value = (Long) ((DefaultMeasurePoint) MeasureFactory
152:                        .getMeasurePoint("de.mcs.jmeasurement.test.proxy.CTestProxy#echo"))
153:                        .getData("accessCount").getValue();
154:
155:                assertEquals(LOOP_COUNT_PROXY, value.intValue());
156:
157:                value = (Long) ((DefaultMeasurePoint) MeasureFactory
158:                        .getMeasurePoint("de.mcs.jmeasurement.test.proxy.CTestProxy#echoNow"))
159:                        .getData("averageMSec").getValue();
160:
161:                assertBetween(CTestProxy.waitEchoNow - 10,
162:                        CTestProxy.waitEchoNow + 10, value.intValue());
163:
164:                value = (Long) ((DefaultMeasurePoint) MeasureFactory
165:                        .getMeasurePoint("de.mcs.jmeasurement.test.proxy.CTestProxy#echoNow"))
166:                        .getData("accessCount").getValue();
167:
168:                assertEquals(0, value.intValue());
169:
170:                value = (Long) ((DefaultMeasurePoint) MeasureFactory
171:                        .getMeasurePoint("de.mcs.jmeasurement.test.proxy.CTestProxy#exceptionNow"))
172:                        .getData("averageMSec").getValue();
173:
174:                assertBetween(CTestProxy.waitException - 10,
175:                        CTestProxy.waitException + 10, value.intValue());
176:
177:                value = (Long) ((DefaultMeasurePoint) MeasureFactory
178:                        .getMeasurePoint("de.mcs.jmeasurement.test.proxy.CTestProxy#exceptionNow"))
179:                        .getData("accessCount").getValue();
180:
181:                assertEquals(0, value.intValue());
182:
183:            }
184:
185:            public void testMethodeCalls() throws MeasurementException {
186:                MeasureFactory.clear();
187:                ITestProxy testProxy = (ITestProxy) MeasureFactory
188:                        .registerInterface(new CTestProxy(), true, true);
189:                DefaultMonitor monitor = new DefaultMonitor(
190:                        "echotest_mit_proxy");
191:                monitor.start();
192:                for (int i = 0; i < LOOP_COUNT; i++) {
193:                    testProxy.iTestMethode(TEST_STRING);
194:                }
195:                monitor.stop();
196:
197:                MeasureFactory.setEnable(false);
198:                testProxy = (ITestProxy) MeasureFactory.registerInterface(
199:                        new CTestProxy(), true, false);
200:                DefaultMonitor monitor1 = new DefaultMonitor(
201:                        "echotest_mit_proxy_aus");
202:                monitor1.start();
203:                for (int i = 0; i < LOOP_COUNT; i++) {
204:                    String murks = testProxy.iTestMethode(TEST_STRING);
205:                }
206:                monitor1.stop();
207:
208:                CTestProxy myProxy = new CTestProxy();
209:
210:                DefaultMonitor monitor2 = new DefaultMonitor(
211:                        "echotest_ohne_proxy");
212:                monitor2.start();
213:                for (int i = 0; i < LOOP_COUNT; i++) {
214:                    String murks = myProxy.iTestMethode(TEST_STRING);
215:                }
216:                monitor2.stop();
217:
218:                System.out.println("Test access time of the proxy methods.");
219:                System.out
220:                        .println("loop count:" + Integer.toString(LOOP_COUNT));
221:                System.out.println("total time:" + monitor.toString());
222:                System.out.println("total time:" + monitor1.toString());
223:                System.out.println("total time:" + monitor2.toString());
224:
225:                MeasureFactory.setEnable(true);
226:                for (int i = 0; i < 10000; i++) {
227:                    Monitor monitor3 = MeasureFactory.getMonitor("dummy_point_"
228:                            + Integer.toString(i));
229:                }
230:                DefaultMonitor dmonitor3 = new DefaultMonitor(
231:                        "accesstest_with_factory_on");
232:                dmonitor3.start();
233:                for (int i = 0; i < LOOP_COUNT; i++) {
234:                    Monitor monitor3 = MeasureFactory
235:                            .getMonitor("accesstest_with_factory_on");
236:                    monitor3.start();
237:                    monitor3.stop();
238:                }
239:                dmonitor3.stop();
240:
241:                MeasureFactory.setEnable(false);
242:                DefaultMonitor dmonitor4 = new DefaultMonitor(
243:                        "accesstest_with_factory_off");
244:                dmonitor4.start();
245:                for (int i = 0; i < LOOP_COUNT; i++) {
246:                    Monitor monitor3 = MeasureFactory
247:                            .getMonitor("accesstest_with_factory_off");
248:                    monitor3.start();
249:                    monitor3.stop();
250:                }
251:                dmonitor4.stop();
252:
253:                System.out.println();
254:                System.out.println("Test access time of factory methods.");
255:                System.out
256:                        .println("loop count:" + Integer.toString(LOOP_COUNT));
257:                System.out.println("total time:" + dmonitor3.toString());
258:                System.out.println("total time:" + dmonitor4.toString());
259:
260:            }
261:
262:            public static void main(String[] args) throws Exception {
263:                ProxyTest proxyTest = new ProxyTest();
264:                proxyTest.testProxy();
265:                proxyTest.testMethodeCalls();
266:                try {
267:                    MeasureFactory.saveToXMLFile("data.xml");
268:                } catch (IOException e) {
269:                    // TODO Auto-generated catch block
270:                    e.printStackTrace();
271:                } catch (SAXException e) {
272:                    // TODO Auto-generated catch block
273:                    e.printStackTrace();
274:                }
275:
276:            }
277:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.