View Javadoc
1   /*
2    * Licensed under the GPL License. You may not use this file except in compliance with the License.
3    * You may obtain a copy of the License at
4    *
5    *   https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
6    *
7    * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
8    * WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
9    * PURPOSE.
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   * The Class AwtAppContextClassloaderListenerTest.
26   */
27  class AwtAppContextClassloaderListenerTest {
28  
29    /** The listener. */
30    @Tested
31    AwtAppContextClassloaderListener listener;
32  
33    /** The event. */
34    @Mocked
35    ServletContextEvent event;
36  
37    /** The image IO. */
38    @Mocked
39    ImageIO imageIO;
40  
41    /**
42     * Context initialized test.
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     * Context initialized error test.
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     * Context destroyed test.
73     */
74    @Test
75    void contextDestroyedTest() {
76      // Dummy Test as method is not implemented
77      listener.contextDestroyed(event);
78    }
79  
80  }