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.3", comments = "See http://jomc.sourceforge.net/jomc/1.3/jomc-tools-1.3" )
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.3", comments = "See http://jomc.sourceforge.net/jomc/1.3/jomc-tools-1.3" )
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 @SuppressWarnings("unused")
301 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.3", comments = "See http://jomc.sourceforge.net/jomc/1.3/jomc-tools-1.3" )
302 private org.jomc.ri.test.support.TestSpecification[] getBoundMultitons()
303 {
304 final org.jomc.ri.test.support.TestSpecification[] _d = (org.jomc.ri.test.support.TestSpecification[]) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "BoundMultitons" );
305 assert _d != null : "'BoundMultitons' dependency not found.";
306 return _d;
307 }
308
309
310
311
312
313
314
315
316
317
318
319
320 @SuppressWarnings("unused")
321 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.3", comments = "See http://jomc.sourceforge.net/jomc/1.3/jomc-tools-1.3" )
322 private org.jomc.ri.test.support.TestSpecification[] getBoundSingletons()
323 {
324 final org.jomc.ri.test.support.TestSpecification[] _d = (org.jomc.ri.test.support.TestSpecification[]) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "BoundSingletons" );
325 assert _d != null : "'BoundSingletons' dependency not found.";
326 return _d;
327 }
328
329
330
331
332
333
334
335
336
337
338
339
340 @SuppressWarnings("unused")
341 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.3", comments = "See http://jomc.sourceforge.net/jomc/1.3/jomc-tools-1.3" )
342 private org.jomc.ri.test.support.InvokerTestSpecification getInvokerTestSpecification()
343 {
344 final org.jomc.ri.test.support.InvokerTestSpecification _d = (org.jomc.ri.test.support.InvokerTestSpecification) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "InvokerTestSpecification" );
345 assert _d != null : "'InvokerTestSpecification' dependency not found.";
346 return _d;
347 }
348
349
350
351
352
353
354
355
356
357
358
359
360
361 @SuppressWarnings("unused")
362 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.3", comments = "See http://jomc.sourceforge.net/jomc/1.3/jomc-tools-1.3" )
363 private java.util.Locale getOptionalLocale()
364 {
365 return (java.util.Locale) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "OptionalLocale" );
366 }
367
368
369
370
371
372
373
374
375
376
377
378
379 @SuppressWarnings("unused")
380 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.3", comments = "See http://jomc.sourceforge.net/jomc/1.3/jomc-tools-1.3" )
381 private org.jomc.ri.test.support.TestSpecification getSelectedBoundMultiton()
382 {
383 final org.jomc.ri.test.support.TestSpecification _d = (org.jomc.ri.test.support.TestSpecification) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "SelectedBoundMultiton" );
384 assert _d != null : "'SelectedBoundMultiton' dependency not found.";
385 return _d;
386 }
387
388
389
390
391
392
393
394
395
396
397
398
399 @SuppressWarnings("unused")
400 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.3", comments = "See http://jomc.sourceforge.net/jomc/1.3/jomc-tools-1.3" )
401 private org.jomc.ri.test.support.TestSpecification getSelectedBoundSingleton()
402 {
403 final org.jomc.ri.test.support.TestSpecification _d = (org.jomc.ri.test.support.TestSpecification) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "SelectedBoundSingleton" );
404 assert _d != null : "'SelectedBoundSingleton' dependency not found.";
405 return _d;
406 }
407
408
409
410
411
412
413
414
415
416
417
418
419 @SuppressWarnings("unused")
420 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.3", comments = "See http://jomc.sourceforge.net/jomc/1.3/jomc-tools-1.3" )
421 private org.jomc.ri.test.support.TestSpecification getSelectedUnboundMultiton()
422 {
423 final org.jomc.ri.test.support.TestSpecification _d = (org.jomc.ri.test.support.TestSpecification) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "SelectedUnboundMultiton" );
424 assert _d != null : "'SelectedUnboundMultiton' dependency not found.";
425 return _d;
426 }
427
428
429
430
431
432
433
434
435
436
437
438
439 @SuppressWarnings("unused")
440 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.3", comments = "See http://jomc.sourceforge.net/jomc/1.3/jomc-tools-1.3" )
441 private org.jomc.ri.test.support.TestSpecification getSelectedUnboundSingleton()
442 {
443 final org.jomc.ri.test.support.TestSpecification _d = (org.jomc.ri.test.support.TestSpecification) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "SelectedUnboundSingleton" );
444 assert _d != null : "'SelectedUnboundSingleton' dependency not found.";
445 return _d;
446 }
447
448
449
450
451
452
453
454
455
456
457
458
459 @SuppressWarnings("unused")
460 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.3", comments = "See http://jomc.sourceforge.net/jomc/1.3/jomc-tools-1.3" )
461 private org.jomc.ri.test.support.TestSpecification[] getUnboundMultitons()
462 {
463 final org.jomc.ri.test.support.TestSpecification[] _d = (org.jomc.ri.test.support.TestSpecification[]) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "UnboundMultitons" );
464 assert _d != null : "'UnboundMultitons' dependency not found.";
465 return _d;
466 }
467
468
469
470
471
472
473
474
475
476
477
478
479 @SuppressWarnings("unused")
480 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.3", comments = "See http://jomc.sourceforge.net/jomc/1.3/jomc-tools-1.3" )
481 private org.jomc.ri.test.support.TestSpecification[] getUnboundSingletons()
482 {
483 final org.jomc.ri.test.support.TestSpecification[] _d = (org.jomc.ri.test.support.TestSpecification[]) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "UnboundSingletons" );
484 assert _d != null : "'UnboundSingletons' dependency not found.";
485 return _d;
486 }
487
488
489
490
491
492
493
494
495
496
497
498
499 @SuppressWarnings("unused")
500 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.3", comments = "See http://jomc.sourceforge.net/jomc/1.3/jomc-tools-1.3" )
501 private java.lang.String getTestProperty()
502 {
503 final java.lang.String _p = (java.lang.String) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "testProperty" );
504 assert _p != null : "'testProperty' property not found.";
505 return _p;
506 }
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523 @SuppressWarnings("unused")
524 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.3", comments = "See http://jomc.sourceforge.net/jomc/1.3/jomc-tools-1.3" )
525 private String getTestMessage( final java.util.Locale locale, final java.lang.String testArgument )
526 {
527 final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "testMessage", locale, testArgument );
528 assert _m != null : "'testMessage' message not found.";
529 return _m;
530 }
531
532
533 }