View Javadoc

1   /*
2    * Copyright 2012 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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.slf4j.Logger;
24  import org.slf4j.LoggerFactory;
25  import org.springframework.context.ConfigurableApplicationContext;
26  import org.springframework.context.support.ClassPathXmlApplicationContext;
27  
28  /**
29   * 
30   * Test using only the {@link WebServiceAwareSpringBeanPostProcessor} class.  
31   * 
32   * The <em>DictionaryService</em> will be resolved using the normal @Autowired annotation.
33   * 
34   * The MessageService will be resolved using the KSB lookup from the QName defined on its @WebService annotation.
35   * 
36   * @author Kuali Student Team
37   *
38   */
39  @RunWith(BlockJUnit4ClassRunner.class)
40  public class TestWebServiceAwareBeanPostProcessorSinglePostProcessor  {
41  
42  	private static final Logger log = LoggerFactory.getLogger(TestWebServiceAwareBeanPostProcessorSinglePostProcessor.class);
43  	private ConfigurableApplicationContext context;
44  	
45  	/**
46  	 * 
47  	 */
48  	public TestWebServiceAwareBeanPostProcessorSinglePostProcessor() {
49  	}
50  	
51  	@Before
52  	public void onBefore() {
53  		
54  		/*
55  		 * In this case the WebServiceAwareSpringBeanPostProcessor is the only spring bean post processor being used.
56  		 */
57  		
58  		context = new ClassPathXmlApplicationContext("classpath:test-spring-post-processor.xml");
59  		
60  		context.registerShutdownHook();
61  		
62  	}
63  
64  	
65  	
66  
67  	@Test
68  	public void testDirectDictionaryServiceWithMessageServiceProxy() {
69  		TestBean bean = context.getBean(TestBean.class);
70  		
71  		String dataDictionaryClassName = bean.getDictionaryService().getClass().getName();
72  		
73  		Assert.assertTrue(dataDictionaryClassName.equals("org.kuali.student.common.spring.FakeDictionaryServiceDecoratorImpl"));
74  		
75  		String messageServiceClassName = bean.getMessageService().getClass().getName();
76  		
77  		Assert.assertTrue("class name must contain $Proxy", messageServiceClassName.contains("$Proxy"));
78  		
79  	}
80  }