org.springframework.web.server.i18n.FixedLocaleContextResolver Java Examples

The following examples show how to use org.springframework.web.server.i18n.FixedLocaleContextResolver. 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: LocaleContextResolverIntegrationTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
protected HandlerStrategies handlerStrategies() {
	return HandlerStrategies.builder()
			.viewResolver(new DummyViewResolver())
			.localeContextResolver(new FixedLocaleContextResolver(Locale.GERMANY))
			.build();
}
 
Example #2
Source File: LocaleContextResolverIntegrationTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
protected HandlerStrategies handlerStrategies() {
	return HandlerStrategies.builder()
			.viewResolver(new DummyViewResolver())
			.localeContextResolver(new FixedLocaleContextResolver(Locale.GERMANY))
			.build();
}
 
Example #3
Source File: LocaleContextResolverIntegrationTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
protected LocaleContextResolver createLocaleContextResolver() {
	return new FixedLocaleContextResolver(Locale.GERMANY);
}
 
Example #4
Source File: LocaleContextResolverIntegrationTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
protected LocaleContextResolver createLocaleContextResolver() {
	return new FixedLocaleContextResolver(Locale.GERMANY);
}
 
Example #5
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));
}