1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
package info.magnolia.module.blossom.dispatcher; |
35 |
|
|
36 |
|
import java.io.IOException; |
37 |
|
import javax.servlet.ServletException; |
38 |
|
import javax.servlet.http.HttpServletRequest; |
39 |
|
import javax.servlet.http.HttpServletResponse; |
40 |
|
|
41 |
|
import org.junit.Test; |
42 |
|
import org.springframework.beans.BeansException; |
43 |
|
import org.springframework.beans.factory.config.BeanFactoryPostProcessor; |
44 |
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; |
45 |
|
import org.springframework.context.support.ClassPathXmlApplicationContext; |
46 |
|
import org.springframework.web.servlet.HandlerExecutionChain; |
47 |
|
import org.springframework.web.servlet.ModelAndView; |
48 |
|
|
49 |
|
import static org.junit.Assert.assertNotNull; |
50 |
|
import static org.junit.Assert.assertSame; |
51 |
|
|
52 |
|
|
53 |
|
@since |
54 |
|
|
|
|
| 71.4% |
Uncovered Elements: 4 (14) |
Complexity: 5 |
Complexity Density: 0.56 |
|
55 |
|
public class DispatcherAwareBeanPostProcessorTest { |
56 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
57 |
1 |
@Test... |
58 |
|
public void testDispatcherAware() { |
59 |
|
|
60 |
1 |
final BlossomDispatcher dispatcher = new BlossomDispatcher() { |
61 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
62 |
0 |
@Override... |
63 |
|
public ModelAndView executeChain(HandlerExecutionChain mappedHandler, HttpServletRequest request, HttpServletResponse response) throws Exception { |
64 |
0 |
return null; |
65 |
|
} |
66 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
67 |
0 |
@Override... |
68 |
|
public void forward(String path, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
69 |
|
} |
70 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
71 |
0 |
@Override... |
72 |
|
public void include(String path, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
73 |
|
} |
74 |
|
}; |
75 |
|
|
76 |
1 |
final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"classpath:info/magnolia/module/blossom/dispatcher/BlossomDispatcherAwareBeanPostProcessor-test.xml"}, false); |
77 |
1 |
context.addBeanFactoryPostProcessor(new BeanFactoryPostProcessor() { |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
78 |
1 |
@Override... |
79 |
|
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { |
80 |
1 |
beanFactory.addBeanPostProcessor(new BlossomDispatcherAwareBeanPostProcessor(dispatcher)); |
81 |
|
} |
82 |
|
}); |
83 |
1 |
context.refresh(); |
84 |
|
|
85 |
1 |
BlossomDispatcherAwareTestBean bean = (BlossomDispatcherAwareTestBean) context.getBean("dispatcherAwareTestBean"); |
86 |
|
|
87 |
1 |
assertNotNull(bean.getDispatcher()); |
88 |
1 |
assertSame(dispatcher, bean.getDispatcher()); |
89 |
|
} |
90 |
|
} |