1
2
3
4
5
6
7
8
9
10
11 package psiprobe.mappers;
12
13 import com.opensymphony.module.sitemesh.Config;
14 import com.opensymphony.module.sitemesh.DecoratorMapper;
15 import com.opensymphony.module.sitemesh.Page;
16
17 import jakarta.servlet.http.HttpServletRequest;
18
19 import java.util.Properties;
20
21 import mockit.Expectations;
22 import mockit.Mocked;
23
24 import org.junit.jupiter.api.Assertions;
25 import org.junit.jupiter.api.BeforeEach;
26 import org.junit.jupiter.api.Test;
27
28
29
30
31 class AjaxDecoratorMapperTest {
32
33
34 AjaxDecoratorMapper mapper;
35
36
37 @Mocked
38 Config config;
39
40
41 Properties properties;
42
43
44 @Mocked
45 DecoratorMapper decoratorMapper;
46
47
48 @Mocked
49 HttpServletRequest request;
50
51
52 @Mocked
53 Page page;
54
55
56
57
58 @BeforeEach
59 void before() {
60 mapper = new AjaxDecoratorMapper();
61 properties = new Properties();
62 }
63
64
65
66
67
68
69 @Test
70 void ajaxDecoratorMapperTest() throws InstantiationException {
71 properties.setProperty("ajaxExtension", ".ajax");
72 mapper.init(config, properties, decoratorMapper);
73
74 new Expectations() {
75 {
76 request.getAttribute("jakarta.servlet.error.request_uri");
77 result = "https://localhost:8443/probe";
78
79 request.getServletPath();
80 result = "probe/ws";
81 }
82 };
83 Assertions.assertNotNull(mapper.getDecorator(request, page));
84 }
85
86 }