Java Code Examples for org.springframework.core.ReactiveAdapterRegistry#getSharedInstance()

The following examples show how to use org.springframework.core.ReactiveAdapterRegistry#getSharedInstance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CookieValueMethodArgumentResolverTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Before
@SuppressWarnings("resource")
public void setup() throws Exception {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
	context.refresh();

	ReactiveAdapterRegistry adapterRegistry = ReactiveAdapterRegistry.getSharedInstance();
	this.resolver = new CookieValueMethodArgumentResolver(context.getBeanFactory(), adapterRegistry);
	this.bindingContext = new BindingContext();

	Method method = ReflectionUtils.findMethod(getClass(), "params", (Class<?>[]) null);
	this.cookieParameter = new SynthesizingMethodParameter(method, 0);
	this.cookieStringParameter = new SynthesizingMethodParameter(method, 1);
	this.stringParameter = new SynthesizingMethodParameter(method, 2);
	this.cookieMonoParameter = new SynthesizingMethodParameter(method, 3);
}
 
Example 2
Source File: RequestHeaderMethodArgumentResolverTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Before
@SuppressWarnings("resource")
public void setup() throws Exception {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
	context.refresh();
	ReactiveAdapterRegistry adapterRegistry = ReactiveAdapterRegistry.getSharedInstance();
	this.resolver = new RequestHeaderMethodArgumentResolver(context.getBeanFactory(), adapterRegistry);

	ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer();
	initializer.setConversionService(new DefaultFormattingConversionService());
	this.bindingContext = new BindingContext(initializer);

	Method method = ReflectionUtils.findMethod(getClass(), "params", (Class<?>[]) null);
	this.paramNamedDefaultValueStringHeader = new SynthesizingMethodParameter(method, 0);
	this.paramNamedValueStringArray = new SynthesizingMethodParameter(method, 1);
	this.paramSystemProperty = new SynthesizingMethodParameter(method, 2);
	this.paramResolvedNameWithExpression = new SynthesizingMethodParameter(method, 3);
	this.paramResolvedNameWithPlaceholder = new SynthesizingMethodParameter(method, 4);
	this.paramNamedValueMap = new SynthesizingMethodParameter(method, 5);
	this.paramDate = new SynthesizingMethodParameter(method, 6);
	this.paramInstant = new SynthesizingMethodParameter(method, 7);
	this.paramMono = new SynthesizingMethodParameter(method, 8);
}
 
Example 3
Source File: ModelAttributeMethodArgumentResolverTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void supportsWithDefaultResolution() throws Exception {
	ModelAttributeMethodArgumentResolver resolver =
			new ModelAttributeMethodArgumentResolver(ReactiveAdapterRegistry.getSharedInstance(), true);

	MethodParameter param = this.testMethod.annotNotPresent(ModelAttribute.class).arg(Foo.class);
	assertTrue(resolver.supportsParameter(param));

	param = this.testMethod.annotNotPresent(ModelAttribute.class).arg(Mono.class, Foo.class);
	assertTrue(resolver.supportsParameter(param));

	param = this.testMethod.annotNotPresent(ModelAttribute.class).arg(String.class);
	assertFalse(resolver.supportsParameter(param));

	param = this.testMethod.annotNotPresent(ModelAttribute.class).arg(Mono.class, String.class);
	assertFalse(resolver.supportsParameter(param));
}
 
Example 4
Source File: ControllerMethodResolverTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Before
public void setup() {
	ArgumentResolverConfigurer resolvers = new ArgumentResolverConfigurer();
	resolvers.addCustomResolver(new CustomArgumentResolver());
	resolvers.addCustomResolver(new CustomSyncArgumentResolver());

	ServerCodecConfigurer codecs = ServerCodecConfigurer.create();
	codecs.customCodecs().decoder(new ByteArrayDecoder());
	codecs.customCodecs().decoder(new ByteBufferDecoder());

	AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
	applicationContext.registerBean(TestControllerAdvice.class);
	applicationContext.refresh();

	this.methodResolver = new ControllerMethodResolver(
			resolvers, ReactiveAdapterRegistry.getSharedInstance(), applicationContext, codecs.getReaders());

	Method method = ResolvableMethod.on(TestController.class).mockCall(TestController::handle).method();
	this.handlerMethod = new HandlerMethod(new TestController(), method);
}
 
