use of cn.taketoday.web.accept.ContentNegotiationManager in project today-infrastructure by TAKETODAY.
the class ReactiveTypeHandlerTests method setup.
@BeforeEach
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();
}
use of cn.taketoday.web.accept.ContentNegotiationManager in project today-infrastructure by TAKETODAY.
the class ReturnValueHandlerManagerTests method contentNegotiationManager.
@Test
void contentNegotiationManager() {
ReturnValueHandlerManager manager = new ReturnValueHandlerManager();
ContentNegotiationManager contentNegotiationManager = new ContentNegotiationManager();
manager.setContentNegotiationManager(contentNegotiationManager);
}
use of cn.taketoday.web.accept.ContentNegotiationManager in project today-infrastructure by TAKETODAY.
the class ContentNegotiationConfigurerTests method ignoreAcceptHeader.
@Test
public void ignoreAcceptHeader() throws Exception {
this.configurer.ignoreAcceptHeader(true);
this.configurer.favorParameter(true);
ContentNegotiationManager manager = this.configurer.buildContentNegotiationManager();
this.servletRequest.setRequestURI("/flower");
this.servletRequest.addHeader("Accept", MediaType.IMAGE_GIF_VALUE);
assertThat(manager.resolveMediaTypes(this.webRequest)).isEqualTo(ContentNegotiationStrategy.MEDIA_TYPE_ALL_LIST);
}
use of cn.taketoday.web.accept.ContentNegotiationManager in project today-infrastructure by TAKETODAY.
the class ContentNegotiationConfigurerTests method favorParameter.
@Test
public void favorParameter() throws Exception {
this.configurer.favorParameter(true);
this.configurer.parameterName("f");
this.configurer.mediaTypes(Collections.singletonMap("json", MediaType.APPLICATION_JSON));
ContentNegotiationManager manager = this.configurer.buildContentNegotiationManager();
this.servletRequest.setRequestURI("/flower");
this.servletRequest.addParameter("f", "json");
assertThat(manager.resolveMediaTypes(this.webRequest).get(0)).isEqualTo(MediaType.APPLICATION_JSON);
}
use of cn.taketoday.web.accept.ContentNegotiationManager in project today-infrastructure by TAKETODAY.
the class ContentNegotiationConfigurerTests method setDefaultContentType.
@Test
public void setDefaultContentType() throws Exception {
this.configurer.defaultContentType(MediaType.APPLICATION_JSON);
ContentNegotiationManager manager = this.configurer.buildContentNegotiationManager();
assertThat(manager.resolveMediaTypes(this.webRequest).get(0)).isEqualTo(MediaType.APPLICATION_JSON);
}
Aggregations