View Javadoc
1   /*
2    * Copyright 2002-2014 the original author or authors.
3    *
4    * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0
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  
17  package org.springframework.context.annotation.aspectj;
18  
19  import org.junit.Assert;
20  import org.junit.Test;
21  
22  import org.springframework.beans.factory.aspectj.ShouldBeConfiguredBySpring;
23  import org.springframework.context.annotation.AnnotationConfigApplicationContext;
24  import org.springframework.context.annotation.Configuration;
25  import org.springframework.context.annotation.ImportResource;
26  
27  /**
28   * Tests that @EnableSpringConfigured properly registers an
29   * {@link org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect},
30   * just as does {@code <context:spring-configured>}.
31   *
32   * @author Chris Beams
33   * @since 3.1
34   */
35  public class AnnotationBeanConfigurerTests {
36  
37  	@Test
38  	public void testInjection() {
39  		AnnotationConfigApplicationContext context = new  AnnotationConfigApplicationContext(Config.class);
40  		ShouldBeConfiguredBySpring myObject = new ShouldBeConfiguredBySpring();
41  		Assert.assertEquals("Rod", myObject.getName());
42  	}
43  
44  
45  	@Configuration
46  	@ImportResource("org/springframework/beans/factory/aspectj/beanConfigurerTests-beans.xml")
47  	@EnableSpringConfigured
48  	static class Config {
49  	}
50  
51  }