From 2907f2facd7563f5a0124b8e22bcb806fe35576c Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Tue, 7 Nov 2017 08:30:04 +0000 Subject: [PATCH] Uncomment ignored test and adapt to new name Fixes gh-269 (actually fixed in Spring Boot). --- .../encrypt/EncryptionIntegrationTests.java | 2 -- ...entDecryptApplicationInitializerTests.java | 28 ++++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EncryptionIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EncryptionIntegrationTests.java index dc0b5835..395e61ad 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EncryptionIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EncryptionIntegrationTests.java @@ -1,6 +1,5 @@ package org.springframework.cloud.bootstrap.encrypt; -import org.junit.Ignore; import org.junit.Test; import org.springframework.boot.WebApplicationType; @@ -25,7 +24,6 @@ public class EncryptionIntegrationTests { } @Test - @Ignore("https://github.com/spring-cloud/spring-cloud-commons/issues/269") public void symmetricConfigurationProperties() { ConfigurableApplicationContext context = new SpringApplicationBuilder( TestConfiguration.class).web(WebApplicationType.NONE).properties( diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EnvironmentDecryptApplicationInitializerTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EnvironmentDecryptApplicationInitializerTests.java index 72e4f0ca..60889642 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EnvironmentDecryptApplicationInitializerTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EnvironmentDecryptApplicationInitializerTests.java @@ -15,17 +15,11 @@ */ package org.springframework.cloud.bootstrap.encrypt; -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import static org.springframework.cloud.bootstrap.encrypt.EnvironmentDecryptApplicationInitializer.DECRYPTED_PROPERTY_SOURCE_NAME; - import java.util.Collections; import java.util.Map; import org.junit.Test; + import org.springframework.boot.test.util.TestPropertyValues; import org.springframework.boot.test.util.TestPropertyValues.Type; import org.springframework.context.ApplicationContext; @@ -37,6 +31,13 @@ import org.springframework.core.env.MutablePropertySources; import org.springframework.core.env.PropertySource; import org.springframework.security.crypto.encrypt.Encryptors; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import static org.springframework.cloud.bootstrap.encrypt.EnvironmentDecryptApplicationInitializer.DECRYPTED_PROPERTY_SOURCE_NAME; + /** * @author Dave Syer * @author Biju Kunjummen @@ -57,7 +58,8 @@ public class EnvironmentDecryptApplicationInitializerTests { @Test public void relaxedBinding() { ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(); - TestPropertyValues.of("FOO_TEXT: {cipher}bar").applyTo(context.getEnvironment(), TestPropertyValues.Type.SYSTEM); + TestPropertyValues.of("FOO_TEXT: {cipher}bar").applyTo(context.getEnvironment(), + TestPropertyValues.Type.SYSTEM_ENVIRONMENT); this.listener.initialize(context); assertEquals("bar", context.getEnvironment().getProperty("foo.text")); } @@ -107,10 +109,10 @@ public class EnvironmentDecryptApplicationInitializerTests { // collection with some encrypted keys and some not encrypted TestPropertyValues - .of("mine[0].someValue: Foo", - "mine[0].someKey: {cipher}Foo0", "mine[1].someValue: Bar", - "mine[1].someKey: {cipher}Bar1", "nonindexed: nonindexval") - .applyTo(context.getEnvironment(), Type.MAP, "combinedTest"); + .of("mine[0].someValue: Foo", "mine[0].someKey: {cipher}Foo0", + "mine[1].someValue: Bar", "mine[1].someKey: {cipher}Bar1", + "nonindexed: nonindexval") + .applyTo(context.getEnvironment(), Type.MAP, "combinedTest"); this.listener.initialize(context); assertEquals("Foo", context.getEnvironment().getProperty("mine[0].someValue")); @@ -124,7 +126,7 @@ public class EnvironmentDecryptApplicationInitializerTests { MutablePropertySources propertySources = context.getEnvironment() .getPropertySources(); - PropertySource> decrypted = (PropertySource>) propertySources + PropertySource> decrypted = (PropertySource>) propertySources .get(DECRYPTED_PROPERTY_SOURCE_NAME); assertThat("decrypted property source had wrong size", decrypted.getSource().size(), is(4));