1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 package org.jomc.ri.test;
37
38 import java.util.Locale;
39 import org.junit.Test;
40 import static org.junit.Assert.assertNull;
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.2.2", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.2" )
69
70
71 public class ImplementationTest
72 implements
73 org.jomc.ri.test.support.TestSpecification,
74 org.jomc.ri.test.support.TestSpecificationOne,
75 org.jomc.ri.test.support.TestSpecificationMany,
76 org.jomc.ri.test.support.TestScopeSpecification
77 {
78
79
80
81
82
83
84
85
86
87
88 private static final int NUM_REQUESTS = 25000;
89
90 private static final int NUM_RUNS = 2;
91
92 @Test
93 public final void testBoundMultitons() throws Exception
94 {
95 this.printEstimatedExecutionTime( "BoundMultitons", new Runnable()
96 {
97
98 public void run()
99 {
100 getBoundMultitons();
101 }
102
103 } );
104
105 }
106
107 @Test
108 public final void testUnboundMultitons() throws Exception
109 {
110 this.printEstimatedExecutionTime( "UnboundMultitons", new Runnable()
111 {
112
113 public void run()
114 {
115 getUnboundMultitons();
116 }
117
118 } );
119
120 }
121
122 @Test
123 public final void testSelectedBoundMultiton() throws Exception
124 {
125 this.printEstimatedExecutionTime( "SelectedBoundMultiton", new Runnable()
126 {
127
128 public void run()
129 {
130 getSelectedBoundMultiton();
131 }
132
133 } );
134
135 }
136
137 @Test
138 public final void testSelectedUnboundMultiton() throws Exception
139 {
140 this.printEstimatedExecutionTime( "SelectedUnboundMultiton", new Runnable()
141 {
142
143 public void run()
144 {
145 getSelectedUnboundMultiton();
146 }
147
148 } );
149
150 }
151
152 @Test
153 public final void testBoundSingletons() throws Exception
154 {
155 this.printEstimatedExecutionTime( "BoundSingletons", new Runnable()
156 {
157
158 public void run()
159 {
160 getBoundSingletons();
161 }
162
163 } );
164
165 }
166
167 @Test
168 public final void testUnboundSingletons() throws Exception
169 {
170 this.printEstimatedExecutionTime( "UnboundSingletons", new Runnable()
171 {
172
173 public void run()
174 {
175 getUnboundSingletons();
176 }
177
178 } );
179
180 }
181
182 @Test
183 public final void testSelectedBoundSingleton() throws Exception
184 {
185 this.printEstimatedExecutionTime( "SelectedBoundSingleton", new Runnable()
186 {
187
188 public void run()
189 {
190 getSelectedBoundSingleton();
191 }
192
193 } );
194
195 }
196
197 @Test
198 public final void testSelectedUnboundSingleton() throws Exception
199 {
200 this.printEstimatedExecutionTime( "SelectedUnboundSingleton", new Runnable()
201 {
202
203 public void run()
204 {
205 getSelectedUnboundSingleton();
206 }
207
208 } );
209
210 }
211
212 @Test
213 public final void testProperties() throws Exception
214 {
215 this.printEstimatedExecutionTime( "TestProperty", new Runnable()
216 {
217
218 public void run()
219 {
220 getTestProperty();
221 }
222
223 } );
224
225 }
226
227 @Test
228 public final void testMessages() throws Exception
229 {
230 this.printEstimatedExecutionTime( "TestMessage", new Runnable()
231 {
232
233 public void run()
234 {
235 getTestMessage( Locale.getDefault(), "arg" );
236 }
237
238 } );
239
240 }
241
242 @Test
243 public final void testOptionalDependency() throws Exception
244 {
245 assertNull( this.getOptionalLocale() );
246 }
247
248 @Test
249 public final void testInvoker() throws Exception
250 {
251 this.getInvokerTestSpecification().invoke( "TEST" );
252 }
253
254 protected void printEstimatedExecutionTime( final String identifier, final Runnable runnable )
255 {
256 long t = 0L;
257
258 for ( int i = NUM_RUNS - 1; i >= 0; i-- )
259 {
260 final long t0 = System.currentTimeMillis();
261
262 for ( long l = NUM_REQUESTS - 1; l >= 0; l-- )
263 {
264 runnable.run();
265 }
266
267 t += ( System.currentTimeMillis() - t0 );
268 }
269
270 System.out.println( NUM_REQUESTS + " * '" + identifier + "': ~" + ( t / NUM_RUNS ) + "ms." );
271 }
272
273
274
275
276
277 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.2.2", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.2" )
278 public ImplementationTest()
279 {
280
281 super();
282
283 }
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.2.2", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.2" )
301 private org.jomc.ri.test.support.TestSpecification[] getBoundMultitons()
302 {
303 final org.jomc.ri.test.support.TestSpecification[] _d = (org.jomc.ri.test.support.TestSpecification[]) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "BoundMultitons" );
304 assert _d != null : "'BoundMultitons' dependency not found.";
305 return _d;
306 }
307
308
309
310
311
312
313
314
315
316
317
318
319 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.2.2", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.2" )
320 private org.jomc.ri.test.support.TestSpecification[] getBoundSingletons()
321 {
322 final org.jomc.ri.test.support.TestSpecification[] _d = (org.jomc.ri.test.support.TestSpecification[]) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "BoundSingletons" );
323 assert _d != null : "'BoundSingletons' dependency not found.";
324 return _d;
325 }
326
327
328
329
330
331
332
333
334
335
336
337
338 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.2.2", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.2" )
339 private org.jomc.ri.test.support.InvokerTestSpecification getInvokerTestSpecification()
340 {
341 final org.jomc.ri.test.support.InvokerTestSpecification _d = (org.jomc.ri.test.support.InvokerTestSpecification) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "InvokerTestSpecification" );
342 assert _d != null : "'InvokerTestSpecification' dependency not found.";
343 return _d;
344 }
345
346
347
348
349
350
351
352
353
354
355
356
357
358 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.2.2", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.2" )
359 private java.util.Locale getOptionalLocale()
360 {
361 return (java.util.Locale) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "OptionalLocale" );
362 }
363
364
365
366
367
368
369
370
371
372
373
374
375 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.2.2", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.2" )
376 private org.jomc.ri.test.support.TestSpecification getSelectedBoundMultiton()
377 {
378 final org.jomc.ri.test.support.TestSpecification _d = (org.jomc.ri.test.support.TestSpecification) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "SelectedBoundMultiton" );
379 assert _d != null : "'SelectedBoundMultiton' dependency not found.";
380 return _d;
381 }
382
383
384
385
386
387
388
389
390
391
392
393
394 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.2.2", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.2" )
395 private org.jomc.ri.test.support.TestSpecification getSelectedBoundSingleton()
396 {
397 final org.jomc.ri.test.support.TestSpecification _d = (org.jomc.ri.test.support.TestSpecification) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "SelectedBoundSingleton" );
398 assert _d != null : "'SelectedBoundSingleton' dependency not found.";
399 return _d;
400 }
401
402
403
404
405
406
407
408
409
410
411
412
413 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.2.2", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.2" )
414 private org.jomc.ri.test.support.TestSpecification getSelectedUnboundMultiton()
415 {
416 final org.jomc.ri.test.support.TestSpecification _d = (org.jomc.ri.test.support.TestSpecification) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "SelectedUnboundMultiton" );
417 assert _d != null : "'SelectedUnboundMultiton' dependency not found.";
418 return _d;
419 }
420
421
422
423
424
425
426
427
428
429
430
431
432 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.2.2", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.2" )
433 private org.jomc.ri.test.support.TestSpecification getSelectedUnboundSingleton()
434 {
435 final org.jomc.ri.test.support.TestSpecification _d = (org.jomc.ri.test.support.TestSpecification) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "SelectedUnboundSingleton" );
436 assert _d != null : "'SelectedUnboundSingleton' dependency not found.";
437 return _d;
438 }
439
440
441
442
443
444
445
446
447
448
449
450
451 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.2.2", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.2" )
452 private org.jomc.ri.test.support.TestSpecification[] getUnboundMultitons()
453 {
454 final org.jomc.ri.test.support.TestSpecification[] _d = (org.jomc.ri.test.support.TestSpecification[]) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "UnboundMultitons" );
455 assert _d != null : "'UnboundMultitons' dependency not found.";
456 return _d;
457 }
458
459
460
461
462
463
464
465
466
467
468
469
470 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.2.2", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.2" )
471 private org.jomc.ri.test.support.TestSpecification[] getUnboundSingletons()
472 {
473 final org.jomc.ri.test.support.TestSpecification[] _d = (org.jomc.ri.test.support.TestSpecification[]) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "UnboundSingletons" );
474 assert _d != null : "'UnboundSingletons' dependency not found.";
475 return _d;
476 }
477
478
479
480
481
482
483
484
485
486
487
488
489 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.2.2", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.2" )
490 private java.lang.String getTestProperty()
491 {
492 final java.lang.String _p = (java.lang.String) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "testProperty" );
493 assert _p != null : "'testProperty' property not found.";
494 return _p;
495 }
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.2.2", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.2" )
513 private String getTestMessage( final java.util.Locale locale, final java.lang.String testArgument )
514 {
515 final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "testMessage", locale, testArgument );
516 assert _m != null : "'testMessage' message not found.";
517 return _m;
518 }
519
520
521 }