1
2
3
4
5
6
7
8
9
10
11 package psiprobe;
12
13 import jakarta.servlet.ServletContextEvent;
14
15 import javax.imageio.ImageIO;
16
17 import mockit.Expectations;
18 import mockit.Mocked;
19 import mockit.Tested;
20 import mockit.Verifications;
21
22 import org.junit.jupiter.api.Test;
23
24
25
26
27 class AwtAppContextClassloaderListenerTest {
28
29
30 @Tested
31 AwtAppContextClassloaderListener listener;
32
33
34 @Mocked
35 ServletContextEvent event;
36
37
38 @Mocked
39 ImageIO imageIO;
40
41
42
43
44 @Test
45 void contextInitializedTest() {
46 listener.contextInitialized(event);
47
48 new Verifications() {
49 {
50 ImageIO.getCacheDirectory();
51 times = 1;
52 }
53 };
54 }
55
56
57
58
59 @Test
60 void contextInitializedErrorTest() {
61 new Expectations() {
62 {
63 ImageIO.getCacheDirectory();
64 result = new Exception();
65 }
66 };
67
68 listener.contextInitialized(event);
69 }
70
71
72
73
74 @Test
75 void contextDestroyedTest() {
76
77 listener.contextDestroyed(event);
78 }
79
80 }