Merge branch 'master' into 2.0.x
This commit is contained in:
@@ -19,7 +19,8 @@ public class BootstrapSourcesOrderingTests {
|
||||
@Test
|
||||
public void sourcesAreOrderedCorrectly() {
|
||||
Class<?> firstConstructedClass = firstToBeCreated.get();
|
||||
assertThat(firstConstructedClass).as("bootstrap sources not ordered correctly").isEqualTo(TestHigherPriorityBootstrapConfiguration.class);
|
||||
assertThat(firstConstructedClass).as("bootstrap sources not ordered correctly")
|
||||
.isEqualTo(TestHigherPriorityBootstrapConfiguration.class);
|
||||
}
|
||||
|
||||
@EnableAutoConfiguration
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package org.springframework.cloud.context.environment;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.mock.env.MockEnvironment;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@@ -7,38 +13,33 @@ import static org.mockito.Mockito.reset;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.mock.env.MockEnvironment;
|
||||
|
||||
public class EnvironmentManagerTest {
|
||||
|
||||
@Test
|
||||
public void testCorrectEvents() {
|
||||
MockEnvironment environment = new MockEnvironment();
|
||||
ApplicationEventPublisher publisher = mock(ApplicationEventPublisher.class);
|
||||
EnvironmentManager environmentManager = new EnvironmentManager(environment);
|
||||
environmentManager.setApplicationEventPublisher(publisher);
|
||||
@Test
|
||||
public void testCorrectEvents() {
|
||||
MockEnvironment environment = new MockEnvironment();
|
||||
ApplicationEventPublisher publisher = mock(ApplicationEventPublisher.class);
|
||||
EnvironmentManager environmentManager = new EnvironmentManager(environment);
|
||||
environmentManager.setApplicationEventPublisher(publisher);
|
||||
|
||||
environmentManager.setProperty("foo", "bar");
|
||||
environmentManager.setProperty("foo", "bar");
|
||||
|
||||
assertThat(environment.getProperty("foo")).isEqualTo("bar");
|
||||
ArgumentCaptor<ApplicationEvent> eventCaptor = ArgumentCaptor.forClass(ApplicationEvent.class);
|
||||
verify(publisher, times(1)).publishEvent(eventCaptor.capture());
|
||||
assertThat(eventCaptor.getValue()).isInstanceOf(EnvironmentChangeEvent.class);
|
||||
EnvironmentChangeEvent event = (EnvironmentChangeEvent) eventCaptor.getValue();
|
||||
assertThat(event.getKeys()).containsExactly("foo");
|
||||
assertThat(environment.getProperty("foo")).isEqualTo("bar");
|
||||
ArgumentCaptor<ApplicationEvent> eventCaptor = ArgumentCaptor
|
||||
.forClass(ApplicationEvent.class);
|
||||
verify(publisher, times(1)).publishEvent(eventCaptor.capture());
|
||||
assertThat(eventCaptor.getValue()).isInstanceOf(EnvironmentChangeEvent.class);
|
||||
EnvironmentChangeEvent event = (EnvironmentChangeEvent) eventCaptor.getValue();
|
||||
assertThat(event.getKeys()).containsExactly("foo");
|
||||
|
||||
reset(publisher);
|
||||
reset(publisher);
|
||||
|
||||
environmentManager.reset();
|
||||
assertThat(environment.getProperty("foo")).isNull();
|
||||
verify(publisher, times(1)).publishEvent(eventCaptor.capture());
|
||||
assertThat(eventCaptor.getValue()).isInstanceOf(EnvironmentChangeEvent.class);
|
||||
event = (EnvironmentChangeEvent) eventCaptor.getValue();
|
||||
assertThat(event.getKeys()).containsExactly("foo");
|
||||
}
|
||||
environmentManager.reset();
|
||||
assertThat(environment.getProperty("foo")).isNull();
|
||||
verify(publisher, times(1)).publishEvent(eventCaptor.capture());
|
||||
assertThat(eventCaptor.getValue()).isInstanceOf(EnvironmentChangeEvent.class);
|
||||
event = (EnvironmentChangeEvent) eventCaptor.getValue();
|
||||
assertThat(event.getKeys()).containsExactly("foo");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,15 +16,13 @@
|
||||
|
||||
package org.springframework.cloud.context.scope.refresh;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
@@ -44,9 +42,12 @@ import org.springframework.jmx.export.annotation.ManagedResource;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = TestConfiguration.class,
|
||||
properties = {"test.messages[0]=one","test.messages[1]=two"})
|
||||
@SpringBootTest(classes = TestConfiguration.class, properties = { "test.messages[0]=one",
|
||||
"test.messages[1]=two" })
|
||||
public class RefreshScopeListBindingIntegrationTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
Reference in New Issue
Block a user