Browse Source

Polishing

pull/1323/head
Juergen Hoeller 8 years ago
parent
commit
e9019cd7d1
  1. 5
      spring-jdbc/src/main/java/org/springframework/jdbc/core/support/SqlLobValue.java
  2. 7
      spring-jdbc/src/main/java/org/springframework/jdbc/support/lob/package-info.java
  3. 21
      spring-jms/src/main/java/org/springframework/jms/connection/ConnectionFactoryUtils.java
  4. 5
      spring-tx/src/main/java/org/springframework/transaction/support/TransactionCallbackWithoutResult.java
  5. 38
      spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java
  6. 22
      spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RouterFunction.java
  7. 6
      spring-webflux/src/main/java/org/springframework/web/reactive/result/view/AbstractView.java
  8. 8
      spring-webflux/src/main/java/org/springframework/web/reactive/result/view/UrlBasedViewResolver.java
  9. 6
      spring-webflux/src/main/java/org/springframework/web/reactive/result/view/ViewResolverSupport.java
  10. 4
      spring-webflux/src/main/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerViewResolver.java
  11. 7
      spring-webflux/src/main/java/org/springframework/web/reactive/result/view/freemarker/package-info.java
  12. 10
      spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicatesTests.java
  13. 11
      spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionsTests.java

