1 /*
2  * JTiger Unit Testing Framework for J2SE 1.5
3  * Copyright (C) 2005 Tony Morris
4  *
5  * This software is licenced under the
6  * Common Public Licence version 1.0
7  * http://www.opensource.org/licenses/cpl1.0.php
8  *
9  * You received a copy of this licence with this software.
10  */
11 package org.jtiger.assertion;
12 
13 import java.lang.reflect.Constructor;
14 import java.lang.reflect.Field;
15 import java.lang.reflect.InvocationTargetException;
16 import java.lang.reflect.Method;
17 import org.jtiger.framework.Category;
18 import org.jtiger.framework.ExpectException;
19 import org.jtiger.framework.Fixture;
20 import org.jtiger.framework.Test;
21 import static org.jtiger.assertion.Basic.assertFalse;
22 import static org.jtiger.assertion.Modifier.assertAbstract;
23 import static org.jtiger.assertion.Modifier.assertNotAbstract;
24 import static org.jtiger.assertion.Modifier.assertFinal;
25 import static org.jtiger.assertion.Modifier.assertNotFinal;
26 import static org.jtiger.assertion.Modifier.assertNative;
27 import static org.jtiger.assertion.Modifier.assertNotNative;
28 import static org.jtiger.assertion.Modifier.assertPrivate;
29 import static org.jtiger.assertion.Modifier.assertNotPrivate;
30 import static org.jtiger.assertion.Modifier.assertDefaultAccess;
31 import static org.jtiger.assertion.Modifier.assertNotDefaultAccess;
32 import static org.jtiger.assertion.Modifier.assertProtected;
33 import static org.jtiger.assertion.Modifier.assertNotProtected;
34 import static org.jtiger.assertion.Modifier.assertPublic;
35 import static org.jtiger.assertion.Modifier.assertNotPublic;
36 import static org.jtiger.assertion.Modifier.assertStatic;
37 import static org.jtiger.assertion.Modifier.assertNotStatic;
38 import static org.jtiger.assertion.Modifier.assertStrictfp;
39 import static org.jtiger.assertion.Modifier.assertNotStrictfp;
40 import static org.jtiger.assertion.Modifier.assertSynchronized;
41 import static org.jtiger.assertion.Modifier.assertNotSynchronized;
42 import static org.jtiger.assertion.Modifier.assertTransient;
43 import static org.jtiger.assertion.Modifier.assertNotTransient;
44 import static org.jtiger.assertion.Modifier.assertVolatile;
45 import static org.jtiger.assertion.Modifier.assertNotVolatile;
46 import static org.jtiger.assertion.Reflection.assertHasDeclaredConstructor;
47 import static org.jtiger.assertion.Reflection.assertHasDeclaredField;
48 import static org.jtiger.assertion.Reflection.assertHasDeclaredMethod;
49 
50 @Fixture(value = "Modifier", description = "Performs Unit Tests on org.jtiger.assertion.Modifier")
51 @Category("org.jtiger.assertion.Modifier")
52 public final class TestModifier
53 {
TestModifier()54     public TestModifier()
55     {
56 
57     }
58 
59     @Test
constructor()60     public void constructor() throws InstantiationException, IllegalAccessException, InvocationTargetException
61     {
62         final Constructor<?> c = assertHasDeclaredConstructor(Modifier.class, null);
63         assertPrivate(c);
64         assertFalse(c.isAccessible());
65         c.setAccessible(true);
66         c.newInstance();
67     }
68 
69     @Test
testAssertAbstract()70     public void testAssertAbstract()
71     {
72         final Class<?> c = AbstractClass.class;
73         assertAbstract(c);
74         final Method m = assertHasDeclaredMethod(c, "abstractMethod", null);
75         assertAbstract(m);
76     }
77 
78     @Test
79     @ExpectException(value = AssertionException.class)
testAssertAbstractInverse1()80     public void testAssertAbstractInverse1()
81     {
82         final Class<?> c = NotAbstractClass.class;
83         assertAbstract(c);
84     }
85 
86     @Test
87     @ExpectException(value = AssertionException.class)
testAssertAbstractInverse2()88     public void testAssertAbstractInverse2()
89     {
90         final Class<?> c = NotAbstractClass.class;
91         final Method m = assertHasDeclaredMethod(c, "notAbstractMethod", null);
92         assertAbstract(m);
93     }
94 
95     @Test
96     @ExpectException(value = AssertionException.class)
testAssertAbstractInverse3()97     public void testAssertAbstractInverse3()
98     {
99         final Class<?> c = NotAbstractClass.class;
100         final Method m = assertHasDeclaredMethod(c, "notAbstractMethod", null);
101         assertAbstract(m);
102     }
103 
104     @Test
testAssertNotAbstract()105     public void testAssertNotAbstract()
106     {
107         final Class<?> c = NotAbstractClass.class;
108         assertNotAbstract(c);
109         final Method m = assertHasDeclaredMethod(c, "notAbstractMethod", null);
110         assertNotAbstract(m);
111     }
112 
113     @Test
114     @ExpectException(value = AssertionException.class)
testAssertNotAbstractInverse1()115     public void testAssertNotAbstractInverse1()
116     {
117         final Class<?> c = AbstractClass.class;
118         assertNotAbstract(c);
119     }
120 
121     @Test
122     @ExpectException(value = AssertionException.class)
testAssertNotAbstractInverse2()123     public void testAssertNotAbstractInverse2()
124     {
125         final Class<?> c = AbstractClass.class;
126         final Method m = assertHasDeclaredMethod(c, "abstractMethod", null);
127         assertNotAbstract(m);
128     }
129 
130     @Test
131     @ExpectException(value = AssertionException.class)
testAssertNotAbstractInverse3()132     public void testAssertNotAbstractInverse3()
133     {
134         final Class<?> c = AbstractClass.class;
135         final Method m = assertHasDeclaredMethod(c, "abstractMethod", null);
136         assertNotAbstract(m);
137     }
138 
139     @Test
testAssertFinal()140     public void testAssertFinal()
141     {
142         final Class<?> c = FinalClass.class;
143         assertFinal(c);
144         final Method m = assertHasDeclaredMethod(c, "finalMethod", null);
145         assertFinal(m);
146         final Field f = assertHasDeclaredField(c, "finalField");
147         assertFinal(f);
148     }
149 
150     @Test
151     @ExpectException(value = AssertionException.class)
testAssertFinalInverse1()152     public void testAssertFinalInverse1()
153     {
154         final Class<?> c = NotFinalClass.class;
155         assertFinal(c);
156     }
157 
158     @Test
159     @ExpectException(value = AssertionException.class)
testAssertFinalInverse2()160     public void testAssertFinalInverse2()
161     {
162         final Class<?> c = NotFinalClass.class;
163         final Method m = assertHasDeclaredMethod(c, "notFinalMethod", null);
164         assertFinal(m);
165     }
166 
167     @Test
168     @ExpectException(value = AssertionException.class)
testAssertFinalInverse3()169     public void testAssertFinalInverse3()
170     {
171         final Class<?> c = NotFinalClass.class;
172         final Field f = assertHasDeclaredField(c, "notFinalField");
173         assertFinal(f);
174     }
175 
176     @Test
testAssertNotFinal()177     public void testAssertNotFinal()
178     {
179         final Class<?> c = NotFinalClass.class;
180         assertNotFinal(c);
181         final Method m = assertHasDeclaredMethod(c, "notFinalMethod", null);
182         assertNotFinal(m);
183         final Field f = assertHasDeclaredField(c, "notFinalField");
184         assertNotFinal(f);
185     }
186 
187     @Test
188     @ExpectException(value = AssertionException.class)
testAssertNotFinalInverse1()189     public void testAssertNotFinalInverse1()
190     {
191         final Class<?> c = FinalClass.class;
192         assertNotFinal(c);
193     }
194 
195     @Test
196     @ExpectException(value = AssertionException.class)
testAssertNotFinalInverse2()197     public void testAssertNotFinalInverse2()
198     {
199         final Class<?> c = FinalClass.class;
200         final Method m = assertHasDeclaredMethod(c, "finalMethod", null);
201         assertNotFinal(m);
202     }
203 
204     @Test
205     @ExpectException(value = AssertionException.class)
testAssertNotFinalInverse3()206     public void testAssertNotFinalInverse3()
207     {
208         final Class<?> c = FinalClass.class;
209         final Field f = assertHasDeclaredField(c, "finalField");
210         assertNotFinal(f);
211     }
212 
213     @Test
testAssertNative()214     public void testAssertNative()
215     {
216         final Class<?> c = NativeClass.class;
217         final Method m = assertHasDeclaredMethod(c, "nativeMethod", null);
218         assertNative(m);
219     }
220 
221     @Test
222     @ExpectException(value = AssertionException.class)
testAssertNativeInverse()223     public void testAssertNativeInverse()
224     {
225         final Class<?> c = NotNativeClass.class;
226         final Method m = assertHasDeclaredMethod(c, "notNativeMethod", null);
227         assertNative(m);
228     }
229 
230     @Test
testAssertNotNative()231     public void testAssertNotNative()
232     {
233         final Class<?> c = NotNativeClass.class;
234         final Method m = assertHasDeclaredMethod(c, "notNativeMethod", null);
235         assertNotNative(m);
236     }
237 
238     @Test
239     @ExpectException(value = AssertionException.class)
testAssertNotNativeInverse()240     public void testAssertNotNativeInverse()
241     {
242         final Class<?> c = NativeClass.class;
243         final Method m = assertHasDeclaredMethod(c, "nativeMethod", null);
244         assertNotNative(m);
245     }
246 
247     @Test
testAssertPrivate()248     public void testAssertPrivate()
249     {
250         final Class<?> c = PrivateClass.class;
251         assertPrivate(c);
252         final Constructor<?> ctor = assertHasDeclaredConstructor(PrivateConstructor.class, null);
253         assertPrivate(ctor);
254         final Method m = assertHasDeclaredMethod(c, "m", null);
255         assertPrivate(m);
256         final Field f = assertHasDeclaredField(c, "f");
257         assertPrivate(f);
258     }
259 
260     @Test
261     @ExpectException(value = AssertionException.class)
testAssertPrivateInverse1()262     public void testAssertPrivateInverse1()
263     {
264         final Class<?> c = NotPrivateClass.class;
265         assertPrivate(c);
266     }
267 
268     @Test
269     @ExpectException(value = AssertionException.class)
testAssertPrivateInverse2()270     public void testAssertPrivateInverse2()
271     {
272         final Constructor<?> ctor = assertHasDeclaredConstructor(NotPrivateConstructor.class, null);
273         assertPrivate(ctor);
274     }
275 
276     @Test
277     @ExpectException(value = AssertionException.class)
testAssertPrivateInverse3()278     public void testAssertPrivateInverse3()
279     {
280         final Class<?> c = NotPrivateClass.class;
281         final Method m = assertHasDeclaredMethod(c, "m", null);
282         assertPrivate(m);
283     }
284 
285     @Test
286     @ExpectException(value = AssertionException.class)
testAssertPrivateInverse4()287     public void testAssertPrivateInverse4()
288     {
289         final Class<?> c = NotPrivateClass.class;
290         final Field f = assertHasDeclaredField(c, "f");
291         assertPrivate(f);
292     }
293     @Test
testAssertNotPrivate()294     public void testAssertNotPrivate()
295     {
296         final Class<?> c = NotPrivateClass.class;
297         assertNotPrivate(c);
298         final Constructor<?> ctor = assertHasDeclaredConstructor(NotPrivateConstructor.class, null);
299         assertNotPrivate(ctor);
300         final Method m = assertHasDeclaredMethod(c, "m", null);
301         assertNotPrivate(m);
302         final Field f = assertHasDeclaredField(c, "f");
303         assertNotPrivate(f);
304     }
305 
306     @Test
307     @ExpectException(value = AssertionException.class)
testAssertNotPrivateInverse1()308     public void testAssertNotPrivateInverse1()
309     {
310         final Class<?> c = PrivateClass.class;
311         assertNotPrivate(c);
312     }
313 
314     @Test
315     @ExpectException(value = AssertionException.class)
testAssertNotPrivateInverse2()316     public void testAssertNotPrivateInverse2()
317     {
318         final Constructor<?> ctor = assertHasDeclaredConstructor(PrivateConstructor.class, null);
319         assertNotPrivate(ctor);
320     }
321 
322     @Test
323     @ExpectException(value = AssertionException.class)
testAssertNotPrivateInverse3()324     public void testAssertNotPrivateInverse3()
325     {
326         final Class<?> c = PrivateClass.class;
327         final Method m = assertHasDeclaredMethod(c, "m", null);
328         assertNotPrivate(m);
329     }
330 
331     @Test
332     @ExpectException(value = AssertionException.class)
testAssertNotPrivateInverse4()333     public void testAssertNotPrivateInverse4()
334     {
335         final Class<?> c = PrivateClass.class;
336         final Field f = assertHasDeclaredField(c, "f");
337         assertNotPrivate(f);
338     }
339 
340     @Test
testAssertProtected()341     public void testAssertProtected()
342     {
343         final Class<?> c = ProtectedClass.class;
344         assertProtected(c);
345         final Constructor<?> ctor = assertHasDeclaredConstructor(c, null);
346         assertProtected(ctor);
347         final Method m = assertHasDeclaredMethod(c, "m", null);
348         assertProtected(m);
349         final Field f = assertHasDeclaredField(c, "f");
350         assertProtected(f);
351     }
352 
353     @Test
354     @ExpectException(value = AssertionException.class)
testAssertProtectedInverse1()355     public void testAssertProtectedInverse1()
356     {
357         final Class<?> c = NotProtectedClass.class;
358         assertProtected(c);
359     }
360 
361     @Test
362     @ExpectException(value = AssertionException.class)
testAssertProtectedInverse2()363     public void testAssertProtectedInverse2()
364     {
365         final Class<?> c = NotProtectedClass.class;
366         final Constructor<?> ctor = assertHasDeclaredConstructor(c, null);
367         assertProtected(ctor);
368     }
369 
370     @Test
371     @ExpectException(value = AssertionException.class)
testAssertProtectedInverse3()372     public void testAssertProtectedInverse3()
373     {
374         final Class<?> c = NotProtectedClass.class;
375         final Method m = assertHasDeclaredMethod(c, "m", null);
376         assertProtected(m);
377     }
378 
379     @Test
380     @ExpectException(value = AssertionException.class)
testAssertProtectedInverse4()381     public void testAssertProtectedInverse4()
382     {
383         final Class<?> c = NotProtectedClass.class;
384         final Field f = assertHasDeclaredField(c, "f");
385         assertProtected(f);
386     }
387 
388     @Test
testAssertNotProtected()389     public void testAssertNotProtected()
390     {
391         final Class<?> c = NotProtectedClass.class;
392         assertNotProtected(c);
393         final Constructor<?> ctor = assertHasDeclaredConstructor(c, null);
394         assertNotProtected(ctor);
395         final Method m = assertHasDeclaredMethod(c, "m", null);
396         assertNotProtected(m);
397         final Field f = assertHasDeclaredField(c, "f");
398         assertNotProtected(f);
399     }
400 
401     @Test
402     @ExpectException(value = AssertionException.class)
testAssertNotProtectedInverse1()403     public void testAssertNotProtectedInverse1()
404     {
405         final Class<?> c = ProtectedClass.class;
406         assertNotProtected(c);
407     }
408 
409     @Test
410     @ExpectException(value = AssertionException.class)
testAssertNotProtectedInverse2()411     public void testAssertNotProtectedInverse2()
412     {
413         final Class<?> c = ProtectedClass.class;
414         final Constructor<?> ctor = assertHasDeclaredConstructor(c, null);
415         assertNotProtected(ctor);
416     }
417 
418     @Test
419     @ExpectException(value = AssertionException.class)
testAssertNotProtectedInverse3()420     public void testAssertNotProtectedInverse3()
421     {
422         final Class<?> c = ProtectedClass.class;
423         final Method m = assertHasDeclaredMethod(c, "m", null);
424         assertNotProtected(m);
425     }
426 
427     @Test
428     @ExpectException(value = AssertionException.class)
testAssertNotProtectedInverse4()429     public void testAssertNotProtectedInverse4()
430     {
431         final Class<?> c = ProtectedClass.class;
432         final Field f = assertHasDeclaredField(c, "f");
433         assertNotProtected(f);
434     }
435 
436     @Test
testAssertPublic()437     public void testAssertPublic()
438     {
439         final Class<?> c = PublicClass.class;
440         assertPublic(c);
441         final Constructor<?> ctor = assertHasDeclaredConstructor(c, null);
442         assertPublic(ctor);
443         final Method m = assertHasDeclaredMethod(c, "m", null);
444         assertPublic(m);
445         final Field f = assertHasDeclaredField(c, "f");
446         assertPublic(f);
447     }
448 
449     @Test
450     @ExpectException(value = AssertionException.class)
testAssertPublicInverse1()451     public void testAssertPublicInverse1()
452     {
453         final Class<?> c = NotPublicClass.class;
454         assertPublic(c);
455     }
456 
457     @Test
458     @ExpectException(value = AssertionException.class)
testAssertPublicInverse2()459     public void testAssertPublicInverse2()
460     {
461         final Class<?> c = NotPublicClass.class;
462         final Constructor<?> ctor = assertHasDeclaredConstructor(c, null);
463         assertPublic(ctor);
464     }
465 
466     @Test
467     @ExpectException(value = AssertionException.class)
testAssertPublicInverse3()468     public void testAssertPublicInverse3()
469     {
470         final Class<?> c = NotPublicClass.class;
471         final Method m = assertHasDeclaredMethod(c, "m", null);
472         assertPublic(m);
473     }
474 
475     @Test
476     @ExpectException(value = AssertionException.class)
testAssertPublicInverse4()477     public void testAssertPublicInverse4()
478     {
479         final Class<?> c = NotPublicClass.class;
480         final Field f = assertHasDeclaredField(c, "f");
481         assertPublic(f);
482     }
483 
484     @Test
testAssertNotPublic()485     public void testAssertNotPublic()
486     {
487         final Class<?> c = NotPublicClass.class;
488         assertNotPublic(c);
489         final Constructor<?> ctor = assertHasDeclaredConstructor(c, null);
490         assertNotPublic(ctor);
491         final Method m = assertHasDeclaredMethod(c, "m", null);
492         assertNotPublic(m);
493         final Field f = assertHasDeclaredField(c, "f");
494         assertNotPublic(f);
495     }
496 
497     @Test
498     @ExpectException(value = AssertionException.class)
testAssertNotPublicInverse1()499     public void testAssertNotPublicInverse1()
500     {
501         final Class<?> c = PublicClass.class;
502         assertNotPublic(c);
503     }
504 
505     @Test
506     @ExpectException(value = AssertionException.class)
testAssertNotPublicInverse2()507     public void testAssertNotPublicInverse2()
508     {
509         final Class<?> c = PublicClass.class;
510         final Constructor<?> ctor = assertHasDeclaredConstructor(c, null);
511         assertNotPublic(ctor);
512     }
513 
514     @Test
515     @ExpectException(value = AssertionException.class)
testAssertNotPublicInverse3()516     public void testAssertNotPublicInverse3()
517     {
518         final Class<?> c = PublicClass.class;
519         final Method m = assertHasDeclaredMethod(c, "m", null);
520         assertNotPublic(m);
521     }
522 
523     @Test
524     @ExpectException(value = AssertionException.class)
testAssertNotPublicInverse4()525     public void testAssertNotPublicInverse4()
526     {
527         final Class<?> c = PublicClass.class;
528         final Field f = assertHasDeclaredField(c, "f");
529         assertNotPublic(f);
530     }
531 
532     @Test
testAssertDefaultAccess()533     public void testAssertDefaultAccess()
534     {
535         final Class<?> c = DefaultAccessClass.class;
536         assertDefaultAccess(c);
537         final Constructor<?> ctor = assertHasDeclaredConstructor(c, null);
538         assertDefaultAccess(ctor);
539         final Method m = assertHasDeclaredMethod(c, "m", null);
540         assertDefaultAccess(m);
541         final Field f = assertHasDeclaredField(c, "f");
542         assertDefaultAccess(f);
543     }
544 
545     @Test
546     @ExpectException(value = AssertionException.class)
testAssertDefaultAccessInverse1()547     public void testAssertDefaultAccessInverse1()
548     {
549         final Class<?> c = NotDefaultAccessClass.class;
550         assertDefaultAccess(c);
551     }
552 
553     @Test
554     @ExpectException(value = AssertionException.class)
testAssertDefaultAccessInverse2()555     public void testAssertDefaultAccessInverse2()
556     {
557         final Class<?> c = NotDefaultAccessClass.class;
558         final Constructor<?> ctor = assertHasDeclaredConstructor(c, null);
559         assertDefaultAccess(ctor);
560     }
561 
562     @Test
563     @ExpectException(value = AssertionException.class)
testAssertDefaultAccessInverse3()564     public void testAssertDefaultAccessInverse3()
565     {
566         final Class<?> c = NotDefaultAccessClass.class;
567         final Method m = assertHasDeclaredMethod(c, "m", null);
568         assertDefaultAccess(m);
569     }
570 
571     @Test
572     @ExpectException(value = AssertionException.class)
testAssertDefaultAccessInverse4()573     public void testAssertDefaultAccessInverse4()
574     {
575         final Class<?> c = NotDefaultAccessClass.class;
576         final Field f = assertHasDeclaredField(c, "f");
577         assertDefaultAccess(f);
578     }
579     @Test
testAssertNotDefaultAccess()580     public void testAssertNotDefaultAccess()
581     {
582         final Class<?> c = NotDefaultAccessClass.class;
583         assertNotDefaultAccess(c);
584         final Constructor<?> ctor = assertHasDeclaredConstructor(c, null);
585         assertNotDefaultAccess(ctor);
586         final Method m = assertHasDeclaredMethod(c, "m", null);
587         assertNotDefaultAccess(m);
588         final Field f = assertHasDeclaredField(c, "f");
589         assertNotDefaultAccess(f);
590     }
591 
592     @Test
593     @ExpectException(value = AssertionException.class)
testAssertNotDefaultAccessInverse1()594     public void testAssertNotDefaultAccessInverse1()
595     {
596         final Class<?> c = DefaultAccessClass.class;
597         assertNotDefaultAccess(c);
598     }
599 
600     @Test
601     @ExpectException(value = AssertionException.class)
testAssertNotDefaultAccessInverse2()602     public void testAssertNotDefaultAccessInverse2()
603     {
604         final Class<?> c = DefaultAccessClass.class;
605         final Constructor<?> ctor = assertHasDeclaredConstructor(c, null);
606         assertNotDefaultAccess(ctor);
607     }
608 
609     @Test
610     @ExpectException(value = AssertionException.class)
testAssertNotDefaultAccessInverse3()611     public void testAssertNotDefaultAccessInverse3()
612     {
613         final Class<?> c = DefaultAccessClass.class;
614         final Method m = assertHasDeclaredMethod(c, "m", null);
615         assertNotDefaultAccess(m);
616     }
617 
618     @Test
619     @ExpectException(value = AssertionException.class)
testNotAssertDefaultAccessInverse4()620     public void testNotAssertDefaultAccessInverse4()
621     {
622         final Class<?> c = DefaultAccessClass.class;
623         final Field f = assertHasDeclaredField(c, "f");
624         assertNotDefaultAccess(f);
625     }
626 
627     @Test
testAssertStatic()628     public void testAssertStatic()
629     {
630         final Class<?> c = StaticClass.class;
631         assertStatic(c);
632         final Method m = assertHasDeclaredMethod(c, "m", null);
633         assertStatic(m);
634         final Field f = assertHasDeclaredField(c, "f");
635         assertStatic(f);
636     }
637 
638     @Test
639     @ExpectException(value = AssertionException.class)
testAssertStaticInverse1()640     public void testAssertStaticInverse1()
641     {
642         final Class<?> c = NotStaticClass.class;
643         assertStatic(c);
644     }
645 
646     @Test
647     @ExpectException(value = AssertionException.class)
testAssertStaticInverse2()648     public void testAssertStaticInverse2()
649     {
650         final Class<?> c = NotStaticClass.class;
651         final Method m = assertHasDeclaredMethod(c, "m", null);
652         assertStatic(m);
653     }
654 
655     @Test
656     @ExpectException(value = AssertionException.class)
testAssertStaticInverse3()657     public void testAssertStaticInverse3()
658     {
659         final Class<?> c = NotStaticClass.class;
660         final Field f = assertHasDeclaredField(c, "f");
661         assertStatic(f);
662     }
663 
664     @Test
testAssertNotStatic()665     public void testAssertNotStatic()
666     {
667         final Class<?> c = NotStaticClass.class;
668         assertNotStatic(c);
669         final Method m = assertHasDeclaredMethod(c, "m", null);
670         assertNotStatic(m);
671         final Field f = assertHasDeclaredField(c, "f");
672         assertNotStatic(f);
673     }
674 
675     @Test
676     @ExpectException(value = AssertionException.class)
testAssertNotStaticInverse1()677     public void testAssertNotStaticInverse1()
678     {
679         final Class<?> c = StaticClass.class;
680         assertNotStatic(c);
681     }
682 
683     @Test
684     @ExpectException(value = AssertionException.class)
testAssertNotStaticInverse2()685     public void testAssertNotStaticInverse2()
686     {
687         final Class<?> c = StaticClass.class;
688         final Method m = assertHasDeclaredMethod(c, "m", null);
689         assertNotStatic(m);
690     }
691 
692     @Test
693     @ExpectException(value = AssertionException.class)
testAssertNotStaticInverse3()694     public void testAssertNotStaticInverse3()
695     {
696         final Class<?> c = StaticClass.class;
697         final Field f = assertHasDeclaredField(c, "f");
698         assertNotStatic(f);
699     }
700 
701     @Test
testAssertStrictfp()702     public void testAssertStrictfp()
703     {
704         final Class<?> c = StrictfpClass.class;
705         assertStrictfp(c);
706     }
707 
708     @Test
709     @ExpectException(value = AssertionException.class)
testAssertStrictfpInverse()710     public void testAssertStrictfpInverse()
711     {
712         final Class<?> c = NotStrictfpClass.class;
713         assertStrictfp(c);
714     }
715 
716     @Test
testAssertNotStrictfp()717     public void testAssertNotStrictfp()
718     {
719         final Class<?> c = NotStrictfpClass.class;
720         assertNotStrictfp(c);
721     }
722 
723     @Test
724     @ExpectException(value = AssertionException.class)
testAssertNotStrictfpInverse()725     public void testAssertNotStrictfpInverse()
726     {
727         final Class<?> c = StrictfpClass.class;
728         assertNotStrictfp(c);
729     }
730 
731     @Test
testAssertSynchronized()732     public void testAssertSynchronized()
733     {
734         final Class<?> c = SynchronizedClass.class;
735         final Method m = assertHasDeclaredMethod(c, "m", null);
736         assertSynchronized(m);
737     }
738 
739     @Test
740     @ExpectException(value = AssertionException.class)
testAssertSynchronizedInverse()741     public void testAssertSynchronizedInverse()
742     {
743         final Class<?> c = NotSynchronizedClass.class;
744         final Method m = assertHasDeclaredMethod(c, "m", null);
745         assertSynchronized(m);
746     }
747 
748     @Test
testAssertNotSynchronized()749     public void testAssertNotSynchronized()
750     {
751         final Class<?> c = NotSynchronizedClass.class;
752         final Method m = assertHasDeclaredMethod(c, "m", null);
753         assertNotSynchronized(m);
754     }
755 
756     @Test
757     @ExpectException(value = AssertionException.class)
testAssertNotSynchronizedInverse()758     public void testAssertNotSynchronizedInverse()
759     {
760         final Class<?> c = SynchronizedClass.class;
761         final Method m = assertHasDeclaredMethod(c, "m", null);
762         assertNotSynchronized(m);
763     }
764 
765     @Test
testAssertTransient()766     public void testAssertTransient()
767     {
768         final Class<?> c = TransientClass.class;
769         final Field f = assertHasDeclaredField(c, "f");
770         assertTransient(f);
771     }
772 
773     @Test
774     @ExpectException(value = AssertionException.class)
testAssertTransientInverse()775     public void testAssertTransientInverse()
776     {
777         final Class<?> c = NotTransientClass.class;
778         final Field f = assertHasDeclaredField(c, "f");
779         assertTransient(f);
780     }
781 
782     @Test
testAssertNotTransient()783     public void testAssertNotTransient()
784     {
785         final Class<?> c = NotTransientClass.class;
786         final Field f = assertHasDeclaredField(c, "f");
787         assertNotTransient(f);
788     }
789 
790     @Test
791     @ExpectException(value = AssertionException.class)
testAssertNotTransientInverse()792     public void testAssertNotTransientInverse()
793     {
794         final Class<?> c = TransientClass.class;
795         final Field f = assertHasDeclaredField(c, "f");
796         assertNotTransient(f);
797     }
798 
799     @Test
testAssertVolatile()800     public void testAssertVolatile()
801     {
802         final Class<?> c = VolatileClass.class;
803         final Field f = assertHasDeclaredField(c, "f");
804         assertVolatile(f);
805     }
806 
807     @Test
808     @ExpectException(value = AssertionException.class)
testAssertVolatileInverse()809     public void testAssertVolatileInverse()
810     {
811         final Class<?> c = NotVolatileClass.class;
812         final Field f = assertHasDeclaredField(c, "f");
813         assertVolatile(f);
814     }
815 
816     @Test
testAssertNotVolatile()817     public void testAssertNotVolatile()
818     {
819         final Class<?> c = NotVolatileClass.class;
820         final Field f = assertHasDeclaredField(c, "f");
821         assertNotVolatile(f);
822     }
823 
824     @Test
825     @ExpectException(value = AssertionException.class)
testAssertNotVolatileInverse()826     public void testAssertNotVolatileInverse()
827     {
828         final Class<?> c = VolatileClass.class;
829         final Field f = assertHasDeclaredField(c, "f");
830         assertNotVolatile(f);
831     }
832 
833     abstract class AbstractClass
834     {
abstractMethod()835         abstract void abstractMethod();
836     }
837 
838     final class NotAbstractClass
839     {
notAbstractMethod()840         final void notAbstractMethod()
841         {
842 
843         }
844     }
845 
846     private final class FinalClass
847     {
848         final int finalField = 7;
849 
finalMethod()850         final void finalMethod()
851         {
852 
853         }
854     }
855 
856     private class NotFinalClass
857     {
858         int notFinalField = 7;
859 
notFinalMethod()860         void notFinalMethod()
861         {
862 
863         }
864     }
865 
866     private static final class NativeClass
867     {
nativeMethod()868         public native void nativeMethod();
869     }
870 
871     private static final class NotNativeClass
872     {
notNativeMethod()873         void notNativeMethod()
874         {
875 
876         }
877     }
878 
879     private static final class PrivateClass
880     {
881         private final int f;
882 
PrivateClass()883         private PrivateClass()
884         {
885             m();
886             f = 7;
887             new Integer(f);
888         }
889 
m()890         private void m()
891         {
892 
893         }
894     }
895 
896     static final class NotPrivateClass
897     {
898         int f;
899 
NotPrivateClass()900         NotPrivateClass()
901         {
902 
903         }
904 
m()905         final void m()
906         {
907 
908         }
909     }
910 
911     protected static final class ProtectedClass
912     {
913         protected int f;
914 
ProtectedClass()915         protected ProtectedClass()
916         {
917 
918         }
919 
m()920         protected final void m()
921         {
922 
923         }
924     }
925 
926     static final class NotProtectedClass
927     {
928         int f;
929 
NotProtectedClass()930         NotProtectedClass()
931         {
932 
933         }
934 
m()935         final void m()
936         {
937 
938         }
939     }
940 
941     static final class DefaultAccessClass
942     {
943         int f;
944 
DefaultAccessClass()945         DefaultAccessClass()
946         {
947 
948         }
949 
m()950         final void m()
951         {
952 
953         }
954     }
955 
956     public static final class NotDefaultAccessClass
957     {
958         public int f;
959 
NotDefaultAccessClass()960         public NotDefaultAccessClass()
961         {
962 
963         }
964 
m()965         public final void m()
966         {
967 
968         }
969     }
970 
971     public static final class PublicClass
972     {
973         public int f;
974 
PublicClass()975         public PublicClass()
976         {
977 
978         }
979 
m()980         public final void m()
981         {
982 
983         }
984     }
985 
986     static final class NotPublicClass
987     {
988         int f;
989 
NotPublicClass()990         NotPublicClass()
991         {
992 
993         }
994 
m()995         final void m()
996         {
997 
998         }
999     }
1000 
1001     private static final class StaticClass
1002     {
1003         static int f;
1004 
m()1005         static void m()
1006         {
1007 
1008         }
1009     }
1010 
1011     private final class NotStaticClass
1012     {
1013         int f;
1014 
m()1015         final void m()
1016         {
1017 
1018         }
1019     }
1020 
1021     private static final strictfp class StrictfpClass
1022     {
1023 
1024     }
1025 
1026     private static final class NotStrictfpClass
1027     {
1028 
1029     }
1030 
1031     private static final class SynchronizedClass
1032     {
m()1033         public synchronized void m()
1034         {
1035 
1036         }
1037     }
1038 
1039     private static final class NotSynchronizedClass
1040     {
m()1041         public void m()
1042         {
1043 
1044         }
1045     }
1046 
1047     private static final class TransientClass
1048     {
1049         transient int f;
1050     }
1051 
1052     private static final class NotTransientClass
1053     {
1054         int f;
1055     }
1056 
1057     private static final class VolatileClass
1058     {
1059         volatile int f;
1060     }
1061 
1062     private static final class NotVolatileClass
1063     {
1064         int f;
1065     }
1066 
1067     static final class PrivateConstructor
1068     {
PrivateConstructor()1069         private PrivateConstructor()
1070         {
1071 
1072         }
1073     }
1074 
1075     static final class NotPrivateConstructor
1076     {
NotPrivateConstructor()1077         public NotPrivateConstructor()
1078         {
1079 
1080         }
1081     }
1082 }
1083