org.springframework.http.codec.support.DefaultServerCodecConfigurer Java Examples

The following examples show how to use org.springframework.http.codec.support.DefaultServerCodecConfigurer. 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: ModifyResponseBodyGatewayFilterFactoryUnitTests.java    From spring-cloud-gateway with Apache License 2.0 5 votes vote down vote up
@Test
public void toStringFormat() {
	Config config = new Config();
	config.setInClass(String.class);
	config.setOutClass(Integer.class);
	config.setNewContentType("mycontenttype");
	GatewayFilter filter = new ModifyResponseBodyGatewayFilterFactory(
			new DefaultServerCodecConfigurer().getReaders(), emptySet(), emptySet())
					.apply(config);
	assertThat(filter.toString()).contains("String").contains("Integer")
			.contains("mycontenttype");
}
 
Example #2
Source File: CorsConfig.java    From microservice-recruit with Apache License 2.0 4 votes vote down vote up
@Bean
public ServerCodecConfigurer serverCodecConfigurer() {
    return new DefaultServerCodecConfigurer();
}
 
Example #3
Source File: GatewayApplication.java    From MyShopPlus with Apache License 2.0 4 votes vote down vote up
@Bean
public ServerCodecConfigurer serverCodecConfigurer() {
    return new DefaultServerCodecConfigurer();
}
 
Example #4
Source File: CorsConfig.java    From open-capacity-platform with Apache License 2.0 4 votes vote down vote up
@Bean
public ServerCodecConfigurer serverCodecConfigurer() {
	return new DefaultServerCodecConfigurer();
}
 
Example #5
Source File: CorsConfig.java    From microservice-recruit with Apache License 2.0 4 votes vote down vote up
@Bean
public ServerCodecConfigurer serverCodecConfigurer() {
    return new DefaultServerCodecConfigurer();
}
 
Example #6
Source File: CorsConfiguration.java    From zuihou-admin-cloud with Apache License 2.0 4 votes vote down vote up
@Bean
public ServerCodecConfigurer serverCodecConfigurer() {
    return new DefaultServerCodecConfigurer();
}
 
Example #7
Source File: WingtipsSpringWebfluxWebFilterTest.java    From wingtips with Apache License 2.0 4 votes vote down vote up
@Before
public void beforeMethod() {
    resetTracing();

    spanRecorder = new SpanRecorder();
    Tracer.getInstance().addSpanLifecycleListener(spanRecorder);

    initialSpanNameFromStrategy = new AtomicReference<>("span-name-from-strategy-" + UUID.randomUUID().toString());
    strategyInitialSpanNameMethodCalled = new AtomicBoolean(false);
    strategyRequestTaggingMethodCalled = new AtomicBoolean(false);
    strategyResponseTaggingAndFinalSpanNameMethodCalled = new AtomicBoolean(false);
    strategyInitialSpanNameArgs = new AtomicReference<>(null);
    strategyRequestTaggingArgs = new AtomicReference<>(null);
    strategyResponseTaggingArgs = new AtomicReference<>(null);
    tagAndNamingStrategy = new ArgCapturingHttpTagAndSpanNamingStrategy<>(
        initialSpanNameFromStrategy, strategyInitialSpanNameMethodCalled, strategyRequestTaggingMethodCalled,
        strategyResponseTaggingAndFinalSpanNameMethodCalled, strategyInitialSpanNameArgs,
        strategyRequestTaggingArgs, strategyResponseTaggingArgs
    );
    //noinspection unchecked
    tagAndNamingAdapterMock = mock(HttpTagAndSpanNamingAdapter.class);

    userIdHeaderKeys = Arrays.asList("user-id", "alt-user-id");

    filterSpy = spy(
        WingtipsSpringWebfluxWebFilter
            .newBuilder()
            .withTagAndNamingStrategy(tagAndNamingStrategy)
            .withTagAndNamingAdapter(tagAndNamingAdapterMock)
            .withUserIdHeaderKeys(userIdHeaderKeys)
            .build()
    );

    requestMock = mock(ServerHttpRequest.class);
    requestHeadersMock = mock(HttpHeaders.class);
    responseMock = mock(ServerHttpResponse.class);
    responseHeadersMock = mock(HttpHeaders.class);

    doReturn("someRequestId").when(requestMock).getId();

    doReturn(requestHeadersMock).when(requestMock).getHeaders();
    doReturn(responseHeadersMock).when(responseMock).getHeaders();

    exchange = new DefaultServerWebExchange(
        requestMock, responseMock, new DefaultWebSessionManager(), new DefaultServerCodecConfigurer(),
        new FixedLocaleContextResolver(Locale.US)
    );
    
    chainMock = mock(WebFilterChain.class);
    expectedResultMonoDuration = Duration.ofMillis(50);
    webFilterChainResult = Mono.delay(expectedResultMonoDuration).flatMap(l -> Mono.empty());

    doReturn(webFilterChainResult).when(chainMock).filter(any(ServerWebExchange.class));
}
 
Example #8
Source File: CorsConfig.java    From simple-microservice with Apache License 2.0 2 votes vote down vote up
/**
 * Server codec configurer.
 *
 * @return the server codec configurer
 */
@Bean
public ServerCodecConfigurer serverCodecConfigurer() {
  return new DefaultServerCodecConfigurer();
}