Skip to content

Commit f31f654

Browse files
committed
Polishing
1 parent 514c0b5 commit f31f654

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

spring-context/src/test/java/org/springframework/context/event/EventPublicationInterceptorTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -49,30 +49,30 @@ public void setUp() {
4949
this.publisher = mock(ApplicationEventPublisher.class);
5050
}
5151

52-
@Test(expected=IllegalArgumentException.class)
52+
@Test(expected = IllegalArgumentException.class)
5353
public void testWithNoApplicationEventClassSupplied() throws Exception {
5454
EventPublicationInterceptor interceptor = new EventPublicationInterceptor();
5555
interceptor.setApplicationEventPublisher(this.publisher);
5656
interceptor.afterPropertiesSet();
5757
}
5858

59-
@Test(expected=IllegalArgumentException.class)
59+
@Test(expected = IllegalArgumentException.class)
6060
public void testWithNonApplicationEventClassSupplied() throws Exception {
6161
EventPublicationInterceptor interceptor = new EventPublicationInterceptor();
6262
interceptor.setApplicationEventPublisher(this.publisher);
6363
interceptor.setApplicationEventClass(getClass());
6464
interceptor.afterPropertiesSet();
6565
}
6666

67-
@Test(expected=IllegalArgumentException.class)
67+
@Test(expected = IllegalArgumentException.class)
6868
public void testWithAbstractStraightApplicationEventClassSupplied() throws Exception {
6969
EventPublicationInterceptor interceptor = new EventPublicationInterceptor();
7070
interceptor.setApplicationEventPublisher(this.publisher);
7171
interceptor.setApplicationEventClass(ApplicationEvent.class);
7272
interceptor.afterPropertiesSet();
7373
}
7474

75-
@Test(expected=IllegalArgumentException.class)
75+
@Test(expected = IllegalArgumentException.class)
7676
public void testWithApplicationEventClassThatDoesntExposeAValidCtor() throws Exception {
7777
EventPublicationInterceptor interceptor = new EventPublicationInterceptor();
7878
interceptor.setApplicationEventPublisher(this.publisher);
@@ -129,7 +129,7 @@ public TestEventWithNoValidOneArgObjectCtor() {
129129
public static class FactoryBeanTestListener extends TestListener implements FactoryBean<Object> {
130130

131131
@Override
132-
public Object getObject() throws Exception {
132+
public Object getObject() {
133133
return "test";
134134
}
135135

spring-context/src/test/java/org/springframework/context/event/PayloadApplicationEventTests.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,31 +35,28 @@ public class PayloadApplicationEventTests {
3535

3636
@Test
3737
public void testEventClassWithInterface() {
38-
ApplicationContext ac = new AnnotationConfigApplicationContext(Listener.class);
39-
MyEventClass event = new MyEventClass<>(this, "xyz");
38+
ApplicationContext ac = new AnnotationConfigApplicationContext(AuditableListener.class);
39+
AuditablePayloadEvent event = new AuditablePayloadEvent<>(this, "xyz");
4040
ac.publishEvent(event);
41-
assertTrue(ac.getBean(Listener.class).events.contains(event));
41+
assertTrue(ac.getBean(AuditableListener.class).events.contains(event));
4242
}
4343

4444

4545
public interface Auditable {
4646
}
4747

4848

49-
public static class MyEventClass<GT> extends PayloadApplicationEvent<GT> implements Auditable {
49+
@SuppressWarnings("serial")
50+
public static class AuditablePayloadEvent<T> extends PayloadApplicationEvent<T> implements Auditable {
5051

51-
public MyEventClass(Object source, GT payload) {
52+
public AuditablePayloadEvent(Object source, T payload) {
5253
super(source, payload);
5354
}
54-
55-
public String toString() {
56-
return "Payload: " + getPayload();
57-
}
5855
}
5956

6057

6158
@Component
62-
public static class Listener {
59+
public static class AuditableListener {
6360

6461
public final List<Auditable> events = new ArrayList<>();
6562

0 commit comments

Comments
 (0)