Commit fffc6f5d authored by Phillip Webb's avatar Phillip Webb

Merge branch '1.2.x'

parents c60d6582 1e40bff1
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
......@@ -2,7 +2,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>${foo}/repository</localRepository>
</settings>
\ No newline at end of file
</settings>
......@@ -92,12 +92,11 @@ public abstract class EnvironmentTestUtils {
int equalIndex = pair.indexOf("=");
if (colonIndex == -1) {
return equalIndex;
} else if (equalIndex == -1) {
return colonIndex;
}
else {
return Math.min(colonIndex, equalIndex);
if (equalIndex == -1) {
return colonIndex;
}
return Math.min(colonIndex, equalIndex);
}
}
......@@ -20,7 +20,6 @@ import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.MapPropertySource;
import org.springframework.core.env.StandardEnvironment;
......@@ -71,16 +70,18 @@ public class EnvironmentTestUtilsTests {
@Test
public void addPairNoValue() {
String propertyName = "my.foo+bar";
assertFalse(environment.containsProperty(propertyName));
EnvironmentTestUtils.addEnvironment(environment, propertyName);
assertTrue(environment.containsProperty(propertyName));
assertEquals("", environment.getProperty(propertyName));
assertFalse(this.environment.containsProperty(propertyName));
EnvironmentTestUtils.addEnvironment(this.environment, propertyName);
assertTrue(this.environment.containsProperty(propertyName));
assertEquals("", this.environment.getProperty(propertyName));
}
private void testAddSimplePair(String key, String value, String delimiter) {
assertFalse("Property '" + key + "' should not exist", environment.containsProperty(key));
EnvironmentTestUtils.addEnvironment(environment, key + delimiter + value);
assertEquals("Wrong value for property '" + key + "'", value, environment.getProperty(key));
assertFalse("Property '" + key + "' should not exist",
this.environment.containsProperty(key));
EnvironmentTestUtils.addEnvironment(this.environment, key + delimiter + value);
assertEquals("Wrong value for property '" + key + "'", value,
this.environment.getProperty(key));
}
@Test
......@@ -88,10 +89,10 @@ public class EnvironmentTestUtilsTests {
Map<String, Object> map = new HashMap<String, Object>();
map.put("my.foo", "bar");
MapPropertySource source = new MapPropertySource("sample", map);
environment.getPropertySources().addFirst(source);
assertEquals("bar", environment.getProperty("my.foo"));
EnvironmentTestUtils.addEnvironment(environment, "my.foo=bar2");
assertEquals("bar2", environment.getProperty("my.foo"));
this.environment.getPropertySources().addFirst(source);
assertEquals("bar", this.environment.getProperty("my.foo"));
EnvironmentTestUtils.addEnvironment(this.environment, "my.foo=bar2");
assertEquals("bar2", this.environment.getProperty("my.foo"));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment