/*
 * Copyright 2002-2014 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.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.core.env;

import java.util.Collections;

import org.junit.Test;

import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;

/**
 * Tests for {@link CompositePropertySource}.
 * @author Phillip Webb
 */
public class CompositePropertySourceTests {

	@Test
	public void addFirst() {
		PropertySource<?> p1 = new MapPropertySource("p1", Collections.emptyMap());
		PropertySource<?> p2 = new MapPropertySource("p2", Collections.emptyMap());
		PropertySource<?> p3 = new MapPropertySource("p3", Collections.emptyMap());
		CompositePropertySource composite = new CompositePropertySource("c");
		composite.addPropertySource(p2);
		composite.addPropertySource(p3);
		composite.addPropertySource(p1);
		composite.addFirstPropertySource(p1);
		assertThat(composite.toString(), containsString("MapPropertySource [name='p1'], "
				+ "MapPropertySource [name='p2'], MapPropertySource [name='p3']"));
	}

}

@@ -708,47 +708,8 @@
 t;%0A%0A
-import static org.hamcrest.Matchers.*;%0A
 impo
@@ -1352,19 +1352,19 @@
 ;%0A%09%09
-assertThat(
+String s = 
 comp
@@ -1383,127 +1383,170 @@
 ng()
-, containsString(%22MapPropertySource %5Bname='p1'%5D, %22%0A%09%09%09%09+ %22MapPropertySource %5Bname='p2'%5D, MapPropertySource %5Bname='p3'%5D%22
+;%0A%09%09int i1 = s.indexOf(%22name='p1'%22);%0A%09%09int i2 = s.indexOf(%22name='p2'%22);%0A%09%09int i3 = s.indexOf(%22name='p3'%22);%0A%09%09assertTrue(%22Bad order: %22 + s, ((i1 %3C i2) && (i2 %3C i3)
 ));%0A

Fix failing CompositePropertySourceTests