Skip to content

Commit bdb9f95

Browse files
committed
Polish
1 parent f6ca21f commit bdb9f95

File tree

4 files changed

+19
-28
lines changed

4 files changed

+19
-28
lines changed

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

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 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.
@@ -16,8 +16,6 @@
1616

1717
package org.springframework.context.event;
1818

19-
import java.io.IOException;
20-
2119
import org.springframework.context.ApplicationEvent;
2220
import org.springframework.context.ApplicationListener;
2321
import org.springframework.core.ResolvableType;
@@ -125,17 +123,8 @@ public void onApplicationEvent(ApplicationEvent event) {
125123

126124
static class TestEvents {
127125

128-
public ApplicationEvent applicationEvent;
129-
130126
public GenericTestEvent<?> wildcardEvent;
131127

132-
public GenericTestEvent<String> stringEvent;
133-
134-
public GenericTestEvent<Long> longEvent;
135-
136-
public GenericTestEvent<IllegalStateException> illegalStateExceptionEvent;
137-
138-
public GenericTestEvent<IOException> ioExceptionEvent;
139128
}
140129

141130
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 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.
@@ -79,13 +79,13 @@ public void multicastSimpleEvent() {
7979
@Test
8080
public void multicastGenericEvent() {
8181
multicastEvent(true, StringEventListener.class, createGenericTestEvent("test"),
82-
getGenericApplicationEventType("stringEvent"));
82+
ResolvableType.forClassWithGenerics(GenericTestEvent.class, String.class));
8383
}
8484

8585
@Test
8686
public void multicastGenericEventWrongType() {
8787
multicastEvent(false, StringEventListener.class, createGenericTestEvent(123L),
88-
getGenericApplicationEventType("longEvent"));
88+
ResolvableType.forClassWithGenerics(GenericTestEvent.class, Long.class));
8989
}
9090

9191
@Test

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 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.
@@ -56,27 +56,27 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
5656
@Test
5757
public void rawListener() {
5858
Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleRaw", ApplicationEvent.class);
59-
supportsEventType(true, method, getGenericApplicationEventType("applicationEvent"));
59+
supportsEventType(true, method, ResolvableType.forClass(ApplicationEvent.class));
6060
}
6161

6262
@Test
6363
public void rawListenerWithGenericEvent() {
6464
Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleRaw", ApplicationEvent.class);
65-
supportsEventType(true, method, getGenericApplicationEventType("stringEvent"));
65+
supportsEventType(true, method, ResolvableType.forClassWithGenerics(GenericTestEvent.class, String.class));
6666
}
6767

6868
@Test
6969
public void genericListener() {
7070
Method method = ReflectionUtils.findMethod(
7171
SampleEvents.class, "handleGenericString", GenericTestEvent.class);
72-
supportsEventType(true, method, getGenericApplicationEventType("stringEvent"));
72+
supportsEventType(true, method, ResolvableType.forClassWithGenerics(GenericTestEvent.class, String.class));
7373
}
7474

7575
@Test
7676
public void genericListenerWrongParameterizedType() {
7777
Method method = ReflectionUtils.findMethod(
7878
SampleEvents.class, "handleGenericString", GenericTestEvent.class);
79-
supportsEventType(false, method, getGenericApplicationEventType("longEvent"));
79+
supportsEventType(false, method, ResolvableType.forClassWithGenerics(GenericTestEvent.class, Long.class));
8080
}
8181

8282
@Test

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 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.
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.context.event;
1818

19+
import java.io.IOException;
20+
1921
import org.junit.jupiter.api.Test;
2022

2123
import org.springframework.context.ApplicationEvent;
@@ -51,7 +53,7 @@ public void supportsSourceTypeWithSmartApplicationListener() {
5153

5254
@Test
5355
public void genericListenerStrictType() {
54-
supportsEventType(true, StringEventListener.class, getGenericApplicationEventType("stringEvent"));
56+
supportsEventType(true, StringEventListener.class, ResolvableType.forClassWithGenerics(GenericTestEvent.class, String.class));
5557
}
5658

5759
@Test // Demonstrates we can't inject that event because the generic type is lost
@@ -83,7 +85,7 @@ public void genericListenerStrictTypeEventSubType() {
8385

8486
@Test
8587
public void genericListenerStrictTypeNotMatching() {
86-
supportsEventType(false, StringEventListener.class, getGenericApplicationEventType("longEvent"));
88+
supportsEventType(false, StringEventListener.class, ResolvableType.forClassWithGenerics(GenericTestEvent.class, Long.class));
8789
}
8890

8991
@Test
@@ -102,25 +104,25 @@ public void genericListenerStrictTypeNotMatchTypeErasure() {
102104

103105
@Test
104106
public void genericListenerStrictTypeSubClass() {
105-
supportsEventType(false, ObjectEventListener.class, getGenericApplicationEventType("longEvent"));
107+
supportsEventType(false, ObjectEventListener.class, ResolvableType.forClassWithGenerics(GenericTestEvent.class, Long.class));
106108
}
107109

108110
@Test
109111
public void genericListenerUpperBoundType() {
110112
supportsEventType(true, UpperBoundEventListener.class,
111-
getGenericApplicationEventType("illegalStateExceptionEvent"));
113+
ResolvableType.forClassWithGenerics(GenericTestEvent.class, IllegalStateException.class));
112114
}
113115

114116
@Test
115117
public void genericListenerUpperBoundTypeNotMatching() {
116118
supportsEventType(false, UpperBoundEventListener.class,
117-
getGenericApplicationEventType("ioExceptionEvent"));
119+
ResolvableType.forClassWithGenerics(GenericTestEvent.class, IOException.class));
118120
}
119121

120122
@Test
121123
public void genericListenerWildcardType() {
122124
supportsEventType(true, GenericEventListener.class,
123-
getGenericApplicationEventType("stringEvent"));
125+
ResolvableType.forClassWithGenerics(GenericTestEvent.class, String.class));
124126
}
125127

126128
@Test // Demonstrates we cant inject that event because the listener has a wildcard
@@ -133,7 +135,7 @@ public void genericListenerWildcardTypeTypeErasure() {
133135
@Test
134136
public void genericListenerRawType() {
135137
supportsEventType(true, RawApplicationListener.class,
136-
getGenericApplicationEventType("stringEvent"));
138+
ResolvableType.forClassWithGenerics(GenericTestEvent.class, String.class));
137139
}
138140

139141
@Test // Demonstrates we cant inject that event because the listener has a raw type

0 commit comments

Comments
 (0)