@@ -0,0 +1,2538 @@
+/*%0A * Copyright 2018 the original author or authors.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.springframework.vault.annotation;%0A%0Aimport org.junit.Test;%0Aimport org.mockito.Mockito;%0A%0Aimport org.springframework.context.annotation.AnnotationConfigApplicationContext;%0Aimport org.springframework.context.annotation.Bean;%0Aimport org.springframework.context.annotation.Configuration;%0Aimport org.springframework.context.annotation.Profile;%0Aimport org.springframework.vault.core.VaultTemplate;%0A%0Aimport static org.mockito.Mockito.never;%0Aimport static org.mockito.Mockito.verify;%0Aimport static org.mockito.Mockito.verifyNoMoreInteractions;%0A%0A/**%0A * Unit test for %7B@link VaultPropertySource%7D.%0A *%0A * @author Mark Paluch%0A */%0Apublic class VaultPropertySourceUnitTests %7B%0A%0A%09@Configuration%0A%09static class Config %7B%0A%0A%09%09@Bean%0A%09%09VaultTemplate vaultTemplate() %7B%0A%09%09%09return Mockito.mock(VaultTemplate.class);%0A%09%09%7D%0A%09%7D%0A%0A%09@Configuration%0A%09@Profile(%22demo%22)%0A%09@VaultPropertySource(%22foo%22)%0A%09static class DemoProfile %7B%0A%09%7D%0A%0A%09@Configuration%0A%09@Profile(%22dev%22)%0A%09@VaultPropertySource(%22bar%22)%0A%09static class DevProfile %7B%0A%09%7D%0A%0A%09@Test%0A%09public void shouldNotEnablePropertySource() %7B%0A%0A%09%09AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();%0A%0A%09%09ctx.register(Config.class);%0A%09%09ctx.register(DemoProfile.class);%0A%09%09ctx.register(DevProfile.class);%0A%09%09ctx.refresh();%0A%0A%09%09VaultTemplate templateMock = ctx.getBean(VaultTemplate.class);%0A%0A%09%09verify(templateMock).afterPropertiesSet();%0A%09%09verifyNoMoreInteractions(templateMock);%0A%09%7D%0A%0A%09@Test%0A%09public void shouldEnablePropertySourceByProfile() %7B%0A%0A%09%09AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();%0A%0A%09%09ctx.getEnvironment().addActiveProfile(%22demo%22);%0A%0A%09%09ctx.register(Config.class);%0A%09%09ctx.register(DemoProfile.class);%0A%09%09ctx.register(DevProfile.class);%0A%0A%09%09ctx.refresh();%0A%0A%09%09VaultTemplate templateMock = ctx.getBean(VaultTemplate.class);%0A%0A%09%09verify(templateMock).afterPropertiesSet();%0A%09%09verify(templateMock).read(%22foo%22);%0A%09%09verify(templateMock, never()).read(%22bar%22);%0A%09%7D%0A%7D%0A

Add unit test for VaultPropertySource with profiles.