|
| 1 | +/* |
| 2 | + * Copyright 2012-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.boot.test; |
| 18 | + |
| 19 | +import org.junit.Test; |
| 20 | +import org.junit.runner.RunWith; |
| 21 | +import org.springframework.beans.factory.annotation.Autowired; |
| 22 | +import org.springframework.context.ApplicationContext; |
| 23 | +import org.springframework.context.annotation.Configuration; |
| 24 | +import org.springframework.test.context.ActiveProfiles; |
| 25 | +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
| 26 | + |
| 27 | +import static org.hamcrest.Matchers.equalTo; |
| 28 | +import static org.junit.Assert.assertThat; |
| 29 | + |
| 30 | +/** |
| 31 | + * Tests for {@link SpringApplicationContextLoader} with active profiles. See gh-1469. |
| 32 | + * |
| 33 | + * @author Phillip Webb |
| 34 | + */ |
| 35 | +@RunWith(SpringJUnit4ClassRunner.class) |
| 36 | +@SpringApplicationConfiguration |
| 37 | +@IntegrationTest("spring.config.name=enableother") |
| 38 | +@ActiveProfiles("override") |
| 39 | +public class SpringApplicationConfigurationActiveProfileTests { |
| 40 | + |
| 41 | + @Autowired |
| 42 | + private ApplicationContext context; |
| 43 | + |
| 44 | + @Test |
| 45 | + public void profiles() throws Exception { |
| 46 | + assertThat(this.context.getEnvironment().getActiveProfiles(), |
| 47 | + equalTo(new String[] { "override" })); |
| 48 | + } |
| 49 | + |
| 50 | + @Configuration |
| 51 | + protected static class Config { |
| 52 | + |
| 53 | + } |
| 54 | + |
| 55 | +} |
0 commit comments