Polishing

This commit is contained in:
Juergen Hoeller
2017-04-10 15:36:45 +02:00
parent cf306037b5
commit 15b5dd9f12
12 changed files with 103 additions and 79 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 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.
@@ -27,8 +27,10 @@ import java.util.List;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import javax.annotation.PostConstruct;
import org.junit.After;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@@ -39,6 +41,7 @@ import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.PayloadApplicationEvent;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
@@ -546,6 +549,14 @@ public class AnnotationDrivenEventListenerTests {
assertThat(listener.order, contains("first", "second", "third"));
}
@Test @Ignore // SPR-15122
public void listenersReceiveEarlyEvents() {
load(EventOnPostConstruct.class, OrderedTestListener.class);
OrderedTestListener listener = this.context.getBean(OrderedTestListener.class);
assertThat(listener.order, contains("first", "second", "third"));
}
private void load(Class<?>... classes) {
List<Class<?>> allClasses = new ArrayList<>();
@@ -936,6 +947,18 @@ public class AnnotationDrivenEventListenerTests {
}
static class EventOnPostConstruct {
@Autowired
ApplicationEventPublisher publisher;
@PostConstruct
public void init() {
this.publisher.publishEvent("earlyEvent");
}
}
private static class CustomScope implements org.springframework.beans.factory.config.Scope {
public boolean active = true;