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.support; |
35 |
|
|
36 |
|
import java.util.ArrayList; |
37 |
|
import java.util.List; |
38 |
|
|
39 |
|
import org.junit.Test; |
40 |
|
import org.springframework.beans.BeansException; |
41 |
|
import org.springframework.beans.factory.config.BeanFactoryPostProcessor; |
42 |
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; |
43 |
|
import org.springframework.context.support.ClassPathXmlApplicationContext; |
44 |
|
import org.springframework.web.servlet.HandlerMapping; |
45 |
|
import org.springframework.web.servlet.handler.AbstractUrlHandlerMapping; |
46 |
|
import static org.junit.Assert.assertEquals; |
47 |
|
|
48 |
|
|
49 |
|
@since |
50 |
|
|
|
|
| 92.3% |
Uncovered Elements: 1 (13) |
Complexity: 4 |
Complexity Density: 0.44 |
|
51 |
|
public class AbstractUrlMappedHandlerPostProcessorTest { |
52 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
53 |
1 |
@Test... |
54 |
|
public void testBeanDetection() { |
55 |
|
|
56 |
1 |
final List<HandlerMapping> handlerMappingsScanned = new ArrayList<HandlerMapping>(); |
57 |
|
|
58 |
1 |
final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"classpath:info/magnolia/module/blossom/support/AbstractUrlMappedHandlerPostProcessor-test.xml"}, false); |
59 |
|
|
60 |
1 |
context.addBeanFactoryPostProcessor(new BeanFactoryPostProcessor() { |
61 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
62 |
1 |
@Override... |
63 |
|
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { |
64 |
1 |
beanFactory.addBeanPostProcessor(new AbstractUrlMappedHandlerPostProcessor() { |
65 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
66 |
2 |
@Override... |
67 |
|
protected void scanHandlerMapping(AbstractUrlHandlerMapping handlerMapping) { |
68 |
2 |
handlerMappingsScanned.add(handlerMapping); |
69 |
2 |
super.scanHandlerMapping(handlerMapping); |
70 |
|
} |
71 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
72 |
0 |
@Override... |
73 |
|
protected void postProcessHandler(Object handler, String handlerPath) { |
74 |
|
} |
75 |
|
}); |
76 |
|
} |
77 |
|
}); |
78 |
|
|
79 |
1 |
context.refresh(); |
80 |
|
|
81 |
1 |
context.getBeansOfType(HandlerMapping.class); |
82 |
|
|
83 |
1 |
assertEquals(2, handlerMappingsScanned.size()); |
84 |
|
} |
85 |
|
} |