DATACMNS-714 - Improved test cases for CompletableFuture support.

We now make sure the converter for CompletableFuture is only registered if Spring 4.2 or better is on the classpath. Adapted test cases to only run tests for CompletableFuture support in the very same scenario.
This commit is contained in:
Oliver Gierke
2015-06-22 11:33:31 +02:00
parent 6da31347b8
commit e0dafd29f4
4 changed files with 41 additions and 4 deletions

View File

@@ -21,11 +21,13 @@ import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Future;
import org.springframework.core.SpringVersion;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.converter.GenericConverter;
import org.springframework.core.convert.support.ConfigurableConversionService;
import org.springframework.data.util.Version;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
@@ -42,6 +44,9 @@ import com.google.common.base.Optional;
*/
public abstract class QueryExecutionConverters {
private static final Version SPRING_VERSION = Version.parse(SpringVersion.getVersion());
private static final Version FOUR_DOT_TWO = new Version(4, 2);
private static final boolean GUAVA_PRESENT = ClassUtils.isPresent("com.google.common.base.Optional",
QueryExecutionConverters.class.getClassLoader());
private static final boolean JDK_8_PRESENT = ClassUtils.isPresent("java.util.Optional",
@@ -60,6 +65,9 @@ public abstract class QueryExecutionConverters {
if (JDK_8_PRESENT) {
WRAPPER_TYPES.add(NullableWrapperToJdk8OptionalConverter.getWrapperType());
}
if (JDK_8_PRESENT && SPRING_VERSION.isGreaterThanOrEqualTo(FOUR_DOT_TWO)) {
WRAPPER_TYPES.add(NullableWrapperToCompletableFutureConverter.getWrapperType());
}
}