1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.student.common.spring;
17
18 import org.junit.Assert;
19 import org.junit.Before;
20 import org.junit.Test;
21 import org.junit.runner.RunWith;
22 import org.junit.runners.BlockJUnit4ClassRunner;
23 import org.kuali.student.r2.common.messages.service.MessageService;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
26 import org.springframework.context.ConfigurableApplicationContext;
27 import org.springframework.context.support.ClassPathXmlApplicationContext;
28
29 import java.io.IOException;
30
31
32
33
34
35
36
37
38
39
40
41
42
43 @RunWith(BlockJUnit4ClassRunner.class)
44 public class TestWebServiceAwareBeanPostProcessorManualWithContextPostProcessor {
45
46 private static final Logger log = LoggerFactory
47 .getLogger(TestWebServiceAwareBeanPostProcessorManualWithContextPostProcessor.class);
48 private ConfigurableApplicationContext context;
49
50
51
52
53 public TestWebServiceAwareBeanPostProcessorManualWithContextPostProcessor() {
54 }
55
56 @Before
57 public void onBefore() {
58
59
60
61
62
63
64
65 context = new ClassPathXmlApplicationContext(
66 "classpath:test-spring-post-processor-with-annotation-config.xml");
67
68 context.registerShutdownHook();
69
70 }
71
72 @Test
73 public void testDirectDictionaryServiceWithMessageServiceProxy() {
74
75 TestBean bean = context.getBean(TestBean.class);
76
77 String dataDictionaryClassName = bean.getDictionaryService().getClass().getName();
78
79
80 Assert.assertTrue(dataDictionaryClassName.equals(FakeDictionaryServiceDecoratorImpl.class.getName()));
81
82 String messageServiceClassName = bean.getMessageService().getClass()
83 .getName();
84
85 Assert.assertTrue("class name must contain $Proxy", messageServiceClassName.contains("$Proxy"));
86
87
88
89
90
91 }
92
93 @Test
94 public void testSerializeProxy() throws IOException, ClassNotFoundException {
95
96 TestBean bean = context.getBean(TestBean.class);
97
98
99
100
101
102 MessageService messageService = bean.getMessageService();
103
104
105 SpringProxyTestUtils.testBeanSerialization(messageService, "org.kuali.student.common.spring.SerializableProxyInvokationHandler (serviceName={http://student.kuali.org/wsdl/message}MessageService)", 408);
106
107
108 SpringProxyTestUtils.testBeanSerialization(new FakeMessageServiceImpl(), FakeMessageServiceImpl.class.getName(), 2018492);
109
110 }
111
112
113 }