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