Example 5
Source File: ModelAttributeMethodArgumentResolverTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void supports() throws Exception {
	ModelAttributeMethodArgumentResolver resolver =
			new ModelAttributeMethodArgumentResolver(ReactiveAdapterRegistry.getSharedInstance(), false);

	MethodParameter param = this.testMethod.annotPresent(ModelAttribute.class).arg(Foo.class);
	assertTrue(resolver.supportsParameter(param));

	param = this.testMethod.annotPresent(ModelAttribute.class).arg(Mono.class, Foo.class);
	assertTrue(resolver.supportsParameter(param));

	param = this.testMethod.annotNotPresent(ModelAttribute.class).arg(Foo.class);
	assertFalse(resolver.supportsParameter(param));

	param = this.testMethod.annotNotPresent(ModelAttribute.class).arg(Mono.class, Foo.class);
	assertFalse(resolver.supportsParameter(param));
}
 
Example 6
Source File: ModelAttributeMethodArgumentResolverTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void supports() throws Exception {
	ModelAttributeMethodArgumentResolver resolver =
			new ModelAttributeMethodArgumentResolver(ReactiveAdapterRegistry.getSharedInstance(), false);

	MethodParameter param = this.testMethod.annotPresent(ModelAttribute.class).arg(Foo.class);
	assertTrue(resolver.supportsParameter(param));

	param = this.testMethod.annotPresent(ModelAttribute.class).arg(Mono.class, Foo.class);
	assertTrue(resolver.supportsParameter(param));

	param = this.testMethod.annotNotPresent(ModelAttribute.class).arg(Foo.class);
	assertFalse(resolver.supportsParameter(param));

	param = this.testMethod.annotNotPresent(ModelAttribute.class).arg(Mono.class, Foo.class);
	assertFalse(resolver.supportsParameter(param));
}
 
Example 7
Source File: PathVariableMapMethodArgumentResolverTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Before
public void setup() throws Exception {
	this.resolver = new PathVariableMapMethodArgumentResolver(ReactiveAdapterRegistry.getSharedInstance());

	Method method = ReflectionUtils.findMethod(getClass(), "handle", (Class<?>[]) null);
	this.paramMap = new MethodParameter(method, 0);
	this.paramNamedMap = new MethodParameter(method, 1);
	this.paramMapNoAnnot = new MethodParameter(method, 2);
	this.paramMonoMap = new MethodParameter(method, 3);
}
 
Example 8
Source File: SessionAttributeMethodArgumentResolverTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Before
@SuppressWarnings("resource")
public void setup() {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
	context.refresh();
	ReactiveAdapterRegistry adapterRegistry = ReactiveAdapterRegistry.getSharedInstance();
	this.resolver = new SessionAttributeMethodArgumentResolver(context.getBeanFactory(), adapterRegistry);
	this.session = mock(WebSession.class);
	this.exchange = MockServerWebExchange.builder(MockServerHttpRequest.get("/")).session(this.session).build();
	this.handleMethod = ReflectionUtils.findMethod(getClass(), "handleWithSessionAttribute", (Class<?>[]) null);
}
 
Example 9
Source File: ReactiveTypeHandlerTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Before
public void setup() throws Exception {
	ContentNegotiationManagerFactoryBean factoryBean = new ContentNegotiationManagerFactoryBean();
	factoryBean.afterPropertiesSet();
	ContentNegotiationManager manager = factoryBean.getObject();
	ReactiveAdapterRegistry adapterRegistry = ReactiveAdapterRegistry.getSharedInstance();
	this.handler = new ReactiveTypeHandler(adapterRegistry, new SyncTaskExecutor(), manager);
	resetRequest();
}
 
Example 10
Source File: ExpressionValueMethodArgumentResolverTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Before
@SuppressWarnings("resource")
public void setup() throws Exception {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
	context.refresh();
	ReactiveAdapterRegistry adapterRegistry = ReactiveAdapterRegistry.getSharedInstance();
	this.resolver = new ExpressionValueMethodArgumentResolver(context.getBeanFactory(), adapterRegistry);

	Method method = ReflectionUtils.findMethod(getClass(), "params", (Class<?>[]) null);
	this.paramSystemProperty = new MethodParameter(method, 0);
	this.paramNotSupported = new MethodParameter(method, 1);
	this.paramAlsoNotSupported = new MethodParameter(method, 2);
}
 