5
spring-jdbc/src/main/java/org/springframework/jdbc/core/support/SqlLobValue.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -169,8 +169,7 @@ public class SqlLobValue implements DisposableSqlTypeValue { @@ -169,8 +169,7 @@ public class SqlLobValue implements DisposableSqlTypeValue {
* Set the specified content via the LobCreator.
*/
@Override
public void setTypeValue(PreparedStatement ps, int paramIndex, int sqlType, String typeName)
throws SQLException {
public void setTypeValue(PreparedStatement ps, int paramIndex, int sqlType, String typeName) throws SQLException {
if (sqlType == Types.BLOB) {
if (this.content instanceof byte[] || this.content == null) {
this.lobCreator.setBlobAsBytes(ps, paramIndex, (byte[]) this.content);

7
spring-jdbc/src/main/java/org/springframework/jdbc/support/lob/package-info.java

@ -1,8 +1,5 @@ @@ -1,8 +1,5 @@
/**
* Provides a stategy interface for Large OBject handling,
* with implementations for various databases.
*
* <p>Can be used independently from jdbc.core and jdbc.object,
* for example in custom JDBC access code.
* Provides a strategy interface for Large OBject handling,
* as well as a customizable default implementation.
*/
package org.springframework.jdbc.support.lob;

21
spring-jms/src/main/java/org/springframework/jms/connection/ConnectionFactoryUtils.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -131,8 +131,8 @@ public abstract class ConnectionFactoryUtils { @@ -131,8 +131,8 @@ public abstract class ConnectionFactoryUtils {
* @return the transactional Session, or {@code null} if none found
* @throws JMSException in case of JMS failure
*/
public static Session getTransactionalSession(
final ConnectionFactory cf, final Connection existingCon, final boolean synchedLocalTransactionAllowed)
public static Session getTransactionalSession(final ConnectionFactory cf,
final Connection existingCon, final boolean synchedLocalTransactionAllowed)
throws JMSException {
return doGetTransactionalSession(cf, new ResourceFactory() {
@ -173,8 +173,8 @@ public abstract class ConnectionFactoryUtils { @@ -173,8 +173,8 @@ public abstract class ConnectionFactoryUtils {
* @return the transactional Session, or {@code null} if none found
* @throws JMSException in case of JMS failure
*/
public static QueueSession getTransactionalQueueSession(
final QueueConnectionFactory cf, final QueueConnection existingCon, final boolean synchedLocalTransactionAllowed)
public static QueueSession getTransactionalQueueSession(final QueueConnectionFactory cf,
final QueueConnection existingCon, final boolean synchedLocalTransactionAllowed)
throws JMSException {
return (QueueSession) doGetTransactionalSession(cf, new ResourceFactory() {
@ -215,8 +215,8 @@ public abstract class ConnectionFactoryUtils { @@ -215,8 +215,8 @@ public abstract class ConnectionFactoryUtils {
* @return the transactional Session, or {@code null} if none found
* @throws JMSException in case of JMS failure
*/
public static TopicSession getTransactionalTopicSession(
final TopicConnectionFactory cf, final TopicConnection existingCon, final boolean synchedLocalTransactionAllowed)
public static TopicSession getTransactionalTopicSession(final TopicConnectionFactory cf,
final TopicConnection existingCon, final boolean synchedLocalTransactionAllowed)
throws JMSException {
return (TopicSession) doGetTransactionalSession(cf, new ResourceFactory() {
@ -234,7 +234,8 @@ public abstract class ConnectionFactoryUtils { @@ -234,7 +234,8 @@ public abstract class ConnectionFactoryUtils {
}
@Override
public Session createSession(Connection con) throws JMSException {
return ((TopicConnection) con).createTopicSession(synchedLocalTransactionAllowed, Session.AUTO_ACKNOWLEDGE);
return ((TopicConnection) con).createTopicSession(
synchedLocalTransactionAllowed, Session.AUTO_ACKNOWLEDGE);
}
@Override
public boolean isSynchedLocalTransactionAllowed() {
@ -339,8 +340,8 @@ public abstract class ConnectionFactoryUtils { @@ -339,8 +340,8 @@ public abstract class ConnectionFactoryUtils {
}
if (resourceHolderToUse != resourceHolder) {
TransactionSynchronizationManager.registerSynchronization(
new JmsResourceSynchronization(
resourceHolderToUse, connectionFactory, resourceFactory.isSynchedLocalTransactionAllowed()));
new JmsResourceSynchronization(resourceHolderToUse, connectionFactory,
resourceFactory.isSynchedLocalTransactionAllowed()));
resourceHolderToUse.setSynchronizedWithTransaction(true);
TransactionSynchronizationManager.bindResource(connectionFactory, resourceHolderToUse);
}

5
spring-tx/src/main/java/org/springframework/transaction/support/TransactionCallbackWithoutResult.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -40,15 +40,12 @@ public abstract class TransactionCallbackWithoutResult implements TransactionCal @@ -40,15 +40,12 @@ public abstract class TransactionCallbackWithoutResult implements TransactionCal
* context. Does not need to care about transactions itself, although it can retrieve
* and influence the status of the current transaction via the given status object,
* e.g. setting rollback-only.
*
* <p>A RuntimeException thrown by the callback is treated as application
* exception that enforces a rollback. An exception gets propagated to the
* caller of the template.
*
* <p>Note when using JTA: JTA transactions only work with transactional
* JNDI resources, so implementations need to use such resources if they
* want transaction support.
*
* @param status associated transaction status
* @see TransactionTemplate#execute
*/

38
spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java

@ -85,8 +85,8 @@ public abstract class BodyInserters { @@ -85,8 +85,8 @@ public abstract class BodyInserters {
* @param <P> the type of the {@code Publisher}
* @return a {@code BodyInserter} that writes a {@code Publisher}
*/
public static <T, P extends Publisher<T>> BodyInserter<P, ReactiveHttpOutputMessage> fromPublisher(P publisher,
Class<T> elementClass) {
public static <T, P extends Publisher<T>> BodyInserter<P, ReactiveHttpOutputMessage> fromPublisher(
P publisher, Class<T> elementClass) {
Assert.notNull(publisher, "'publisher' must not be null");
Assert.notNull(elementClass, "'elementClass' must not be null");
@ -101,8 +101,8 @@ public abstract class BodyInserters { @@ -101,8 +101,8 @@ public abstract class BodyInserters {
* @param <P> the type of the {@code Publisher}
* @return a {@code BodyInserter} that writes a {@code Publisher}
*/
public static <T, P extends Publisher<T>> BodyInserter<P, ReactiveHttpOutputMessage> fromPublisher(P publisher,
ResolvableType elementType) {
public static <T, P extends Publisher<T>> BodyInserter<P, ReactiveHttpOutputMessage> fromPublisher(
P publisher, ResolvableType elementType) {
Assert.notNull(publisher, "'publisher' must not be null");
Assert.notNull(elementType, "'elementType' must not be null");
@ -111,9 +111,8 @@ public abstract class BodyInserters { @@ -111,9 +111,8 @@ public abstract class BodyInserters {
/**
* Return a {@code BodyInserter} that writes the given {@code Resource}.
* If the resource can be resolved to a {@linkplain Resource#getFile() file}, it will be copied
* using
* <a href="https://en.wikipedia.org/wiki/Zero-copy">zero-copy</a>
* <p>If the resource can be resolved to a {@linkplain Resource#getFile() file}, it will
* be copied using <a href="https://en.wikipedia.org/wiki/Zero-copy">zero-copy</a>.
* @param resource the resource to write to the output message
* @param <T> the type of the {@code Resource}
* @return a {@code BodyInserter} that writes a {@code Publisher}
@ -133,7 +132,7 @@ public abstract class BodyInserters { @@ -133,7 +132,7 @@ public abstract class BodyInserters {
.findFirst()
.map(BodyInserters::<Resource>cast)
.orElseThrow(() -> new IllegalStateException(
"Could not find HttpMessageWriter that supports Resources."));
"Could not find HttpMessageWriter that supports Resource objects"));
}
/**
@ -212,9 +211,10 @@ public abstract class BodyInserters { @@ -212,9 +211,10 @@ public abstract class BodyInserters {
* @param formData the form data to write to the output message
* @return a {@code BodyInserter} that writes form data
*/
public static BodyInserter<MultiValueMap<String, String>, ClientHttpRequest> fromFormData(MultiValueMap<String, String> formData) {
Assert.notNull(formData, "'formData' must not be null");
public static BodyInserter<MultiValueMap<String, String>, ClientHttpRequest> fromFormData(
MultiValueMap<String, String> formData) {
Assert.notNull(formData, "'formData' must not be null");
return (outputMessage, context) -> {
HttpMessageWriter<MultiValueMap<String, String>> messageWriter =
findMessageWriter(context, FORM_TYPE, MediaType.APPLICATION_FORM_URLENCODED);
@ -223,9 +223,8 @@ public abstract class BodyInserters { @@ -223,9 +223,8 @@ public abstract class BodyInserters {
};
}
private static <T> HttpMessageWriter<T> findMessageWriter(BodyInserter.Context context,
ResolvableType type,
MediaType mediaType) {
private static <T> HttpMessageWriter<T> findMessageWriter(
BodyInserter.Context context, ResolvableType type, MediaType mediaType) {
return context.messageWriters().get()
.filter(messageWriter -> messageWriter.canWrite(type, mediaType))
@ -238,24 +237,24 @@ public abstract class BodyInserters { @@ -238,24 +237,24 @@ public abstract class BodyInserters {
/**
* Return a {@code BodyInserter} that writes the given {@code Publisher<DataBuffer>} to the
* body.
* Return a {@code BodyInserter} that writes the given {@code Publisher<DataBuffer>} to the body.
* @param publisher the data buffer publisher to write
* @param <T> the type of the publisher
* @return a {@code BodyInserter} that writes directly to the body
* @see ReactiveHttpOutputMessage#writeWith(Publisher)
*/
public static <T extends Publisher<DataBuffer>> BodyInserter<T, ReactiveHttpOutputMessage> fromDataBuffers(T publisher) {
Assert.notNull(publisher, "'publisher' must not be null");
public static <T extends Publisher<DataBuffer>> BodyInserter<T, ReactiveHttpOutputMessage> fromDataBuffers(
T publisher) {
Assert.notNull(publisher, "'publisher' must not be null");
return (outputMessage, context) -> outputMessage.writeWith(publisher);
}
private static <T, P extends Publisher<?>, M extends ReactiveHttpOutputMessage> BodyInserter<T, M> bodyInserterFor(P body, ResolvableType bodyType) {
private static <T, P extends Publisher<?>, M extends ReactiveHttpOutputMessage> BodyInserter<T, M> bodyInserterFor(
P body, ResolvableType bodyType) {
return (m, context) -> {
MediaType contentType = m.getHeaders().getContentType();
Supplier<Stream<HttpMessageWriter<?>>> messageWriters = context.messageWriters();
return messageWriters.get()
@ -280,5 +279,4 @@ public abstract class BodyInserters { @@ -280,5 +279,4 @@ public abstract class BodyInserters {
return (HttpMessageWriter<T>) messageWriter;
}
}

22
spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RouterFunction.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -41,12 +41,11 @@ public interface RouterFunction<T extends ServerResponse> { @@ -41,12 +41,11 @@ public interface RouterFunction<T extends ServerResponse> {
/**
* Return a composed routing function that first invokes this function,
* and then invokes the {@code other} function (of the same type {@code T}) if this route had
* {@linkplain Mono#empty() no result}.
*
* and then invokes the {@code other} function (of the same type {@code T})
* if this route had {@linkplain Mono#empty() no result}.
* @param other the function of type {@code T} to apply when this function has no result
* @return a composed function that first routes with this function and then the {@code other} function if this
* function has no result
* @return a composed function that first routes with this function and then the
* {@code other} function if this function has no result
*/
default RouterFunction<T> andSame(RouterFunction<T> other) {
return request -> this.route(request).otherwiseIfEmpty(other.route(request));
@ -56,10 +55,9 @@ public interface RouterFunction<T extends ServerResponse> { @@ -56,10 +55,9 @@ public interface RouterFunction<T extends ServerResponse> {
* Return a composed routing function that first invokes this function,
* and then invokes the {@code other} function (of a different type) if this route had
* {@linkplain Optional#empty() no result}.
*
* @param other the function to apply when this function has no result
* @return a composed function that first routes with this function and then the {@code other} function if this
* function has no result
* @return a composed function that first routes with this function and then the
* {@code other} function if this function has no result
*/
default RouterFunction<?> and(RouterFunction<?> other) {
return request -> this.route(request)
@ -72,24 +70,24 @@ public interface RouterFunction<T extends ServerResponse> { @@ -72,24 +70,24 @@ public interface RouterFunction<T extends ServerResponse> {
* and then routes to the given handler function if the given request predicate applies. This
* method is a convenient combination of {@link #and(RouterFunction)} and
* {@link RouterFunctions#route(RequestPredicate, HandlerFunction)}.
* @param <S> the handler function type
* @param predicate the predicate to test
* @param handlerFunction the handler function to route to
* @param <S> the handler function type
* @return a composed function that first routes with this function and then the function
* created from {@code predicate} and {@code handlerFunction} if this
* function has no result
*/
default <S extends ServerResponse> RouterFunction<?> andRoute(RequestPredicate predicate,
HandlerFunction<S> handlerFunction) {
return and(RouterFunctions.route(predicate, handlerFunction));
}
/**
* Filter all {@linkplain HandlerFunction handler functions} routed by this function with the given
* {@linkplain HandlerFilterFunction filter function}.
*
* @param <S> the filter return type
* @param filterFunction the filter to apply
* @param <S> the filter return type
* @return the filtered routing function
*/
default <S extends ServerResponse> RouterFunction<S> filter(HandlerFilterFunction<T, S> filterFunction) {

6
spring-webflux/src/main/java/org/springframework/web/reactive/result/view/AbstractView.java

@ -41,7 +41,7 @@ import org.springframework.web.server.ServerWebExchange; @@ -41,7 +41,7 @@ import org.springframework.web.server.ServerWebExchange;
*/
public abstract class AbstractView implements View, ApplicationContextAware {
/** Well-known name for the RequestDataValueProcessor in the bean factory. */
/** Well-known name for the RequestDataValueProcessor in the bean factory */
public static final String REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME = "requestDataValueProcessor";
@ -68,7 +68,7 @@ public abstract class AbstractView implements View, ApplicationContextAware { @@ -68,7 +68,7 @@ public abstract class AbstractView implements View, ApplicationContextAware {
* Default is "text/html;charset=UTF-8".
*/
public void setSupportedMediaTypes(List<MediaType> supportedMediaTypes) {
Assert.notEmpty(supportedMediaTypes, "'supportedMediaTypes' is required.");
Assert.notEmpty(supportedMediaTypes, "MediaType List must not be empty");
this.mediaTypes.clear();
if (supportedMediaTypes != null) {
this.mediaTypes.addAll(supportedMediaTypes);
@ -122,7 +122,7 @@ public abstract class AbstractView implements View, ApplicationContextAware { @@ -122,7 +122,7 @@ public abstract class AbstractView implements View, ApplicationContextAware {
}
public ApplicationContext getApplicationContext() {
return applicationContext;
return this.applicationContext;
}
/**

8
spring-webflux/src/main/java/org/springframework/web/reactive/result/view/UrlBasedViewResolver.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -25,7 +25,6 @@ import org.springframework.beans.BeanUtils; @@ -25,7 +25,6 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.PatternMatchUtils;
/**
* A {@link ViewResolver} that allow direct resolution of symbolic view names
* to URLs without explicit mapping definition. This is useful if symbolic names
@ -52,6 +51,7 @@ import org.springframework.util.PatternMatchUtils; @@ -52,6 +51,7 @@ import org.springframework.util.PatternMatchUtils;
*
* <p>Note: This class does not support localized resolution, i.e. resolving
* a symbolic view name to different resources depending on the current locale.
*
* @author Rossen Stoyanchev
* @author Sebastien Deleuze
* @since 5.0
@ -75,7 +75,7 @@ public class UrlBasedViewResolver extends ViewResolverSupport implements ViewRes @@ -75,7 +75,7 @@ public class UrlBasedViewResolver extends ViewResolverSupport implements ViewRes
private String[] viewNames;
private Function<String, RedirectView> redirectViewProvider = url -> new RedirectView(url);
private Function<String, RedirectView> redirectViewProvider = RedirectView::new;
private String requestContextAttribute;
@ -194,6 +194,7 @@ public class UrlBasedViewResolver extends ViewResolverSupport implements ViewRes @@ -194,6 +194,7 @@ public class UrlBasedViewResolver extends ViewResolverSupport implements ViewRes
if (!canHandle(viewName, locale)) {
return Mono.empty();
}
AbstractUrlBasedView urlBasedView;
if (viewName.startsWith(REDIRECT_URL_PREFIX)) {
String redirectUrl = viewName.substring(REDIRECT_URL_PREFIX.length());
@ -202,6 +203,7 @@ public class UrlBasedViewResolver extends ViewResolverSupport implements ViewRes @@ -202,6 +203,7 @@ public class UrlBasedViewResolver extends ViewResolverSupport implements ViewRes
else {
urlBasedView = createUrlBasedView(viewName);
}
View view = applyLifecycleMethods(viewName, urlBasedView);
try {
return (urlBasedView.checkResourceExists(locale) ? Mono.just(view) : Mono.empty());

6
spring-webflux/src/main/java/org/springframework/web/reactive/result/view/ViewResolverSupport.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -57,7 +57,7 @@ public abstract class ViewResolverSupport implements ApplicationContextAware, Or @@ -57,7 +57,7 @@ public abstract class ViewResolverSupport implements ApplicationContextAware, Or
* Default is "text/html;charset=UTF-8".
*/
public void setSupportedMediaTypes(List<MediaType> supportedMediaTypes) {
Assert.notEmpty(supportedMediaTypes, "'supportedMediaTypes' is required.");
Assert.notEmpty(supportedMediaTypes, "MediaType List must not be empty");
this.mediaTypes.clear();
if (supportedMediaTypes != null) {
this.mediaTypes.addAll(supportedMediaTypes);
@ -77,7 +77,7 @@ public abstract class ViewResolverSupport implements ApplicationContextAware, Or @@ -77,7 +77,7 @@ public abstract class ViewResolverSupport implements ApplicationContextAware, Or
* Default is {@linkplain StandardCharsets#UTF_8 UTF 8}.
*/
public void setDefaultCharset(Charset defaultCharset) {
Assert.notNull(defaultCharset, "'defaultCharset' must not be null");
Assert.notNull(defaultCharset, "Default Charset must not be null");
this.defaultCharset = defaultCharset;
}

4
spring-webflux/src/main/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerViewResolver.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,6 +13,7 @@ @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.web.reactive.result.view.freemarker;
import org.springframework.web.reactive.result.view.UrlBasedViewResolver;
@ -29,7 +30,6 @@ import org.springframework.web.reactive.result.view.UrlBasedViewResolver; @@ -29,7 +30,6 @@ import org.springframework.web.reactive.result.view.UrlBasedViewResolver;
*/
public class FreeMarkerViewResolver extends UrlBasedViewResolver {
/**
* Simple constructor.
*/

7
spring-webflux/src/main/java/org/springframework/web/reactive/result/view/freemarker/package-info.java

@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
/**
* Support classes for the integration of
* <a href="http://www.freemarker.org">FreeMarker</a>
* as Spring web view technology.
* Contains a View implementation for FreeMarker templates.
*/
package org.springframework.web.reactive.result.view.freemarker;

10
spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicatesTests.java

@ -81,7 +81,6 @@ public class RequestPredicatesTests { @@ -81,7 +81,6 @@ public class RequestPredicatesTests {
predicate = RequestPredicates.OPTIONS("/p*");
request = MockServerRequest.builder().method(HttpMethod.OPTIONS).uri(uri).build();
assertTrue(predicate.test(request));
}
@Test
@ -100,10 +99,8 @@ public class RequestPredicatesTests { @@ -100,10 +99,8 @@ public class RequestPredicatesTests {
String name = "MyHeader";
String value = "MyValue";
RequestPredicate predicate =
RequestPredicates.headers(headers -> {
return headers.header(name).equals(
Collections.singletonList(value));
});
RequestPredicates.headers(
headers -> headers.header(name).equals(Collections.singletonList(value)));
MockServerRequest request = MockServerRequest.builder().header(name, value).build();
assertTrue(predicate.test(request));
@ -115,8 +112,7 @@ public class RequestPredicatesTests { @@ -115,8 +112,7 @@ public class RequestPredicatesTests {
public void contentType() throws Exception {
MediaType json = MediaType.APPLICATION_JSON;
RequestPredicate predicate = RequestPredicates.contentType(json);
MockServerRequest
request = MockServerRequest.builder().header("Content-Type", json.toString()).build();
MockServerRequest request = MockServerRequest.builder().header("Content-Type", json.toString()).build();
assertTrue(predicate.test(request));
request = MockServerRequest.builder().build();

11
spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionsTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -30,11 +30,8 @@ import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse @@ -30,11 +30,8 @@ import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse
import org.springframework.web.reactive.result.view.ViewResolver;
import org.springframework.web.server.ServerWebExchange;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
/**
* @author Arjen Poutsma
@ -114,7 +111,6 @@ public class RouterFunctionsTests { @@ -114,7 +111,6 @@ public class RouterFunctionsTests {
StepVerifier.create(resultHandlerFunction)
.expectComplete()
.verify();
}
@Test
@ -140,7 +136,6 @@ public class RouterFunctionsTests { @@ -140,7 +136,6 @@ public class RouterFunctionsTests {
RequestPredicate requestPredicate = mock(RequestPredicate.class);
when(requestPredicate.test(request)).thenReturn(false);
HttpHandler result = RouterFunctions.toHttpHandler(routerFunction, strategies);
assertNotNull(result);

Loading…
Cancel
Save