Search in sources :

Example 51 with ResolvableType

use of org.springframework.core.ResolvableType in project spring-framework by spring-projects.

the class GenericApplicationListenerAdapterTests method genericListenerStrictTypeTypeErasure.

// Demonstrates we can't inject that event because the generic type is lost
@Test
public void genericListenerStrictTypeTypeErasure() {
    GenericTestEvent<String> stringEvent = createGenericTestEvent("test");
    ResolvableType eventType = ResolvableType.forType(stringEvent.getClass());
    supportsEventType(false, StringEventListener.class, eventType);
}
Also used : ResolvableType(org.springframework.core.ResolvableType) Test(org.junit.Test)

Example 52 with ResolvableType

use of org.springframework.core.ResolvableType in project spring-framework by spring-projects.

the class GenericApplicationListenerAdapterTests method genericListenerStrictTypeAndResolvableTypeProvider.

// or if the event provides its precise type
@Test
public void genericListenerStrictTypeAndResolvableTypeProvider() {
    ResolvableType eventType = new SmartGenericTestEvent<>(this, "foo").getResolvableType();
    supportsEventType(true, StringEventListener.class, eventType);
}
Also used : ResolvableType(org.springframework.core.ResolvableType) Test(org.junit.Test)

Example 53 with ResolvableType

use of org.springframework.core.ResolvableType in project spring-framework by spring-projects.

the class GenericApplicationListenerAdapterTests method genericListenerRawTypeTypeErasure.

// Demonstrates we cant inject that event because the listener has a raw type
@Test
public void genericListenerRawTypeTypeErasure() {
    GenericTestEvent<String> stringEvent = createGenericTestEvent("test");
    ResolvableType eventType = ResolvableType.forType(stringEvent.getClass());
    supportsEventType(true, RawApplicationListener.class, eventType);
}
Also used : ResolvableType(org.springframework.core.ResolvableType) Test(org.junit.Test)

Example 54 with ResolvableType

use of org.springframework.core.ResolvableType in project spring-framework by spring-projects.

the class GenericApplicationListenerAdapterTests method genericListenerStrictTypeEventSubTypeNotMatching.

@Test
public void genericListenerStrictTypeEventSubTypeNotMatching() {
    LongEvent stringEvent = new LongEvent(this, 123L);
    ResolvableType eventType = ResolvableType.forType(stringEvent.getClass());
    supportsEventType(false, StringEventListener.class, eventType);
}
Also used : ResolvableType(org.springframework.core.ResolvableType) Test(org.junit.Test)

Example 55 with ResolvableType

use of org.springframework.core.ResolvableType in project spring-framework by spring-projects.

the class GenericApplicationListenerAdapterTests method genericListenerStrictTypeEventSubType.

// Demonstrates it works if we actually use the subtype
@Test
public void genericListenerStrictTypeEventSubType() {
    StringEvent stringEvent = new StringEvent(this, "test");
    ResolvableType eventType = ResolvableType.forType(stringEvent.getClass());
    supportsEventType(true, StringEventListener.class, eventType);
}
Also used : ResolvableType(org.springframework.core.ResolvableType) Test(org.junit.Test)

Aggregations

ResolvableType (org.springframework.core.ResolvableType)96 Test (org.junit.Test)66 MethodParameter (org.springframework.core.MethodParameter)20 DataBuffer (org.springframework.core.io.buffer.DataBuffer)15 ServerWebExchange (org.springframework.web.server.ServerWebExchange)14 List (java.util.List)11 MediaType (org.springframework.http.MediaType)10 Flux (reactor.core.publisher.Flux)10 Mono (reactor.core.publisher.Mono)10 Map (java.util.Map)9 Assert (org.springframework.util.Assert)7 Collections (java.util.Collections)6 MockServerWebExchange (org.springframework.mock.http.server.reactive.test.MockServerWebExchange)6 ArrayList (java.util.ArrayList)5 ReactiveAdapter (org.springframework.core.ReactiveAdapter)5 Pojo (org.springframework.http.codec.Pojo)5 ServerWebInputException (org.springframework.web.server.ServerWebInputException)5 Publisher (org.reactivestreams.Publisher)4 HttpMessageReader (org.springframework.http.codec.HttpMessageReader)4 Single (rx.Single)4