Example 11
Source File: PathVariableMethodArgumentResolverTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Before
public void setup() throws Exception {
	this.resolver = new PathVariableMethodArgumentResolver(null, ReactiveAdapterRegistry.getSharedInstance());

	Method method = ReflectionUtils.findMethod(getClass(), "handle", (Class<?>[]) null);
	paramNamedString = new SynthesizingMethodParameter(method, 0);
	paramString = new SynthesizingMethodParameter(method, 1);
	paramNotRequired = new SynthesizingMethodParameter(method, 2);
	paramOptional = new SynthesizingMethodParameter(method, 3);
	paramMono = new SynthesizingMethodParameter(method, 4);
}
 
Example 12
Source File: RequestParamMethodArgumentResolverTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void doesNotSupportParameterWithDefaultResolutionTurnedOff() {
	ReactiveAdapterRegistry adapterRegistry = ReactiveAdapterRegistry.getSharedInstance();
	this.resolver = new RequestParamMethodArgumentResolver(null, adapterRegistry, false);

	MethodParameter param = this.testMethod.annotNotPresent(RequestParam.class).arg(String.class);
	assertFalse(this.resolver.supportsParameter(param));
}
 
Example 13
Source File: PathVariableMethodArgumentResolverTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Before
public void setup() throws Exception {
	this.resolver = new PathVariableMethodArgumentResolver(null, ReactiveAdapterRegistry.getSharedInstance());

	Method method = ReflectionUtils.findMethod(getClass(), "handle", (Class<?>[]) null);
	paramNamedString = new SynthesizingMethodParameter(method, 0);
	paramString = new SynthesizingMethodParameter(method, 1);
	paramNotRequired = new SynthesizingMethodParameter(method, 2);
	paramOptional = new SynthesizingMethodParameter(method, 3);
	paramMono = new SynthesizingMethodParameter(method, 4);
}
 
Example 14
Source File: ReactiveTypeHandler.java    From spring-analysis-note with MIT License 4 votes vote down vote up
public ReactiveTypeHandler() {
	this(ReactiveAdapterRegistry.getSharedInstance(), new SyncTaskExecutor(), new ContentNegotiationManager());
}
 
Example 15
Source File: ModelAttributeMethodArgumentResolverTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
private ModelAttributeMethodArgumentResolver createResolver() {
	return new ModelAttributeMethodArgumentResolver(ReactiveAdapterRegistry.getSharedInstance(), false);
}
 
Example 16
Source File: RequestBodyArgumentResolverTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Before
public void setup() {
	List<HttpMessageReader<?>> readers = new ArrayList<>();
	readers.add(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes()));
	this.resolver = new RequestBodyArgumentResolver(readers, ReactiveAdapterRegistry.getSharedInstance());
}
 
Example 17
Source File: HandlerResultHandlerTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
public TestResultHandler(RequestedContentTypeResolver contentTypeResolver) {
	super(contentTypeResolver, ReactiveAdapterRegistry.getSharedInstance());
}
 
Example 18
Source File: ModelInitializerTests.java    From java-technology-stack with MIT License 3 votes vote down vote up
@Before
public void setUp() throws Exception {

	ReactiveAdapterRegistry adapterRegistry = ReactiveAdapterRegistry.getSharedInstance();

	ArgumentResolverConfigurer resolverConfigurer = new ArgumentResolverConfigurer();
	resolverConfigurer.addCustomResolver(new ModelArgumentResolver(adapterRegistry));

	ControllerMethodResolver methodResolver = new ControllerMethodResolver(
			resolverConfigurer, adapterRegistry, new StaticApplicationContext(), Collections.emptyList());

	this.modelInitializer = new ModelInitializer(methodResolver, adapterRegistry);
}
 
Example 19
Source File: AbstractMessageWriterResultHandler.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Constructor with {@link HttpMessageWriter HttpMessageWriters} and a
 * {@code RequestedContentTypeResolver}.
 * @param messageWriters for serializing Objects to the response body stream
 * @param contentTypeResolver for resolving the requested content type
 */
protected AbstractMessageWriterResultHandler(List<HttpMessageWriter<?>> messageWriters,
		RequestedContentTypeResolver contentTypeResolver) {

	this(messageWriters, contentTypeResolver, ReactiveAdapterRegistry.getSharedInstance());
}
 
Example 20
Source File: AbstractMessageReaderArgumentResolver.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Constructor with {@link HttpMessageReader}'s and a {@link Validator}.
 * @param readers readers to convert from the request body
 */
protected AbstractMessageReaderArgumentResolver(List<HttpMessageReader<?>> readers) {
	this(readers, ReactiveAdapterRegistry.getSharedInstance());
}