Merge branch '1.2.x'
This commit is contained in:
commit
fffc6f5dd2
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* 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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* 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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* 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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* 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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -92,12 +92,11 @@ public abstract class EnvironmentTestUtils {
|
||||||
int equalIndex = pair.indexOf("=");
|
int equalIndex = pair.indexOf("=");
|
||||||
if (colonIndex == -1) {
|
if (colonIndex == -1) {
|
||||||
return equalIndex;
|
return equalIndex;
|
||||||
} else if (equalIndex == -1) {
|
}
|
||||||
|
if (equalIndex == -1) {
|
||||||
return colonIndex;
|
return colonIndex;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
return Math.min(colonIndex, equalIndex);
|
return Math.min(colonIndex, equalIndex);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.springframework.core.env.ConfigurableEnvironment;
|
import org.springframework.core.env.ConfigurableEnvironment;
|
||||||
import org.springframework.core.env.MapPropertySource;
|
import org.springframework.core.env.MapPropertySource;
|
||||||
import org.springframework.core.env.StandardEnvironment;
|
import org.springframework.core.env.StandardEnvironment;
|
||||||
|
@ -71,16 +70,18 @@ public class EnvironmentTestUtilsTests {
|
||||||
@Test
|
@Test
|
||||||
public void addPairNoValue() {
|
public void addPairNoValue() {
|
||||||
String propertyName = "my.foo+bar";
|
String propertyName = "my.foo+bar";
|
||||||
assertFalse(environment.containsProperty(propertyName));
|
assertFalse(this.environment.containsProperty(propertyName));
|
||||||
EnvironmentTestUtils.addEnvironment(environment, propertyName);
|
EnvironmentTestUtils.addEnvironment(this.environment, propertyName);
|
||||||
assertTrue(environment.containsProperty(propertyName));
|
assertTrue(this.environment.containsProperty(propertyName));
|
||||||
assertEquals("", environment.getProperty(propertyName));
|
assertEquals("", this.environment.getProperty(propertyName));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testAddSimplePair(String key, String value, String delimiter) {
|
private void testAddSimplePair(String key, String value, String delimiter) {
|
||||||
assertFalse("Property '" + key + "' should not exist", environment.containsProperty(key));
|
assertFalse("Property '" + key + "' should not exist",
|
||||||
EnvironmentTestUtils.addEnvironment(environment, key + delimiter + value);
|
this.environment.containsProperty(key));
|
||||||
assertEquals("Wrong value for property '" + key + "'", value, environment.getProperty(key));
|
EnvironmentTestUtils.addEnvironment(this.environment, key + delimiter + value);
|
||||||
|
assertEquals("Wrong value for property '" + key + "'", value,
|
||||||
|
this.environment.getProperty(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -88,10 +89,10 @@ public class EnvironmentTestUtilsTests {
|
||||||
Map<String, Object> map = new HashMap<String, Object>();
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
map.put("my.foo", "bar");
|
map.put("my.foo", "bar");
|
||||||
MapPropertySource source = new MapPropertySource("sample", map);
|
MapPropertySource source = new MapPropertySource("sample", map);
|
||||||
environment.getPropertySources().addFirst(source);
|
this.environment.getPropertySources().addFirst(source);
|
||||||
assertEquals("bar", environment.getProperty("my.foo"));
|
assertEquals("bar", this.environment.getProperty("my.foo"));
|
||||||
EnvironmentTestUtils.addEnvironment(environment, "my.foo=bar2");
|
EnvironmentTestUtils.addEnvironment(this.environment, "my.foo=bar2");
|
||||||
assertEquals("bar2", environment.getProperty("my.foo"));
|
assertEquals("bar2", this.environment.getProperty("my.foo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue