|
| 1 | +/* |
| 2 | + * Copyright 2009 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.test.context.junit4.spr6128; |
| 18 | + |
| 19 | +import static org.hamcrest.core.IsEqual.equalTo; |
| 20 | +import static org.junit.Assert.assertThat; |
| 21 | + |
| 22 | +import org.junit.Test; |
| 23 | +import org.junit.runner.RunWith; |
| 24 | +import org.springframework.beans.factory.annotation.Autowired; |
| 25 | +import org.springframework.beans.factory.annotation.Qualifier; |
| 26 | +import org.springframework.test.context.ContextConfiguration; |
| 27 | +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
| 28 | + |
| 29 | +/** |
| 30 | + * Unit tests to verify claims made in <a |
| 31 | + * href="http://jira.springframework.org/browse/SPR-6128" |
| 32 | + * target="_blank">SPR-6128</a>. |
| 33 | + * |
| 34 | + * @author Sam Brannen |
| 35 | + * @author Chris Beams |
| 36 | + * @since 3.0 |
| 37 | + */ |
| 38 | +@ContextConfiguration |
| 39 | +@RunWith(SpringJUnit4ClassRunner.class) |
| 40 | +public class AutowiredQualifierTests { |
| 41 | + |
| 42 | + @Autowired |
| 43 | + private String foo; |
| 44 | + |
| 45 | + @Autowired |
| 46 | + @Qualifier("customFoo") |
| 47 | + private String customFoo; |
| 48 | + |
| 49 | + |
| 50 | + @Test |
| 51 | + public void test() { |
| 52 | + assertThat(foo, equalTo("normal")); |
| 53 | + assertThat(customFoo, equalTo("custom")); |
| 54 | + } |
| 55 | + |
| 56 | +} |
0 commit comments