1
2
3
4
5
6 package integration.tests;
7
8 import static java.lang.annotation.RetentionPolicy.RUNTIME;
9
10 import static org.junit.jupiter.api.Assertions.assertNotNull;
11 import static org.junit.jupiter.api.Assertions.assertNull;
12 import static org.junit.jupiter.api.Assertions.assertTrue;
13
14 import java.beans.ConstructorProperties;
15 import java.lang.annotation.Retention;
16 import java.lang.reflect.Constructor;
17
18 import mockit.Injectable;
19 import mockit.Mocked;
20 import mockit.Tested;
21
22 import org.junit.jupiter.api.Test;
23
24 class MiscellaneousTest {
25 @Test
26 void methodWithIINCWideInstruction() {
27 int i = 0;
28 i += 1000;
29 assert i == 1000;
30 }
31
32 @Retention(RUNTIME)
33 public @interface Dummy {
34 Class<?> value();
35 }
36
37 @Dummy(String.class)
38 static class AnnotatedClass {
39 }
40
41 @Test
42 void havingAnnotationWithClassValue(@Injectable AnnotatedClass dummy) {
43 assertNotNull(dummy);
44 }
45
46 @Test
47 void verifyAnnotationsArePreserved() throws Exception {
48 Constructor<ClassWithAnnotations> constructor = ClassWithAnnotations.class.getDeclaredConstructor();
49
50 assertTrue(constructor.isAnnotationPresent(ConstructorProperties.class));
51 }
52
53 @Test
54 void mockingAnAnnotation(@Tested @Mocked AnAnnotation mockedAnnotation) {
55 assertNull(mockedAnnotation.value());
56 }
57 }