diff --git a/pom.xml b/pom.xml index 5d66db9203..4d804cfa9a 100644 --- a/pom.xml +++ b/pom.xml @@ -848,7 +848,8 @@ ${project.build.sourceDirectory} - ${project.build.directory}/generated-sources + ${project.build.testSourceDirectory} + ${project.basedir}/src/main/templates diff --git a/src/main/java/io/lettuce/core/dynamic/SimpleBatcher.java b/src/main/java/io/lettuce/core/dynamic/SimpleBatcher.java index 9d42d37b69..a2ecf48834 100644 --- a/src/main/java/io/lettuce/core/dynamic/SimpleBatcher.java +++ b/src/main/java/io/lettuce/core/dynamic/SimpleBatcher.java @@ -184,4 +184,5 @@ private List> prepareDefaultFlush(int consu private ArrayList newDrainTarget() { return new ArrayList<>(Math.max(0, Math.min(batchSize, queue.size()))); } + } diff --git a/src/main/templates/io/lettuce/core/api/BaseRedisCommands.java b/src/main/templates/io/lettuce/core/api/BaseRedisCommands.java index 40d5165f16..405b702307 100644 --- a/src/main/templates/io/lettuce/core/api/BaseRedisCommands.java +++ b/src/main/templates/io/lettuce/core/api/BaseRedisCommands.java @@ -180,8 +180,8 @@ public interface BaseRedisCommands { /** * @return {@code true} if the connection is open (connected and not closed). - * @deprecated since 6.2. Use the corresponding {@link io.lettuce.core.api.StatefulConnection#isOpen()} method on the connection - * interface. To be removed with Lettuce 7.0. + * @deprecated since 6.2. Use the corresponding {@link io.lettuce.core.api.StatefulConnection#isOpen()} method on the + * connection interface. To be removed with Lettuce 7.0. */ @Deprecated boolean isOpen(); @@ -189,8 +189,9 @@ public interface BaseRedisCommands { /** * Reset the command state. Queued commands will be canceled and the internal state will be reset. This is useful when the * internal state machine gets out of sync with the connection. - * @deprecated since 6.2. Use the corresponding {@link io.lettuce.core.api.StatefulConnection#reset()} method on the connection - * interface. To be removed with Lettuce 7.0. + * + * @deprecated since 6.2. Use the corresponding {@link io.lettuce.core.api.StatefulConnection#reset()} method on the + * connection interface. To be removed with Lettuce 7.0. */ @Deprecated void reset(); @@ -201,9 +202,9 @@ public interface BaseRedisCommands { * issued. After calling {@link #flushCommands()} commands are sent to the transport and executed by Redis. * * @param autoFlush state of autoFlush. - * @deprecated since 6.2. Use the corresponding {@link io.lettuce.core.api.StatefulConnection#setAutoFlushCommands(boolean)} method on the connection - * interface. To be removed with Lettuce 7.0. - + * @deprecated since 6.2. Use the corresponding {@link io.lettuce.core.api.StatefulConnection#setAutoFlushCommands(boolean)} + * method on the connection interface. To be removed with Lettuce 7.0. + * */ @Deprecated void setAutoFlushCommands(boolean autoFlush); @@ -211,9 +212,10 @@ public interface BaseRedisCommands { /** * Flush pending commands. This commands forces a flush on the channel and can be used to buffer ("pipeline") commands to * achieve batching. No-op if channel is not connected. - * @deprecated since 6.2. Use the corresponding {@link io.lettuce.core.api.StatefulConnection#flushCommands()} method on the connection - * interface. To be removed with Lettuce 7.0. - + * + * @deprecated since 6.2. Use the corresponding {@link io.lettuce.core.api.StatefulConnection#flushCommands()} method on the + * connection interface. To be removed with Lettuce 7.0. + * */ @Deprecated void flushCommands(); diff --git a/src/main/templates/io/lettuce/core/api/RedisAclCommands.java b/src/main/templates/io/lettuce/core/api/RedisAclCommands.java index 6a3b0e58f6..c4dd88c499 100644 --- a/src/main/templates/io/lettuce/core/api/RedisAclCommands.java +++ b/src/main/templates/io/lettuce/core/api/RedisAclCommands.java @@ -110,8 +110,8 @@ public interface RedisAclCommands { List aclList(); /** - * When Redis is configured to use an ACL file (with the aclfile configuration option), this command - * will reload the ACLs from the file, replacing all the current ACL rules with the ones defined in the file. + * When Redis is configured to use an ACL file (with the aclfile configuration option), this command will reload the ACLs + * from the file, replacing all the current ACL rules with the ones defined in the file. * * @return String simple-string-reply OK or error message. */ @@ -140,8 +140,8 @@ public interface RedisAclCommands { String aclLogReset(); /** - * When Redis is configured to use an ACL file (with the aclfile configuration option), - * this command will save the currently defined ACLs from the server memory to the ACL file. + * When Redis is configured to use an ACL file (with the aclfile configuration option), this command will save the currently + * defined ACLs from the server memory to the ACL file. * * @return String simple-string-reply OK or error message. */ @@ -169,4 +169,5 @@ public interface RedisAclCommands { * @return K bulk-string-reply the username of the current connection. */ String aclWhoami(); + } diff --git a/src/main/templates/io/lettuce/core/api/RedisGeoCommands.java b/src/main/templates/io/lettuce/core/api/RedisGeoCommands.java index 7a9a8663e2..3bab7c2b01 100644 --- a/src/main/templates/io/lettuce/core/api/RedisGeoCommands.java +++ b/src/main/templates/io/lettuce/core/api/RedisGeoCommands.java @@ -191,8 +191,8 @@ Long georadius(K key, double longitude, double latitude, double distance, GeoArg Long georadiusbymember(K key, V member, double distance, GeoArgs.Unit unit, GeoRadiusStoreArgs geoRadiusStoreArgs); /** - * Retrieve members selected by distance with the center of {@code reference} the search {@code predicate}. - * Use {@link GeoSearch} to create reference and predicate objects. + * Retrieve members selected by distance with the center of {@code reference} the search {@code predicate}. Use + * {@link GeoSearch} to create reference and predicate objects. * * @param key the key of the geo set. * @param reference the reference member or longitude/latitude coordinates. @@ -203,8 +203,8 @@ Long georadius(K key, double longitude, double latitude, double distance, GeoArg Set geosearch(K key, GeoSearch.GeoRef reference, GeoSearch.GeoPredicate predicate); /** - * Retrieve members selected by distance with the center of {@code reference} the search {@code predicate}. - * Use {@link GeoSearch} to create reference and predicate objects. + * Retrieve members selected by distance with the center of {@code reference} the search {@code predicate}. Use + * {@link GeoSearch} to create reference and predicate objects. * * @param key the key of the geo set. * @param reference the reference member or longitude/latitude coordinates. @@ -224,7 +224,8 @@ Long georadius(K key, double longitude, double latitude, double distance, GeoArg * @param reference the reference member or longitude/latitude coordinates. * @param predicate the bounding box or radius to search in. * @param geoArgs args to control the result. - * @param storeDist stores the items in a sorted set populated with their distance from the center of the circle or box, as a floating-point number, in the same unit specified for that shape. + * @param storeDist stores the items in a sorted set populated with their distance from the center of the circle or box, as + * a floating-point number, in the same unit specified for that shape. * @return Long integer-reply the number of elements in the result. * @since 6.1 */ diff --git a/src/main/templates/io/lettuce/core/api/RedisHashCommands.java b/src/main/templates/io/lettuce/core/api/RedisHashCommands.java index 96dfe525eb..53896d05a7 100644 --- a/src/main/templates/io/lettuce/core/api/RedisHashCommands.java +++ b/src/main/templates/io/lettuce/core/api/RedisHashCommands.java @@ -575,4 +575,5 @@ public interface RedisHashCommands { * associated timeout. */ Boolean hpersist(K key, K... fields); + } diff --git a/src/main/templates/io/lettuce/core/api/RedisSortedSetCommands.java b/src/main/templates/io/lettuce/core/api/RedisSortedSetCommands.java index 841e14a835..1c7f4fca79 100644 --- a/src/main/templates/io/lettuce/core/api/RedisSortedSetCommands.java +++ b/src/main/templates/io/lettuce/core/api/RedisSortedSetCommands.java @@ -488,7 +488,8 @@ public interface RedisSortedSetCommands { * Return {@code count} random members from the sorted set stored at {@code key}. * * @param key the key. - * @param count the number of members to return. If the provided count argument is positive, return an array of distinct fields. + * @param count the number of members to return. If the provided count argument is positive, return an array of distinct + * fields. * @return List<ScoredValue<V>> array-reply list of scores and elements. * @since 6.1 */ @@ -507,7 +508,8 @@ public interface RedisSortedSetCommands { * Return {@code count} random members along their value from the sorted set stored at {@code key}. * * @param key the key. - * @param count the number of members to return. If the provided count argument is positive, return an array of distinct fields. + * @param count the number of members to return. If the provided count argument is positive, return an array of distinct + * fields. * @return List<ScoredValue<V>> array-reply list of scores and elements. * @since 6.1 */ @@ -909,7 +911,8 @@ Long zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, Stri Long zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, Range range, Limit limit); /** - * Get the specified range of elements in the sorted set stored at {@code srcKey} and stores the result in the {@code dstKey} destination key. + * Get the specified range of elements in the sorted set stored at {@code srcKey} and stores the result in the + * {@code dstKey} destination key. * * @param dstKey the dst key. * @param srcKey the src key. @@ -920,7 +923,8 @@ Long zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, Stri Long zrangestore(K dstKey, K srcKey, Range range); /** - * Get the specified range of elements in the sorted set stored at {@code srcKey} and stores the result in the {@code dstKey} destination key. + * Get the specified range of elements in the sorted set stored at {@code srcKey} and stores the result in the + * {@code dstKey} destination key. * * @param dstKey the dst key. * @param srcKey the src key. @@ -932,7 +936,8 @@ Long zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, Stri Long zrangestorebylex(K dstKey, K srcKey, Range range, Limit limit); /** - * Get the specified range of elements in the sorted set stored at {@code srcKey} and stores the result in the {@code dstKey} destination key. + * Get the specified range of elements in the sorted set stored at {@code srcKey} and stores the result in the + * {@code dstKey} destination key. * * @param dstKey the dst key. * @param srcKey the src key. @@ -1409,7 +1414,8 @@ Long zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, S Long zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, Range range, Limit limit); /** - * Get the specified range of elements ordered from high to low in the sorted set stored at {@code srcKey} and stores the result in the {@code dstKey} destination key. + * Get the specified range of elements ordered from high to low in the sorted set stored at {@code srcKey} and stores the + * result in the {@code dstKey} destination key. * * @param dstKey the dst key. * @param srcKey the src key. @@ -1420,7 +1426,8 @@ Long zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, S Long zrevrangestore(K dstKey, K srcKey, Range range); /** - * Get the lexicographical range ordered from high to low of elements in the sorted set stored at {@code srcKey} and stores the result in the {@code dstKey} destination key. + * Get the lexicographical range ordered from high to low of elements in the sorted set stored at {@code srcKey} and stores + * the result in the {@code dstKey} destination key. * * @param dstKey the src key. * @param srcKey the dst key. @@ -1432,9 +1439,11 @@ Long zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, S Long zrevrangestorebylex(K dstKey, K srcKey, Range range, Limit limit); /** - * Get the specified range of elements in the sorted set stored at {@code srcKey with scores ordered from high to low and stores the result in the {@code dstKey} destination key. + * Get the specified range of elements in the sorted set stored at {@code srcKey with scores ordered from high to low and + * stores the result in the {@code dstKey} destination key. * * @param dstKey the src key. + * * @param srcKey the dst key. * @param range the score range. * @param limit the limit to apply. diff --git a/src/main/templates/io/lettuce/core/api/RedisStreamCommands.java b/src/main/templates/io/lettuce/core/api/RedisStreamCommands.java index 29c39e379a..232f1f618c 100644 --- a/src/main/templates/io/lettuce/core/api/RedisStreamCommands.java +++ b/src/main/templates/io/lettuce/core/api/RedisStreamCommands.java @@ -373,4 +373,5 @@ public interface RedisStreamCommands { * @since 6.1 */ Long xtrim(K key, XTrimArgs args); + } diff --git a/src/test/java/biz/paluch/redis/extensibility/LettuceGeoDemo.java b/src/test/java/biz/paluch/redis/extensibility/LettuceGeoDemo.java index 57bf25031c..ab9432db10 100644 --- a/src/test/java/biz/paluch/redis/extensibility/LettuceGeoDemo.java +++ b/src/test/java/biz/paluch/redis/extensibility/LettuceGeoDemo.java @@ -47,4 +47,5 @@ public static void main(String[] args) { redis.getStatefulConnection().close(); redisClient.shutdown(); } + } diff --git a/src/test/java/biz/paluch/redis/extensibility/MyExtendedRedisClient.java b/src/test/java/biz/paluch/redis/extensibility/MyExtendedRedisClient.java index c52c768140..99b029a588 100644 --- a/src/test/java/biz/paluch/redis/extensibility/MyExtendedRedisClient.java +++ b/src/test/java/biz/paluch/redis/extensibility/MyExtendedRedisClient.java @@ -32,4 +32,5 @@ protected StatefulRedisPubSubConnectionImpl newStatefulRedisPubSubC RedisChannelWriter channelWriter, RedisCodec codec, Duration timeout) { return new MyPubSubConnection<>(endpoint, channelWriter, codec, timeout); } + } diff --git a/src/test/java/biz/paluch/redis/extensibility/MyPubSubConnection.java b/src/test/java/biz/paluch/redis/extensibility/MyPubSubConnection.java index 6e91f06a70..7fd38c7750 100644 --- a/src/test/java/biz/paluch/redis/extensibility/MyPubSubConnection.java +++ b/src/test/java/biz/paluch/redis/extensibility/MyPubSubConnection.java @@ -28,7 +28,8 @@ class MyPubSubConnection extends StatefulRedisPubSubConnectionImpl { * @param codec Codec used to encode/decode keys and values. * @param timeout Maximum time to wait for a response. */ - public MyPubSubConnection(PubSubEndpoint endpoint, RedisChannelWriter writer, RedisCodec codec, Duration timeout) { + public MyPubSubConnection(PubSubEndpoint endpoint, RedisChannelWriter writer, RedisCodec codec, + Duration timeout) { super(endpoint, writer, codec, timeout); } @@ -41,4 +42,5 @@ public RedisCommand dispatch(RedisCommand command) { return super.dispatch(command); } + } diff --git a/src/test/java/io/lettuce/RedisBug.java b/src/test/java/io/lettuce/RedisBug.java index 429cf77353..12078cfd86 100644 --- a/src/test/java/io/lettuce/RedisBug.java +++ b/src/test/java/io/lettuce/RedisBug.java @@ -14,5 +14,7 @@ @Documented @Disabled("Redis Bug") public @interface RedisBug { + String value() default ""; + } diff --git a/src/test/java/io/lettuce/apigenerator/CompilationUnitFactory.java b/src/test/java/io/lettuce/apigenerator/CompilationUnitFactory.java index 2be57d325b..55e54d0496 100644 --- a/src/test/java/io/lettuce/apigenerator/CompilationUnitFactory.java +++ b/src/test/java/io/lettuce/apigenerator/CompilationUnitFactory.java @@ -90,22 +90,24 @@ class CompilationUnitFactory { private CompilationUnit template; private final CompilationUnit result = new CompilationUnit(); + private ClassOrInterfaceDeclaration resultType; public CompilationUnitFactory(File templateFile, File sources, String targetPackage, String targetName, - Function typeDocFunction, Function methodReturnTypeFunction, - Predicate methodFilter, Supplier> importSupplier, - Consumer typeMutator, Function methodCommentMutator) { + Function typeDocFunction, Function methodReturnTypeFunction, + Predicate methodFilter, Supplier> importSupplier, + Consumer typeMutator, Function methodCommentMutator) { this(templateFile, sources, targetPackage, targetName, typeDocFunction, methodReturnTypeFunction, methodDeclaration -> { - }, methodFilter, importSupplier, typeMutator, (m, c) -> methodCommentMutator != null ? methodCommentMutator.apply(c) : c); + }, methodFilter, importSupplier, typeMutator, + (m, c) -> methodCommentMutator != null ? methodCommentMutator.apply(c) : c); } public CompilationUnitFactory(File templateFile, File sources, String targetPackage, String targetName, - Function typeDocFunction, Function methodReturnTypeFunction, - Consumer onMethod, Predicate methodFilter, - Supplier> importSupplier, Consumer typeMutator, - BiFunction methodCommentMutator) { + Function typeDocFunction, Function methodReturnTypeFunction, + Consumer onMethod, Predicate methodFilter, + Supplier> importSupplier, Consumer typeMutator, + BiFunction methodCommentMutator) { this.templateFile = templateFile; this.sources = sources; @@ -139,11 +141,13 @@ public void createInterface() throws Exception { if (!templateTypeDeclaration.getTypeParameters().isEmpty()) { resultType.setTypeParameters(new NodeList<>()); for (TypeParameter typeParameter : templateTypeDeclaration.getTypeParameters()) { - resultType.getTypeParameters().add(new TypeParameter(typeParameter.getName().getIdentifier(), typeParameter.getTypeBound())); + resultType.getTypeParameters() + .add(new TypeParameter(typeParameter.getName().getIdentifier(), typeParameter.getTypeBound())); } } - resultType.setComment(new JavadocComment(typeDocFunction.apply(templateTypeDeclaration.getComment().get().getContent()))); + resultType + .setComment(new JavadocComment(typeDocFunction.apply(templateTypeDeclaration.getComment().get().getContent()))); result.setComment(template.getComment().orElse(null)); result.setImports(new NodeList<>()); @@ -209,24 +213,19 @@ public static boolean contains(Collection haystack, MethodDeclaration ne public void removeUnusedImports() { ClassOrInterfaceDeclaration declaringClass = (ClassOrInterfaceDeclaration) result.getChildNodes().get(1); - List optimizedImports = result - .getImports() - .stream() - .filter(i -> i.isAsterisk() - || i.isStatic() - || declaringClass.findFirst(Type.class, t -> { - String fullType = t.toString(); - String importIdentifier = i.getName().getIdentifier(); - - return fullType.contains(importIdentifier); - }).isPresent() - ) - .sorted((o1, o2) -> { - if (o1.getNameAsString().startsWith("java")) return -1; - if (o2.getNameAsString().startsWith("java")) return 1; + List optimizedImports = result.getImports().stream() + .filter(i -> i.isAsterisk() || i.isStatic() || declaringClass.findFirst(Type.class, t -> { + String fullType = t.toString(); + String importIdentifier = i.getName().getIdentifier(); + + return fullType.contains(importIdentifier); + }).isPresent()).sorted((o1, o2) -> { + if (o1.getNameAsString().startsWith("java")) + return -1; + if (o2.getNameAsString().startsWith("java")) + return 1; return o1.getNameAsString().compareTo(o2.getNameAsString()); - }) - .collect(Collectors.toList()); + }).collect(Collectors.toList()); result.setImports(NodeList.nodeList(optimizedImports)); } @@ -263,16 +262,15 @@ public void visit(MethodDeclaration parsedDeclaration, Object arg) { private Type getMethodReturnType(MethodDeclaration parsedDeclaration) { - List, Function>> entries = new ArrayList<>(methodReturnTypeMutation.entrySet()); + List, Function>> entries = new ArrayList<>( + methodReturnTypeMutation.entrySet()); Collections.reverse(entries); - return entries - .stream() - .filter(entry -> entry.getKey().test(parsedDeclaration)) - .findFirst() - .map(entry -> entry.getValue().apply(parsedDeclaration)) - .orElse(null); + return entries.stream().filter(entry -> entry.getKey().test(parsedDeclaration)).findFirst() + .map(entry -> entry.getValue().apply(parsedDeclaration)).orElse(null); } + } + } diff --git a/src/test/java/io/lettuce/apigenerator/Constants.java b/src/test/java/io/lettuce/apigenerator/Constants.java index 744fccbf16..2779ed17aa 100644 --- a/src/test/java/io/lettuce/apigenerator/Constants.java +++ b/src/test/java/io/lettuce/apigenerator/Constants.java @@ -26,26 +26,15 @@ */ class Constants { - public static final String[] TEMPLATE_NAMES = { - "BaseRedisCommands", - "RedisAclCommands", - "RedisFunctionCommands", - "RedisGeoCommands", - "RedisHashCommands", - "RedisHLLCommands", - "RedisKeyCommands", - "RedisListCommands", - "RedisScriptingCommands", - "RedisSentinelCommands", - "RedisServerCommands", - "RedisSetCommands", - "RedisSortedSetCommands", - "RedisStreamCommands", - "RedisStringCommands", - "RedisTransactionalCommands" - }; + public static final String[] TEMPLATE_NAMES = { "BaseRedisCommands", "RedisAclCommands", "RedisFunctionCommands", + "RedisGeoCommands", "RedisHashCommands", "RedisHLLCommands", "RedisKeyCommands", "RedisListCommands", + "RedisScriptingCommands", "RedisSentinelCommands", "RedisServerCommands", "RedisSetCommands", + "RedisSortedSetCommands", "RedisStreamCommands", "RedisStringCommands", "RedisTransactionalCommands" }; public static final File TEMPLATES = new File("src/main/templates"); + public static final File SOURCES = new File("src/main/java"); + public static final File KOTLIN_SOURCES = new File("src/main/kotlin"); + } diff --git a/src/test/java/io/lettuce/apigenerator/CreateAsyncApi.java b/src/test/java/io/lettuce/apigenerator/CreateAsyncApi.java index 300ce31c57..8006578bd7 100644 --- a/src/test/java/io/lettuce/apigenerator/CreateAsyncApi.java +++ b/src/test/java/io/lettuce/apigenerator/CreateAsyncApi.java @@ -42,7 +42,9 @@ */ class CreateAsyncApi { - public static final Set KEEP_METHOD_RESULT_TYPE = LettuceSets.unmodifiableSet("shutdown", "debugOom", "debugSegfault", "digest", "close", "isOpen", "BaseRedisCommands.reset", "getStatefulConnection", "setAutoFlushCommands", "flushCommands"); + public static final Set KEEP_METHOD_RESULT_TYPE = LettuceSets.unmodifiableSet("shutdown", "debugOom", + "debugSegfault", "digest", "close", "isOpen", "BaseRedisCommands.reset", "getStatefulConnection", + "setAutoFlushCommands", "flushCommands"); /** * Mutate type comment. @@ -101,4 +103,5 @@ private CompilationUnitFactory createFactory(String templateName) { return factory; } + } diff --git a/src/test/java/io/lettuce/apigenerator/CreateAsyncNodeSelectionClusterApi.java b/src/test/java/io/lettuce/apigenerator/CreateAsyncNodeSelectionClusterApi.java index 294d117c93..7fc1a4f516 100644 --- a/src/test/java/io/lettuce/apigenerator/CreateAsyncNodeSelectionClusterApi.java +++ b/src/test/java/io/lettuce/apigenerator/CreateAsyncNodeSelectionClusterApi.java @@ -45,9 +45,12 @@ */ class CreateAsyncNodeSelectionClusterApi { - private static final Set FILTER_TEMPLATES = LettuceSets.unmodifiableSet("RedisSentinelCommands", "RedisTransactionalCommands"); - private static final Set FILTER_METHODS = LettuceSets.unmodifiableSet("shutdown", "debugOom", "debugSegfault", "digest", "close", - "isOpen", "BaseRedisCommands.reset", "readOnly", "readWrite", "setAutoFlushCommands", "flushCommands"); + private static final Set FILTER_TEMPLATES = LettuceSets.unmodifiableSet("RedisSentinelCommands", + "RedisTransactionalCommands"); + + private static final Set FILTER_METHODS = LettuceSets.unmodifiableSet("shutdown", "debugOom", "debugSegfault", + "digest", "close", "isOpen", "BaseRedisCommands.reset", "readOnly", "readWrite", "setAutoFlushCommands", + "flushCommands"); /** * Mutate type comment. @@ -93,10 +96,7 @@ void createInterface(String argument) throws Exception { } static List arguments() { - return Stream - .of(Constants.TEMPLATE_NAMES) - .filter(t -> !FILTER_TEMPLATES.contains(t)) - .collect(Collectors.toList()); + return Stream.of(Constants.TEMPLATE_NAMES).filter(t -> !FILTER_TEMPLATES.contains(t)).collect(Collectors.toList()); } private CompilationUnitFactory createFactory(String templateName) { @@ -110,4 +110,5 @@ private CompilationUnitFactory createFactory(String templateName) { return factory; } + } diff --git a/src/test/java/io/lettuce/apigenerator/CreateKotlinCoroutinesApi.java b/src/test/java/io/lettuce/apigenerator/CreateKotlinCoroutinesApi.java index 4069bf8da2..ce38436e25 100644 --- a/src/test/java/io/lettuce/apigenerator/CreateKotlinCoroutinesApi.java +++ b/src/test/java/io/lettuce/apigenerator/CreateKotlinCoroutinesApi.java @@ -44,10 +44,7 @@ public class CreateKotlinCoroutinesApi { * @return */ Supplier> importSupplier() { - return () -> Arrays.asList( - "io.lettuce.core.ExperimentalLettuceCoroutinesApi", - "kotlinx.coroutines.flow.Flow" - ); + return () -> Arrays.asList("io.lettuce.core.ExperimentalLettuceCoroutinesApi", "kotlinx.coroutines.flow.Flow"); } /** @@ -56,11 +53,8 @@ Supplier> importSupplier() { * @return */ Function commentInjector() { - return s -> s - .replaceAll("\\$\\{intent}", "Coroutine executed commands") - .replaceAll("\\$\\{author}", "Mikhael Sokolov") - .replaceAll("\\$\\{since}", "6.0") - .replaceAll("\\$\\{generator}", getClass().getName()); + return s -> s.replaceAll("\\$\\{intent}", "Coroutine executed commands").replaceAll("\\$\\{author}", "Mikhael Sokolov") + .replaceAll("\\$\\{since}", "6.0").replaceAll("\\$\\{generator}", getClass().getName()); } @ParameterizedTest @@ -84,7 +78,8 @@ private KotlinCompilationUnitFactory createFactory(String templateName) { targetPackage = "io.lettuce.core.api.coroutines"; } - return new KotlinCompilationUnitFactory(templateFile, KOTLIN_SOURCES, targetPackage, - targetName, importSupplier(), commentInjector()); + return new KotlinCompilationUnitFactory(templateFile, KOTLIN_SOURCES, targetPackage, targetName, importSupplier(), + commentInjector()); } + } diff --git a/src/test/java/io/lettuce/apigenerator/CreateReactiveApi.java b/src/test/java/io/lettuce/apigenerator/CreateReactiveApi.java index 8444a7c645..d66872e4bc 100644 --- a/src/test/java/io/lettuce/apigenerator/CreateReactiveApi.java +++ b/src/test/java/io/lettuce/apigenerator/CreateReactiveApi.java @@ -51,10 +51,12 @@ */ public class CreateReactiveApi { - public static Set KEEP_METHOD_RESULT_TYPE = LettuceSets.unmodifiableSet("digest", "close", "isOpen", "BaseRedisCommands.reset", "getStatefulConnection", "setAutoFlushCommands", "flushCommands"); + public static Set KEEP_METHOD_RESULT_TYPE = LettuceSets.unmodifiableSet("digest", "close", "isOpen", + "BaseRedisCommands.reset", "getStatefulConnection", "setAutoFlushCommands", "flushCommands"); public static Set FORCE_FLUX_RESULT = LettuceSets.unmodifiableSet("eval", "evalsha", "evalReadOnly", "evalshaReadOnly", "fcall", "fcallReadOnly", "dispatch"); + public static Set VALUE_WRAP = LettuceSets.unmodifiableSet("geopos", "bitfield"); private static final Map RESULT_SPEC; @@ -160,8 +162,7 @@ Function methodTypeMutator() { }; } - private String getResultType(MethodDeclaration method, - ClassOrInterfaceDeclaration classOfMethod) { + private String getResultType(MethodDeclaration method, ClassOrInterfaceDeclaration classOfMethod) { String declaration = nameAndParameters(method); if (RESULT_SPEC.containsKey(declaration)) { @@ -211,8 +212,8 @@ private CompilationUnitFactory createFactory(String templateName) { targetPackage = "io.lettuce.core.api.reactive"; } - CompilationUnitFactory factory = new CompilationUnitFactory(templateFile, Constants.SOURCES, targetPackage, targetName, commentMutator(), - methodTypeMutator(), methodMutator(), methodDeclaration -> true, importSupplier(), null, + CompilationUnitFactory factory = new CompilationUnitFactory(templateFile, Constants.SOURCES, targetPackage, targetName, + commentMutator(), methodTypeMutator(), methodMutator(), methodDeclaration -> true, importSupplier(), null, methodCommentMutator()); factory.keepMethodSignaturesFor(KEEP_METHOD_RESULT_TYPE); return factory; @@ -234,4 +235,5 @@ static String nameAndParameters(MethodDeclaration method) { sb.append(")"); return sb.toString(); } + } diff --git a/src/test/java/io/lettuce/apigenerator/CreateSyncApi.java b/src/test/java/io/lettuce/apigenerator/CreateSyncApi.java index fb9bf9fcc0..697bf5dce7 100644 --- a/src/test/java/io/lettuce/apigenerator/CreateSyncApi.java +++ b/src/test/java/io/lettuce/apigenerator/CreateSyncApi.java @@ -51,8 +51,8 @@ class CreateSyncApi { * @return */ Function commentMutator() { - return s -> s.replaceAll("\\$\\{intent\\}", "Synchronous executed commands") + "* @generated by " - + getClass().getName() + "\r\n "; + return s -> s.replaceAll("\\$\\{intent\\}", "Synchronous executed commands") + "* @generated by " + getClass().getName() + + "\r\n "; } /** @@ -106,4 +106,5 @@ private CompilationUnitFactory createFactory(String templateName) { return new CompilationUnitFactory(templateFile, Constants.SOURCES, targetPackage, targetName, commentMutator(), methodTypeMutator(), methodFilter(), importSupplier(), null, Function.identity()); } + } diff --git a/src/test/java/io/lettuce/apigenerator/CreateSyncNodeSelectionClusterApi.java b/src/test/java/io/lettuce/apigenerator/CreateSyncNodeSelectionClusterApi.java index 88ae384697..9813912cc2 100644 --- a/src/test/java/io/lettuce/apigenerator/CreateSyncNodeSelectionClusterApi.java +++ b/src/test/java/io/lettuce/apigenerator/CreateSyncNodeSelectionClusterApi.java @@ -47,9 +47,12 @@ @SuppressWarnings("OptionalGetWithoutIsPresent") public class CreateSyncNodeSelectionClusterApi { - private static final Set FILTER_TEMPLATES = LettuceSets.unmodifiableSet("RedisSentinelCommands", "RedisTransactionalCommands"); - private static final Set FILTER_METHODS = LettuceSets.unmodifiableSet("shutdown", "debugOom", "debugSegfault", "digest", - "close", "isOpen", "BaseRedisCommands.reset", "readOnly", "readWrite", "dispatch", "setAutoFlushCommands", "flushCommands"); + private static final Set FILTER_TEMPLATES = LettuceSets.unmodifiableSet("RedisSentinelCommands", + "RedisTransactionalCommands"); + + private static final Set FILTER_METHODS = LettuceSets.unmodifiableSet("shutdown", "debugOom", "debugSegfault", + "digest", "close", "isOpen", "BaseRedisCommands.reset", "readOnly", "readWrite", "dispatch", "setAutoFlushCommands", + "flushCommands"); /** * Mutate type comment. @@ -99,10 +102,7 @@ void createInterface(String argument) throws Exception { } static List arguments() { - return Stream - .of(Constants.TEMPLATE_NAMES) - .filter(t -> !FILTER_TEMPLATES.contains(t)) - .collect(Collectors.toList()); + return Stream.of(Constants.TEMPLATE_NAMES).filter(t -> !FILTER_TEMPLATES.contains(t)).collect(Collectors.toList()); } private CompilationUnitFactory createFactory(String templateName) { @@ -116,4 +116,5 @@ private CompilationUnitFactory createFactory(String templateName) { factory.keepMethodSignaturesFor(FILTER_METHODS); return factory; } + } diff --git a/src/test/java/io/lettuce/apigenerator/KotlinCompilationUnitFactory.java b/src/test/java/io/lettuce/apigenerator/KotlinCompilationUnitFactory.java index 341b1d0477..9b160643ee 100644 --- a/src/test/java/io/lettuce/apigenerator/KotlinCompilationUnitFactory.java +++ b/src/test/java/io/lettuce/apigenerator/KotlinCompilationUnitFactory.java @@ -60,26 +60,33 @@ @SuppressWarnings("OptionalGetWithoutIsPresent") class KotlinCompilationUnitFactory { - private static final Set SKIP_IMPORTS = LettuceSets.unmodifiableSet("java.util.List", "java.util.Set", "java.util.Map"); - private static final Set NON_SUSPENDABLE_METHODS = LettuceSets.unmodifiableSet("isOpen", "flushCommands", "setAutoFlushCommands"); - private static final Set SKIP_METHODS = LettuceSets.unmodifiableSet("BaseRedisCommands.reset", "getStatefulConnection"); - - private static final Set FLOW_METHODS = LettuceSets.unmodifiableSet("aclList", "aclLog", "dispatch", "geohash", "georadius", - "georadiusbymember", "geosearch", - "hgetall", "hkeys", "hmget", "hvals", "keys", "mget", "sdiff", "sinter", "smembers", "smismember", "sort", - "sortReadOnly", "srandmember", "sunion", - "xclaim", "xpending", "xrange", "xread", "xreadgroup", "xrevrange", "zdiff", "zdiffWithScores", "zinter", "zinterWithScores", "zpopmax", "zpopmin", "zrange", - "zrangeWithScores", "zrangebylex", "zrangebyscore", "zrangebyscoreWithScores", "zrevrange", "zrevrangeWithScores", "zrevrangebylex", - "zrevrangebyscore", "zrevrangebyscore", "zrevrangebyscoreWithScores", "zunion", "zunionWithScores"); + private static final Set SKIP_IMPORTS = LettuceSets.unmodifiableSet("java.util.List", "java.util.Set", + "java.util.Map"); + + private static final Set NON_SUSPENDABLE_METHODS = LettuceSets.unmodifiableSet("isOpen", "flushCommands", + "setAutoFlushCommands"); + + private static final Set SKIP_METHODS = LettuceSets.unmodifiableSet("BaseRedisCommands.reset", + "getStatefulConnection"); + + private static final Set FLOW_METHODS = LettuceSets.unmodifiableSet("aclList", "aclLog", "dispatch", "geohash", + "georadius", "georadiusbymember", "geosearch", "hgetall", "hkeys", "hmget", "hvals", "keys", "mget", "sdiff", + "sinter", "smembers", "smismember", "sort", "sortReadOnly", "srandmember", "sunion", "xclaim", "xpending", "xrange", + "xread", "xreadgroup", "xrevrange", "zdiff", "zdiffWithScores", "zinter", "zinterWithScores", "zpopmax", "zpopmin", + "zrange", "zrangeWithScores", "zrangebylex", "zrangebyscore", "zrangebyscoreWithScores", "zrevrange", + "zrevrangeWithScores", "zrevrangebylex", "zrevrangebyscore", "zrevrangebyscore", "zrevrangebyscoreWithScores", + "zunion", "zunionWithScores"); private static final Set NON_NULLABLE_RESULT_METHODS = LettuceSets.unmodifiableSet("discard", "multi", "exec", "watch", "unwatch", "getMasterAddrByName", "master", "reset", "failover", "monitor", "RedisSentinelCoroutinesCommands.set", "remove", "RedisSentinelCoroutinesCommands.clientSetname", "RedisSentinelCoroutinesCommands.clientKill", "RedisSentinelCoroutinesCommands.clientPause", "RedisSentinelCoroutinesCommands.clientList", "RedisSentinelCoroutinesCommands.info", - "RedisSentinelCoroutinesCommands.ping", "pubsubNumsub", "pubsubShardNumsub", "pubsubNumpat", "echo", "ping", "readOnly", "readWrite"); + "RedisSentinelCoroutinesCommands.ping", "pubsubNumsub", "pubsubShardNumsub", "pubsubNumpat", "echo", "ping", + "readOnly", "readWrite"); private static final Map RESULT_SPEC; + private static final Map KEEP_DEPRECATED_METHODS; static { @@ -100,21 +107,21 @@ class KotlinCompilationUnitFactory { private static final String FORMATTING_INDENT = " "; private final File templateFile; + private final File target; + private final String targetPackage; + private final String targetName; private final Supplier> importSupplier; + private final Function commentInjector; private final StringBuilder result = new StringBuilder(); - public KotlinCompilationUnitFactory(File templateFile, - File sources, - String targetPackage, - String targetName, - Supplier> importSupplier, - Function commentInjector) { + public KotlinCompilationUnitFactory(File templateFile, File sources, String targetPackage, String targetName, + Supplier> importSupplier, Function commentInjector) { this.templateFile = templateFile; this.targetPackage = targetPackage; this.targetName = targetName; @@ -136,40 +143,23 @@ public void create() throws Exception { importSupplier.get().forEach(l -> result.append("import ").append(l).append("\n")); - template - .getImports() - .stream() - .filter(i -> SKIP_IMPORTS - .stream() - .noneMatch(si -> si.equals(i.getNameAsString())) - ) - .forEach(i -> result - .append("import ") - .append(i.getNameAsString()) - .append(i.isAsterisk() ? ".*" : "") - .append("\n") - ); + template.getImports().stream().filter(i -> SKIP_IMPORTS.stream().noneMatch(si -> si.equals(i.getNameAsString()))) + .forEach(i -> result.append("import ").append(i.getNameAsString()).append(i.isAsterisk() ? ".*" : "") + .append("\n")); result.append("\n"); ClassOrInterfaceDeclaration clazz = (ClassOrInterfaceDeclaration) template.getTypes().get(0); result.append(commentInjector.apply(extractJavadoc(clazz.getJavadoc().get()) - .replaceAll("@author Mark Paluch", "@author \\${author}") - .replaceAll("@since [0-9].0", "@since \\${since}") - .replaceAll("\\*/", "* @generated by \\${generator}\r\n */") - )); + .replaceAll("@author Mark Paluch", "@author \\${author}").replaceAll("@since [0-9].0", "@since \\${since}") + .replaceAll("\\*/", "* @generated by \\${generator}\r\n */"))); result.append("@ExperimentalLettuceCoroutinesApi").append("\n"); NodeList typeParameters = clazz.getTypeParameters(); - result - .append("interface ") - .append(targetName) - .append(extractTypeParams(typeParameters, "Any")) - .append(" "); - + result.append("interface ").append(targetName).append(extractTypeParams(typeParameters, "Any")).append(" "); result.append("{\n\n"); new MethodVisitor().visit(template, null); @@ -190,59 +180,51 @@ public void visit(MethodDeclaration method, Object arg) { return; } - result - .append(FORMATTING_INDENT) + result.append(FORMATTING_INDENT) .append(extractJavadoc(method.getJavadoc().get()).replace("\n", "\n" + FORMATTING_INDENT)) .append(extractAnnotations(method)) - .append(contains(NON_SUSPENDABLE_METHODS, method) || isFlowable(method) ? "" : "suspend ") - .append("fun ") - .append(method.getTypeParameters().isNonEmpty() ? extractTypeParams(method.getTypeParameters(), "Any").concat(" ") : "") - .append(method.getNameAsString()) - .append("(") - .append(extractParameters(method)) - .append(")") - .append(customResultType(method).orElse(toKotlinType(method.getType(), isFlowable(method), contains(NON_NULLABLE_RESULT_METHODS, method)))) + .append(contains(NON_SUSPENDABLE_METHODS, method) || isFlowable(method) ? "" : "suspend ").append("fun ") + .append(method.getTypeParameters().isNonEmpty() + ? extractTypeParams(method.getTypeParameters(), "Any").concat(" ") + : "") + .append(method.getNameAsString()).append("(").append(extractParameters(method)).append(")") + .append(customResultType(method).orElse( + toKotlinType(method.getType(), isFlowable(method), contains(NON_NULLABLE_RESULT_METHODS, method)))) .append("\n\n"); } private String extractAnnotations(MethodDeclaration method) { - return method - .getAnnotations() - .stream() - .map(a -> { - String annotation = a.getNameAsString(); - if (annotation.equals("Deprecated")) { - String identifier = method.getName().getIdentifier(); - String replacement = KEEP_DEPRECATED_METHODS.get(identifier); - return "@" + annotation + "(\"Use [" + replacement + "] instead.\", ReplaceWith(\"" + replacement + "\"))\n" + FORMATTING_INDENT; - } else { - return "@" + annotation + "\n" + FORMATTING_INDENT; - } - }) - .collect(joining()); + return method.getAnnotations().stream().map(a -> { + String annotation = a.getNameAsString(); + if (annotation.equals("Deprecated")) { + String identifier = method.getName().getIdentifier(); + String replacement = KEEP_DEPRECATED_METHODS.get(identifier); + return "@" + annotation + "(\"Use [" + replacement + "] instead.\", ReplaceWith(\"" + replacement + "\"))\n" + + FORMATTING_INDENT; + } else { + return "@" + annotation + "\n" + FORMATTING_INDENT; + } + }).collect(joining()); } private String extractParameters(MethodDeclaration method) { - return method - .getParameters() - .stream() + return method.getParameters().stream() .map(p -> (p.isVarArgs() ? "vararg " : "") + p.getName() + toKotlinType(p.getType(), false, true)) .collect(joining(", ")); } private Optional customResultType(MethodDeclaration method) { ClassOrInterfaceDeclaration declaringClass = (ClassOrInterfaceDeclaration) method.getParentNode().get(); - return RESULT_SPEC - .entrySet() - .stream() - .filter(e -> e.getKey().equals(method.getNameAsString()) || e.getKey().contains(declaringClass.getNameAsString() + "." + method.getNameAsString())) - .findFirst() - .map(e -> ": " + e.getValue()); + return RESULT_SPEC.entrySet().stream() + .filter(e -> e.getKey().equals(method.getNameAsString()) + || e.getKey().contains(declaringClass.getNameAsString() + "." + method.getNameAsString())) + .findFirst().map(e -> ": " + e.getValue()); } private boolean contains(Collection haystack, MethodDeclaration method) { ClassOrInterfaceDeclaration declaringClass = (ClassOrInterfaceDeclaration) method.getParentNode().get(); - return haystack.contains(method.getNameAsString()) || haystack.contains(declaringClass.getNameAsString() + "." + method.getNameAsString()); + return haystack.contains(method.getNameAsString()) + || haystack.contains(declaringClass.getNameAsString() + "." + method.getNameAsString()); } private boolean isCollection(Type type) { @@ -266,54 +248,34 @@ private String toKotlinType(Type type, boolean isFlowable, boolean isForceNonNul fixedType = String.format("Array<%s>", componentType.asString()); } } else if (type.isPrimitiveType()) { - fixedType = type - .asPrimitiveType() - .toBoxedType() - .getName() - .asString() - .replace("Integer", "Int") + fixedType = type.asPrimitiveType().toBoxedType().getName().asString().replace("Integer", "Int") .replace("Object", "Any"); } else if (isFlowable) { - fixedType = type - .asString() - .replaceFirst("List|Map|Set", "Flow") - .replace("T", "Flow") - .replace("Object", "Any") - .replace(",", ", "); + fixedType = type.asString().replaceFirst("List|Map|Set", "Flow").replace("T", "Flow") + .replace("Object", "Any").replace(",", ", "); } else { - fixedType = type - .asString() - .replace("void", "Unit") - .replace("Object", "Any") - .replace("? extends", "out") - .replace("? super", "in") - .replace(",", ", "); + fixedType = type.asString().replace("void", "Unit").replace("Object", "Any").replace("? extends", "out") + .replace("? super", "in").replace(",", ", "); } boolean nullable = !isForceNonNullable && !isFlowable && !type.isPrimitiveType() && !isCollection(type); return fixedType.equals("Unit") ? "" : ": " + (nullable ? fixedType + "?" : fixedType); } + } public static String extractTypeParams(NodeList typeParams, String bounds) { if (typeParams.isEmpty()) { return ""; } else { - return typeParams - .stream() - .map(tp -> tp.getName().getIdentifier() + (bounds != null ? " : " + bounds : "")) + return typeParams.stream().map(tp -> tp.getName().getIdentifier() + (bounds != null ? " : " + bounds : "")) .collect(joining(", ", "<", ">")); } } public static String extractJavadoc(Javadoc javadoc) { - String plainJavadoc = javadoc - .toComment() - .getContent() - .replace("<", "<") - .replace(">", ">") - .replace("* \n", "*\n"); + String plainJavadoc = javadoc.toComment().getContent().replace("<", "<").replace(">", ">").replace("* \n", "*\n"); return String.format("/**%s*/\n", convertToKotlinDoc(plainJavadoc)); } @@ -332,26 +294,25 @@ public static String convertToKotlinDoc(String javaDoc) { res = replaceSurrounding(res, "{@code ", "}", "`", "`"); res = replaceSurrounding(res, "{@link ", "}", "[", "]"); - return res - .replace("java.lang.Object", "Any") - .replace("Object", "Any") - .replaceAll("\\bdouble\\b", "Double") + return res.replace("java.lang.Object", "Any").replace("Object", "Any").replaceAll("\\bdouble\\b", "Double") .replaceAll("\\bint\\b", "Integer"); } - public static String replaceSurrounding(String original, String prefix, String suffix, String replacePrefix, String replaceSuffix) { - Matcher matcher = Pattern.compile(Pattern.quote(prefix) + "[a-zA-Z0-9.,#\\-~()*\\s]+" + Pattern.quote(suffix)).matcher(original); + public static String replaceSurrounding(String original, String prefix, String suffix, String replacePrefix, + String replaceSuffix) { + Matcher matcher = Pattern.compile(Pattern.quote(prefix) + "[a-zA-Z0-9.,#\\-~()*\\s]+" + Pattern.quote(suffix)) + .matcher(original); StringBuffer result = new StringBuffer(); while (matcher.find()) { String substr = StringUtils.substringBetween(matcher.group(), prefix, suffix); - String replacement = (replacePrefix + substr + replaceSuffix) - .replace("()", "") - .replace(replacePrefix + "#", replacePrefix); + String replacement = (replacePrefix + substr + replaceSuffix).replace("()", "").replace(replacePrefix + "#", + replacePrefix); matcher.appendReplacement(result, replacement); } matcher.appendTail(result); return result.toString(); } + } diff --git a/src/test/java/io/lettuce/codec/CRC16UnitTests.java b/src/test/java/io/lettuce/codec/CRC16UnitTests.java index 6d51a0bd57..5f8ae13c22 100644 --- a/src/test/java/io/lettuce/codec/CRC16UnitTests.java +++ b/src/test/java/io/lettuce/codec/CRC16UnitTests.java @@ -40,6 +40,7 @@ void testCRC16(Fixture fixture) { static class Fixture { final byte[] bytes; + final int expected; Fixture(byte[] bytes, int expected) { @@ -51,5 +52,7 @@ static class Fixture { public String toString() { return "Expects 0x" + Integer.toHexString(expected).toUpperCase(); } + } + } diff --git a/src/test/java/io/lettuce/core/AbstractRedisClientTest.java b/src/test/java/io/lettuce/core/AbstractRedisClientTest.java index f73c5083f8..b7a338baec 100644 --- a/src/test/java/io/lettuce/core/AbstractRedisClientTest.java +++ b/src/test/java/io/lettuce/core/AbstractRedisClientTest.java @@ -34,6 +34,7 @@ public abstract class AbstractRedisClientTest extends TestSupport { protected static RedisClient client; + protected RedisCommands redis; @BeforeAll @@ -81,4 +82,5 @@ public void closeConnection() throws Exception { redis.getStatefulConnection().close(); } } + } diff --git a/src/test/java/io/lettuce/core/AsyncConnectionIntegrationTests.java b/src/test/java/io/lettuce/core/AsyncConnectionIntegrationTests.java index af5b21b5ba..35e23a7b52 100644 --- a/src/test/java/io/lettuce/core/AsyncConnectionIntegrationTests.java +++ b/src/test/java/io/lettuce/core/AsyncConnectionIntegrationTests.java @@ -47,7 +47,9 @@ class AsyncConnectionIntegrationTests extends TestSupport { private final RedisClient client; + private final StatefulRedisConnection connection; + private final RedisAsyncCommands async; @Inject @@ -126,10 +128,12 @@ void futureListenerCompleted() { final List run = new ArrayList<>(); Runnable listener = new Runnable() { + @Override public void run() { run.add(new Object()); } + }; RedisAsyncCommands connection = client.connect().async(); @@ -173,4 +177,5 @@ void awaitAllTimeout() { Future> blpop = async.blpop(1, key); assertThat(Futures.await(1, TimeUnit.NANOSECONDS, blpop)).isFalse(); } + } diff --git a/src/test/java/io/lettuce/core/ByteBufferCodec.java b/src/test/java/io/lettuce/core/ByteBufferCodec.java index 4a46fdd9a9..f84b10c347 100644 --- a/src/test/java/io/lettuce/core/ByteBufferCodec.java +++ b/src/test/java/io/lettuce/core/ByteBufferCodec.java @@ -34,4 +34,5 @@ public ByteBuffer encodeKey(ByteBuffer key) { public ByteBuffer encodeValue(ByteBuffer value) { return value.asReadOnlyBuffer(); } + } diff --git a/src/test/java/io/lettuce/core/ClientMetricsIntegrationTests.java b/src/test/java/io/lettuce/core/ClientMetricsIntegrationTests.java index 05ff559d0a..55a9fd26f1 100644 --- a/src/test/java/io/lettuce/core/ClientMetricsIntegrationTests.java +++ b/src/test/java/io/lettuce/core/ClientMetricsIntegrationTests.java @@ -63,4 +63,5 @@ private void generateTestData(RedisCommands redis) { redis.get(key); redis.get(key); } + } diff --git a/src/test/java/io/lettuce/core/ClientOptionsIntegrationTests.java b/src/test/java/io/lettuce/core/ClientOptionsIntegrationTests.java index b3b2a84b02..347ec18e92 100644 --- a/src/test/java/io/lettuce/core/ClientOptionsIntegrationTests.java +++ b/src/test/java/io/lettuce/core/ClientOptionsIntegrationTests.java @@ -548,4 +548,5 @@ void authenticatedPingBeforeConnectWithQueuedCommandsAndReconnect() { redisConnection.close(); }); } + } diff --git a/src/test/java/io/lettuce/core/ClientOptionsUnitTests.java b/src/test/java/io/lettuce/core/ClientOptionsUnitTests.java index 3446caaf81..e7a29c6bb9 100644 --- a/src/test/java/io/lettuce/core/ClientOptionsUnitTests.java +++ b/src/test/java/io/lettuce/core/ClientOptionsUnitTests.java @@ -59,4 +59,5 @@ void checkAssertions(ClientOptions sut) { assertThat(sut.isSuspendReconnectOnProtocolFailure()).isFalse(); assertThat(sut.getDisconnectedBehavior()).isEqualTo(ClientOptions.DisconnectedBehavior.DEFAULT); } + } diff --git a/src/test/java/io/lettuce/core/ConnectMethodsIntegrationTests.java b/src/test/java/io/lettuce/core/ConnectMethodsIntegrationTests.java index 7461b5da76..a5879a4758 100644 --- a/src/test/java/io/lettuce/core/ConnectMethodsIntegrationTests.java +++ b/src/test/java/io/lettuce/core/ConnectMethodsIntegrationTests.java @@ -17,6 +17,7 @@ class ConnectMethodsIntegrationTests { private final RedisClient redisClient; + private final RedisClusterClient clusterClient; @Inject diff --git a/src/test/java/io/lettuce/core/ConnectionFutureUnitTests.java b/src/test/java/io/lettuce/core/ConnectionFutureUnitTests.java index bc3807a3ab..68f434ac77 100644 --- a/src/test/java/io/lettuce/core/ConnectionFutureUnitTests.java +++ b/src/test/java/io/lettuce/core/ConnectionFutureUnitTests.java @@ -63,7 +63,6 @@ void composeTransformShouldFailWhileTransformationRetainOriginalException() { Throwable t = new Throwable(); foo.completeExceptionally(t); - assertThat(transformed.toCompletableFuture()).isDone(); assertThat(transformed.toCompletableFuture()).isCompletedExceptionally(); @@ -106,7 +105,8 @@ void shouldComposeWithErrorFlow() { assertThat(transformed2.toCompletableFuture()).isDone(); assertThat(transformed2.toCompletableFuture()).isCompletedExceptionally(); - assertThatThrownBy(transformed2::join).hasCauseInstanceOf(IllegalStateException.class).hasRootCauseInstanceOf( - IllegalArgumentException.class); + assertThatThrownBy(transformed2::join).hasCauseInstanceOf(IllegalStateException.class) + .hasRootCauseInstanceOf(IllegalArgumentException.class); } + } diff --git a/src/test/java/io/lettuce/core/CustomCodecIntegrationTests.java b/src/test/java/io/lettuce/core/CustomCodecIntegrationTests.java index c68377344f..94fa64205d 100644 --- a/src/test/java/io/lettuce/core/CustomCodecIntegrationTests.java +++ b/src/test/java/io/lettuce/core/CustomCodecIntegrationTests.java @@ -30,7 +30,9 @@ class CustomCodecIntegrationTests extends TestSupport { private final SecretKeySpec secretKey = new SecretKeySpec("1234567890123456".getBytes(), "AES"); + private final IvParameterSpec iv = new IvParameterSpec("1234567890123456".getBytes()); + // Creates a CryptoCipher instance with the transformation and properties. private final String transform = "AES/CBC/PKCS5Padding"; @@ -205,9 +207,11 @@ public ByteBuffer encodeValue(Object value) { return null; } } + } static class Person implements Serializable { } + } diff --git a/src/test/java/io/lettuce/core/ExceptionFactoryUnitTests.java b/src/test/java/io/lettuce/core/ExceptionFactoryUnitTests.java index dd73b86f84..41af0392f5 100644 --- a/src/test/java/io/lettuce/core/ExceptionFactoryUnitTests.java +++ b/src/test/java/io/lettuce/core/ExceptionFactoryUnitTests.java @@ -63,8 +63,8 @@ void shouldCreateExecutionException() { assertThat(ExceptionFactory.createExecutionException("ERR foo bar", new IllegalStateException())) .isInstanceOf(RedisCommandExecutionException.class).hasMessage("ERR foo bar") .hasRootCauseInstanceOf(IllegalStateException.class); - assertThat(ExceptionFactory.createExecutionException(null, new IllegalStateException())).isInstanceOf( - RedisCommandExecutionException.class).hasRootCauseInstanceOf(IllegalStateException.class); + assertThat(ExceptionFactory.createExecutionException(null, new IllegalStateException())) + .isInstanceOf(RedisCommandExecutionException.class).hasRootCauseInstanceOf(IllegalStateException.class); } @Test @@ -106,10 +106,11 @@ void shouldFormatExactUnits() { @Test void shouldFormatToMinmalApplicableTimeunit() { - assertThat(ExceptionFactory.formatTimeout(Duration.ofMinutes(2).plus(Duration.ofSeconds(10)))).isEqualTo( - "130 second(s)"); - assertThat(ExceptionFactory.formatTimeout(Duration.ofSeconds(2).plus(Duration.ofMillis(5)))).isEqualTo( - "2005 millisecond(s)"); + assertThat(ExceptionFactory.formatTimeout(Duration.ofMinutes(2).plus(Duration.ofSeconds(10)))) + .isEqualTo("130 second(s)"); + assertThat(ExceptionFactory.formatTimeout(Duration.ofSeconds(2).plus(Duration.ofMillis(5)))) + .isEqualTo("2005 millisecond(s)"); assertThat(ExceptionFactory.formatTimeout(Duration.ofNanos(2))).isEqualTo("2 ns"); } + } diff --git a/src/test/java/io/lettuce/core/GeoModelUnitTests.java b/src/test/java/io/lettuce/core/GeoModelUnitTests.java index 2aa55cb8e9..35e75bd2cf 100644 --- a/src/test/java/io/lettuce/core/GeoModelUnitTests.java +++ b/src/test/java/io/lettuce/core/GeoModelUnitTests.java @@ -82,4 +82,5 @@ void geoCoordinatesSlightlyDifferent() { assertThat(sut.toString()).isNotEqualTo(slightlyDifferent.toString()); } + } diff --git a/src/test/java/io/lettuce/core/KeyValueUnitTests.java b/src/test/java/io/lettuce/core/KeyValueUnitTests.java index 42c5dac759..08191831d7 100644 --- a/src/test/java/io/lettuce/core/KeyValueUnitTests.java +++ b/src/test/java/io/lettuce/core/KeyValueUnitTests.java @@ -122,4 +122,5 @@ void toStringShouldRenderCorrectly() { KeyValue kv(String key, String value) { return KeyValue.just(key, value); } + } diff --git a/src/test/java/io/lettuce/core/LimitUnitTests.java b/src/test/java/io/lettuce/core/LimitUnitTests.java index c8f9417519..d4d6490e3f 100644 --- a/src/test/java/io/lettuce/core/LimitUnitTests.java +++ b/src/test/java/io/lettuce/core/LimitUnitTests.java @@ -28,4 +28,5 @@ void unlimited() { assertThat(limit.getCount()).isEqualTo(-1); assertThat(limit.isLimited()).isFalse(); } + } diff --git a/src/test/java/io/lettuce/core/PipeliningIntegrationTests.java b/src/test/java/io/lettuce/core/PipeliningIntegrationTests.java index 8138a31cc0..b0ba4a3544 100644 --- a/src/test/java/io/lettuce/core/PipeliningIntegrationTests.java +++ b/src/test/java/io/lettuce/core/PipeliningIntegrationTests.java @@ -27,6 +27,7 @@ class PipeliningIntegrationTests extends TestSupport { private final RedisClient client; + private final StatefulRedisConnection connection; @Inject @@ -109,4 +110,5 @@ String value(int i) { String key(int i) { return key + "-" + i; } + } diff --git a/src/test/java/io/lettuce/core/ProtectedModeTests.java b/src/test/java/io/lettuce/core/ProtectedModeTests.java index 1b2c9493a0..490e6d99d7 100644 --- a/src/test/java/io/lettuce/core/ProtectedModeTests.java +++ b/src/test/java/io/lettuce/core/ProtectedModeTests.java @@ -27,6 +27,7 @@ class ProtectedModeTests { private static MockTcpServer server; + private static RedisClient client; @BeforeAll @@ -36,6 +37,7 @@ static void beforeClass() throws Exception { server.addHandler(() -> { return new ChannelInboundHandlerAdapter() { + @Override public void channelActive(ChannelHandlerContext ctx) { @@ -49,6 +51,7 @@ public void channelActive(ChannelHandlerContext ctx) { ctx.close(); }); } + }; }); @@ -106,8 +109,8 @@ void regularClientFailsOnFirstCommandWithDelay() { void connectFailsOnPing() { client.setOptions(ClientOptions.builder().build()); - assertThatThrownBy(() -> client.connect()).isInstanceOf(RedisConnectionException.class).hasCauseInstanceOf( - RedisConnectionException.class); + assertThatThrownBy(() -> client.connect()).isInstanceOf(RedisConnectionException.class) + .hasCauseInstanceOf(RedisConnectionException.class); } private static String getMessage() { @@ -125,4 +128,5 @@ private static String getMessage() { + "things in order for the server to start accepting connections from the outside."; } + } diff --git a/src/test/java/io/lettuce/core/RangeUnitTests.java b/src/test/java/io/lettuce/core/RangeUnitTests.java index 941270497c..5341c65ba4 100644 --- a/src/test/java/io/lettuce/core/RangeUnitTests.java +++ b/src/test/java/io/lettuce/core/RangeUnitTests.java @@ -97,4 +97,5 @@ void lessOrEquals() { assertThat(lte.getUpper().getValue()).isEqualTo("zero"); assertThat(lte.toString()).isEqualTo("Range [[unbounded] to [zero]"); } + } diff --git a/src/test/java/io/lettuce/core/ReactiveBackpressurePropagationUnitTests.java b/src/test/java/io/lettuce/core/ReactiveBackpressurePropagationUnitTests.java index 72b6a2467d..2a1e701fb1 100644 --- a/src/test/java/io/lettuce/core/ReactiveBackpressurePropagationUnitTests.java +++ b/src/test/java/io/lettuce/core/ReactiveBackpressurePropagationUnitTests.java @@ -39,6 +39,7 @@ class ReactiveBackpressurePropagationUnitTests { private CommandHandler commandHandler; + private EmbeddedChannel embeddedChannel; @Mock @@ -183,6 +184,7 @@ static byte[] arrayHeader(int count) { static byte[] bulkString(String string) { return String.format("$%d\r\n%s\r\n", string.getBytes().length, string).getBytes(); } + } } diff --git a/src/test/java/io/lettuce/core/ReactiveConnectionIntegrationTests.java b/src/test/java/io/lettuce/core/ReactiveConnectionIntegrationTests.java index 66af01406d..6b26c79295 100644 --- a/src/test/java/io/lettuce/core/ReactiveConnectionIntegrationTests.java +++ b/src/test/java/io/lettuce/core/ReactiveConnectionIntegrationTests.java @@ -59,7 +59,9 @@ class ReactiveConnectionIntegrationTests extends TestSupport { private final StatefulRedisConnection connection; + private final RedisCommands redis; + private final RedisReactiveCommands reactive; @Inject @@ -250,6 +252,7 @@ public void onError(Throwable e) { @Override public void onNext(String s) { } + }; } @@ -280,5 +283,7 @@ public void onError(Throwable e) { public void onNext(Object o) { result.add(o); } + } + } diff --git a/src/test/java/io/lettuce/core/ReactiveStreamingOutputIntegrationTests.java b/src/test/java/io/lettuce/core/ReactiveStreamingOutputIntegrationTests.java index 490f70d556..98549b93ae 100644 --- a/src/test/java/io/lettuce/core/ReactiveStreamingOutputIntegrationTests.java +++ b/src/test/java/io/lettuce/core/ReactiveStreamingOutputIntegrationTests.java @@ -29,6 +29,7 @@ class ReactiveStreamingOutputIntegrationTests extends TestSupport { private final RedisCommands redis; + private final RedisReactiveCommands reactive; @Inject @@ -82,16 +83,12 @@ void geoWithinListCommandShouldReturnAllElements() { redis.geoadd(key, 50, 20, "value1"); redis.geoadd(key, 50, 21, "value2"); - StepVerifier - .create(reactive.georadius(key, 50, 20, 1000, Unit.km, new GeoArgs().withHash())) - .recordWith(ArrayList::new) - .expectNextCount(2) - .consumeRecordedWith( - values -> { - assertThat(values).hasSize(2).contains(new GeoWithin<>("value1", null, 3542523898362974L, null), - new GeoWithin<>("value2", null, 3542609801095198L, null)); + StepVerifier.create(reactive.georadius(key, 50, 20, 1000, Unit.km, new GeoArgs().withHash())).recordWith(ArrayList::new) + .expectNextCount(2).consumeRecordedWith(values -> { + assertThat(values).hasSize(2).contains(new GeoWithin<>("value1", null, 3542523898362974L, null), + new GeoWithin<>("value2", null, 3542609801095198L, null)); - }).verifyComplete(); + }).verifyComplete(); } @Test @@ -103,4 +100,5 @@ void geoCoordinatesListCommandShouldReturnAllElements() { StepVerifier.create(reactive.geopos(key, "value1", "value2")).expectNextCount(2).verifyComplete(); } + } diff --git a/src/test/java/io/lettuce/core/RedisClientConnectIntegrationTests.java b/src/test/java/io/lettuce/core/RedisClientConnectIntegrationTests.java index d0bb44f842..83e2c351e3 100644 --- a/src/test/java/io/lettuce/core/RedisClientConnectIntegrationTests.java +++ b/src/test/java/io/lettuce/core/RedisClientConnectIntegrationTests.java @@ -136,7 +136,7 @@ void shutdownSyncInRedisFutureTest() { CompletableFuture f = connection.async().get("key1").whenComplete((result, e) -> { connection.close(); redisClient.shutdown(0, 0, SECONDS); // deadlock expected. - }).toCompletableFuture(); + }).toCompletableFuture(); assertThatThrownBy(() -> TestFutures.awaitOrTimeout(f)).isInstanceOf(TimeoutException.class); } @@ -200,8 +200,7 @@ void connectPubSubCodecOwnUri() { @Test void connectPubSubAsync() { RedisURI redisURI = redis(host, port).build(); - ConnectionFuture> future = client.connectPubSubAsync( -UTF8, redisURI); + ConnectionFuture> future = client.connectPubSubAsync(UTF8, redisURI); StatefulRedisPubSubConnection connection = future.join(); assertThat(connection.getTimeout()).isEqualTo(redisURI.getTimeout()); connection.close(); @@ -278,4 +277,5 @@ private static RedisURI invalidSentinel() { return redisURI; } + } diff --git a/src/test/java/io/lettuce/core/RedisClientFactoryUnitTests.java b/src/test/java/io/lettuce/core/RedisClientFactoryUnitTests.java index d16f0b1613..20351373d5 100644 --- a/src/test/java/io/lettuce/core/RedisClientFactoryUnitTests.java +++ b/src/test/java/io/lettuce/core/RedisClientFactoryUnitTests.java @@ -15,6 +15,7 @@ class RedisClientFactoryUnitTests { private static final String URI = "redis://" + TestSettings.host() + ":" + TestSettings.port(); + private static final RedisURI REDIS_URI = RedisURI.create(URI); @Test @@ -59,8 +60,8 @@ void clientResourcesWithStringUri() { @Test void clientResourcesWithStringUriNull() { - assertThatThrownBy(() -> RedisClient.create(TestClientResources.get(), (String) null)).isInstanceOf( - IllegalArgumentException.class); + assertThatThrownBy(() -> RedisClient.create(TestClientResources.get(), (String) null)) + .isInstanceOf(IllegalArgumentException.class); } @Test @@ -70,17 +71,18 @@ void clientResourcesNullWithStringUri() { @Test void clientResourcesWithUri() { - FastShutdown.shutdown(RedisClient.create(TestClientResources.get(), REDIS_URI)); + FastShutdown.shutdown(RedisClient.create(TestClientResources.get(), REDIS_URI)); } @Test void clientResourcesWithUriNull() { - assertThatThrownBy(() -> RedisClient.create(TestClientResources.get(), (RedisURI) null)).isInstanceOf( - IllegalArgumentException.class); + assertThatThrownBy(() -> RedisClient.create(TestClientResources.get(), (RedisURI) null)) + .isInstanceOf(IllegalArgumentException.class); } @Test void clientResourcesNullWithUri() { assertThatThrownBy(() -> RedisClient.create(null, REDIS_URI)).isInstanceOf(IllegalArgumentException.class); } + } diff --git a/src/test/java/io/lettuce/core/RedisClientIntegrationTests.java b/src/test/java/io/lettuce/core/RedisClientIntegrationTests.java index 57eb8d2bbc..6b87bd2e3e 100644 --- a/src/test/java/io/lettuce/core/RedisClientIntegrationTests.java +++ b/src/test/java/io/lettuce/core/RedisClientIntegrationTests.java @@ -212,8 +212,11 @@ private Map, EventExecutorGroup> getExecutor private class TestConnectionListener implements RedisConnectionStateListener { volatile SocketAddress onConnectedSocketAddress; + volatile RedisChannelHandler onConnected; + volatile RedisChannelHandler onDisconnected; + volatile RedisChannelHandler onException; @Override @@ -231,6 +234,7 @@ public void onRedisDisconnected(RedisChannelHandler connection) { public void onRedisExceptionCaught(RedisChannelHandler connection, Throwable cause) { onException = connection; } + } static class TestCommandListener implements CommandListener { @@ -263,4 +267,5 @@ public void commandFailed(CommandFailedEvent event) { } } + } diff --git a/src/test/java/io/lettuce/core/RedisClientListenerIntegrationTests.java b/src/test/java/io/lettuce/core/RedisClientListenerIntegrationTests.java index 1e8b2dcf54..478d5a1700 100644 --- a/src/test/java/io/lettuce/core/RedisClientListenerIntegrationTests.java +++ b/src/test/java/io/lettuce/core/RedisClientListenerIntegrationTests.java @@ -12,5 +12,4 @@ @ExtendWith(LettuceExtension.class) class RedisClientListenerIntegrationTests extends TestSupport { - } diff --git a/src/test/java/io/lettuce/core/RedisClientUnitTests.java b/src/test/java/io/lettuce/core/RedisClientUnitTests.java index 4614519091..608035e43c 100644 --- a/src/test/java/io/lettuce/core/RedisClientUnitTests.java +++ b/src/test/java/io/lettuce/core/RedisClientUnitTests.java @@ -88,4 +88,5 @@ void shutdownShutsDownResourcesAfterChannels() throws Exception { verify(clientResources).shutdown(anyLong(), anyLong(), any()); assertThat(future).isDone(); } + } diff --git a/src/test/java/io/lettuce/core/RedisCommandBuilderUnitTests.java b/src/test/java/io/lettuce/core/RedisCommandBuilderUnitTests.java index 01b5be2241..b29d81ad21 100644 --- a/src/test/java/io/lettuce/core/RedisCommandBuilderUnitTests.java +++ b/src/test/java/io/lettuce/core/RedisCommandBuilderUnitTests.java @@ -16,11 +16,14 @@ * @author Mark Paluch */ class RedisCommandBuilderUnitTests { + public static final String MY_KEY = "hKey"; + public static final String MY_FIELD1 = "hField1"; + public static final String MY_FIELD2 = "hField2"; - public static final String MY_FIELD3 = "hField3"; + public static final String MY_FIELD3 = "hField3"; RedisCommandBuilder sut = new RedisCommandBuilder<>(StringCodec.UTF8); @@ -37,27 +40,25 @@ void shouldCorrectlyConstructXreadgroup() { @Test void shouldCorrectlyConstructHexpire() { - Command command = - sut.hexpire(MY_KEY, 1, ExpireArgs.Builder.nx(), MY_FIELD1, MY_FIELD2, MY_FIELD3); + Command command = sut.hexpire(MY_KEY, 1, ExpireArgs.Builder.nx(), MY_FIELD1, MY_FIELD2, MY_FIELD3); ByteBuf buf = Unpooled.directBuffer(); command.encode(buf); - assertThat(buf.toString(StandardCharsets.UTF_8)).isEqualTo("*8\r\n" + "$7\r\n" + "HEXPIRE\r\n" + "$4\r\n" - + "hKey\r\n" + "$1\r\n" + "1\r\n" + "$2\r\n" + "NX\r\n" + "$1\r\n" + "3\r\n" + "$7\r\n" + "hField1\r\n" - + "$7\r\n" + "hField2\r\n" + "$7\r\n" + "hField3\r\n"); + assertThat(buf.toString(StandardCharsets.UTF_8)).isEqualTo( + "*8\r\n" + "$7\r\n" + "HEXPIRE\r\n" + "$4\r\n" + "hKey\r\n" + "$1\r\n" + "1\r\n" + "$2\r\n" + "NX\r\n" + + "$1\r\n" + "3\r\n" + "$7\r\n" + "hField1\r\n" + "$7\r\n" + "hField2\r\n" + "$7\r\n" + "hField3\r\n"); } @Test void shouldCorrectlyConstructHexpireat() { - Command command = - sut.hexpireat(MY_KEY, 1, ExpireArgs.Builder.nx(), MY_FIELD1, MY_FIELD2, MY_FIELD3); + Command command = sut.hexpireat(MY_KEY, 1, ExpireArgs.Builder.nx(), MY_FIELD1, MY_FIELD2, MY_FIELD3); ByteBuf buf = Unpooled.directBuffer(); command.encode(buf); - assertThat(buf.toString(StandardCharsets.UTF_8)).isEqualTo("*8\r\n" + "$9\r\n" + "HEXPIREAT\r\n" + "$4\r\n" - + "hKey\r\n" + "$1\r\n" + "1\r\n" + "$2\r\n" + "NX\r\n" + "$1\r\n" + "3\r\n" + "$7\r\n" + "hField1\r\n" - + "$7\r\n" + "hField2\r\n" + "$7\r\n" + "hField3\r\n"); + assertThat(buf.toString(StandardCharsets.UTF_8)).isEqualTo( + "*8\r\n" + "$9\r\n" + "HEXPIREAT\r\n" + "$4\r\n" + "hKey\r\n" + "$1\r\n" + "1\r\n" + "$2\r\n" + "NX\r\n" + + "$1\r\n" + "3\r\n" + "$7\r\n" + "hField1\r\n" + "$7\r\n" + "hField2\r\n" + "$7\r\n" + "hField3\r\n"); } @Test @@ -67,9 +68,9 @@ void shouldCorrectlyConstructHexpiretime() { ByteBuf buf = Unpooled.directBuffer(); command.encode(buf); - assertThat(buf.toString(StandardCharsets.UTF_8)).isEqualTo("*6\r\n" + "$11\r\n" + "HEXPIRETIME\r\n" + "$4\r\n" - + "hKey\r\n" + "$1\r\n" + "3\r\n" + "$7\r\n" + "hField1\r\n" + "$7\r\n" + "hField2\r\n" + "$7\r\n" - + "hField3\r\n"); + assertThat(buf.toString(StandardCharsets.UTF_8)) + .isEqualTo("*6\r\n" + "$11\r\n" + "HEXPIRETIME\r\n" + "$4\r\n" + "hKey\r\n" + "$1\r\n" + "3\r\n" + "$7\r\n" + + "hField1\r\n" + "$7\r\n" + "hField2\r\n" + "$7\r\n" + "hField3\r\n"); } @Test @@ -79,8 +80,8 @@ void shouldCorrectlyConstructHpersist() { ByteBuf buf = Unpooled.directBuffer(); command.encode(buf); - assertThat(buf.toString(StandardCharsets.UTF_8)).isEqualTo("*6\r\n" + "$8\r\n" + "HPERSIST\r\n" + "$4\r\n" - + "hKey\r\n" + "$1\r\n" + "3\r\n" + "$7\r\n" + "hField1\r\n" + "$7\r\n" + "hField2\r\n" + "$7\r\n" - + "hField3\r\n"); + assertThat(buf.toString(StandardCharsets.UTF_8)).isEqualTo("*6\r\n" + "$8\r\n" + "HPERSIST\r\n" + "$4\r\n" + "hKey\r\n" + + "$1\r\n" + "3\r\n" + "$7\r\n" + "hField1\r\n" + "$7\r\n" + "hField2\r\n" + "$7\r\n" + "hField3\r\n"); } + } diff --git a/src/test/java/io/lettuce/core/ScanArgsUnitTests.java b/src/test/java/io/lettuce/core/ScanArgsUnitTests.java index 8bb1228580..2d655c3637 100644 --- a/src/test/java/io/lettuce/core/ScanArgsUnitTests.java +++ b/src/test/java/io/lettuce/core/ScanArgsUnitTests.java @@ -22,4 +22,5 @@ void shouldEncodeMatchUsingUtf8() { assertThat(commandArgs.toCommandString()).isEqualTo("MATCH w7Y="); } + } diff --git a/src/test/java/io/lettuce/core/ScanCursorUnitTests.java b/src/test/java/io/lettuce/core/ScanCursorUnitTests.java index d00e06de17..8cdeec4334 100644 --- a/src/test/java/io/lettuce/core/ScanCursorUnitTests.java +++ b/src/test/java/io/lettuce/core/ScanCursorUnitTests.java @@ -26,4 +26,5 @@ void setCursorOnImmutableInstance() { void setFinishedOnImmutableInstance() { assertThatThrownBy(() -> ScanCursor.INITIAL.setFinished(false)).isInstanceOf(UnsupportedOperationException.class); } + } diff --git a/src/test/java/io/lettuce/core/ScanIteratorIntegrationTests.java b/src/test/java/io/lettuce/core/ScanIteratorIntegrationTests.java index 31cabb1870..c3b5a8e203 100644 --- a/src/test/java/io/lettuce/core/ScanIteratorIntegrationTests.java +++ b/src/test/java/io/lettuce/core/ScanIteratorIntegrationTests.java @@ -126,8 +126,7 @@ void hscanNovaluesShouldThrowNoSuchElementExceptionOnEmpty() { redis.mset(KeysAndValues.MAP); - ScanIterator scan = ScanIterator.hscanNovalues(redis, "none", - ScanArgs.Builder.limit(50).match("key-foo")); + ScanIterator scan = ScanIterator.hscanNovalues(redis, "none", ScanArgs.Builder.limit(50).match("key-foo")); assertThat(scan.hasNext()).isFalse(); try { @@ -162,8 +161,7 @@ void hashNoValuesSinglePass() { redis.hmset(key, KeysAndValues.MAP); - ScanIterator scan = ScanIterator.hscanNovalues(redis, key, - ScanArgs.Builder.limit(50).match("key-11*")); + ScanIterator scan = ScanIterator.hscanNovalues(redis, key, ScanArgs.Builder.limit(50).match("key-11*")); assertThat(scan.hasNext()).isTrue(); assertThat(scan.hasNext()).isTrue(); @@ -187,8 +185,8 @@ void hashMultiPass() { List> keys = scan.stream().collect(Collectors.toList()); - assertThat(keys).containsAll( - KeysAndValues.KEYS.stream().map(s -> KeyValue.fromNullable(s, KeysAndValues.MAP.get(s))).collect(Collectors.toList())); + assertThat(keys).containsAll(KeysAndValues.KEYS.stream().map(s -> KeyValue.fromNullable(s, KeysAndValues.MAP.get(s))) + .collect(Collectors.toList())); } @Test @@ -208,8 +206,7 @@ void sscanShouldThrowNoSuchElementExceptionOnEmpty() { redis.sadd(key, KeysAndValues.VALUES.toArray(new String[0])); - ScanIterator scan = ScanIterator.sscan(redis, "none", - ScanArgs.Builder.limit(50).match("key-foo")); + ScanIterator scan = ScanIterator.sscan(redis, "none", ScanArgs.Builder.limit(50).match("key-foo")); assertThat(scan.hasNext()).isFalse(); try { @@ -225,8 +222,7 @@ void setSinglePass() { redis.sadd(key, KeysAndValues.KEYS.toArray(new String[0])); - ScanIterator scan = ScanIterator.sscan(redis, key, - ScanArgs.Builder.limit(50).match("key-11*")); + ScanIterator scan = ScanIterator.sscan(redis, key, ScanArgs.Builder.limit(50).match("key-11*")); assertThat(scan.hasNext()).isTrue(); assertThat(scan.hasNext()).isTrue(); @@ -258,9 +254,7 @@ void zscanShouldThrowNoSuchElementExceptionOnEmpty() { redis.zadd(key, ScoredValue.just(i, KeysAndValues.KEYS.get(i))); } - - ScanIterator> scan = ScanIterator.zscan(redis, "none", - ScanArgs.Builder.limit(50).match("key-foo")); + ScanIterator> scan = ScanIterator.zscan(redis, "none", ScanArgs.Builder.limit(50).match("key-foo")); assertThat(scan.hasNext()).isFalse(); try { @@ -278,8 +272,7 @@ void zsetSinglePass() { redis.zadd(key, ScoredValue.just(i, KeysAndValues.KEYS.get(i))); } - ScanIterator> scan = ScanIterator.zscan(redis, key, - ScanArgs.Builder.limit(50).match("key-11*")); + ScanIterator> scan = ScanIterator.zscan(redis, key, ScanArgs.Builder.limit(50).match("key-11*")); assertThat(scan.hasNext()).isTrue(); assertThat(scan.hasNext()).isTrue(); @@ -308,4 +301,5 @@ void zsetMultiPass() { assertThat(values).containsAll(values); } + } diff --git a/src/test/java/io/lettuce/core/ScanStreamIntegrationTests.java b/src/test/java/io/lettuce/core/ScanStreamIntegrationTests.java index 1dc7a22628..f527eafcb7 100644 --- a/src/test/java/io/lettuce/core/ScanStreamIntegrationTests.java +++ b/src/test/java/io/lettuce/core/ScanStreamIntegrationTests.java @@ -46,6 +46,7 @@ class ScanStreamIntegrationTests extends TestSupport { private final StatefulRedisConnection connection; + private final RedisCommands redis; @Inject @@ -176,4 +177,5 @@ void shouldCorrectlyEmitKeysWithConcurrentPoll() { assertThat(redis.scard(targetKey)).isEqualTo(5_000); } + } diff --git a/src/test/java/io/lettuce/core/ScoredValueStreamingAdapter.java b/src/test/java/io/lettuce/core/ScoredValueStreamingAdapter.java index 9d2c980f86..ae9ef8f2a4 100644 --- a/src/test/java/io/lettuce/core/ScoredValueStreamingAdapter.java +++ b/src/test/java/io/lettuce/core/ScoredValueStreamingAdapter.java @@ -10,6 +10,7 @@ * @since 3.0 */ public class ScoredValueStreamingAdapter implements ScoredValueStreamingChannel { + private List> list = new ArrayList<>(); @Override @@ -20,4 +21,5 @@ public void onValue(ScoredValue value) { public List> getList() { return list; } + } diff --git a/src/test/java/io/lettuce/core/ScoredValueUnitTests.java b/src/test/java/io/lettuce/core/ScoredValueUnitTests.java index 98114db288..3a786971e3 100644 --- a/src/test/java/io/lettuce/core/ScoredValueUnitTests.java +++ b/src/test/java/io/lettuce/core/ScoredValueUnitTests.java @@ -124,4 +124,5 @@ void toStringShouldRenderCorrectly() { assertThat(value.toString()).contains("ScoredValue[12").contains("340000, hello]"); assertThat(empty.toString()).contains(String.format("ScoredValue[%f].empty", 0d)); } + } diff --git a/src/test/java/io/lettuce/core/SocketOptionsIntegrationTests.java b/src/test/java/io/lettuce/core/SocketOptionsIntegrationTests.java index 82a3f275d0..a7f7e2a548 100644 --- a/src/test/java/io/lettuce/core/SocketOptionsIntegrationTests.java +++ b/src/test/java/io/lettuce/core/SocketOptionsIntegrationTests.java @@ -50,4 +50,5 @@ void testConnectTimeout() { } } } + } diff --git a/src/test/java/io/lettuce/core/SocketOptionsUnitTests.java b/src/test/java/io/lettuce/core/SocketOptionsUnitTests.java index 1554efa6f0..57aee0a22f 100644 --- a/src/test/java/io/lettuce/core/SocketOptionsUnitTests.java +++ b/src/test/java/io/lettuce/core/SocketOptionsUnitTests.java @@ -102,9 +102,11 @@ void testDefaultTcpUserTimeoutOption() { @Test void testConfigTcpUserTimeoutOption() { - SocketOptions sut = SocketOptions.builder().tcpUserTimeout(TcpUserTimeoutOptions - .builder().enable().tcpUserTimeout(Duration.ofSeconds(60)).build()).build(); + SocketOptions sut = SocketOptions.builder() + .tcpUserTimeout(TcpUserTimeoutOptions.builder().enable().tcpUserTimeout(Duration.ofSeconds(60)).build()) + .build(); assertThat(sut.isEnableTcpUserTimeout()).isTrue(); assertThat(sut.getTcpUserTimeout().getTcpUserTimeout()).isEqualTo(Duration.ofSeconds(60)); } + } diff --git a/src/test/java/io/lettuce/core/SslIntegrationTests.java b/src/test/java/io/lettuce/core/SslIntegrationTests.java index 098ee9eb80..cee9db988a 100644 --- a/src/test/java/io/lettuce/core/SslIntegrationTests.java +++ b/src/test/java/io/lettuce/core/SslIntegrationTests.java @@ -63,9 +63,13 @@ class SslIntegrationTests extends TestSupport { private static final String KEYSTORE = "work/keystore.jks"; + private static final String TRUSTSTORE = "work/truststore.jks"; + private static final File TRUSTSTORE_FILE = new File(TRUSTSTORE); + private static final File CA_CERT_FILE = new File("work/ca/certs/ca.cert.pem"); + private static final int MASTER_SLAVE_BASE_PORT_OFFSET = 2000; private static final RedisURI URI_VERIFY = sslURIBuilder(0) // @@ -74,8 +78,7 @@ class SslIntegrationTests extends TestSupport { private static final RedisURI URI_VERIFY_IMPOSSIBLE_TIMEOUT = sslURIBuilder(0) // .withVerifyPeer(true) // - .withTimeout(Duration.ZERO) - .build(); + .withTimeout(Duration.ZERO).build(); private static final RedisURI URI_NO_VERIFY = sslURIBuilder(1) // .withVerifyPeer(false) // @@ -430,4 +433,5 @@ private void verifyMasterSlaveConnection(List redisUris) { connection.sync().ping(); } } + } diff --git a/src/test/java/io/lettuce/core/SslOptionsUnitTests.java b/src/test/java/io/lettuce/core/SslOptionsUnitTests.java index c4733fea34..c134da39a8 100644 --- a/src/test/java/io/lettuce/core/SslOptionsUnitTests.java +++ b/src/test/java/io/lettuce/core/SslOptionsUnitTests.java @@ -82,4 +82,5 @@ void shouldApplyContextCustomizer() throws Exception { SslContext context = options.createSslContextBuilder().build(); assertThat(context.cipherSuites()).containsOnly("TLS_RSA_WITH_AES_128_CBC_SHA"); } + } diff --git a/src/test/java/io/lettuce/core/SyncAsyncApiConvergenceUnitTests.java b/src/test/java/io/lettuce/core/SyncAsyncApiConvergenceUnitTests.java index 13474aa25d..e033b7cf7b 100644 --- a/src/test/java/io/lettuce/core/SyncAsyncApiConvergenceUnitTests.java +++ b/src/test/java/io/lettuce/core/SyncAsyncApiConvergenceUnitTests.java @@ -61,7 +61,8 @@ void testSameResultType(Method syncMethod) throws Exception { } } - assertThat(returnType.toString()).describedAs(syncMethod.toString()).isEqualTo( - syncMethod.getGenericReturnType().toString()); + assertThat(returnType.toString()).describedAs(syncMethod.toString()) + .isEqualTo(syncMethod.getGenericReturnType().toString()); } + } diff --git a/src/test/java/io/lettuce/core/TestRedisPublisher.java b/src/test/java/io/lettuce/core/TestRedisPublisher.java index cd730345e7..a774c15c60 100644 --- a/src/test/java/io/lettuce/core/TestRedisPublisher.java +++ b/src/test/java/io/lettuce/core/TestRedisPublisher.java @@ -19,4 +19,5 @@ public TestRedisPublisher(Supplier> redisCommandSupplier, boolean dissolve) { super(redisCommandSupplier, connection, dissolve, ImmediateEventExecutor.INSTANCE); } + } diff --git a/src/test/java/io/lettuce/core/TestSupport.java b/src/test/java/io/lettuce/core/TestSupport.java index 389f3a2e05..7eb1b892b2 100644 --- a/src/test/java/io/lettuce/core/TestSupport.java +++ b/src/test/java/io/lettuce/core/TestSupport.java @@ -33,7 +33,9 @@ public abstract class TestSupport { public static final String host = TestSettings.hostAddr(); + public static final int port = TestSettings.port(); + public static final String username = TestSettings.username(); public static final CharSequence passwd = TestSettings.password(); @@ -43,6 +45,7 @@ public abstract class TestSupport { public static final CharSequence aclPasswd = TestSettings.aclPassword(); public static final String key = "key"; + public static final String value = "value"; protected static List list(String... args) { @@ -72,4 +75,5 @@ protected static ScoredValue sv(double score, long value) { protected static Set set(String... args) { return LettuceSets.newHashSet(args); } + } diff --git a/src/test/java/io/lettuce/core/TimeoutOptionsUnitTests.java b/src/test/java/io/lettuce/core/TimeoutOptionsUnitTests.java index 4ef823f540..dd0ae8f4a1 100644 --- a/src/test/java/io/lettuce/core/TimeoutOptionsUnitTests.java +++ b/src/test/java/io/lettuce/core/TimeoutOptionsUnitTests.java @@ -43,4 +43,5 @@ void fixedConnectionTimeout() { assertThat(timeoutOptions.isApplyConnectionTimeout()).isFalse(); assertThat(source.getTimeout(null)).isEqualTo(TimeUnit.MINUTES.toNanos(1)); } + } diff --git a/src/test/java/io/lettuce/core/UnixDomainSocketIntegrationTests.java b/src/test/java/io/lettuce/core/UnixDomainSocketIntegrationTests.java index ae96c80554..ba440b03c6 100644 --- a/src/test/java/io/lettuce/core/UnixDomainSocketIntegrationTests.java +++ b/src/test/java/io/lettuce/core/UnixDomainSocketIntegrationTests.java @@ -32,7 +32,9 @@ class UnixDomainSocketIntegrationTests { private static RedisClient sentinelClient; private Logger log = LogManager.getLogger(getClass()); + private String key = "key"; + private String value = "value"; @BeforeAll @@ -169,8 +171,7 @@ private static RedisClient getRedisSentinelClient() { private void assumeTestSupported() { String osName = SystemPropertyUtil.get("os.name").toLowerCase(Locale.UK).trim(); assumeTrue(Transports.NativeTransports.isDomainSocketSupported(), - "Only supported on Linux/OSX, your os is " + osName - + " with epoll/kqueue support."); + "Only supported on Linux/OSX, your os is " + osName + " with epoll/kqueue support."); } private static RedisURI getSocketRedisUri() throws IOException { diff --git a/src/test/java/io/lettuce/core/Utf8StringCodecIntegrationTests.java b/src/test/java/io/lettuce/core/Utf8StringCodecIntegrationTests.java index 42326ca1c0..2feb8d11b5 100644 --- a/src/test/java/io/lettuce/core/Utf8StringCodecIntegrationTests.java +++ b/src/test/java/io/lettuce/core/Utf8StringCodecIntegrationTests.java @@ -51,4 +51,5 @@ void decodeHugeBuffer(StatefulRedisConnection connection) { redis.set(key, value); assertThat(redis.get(key)).isEqualTo(value); } + } diff --git a/src/test/java/io/lettuce/core/ValueUnitTests.java b/src/test/java/io/lettuce/core/ValueUnitTests.java index e3af0fbe68..f78b355091 100644 --- a/src/test/java/io/lettuce/core/ValueUnitTests.java +++ b/src/test/java/io/lettuce/core/ValueUnitTests.java @@ -126,8 +126,8 @@ void emptyValueGetValueOrElseShouldThrowException() { Value value = Value.from(Optional.empty()); - assertThatThrownBy(() -> value.getValueOrElseThrow(IllegalArgumentException::new)).isInstanceOf( - IllegalArgumentException.class); + assertThatThrownBy(() -> value.getValueOrElseThrow(IllegalArgumentException::new)) + .isInstanceOf(IllegalArgumentException.class); } @Test @@ -263,4 +263,5 @@ void streamShouldCreateAStream() { assertThat(empty.stream().count()).isEqualTo(1); } + } diff --git a/src/test/java/io/lettuce/core/ZAggregateArgsUnitTests.java b/src/test/java/io/lettuce/core/ZAggregateArgsUnitTests.java index a7abfe56db..1973c6393b 100644 --- a/src/test/java/io/lettuce/core/ZAggregateArgsUnitTests.java +++ b/src/test/java/io/lettuce/core/ZAggregateArgsUnitTests.java @@ -48,4 +48,5 @@ void shouldOmitWeights() { assertThat(args.toString()).doesNotContain("WEIGHTS"); } + } diff --git a/src/test/java/io/lettuce/core/cluster/AdvancedClusterClientIntegrationTests.java b/src/test/java/io/lettuce/core/cluster/AdvancedClusterClientIntegrationTests.java index bdebd0b21c..64c5a04fab 100644 --- a/src/test/java/io/lettuce/core/cluster/AdvancedClusterClientIntegrationTests.java +++ b/src/test/java/io/lettuce/core/cluster/AdvancedClusterClientIntegrationTests.java @@ -70,11 +70,15 @@ class AdvancedClusterClientIntegrationTests extends TestSupport { private static final String KEY_ON_NODE_1 = "a"; + private static final String KEY_ON_NODE_2 = "b"; private final RedisClusterClient clusterClient; + private final StatefulRedisClusterConnection clusterConnection; + private final RedisAdvancedClusterAsyncCommands async; + private final RedisAdvancedClusterCommands sync; @Inject @@ -137,8 +141,8 @@ void differentConnections() { for (RedisClusterNode redisClusterNode : clusterClient.getPartitions()) { StatefulRedisConnection nodeId = statefulConnection.getConnection(redisClusterNode.getNodeId()); - StatefulRedisConnection hostAndPort = statefulConnection.getConnection(redisClusterNode.getUri() - .getHost(), redisClusterNode.getUri().getPort()); + StatefulRedisConnection hostAndPort = statefulConnection + .getConnection(redisClusterNode.getUri().getHost(), redisClusterNode.getUri().getPort()); assertThat(nodeId).isNotSameAs(hostAndPort); } @@ -326,10 +330,10 @@ void dbSize() { writeKeysToTwoNodes(); - RedisClusterCommands nodeConnection1 = clusterConnection.getConnection(ClusterTestSettings.host, - ClusterTestSettings.port1).sync(); - RedisClusterCommands nodeConnection2 = clusterConnection.getConnection(ClusterTestSettings.host, - ClusterTestSettings.port1).sync(); + RedisClusterCommands nodeConnection1 = clusterConnection + .getConnection(ClusterTestSettings.host, ClusterTestSettings.port1).sync(); + RedisClusterCommands nodeConnection2 = clusterConnection + .getConnection(ClusterTestSettings.host, ClusterTestSettings.port1).sync(); assertThat(nodeConnection1.dbsize()).isEqualTo(1); assertThat(nodeConnection2.dbsize()).isEqualTo(1); @@ -652,8 +656,8 @@ void clusterScanStreamingWithArgs() { } } while (!scanCursor.isFinished()); - assertThat(adapter.getList()).containsAll( - KeysAndValues.KEYS.stream().filter(k -> k.startsWith("a")).collect(Collectors.toList())); + assertThat(adapter.getList()) + .containsAll(KeysAndValues.KEYS.stream().filter(k -> k.startsWith("a")).collect(Collectors.toList())); } diff --git a/src/test/java/io/lettuce/core/cluster/AdvancedClusterReactiveIntegrationTests.java b/src/test/java/io/lettuce/core/cluster/AdvancedClusterReactiveIntegrationTests.java index b6758b580a..cfa4cc8519 100644 --- a/src/test/java/io/lettuce/core/cluster/AdvancedClusterReactiveIntegrationTests.java +++ b/src/test/java/io/lettuce/core/cluster/AdvancedClusterReactiveIntegrationTests.java @@ -75,10 +75,13 @@ class AdvancedClusterReactiveIntegrationTests extends TestSupport { private static final String KEY_ON_NODE_1 = "a"; + private static final String KEY_ON_NODE_2 = "b"; private final RedisClusterClient clusterClient; + private final RedisAdvancedClusterReactiveCommands commands; + private final RedisAdvancedClusterCommands syncCommands; @Inject @@ -498,4 +501,5 @@ Map prepareMset() { } return mset; } + } diff --git a/src/test/java/io/lettuce/core/cluster/AsyncConnectionProviderIntegrationTests.java b/src/test/java/io/lettuce/core/cluster/AsyncConnectionProviderIntegrationTests.java index ba92d9c3ce..c2352a7898 100644 --- a/src/test/java/io/lettuce/core/cluster/AsyncConnectionProviderIntegrationTests.java +++ b/src/test/java/io/lettuce/core/cluster/AsyncConnectionProviderIntegrationTests.java @@ -60,8 +60,11 @@ class AsyncConnectionProviderIntegrationTests { private final ClientResources resources; + private RedisClusterClient client; + private ServerSocket serverSocket; + private CountDownLatch connectInitiated = new CountDownLatch(1); private AsyncConnectionProvider, ConnectionFuture>> sut; @@ -79,6 +82,7 @@ void before() throws Exception { client = RedisClusterClient.create(resources, "redis://localhost"); client.setOptions(ClusterClientOptions.builder().protocolVersion(ProtocolVersion.RESP2).build()); sut = new AsyncConnectionProvider<>(new AbstractClusterNodeConnectionFactory(resources) { + @Override public ConnectionFuture> apply(ConnectionKey connectionKey) { @@ -92,6 +96,7 @@ public ConnectionFuture> apply(Connectio return future; } + }); } @@ -103,8 +108,7 @@ void after() throws Exception { @Test void shouldCloseConnectionByKey() throws IOException { - ConnectionKey connectionKey = new ConnectionKey(ConnectionIntent.READ, TestSettings.host(), - TestSettings.port()); + ConnectionKey connectionKey = new ConnectionKey(ConnectionIntent.READ, TestSettings.host(), TestSettings.port()); sut.getConnection(connectionKey); sut.close(connectionKey); @@ -118,8 +122,7 @@ void shouldCloseConnectionByKey() throws IOException { @Test void shouldCloseConnections() throws IOException { - ConnectionKey connectionKey = new ConnectionKey(ConnectionIntent.READ, TestSettings.host(), - TestSettings.port()); + ConnectionKey connectionKey = new ConnectionKey(ConnectionIntent.READ, TestSettings.host(), TestSettings.port()); sut.getConnection(connectionKey); TestFutures.awaitOrTimeout(sut.close()); @@ -145,14 +148,12 @@ void connectShouldFail() throws Exception { StopWatch stopWatch = new StopWatch(); assertThatThrownBy(() -> TestFutures.awaitOrTimeout(sut.getConnection(connectionKey))) - .hasCauseInstanceOf( - ConnectTimeoutException.class); + .hasCauseInstanceOf(ConnectTimeoutException.class); stopWatch.start(); assertThatThrownBy(() -> TestFutures.awaitOrTimeout(sut.getConnection(connectionKey))) - .hasCauseInstanceOf( - ConnectTimeoutException.class); + .hasCauseInstanceOf(ConnectTimeoutException.class); stopWatch.stop(); @@ -207,4 +208,5 @@ void connectShouldFailConcurrently() throws Exception { sut.close(); socket.close(); } + } diff --git a/src/test/java/io/lettuce/core/cluster/ByteCodecClusterIntegrationTests.java b/src/test/java/io/lettuce/core/cluster/ByteCodecClusterIntegrationTests.java index b5066903d4..17f5ddd57c 100644 --- a/src/test/java/io/lettuce/core/cluster/ByteCodecClusterIntegrationTests.java +++ b/src/test/java/io/lettuce/core/cluster/ByteCodecClusterIntegrationTests.java @@ -27,4 +27,5 @@ void testByteCodec(RedisClusterClient clusterClient) { connection.sync().set(key.getBytes(), value.getBytes()); assertThat(connection.sync().get(key.getBytes())).isEqualTo(value.getBytes()); } + } diff --git a/src/test/java/io/lettuce/core/cluster/ClusterClientOptionsIntegrationTests.java b/src/test/java/io/lettuce/core/cluster/ClusterClientOptionsIntegrationTests.java index b75954e65f..d83b7ee0cf 100644 --- a/src/test/java/io/lettuce/core/cluster/ClusterClientOptionsIntegrationTests.java +++ b/src/test/java/io/lettuce/core/cluster/ClusterClientOptionsIntegrationTests.java @@ -40,8 +40,8 @@ void tearDown() { @Test void shouldApplyTimeoutOptionsToClusterConnection() throws InterruptedException { - clusterClient.setOptions(ClusterClientOptions.builder().timeoutOptions(TimeoutOptions.enabled(Duration.ofMillis(100))) - .build()); + clusterClient.setOptions( + ClusterClientOptions.builder().timeoutOptions(TimeoutOptions.enabled(Duration.ofMillis(100))).build()); try (StatefulRedisClusterConnection connection = clusterClient.connect()) { @@ -60,8 +60,8 @@ void shouldApplyTimeoutOptionsToClusterConnection() throws InterruptedException @Test void shouldApplyTimeoutOptionsToPubSubClusterConnection() throws InterruptedException { - clusterClient.setOptions(ClusterClientOptions.builder().timeoutOptions(TimeoutOptions.enabled(Duration.ofMillis(100))) - .build()); + clusterClient.setOptions( + ClusterClientOptions.builder().timeoutOptions(TimeoutOptions.enabled(Duration.ofMillis(100))).build()); try (StatefulRedisClusterPubSubConnection connection = clusterClient.connectPubSub()) { connection.setTimeout(Duration.ofMillis(100)); @@ -76,4 +76,5 @@ void shouldApplyTimeoutOptionsToPubSubClusterConnection() throws InterruptedExce Thread.sleep(300); } + } diff --git a/src/test/java/io/lettuce/core/cluster/ClusterClientOptionsUnitTests.java b/src/test/java/io/lettuce/core/cluster/ClusterClientOptionsUnitTests.java index 98690cd668..abd9b270c2 100644 --- a/src/test/java/io/lettuce/core/cluster/ClusterClientOptionsUnitTests.java +++ b/src/test/java/io/lettuce/core/cluster/ClusterClientOptionsUnitTests.java @@ -26,8 +26,8 @@ void testCopy() { Predicate nodeFilter = it -> true; ClusterClientOptions options = ClusterClientOptions.builder().autoReconnect(false).requestQueueSize(100) .suspendReconnectOnProtocolFailure(true).maxRedirects(1234).validateClusterNodeMembership(false) - .readOnlyCommands(command -> command.getType() == CommandType.PING) - .protocolVersion(ProtocolVersion.RESP2).nodeFilter(nodeFilter).build(); + .readOnlyCommands(command -> command.getType() == CommandType.PING).protocolVersion(ProtocolVersion.RESP2) + .nodeFilter(nodeFilter).build(); ClusterClientOptions copy = ClusterClientOptions.copyOf(options); @@ -102,4 +102,5 @@ void builderFromClusterClientOptions() { assertThat(copy.getReadOnlyCommands().isReadOnly(new Command<>(CommandType.PING, null))).isTrue(); assertThat(options.mutate()).isNotSameAs(copy.mutate()); } + } diff --git a/src/test/java/io/lettuce/core/cluster/ClusterCommandIntegrationTests.java b/src/test/java/io/lettuce/core/cluster/ClusterCommandIntegrationTests.java index 3c29bdbdf4..2cdff16990 100644 --- a/src/test/java/io/lettuce/core/cluster/ClusterCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/cluster/ClusterCommandIntegrationTests.java @@ -39,9 +39,13 @@ class ClusterCommandIntegrationTests extends TestSupport { private final RedisClient client; + private final RedisClusterClient clusterClient; + private final StatefulRedisConnection connection; + private final RedisClusterAsyncCommands async; + private final RedisClusterCommands sync; @Inject @@ -186,8 +190,8 @@ void readOnly() throws Exception { prepareReadonlyTest(key); // assume cluster node 3 is a replica for the master 1 - RedisCommands connect3 = client - .connect(RedisURI.Builder.redis(host, ClusterTestSettings.port3).build()).sync(); + RedisCommands connect3 = client.connect(RedisURI.Builder.redis(host, ClusterTestSettings.port3).build()) + .sync(); assertThat(connect3.readOnly()).isEqualTo("OK"); waitUntilValueIsVisible(key, connect3); @@ -209,8 +213,8 @@ void readOnlyWithReconnect() throws Exception { prepareReadonlyTest(key); // assume cluster node 3 is a replica for the master 1 - RedisCommands connect3 = client - .connect(RedisURI.Builder.redis(host, ClusterTestSettings.port3).build()).sync(); + RedisCommands connect3 = client.connect(RedisURI.Builder.redis(host, ClusterTestSettings.port3).build()) + .sync(); assertThat(connect3.readOnly()).isEqualTo("OK"); connect3.quit(); @@ -229,8 +233,8 @@ void readOnlyReadWrite() throws Exception { prepareReadonlyTest(key); // assume cluster node 3 is a replica for the master 1 - final RedisCommands connect3 = client.connect( - RedisURI.Builder.redis(host, ClusterTestSettings.port3).build()).sync(); + final RedisCommands connect3 = client + .connect(RedisURI.Builder.redis(host, ClusterTestSettings.port3).build()).sync(); try { connect3.get("b"); @@ -279,4 +283,5 @@ private void prepareReadonlyTest(String key) { private static void waitUntilValueIsVisible(String key, RedisCommands commands) { Wait.untilTrue(() -> commands.get(key) != null).waitOrTimeout(); } + } diff --git a/src/test/java/io/lettuce/core/cluster/ClusterCommandUnitTests.java b/src/test/java/io/lettuce/core/cluster/ClusterCommandUnitTests.java index 561fd4b4b2..2c028f0b39 100644 --- a/src/test/java/io/lettuce/core/cluster/ClusterCommandUnitTests.java +++ b/src/test/java/io/lettuce/core/cluster/ClusterCommandUnitTests.java @@ -30,6 +30,7 @@ class ClusterCommandUnitTests { private RedisChannelWriter writerMock; private ClusterCommand sut; + private Command command = new Command<>(CommandType.TYPE, new StatusOutput<>(StringCodec.UTF8), null); @@ -100,4 +101,5 @@ void testCompleteListener() { assertThat(sut.isCompleted()).isTrue(); assertThat(someList.size()).describedAs("Inner listener has to add one element").isEqualTo(1); } + } diff --git a/src/test/java/io/lettuce/core/cluster/ClusterDistributionChannelWriterUnitTests.java b/src/test/java/io/lettuce/core/cluster/ClusterDistributionChannelWriterUnitTests.java index 95b6806350..f76d481c00 100644 --- a/src/test/java/io/lettuce/core/cluster/ClusterDistributionChannelWriterUnitTests.java +++ b/src/test/java/io/lettuce/core/cluster/ClusterDistributionChannelWriterUnitTests.java @@ -127,7 +127,8 @@ void shouldParseIPv6AskTargetCorrectly() { @Test void shouldParseMovedTargetCorrectly() { - HostAndPort moveTarget = ClusterDistributionChannelWriter.getMoveTarget(new Partitions(), "MOVED 1234-2020 127.0.0.1:6381"); + HostAndPort moveTarget = ClusterDistributionChannelWriter.getMoveTarget(new Partitions(), + "MOVED 1234-2020 127.0.0.1:6381"); assertThat(moveTarget.getHostText()).isEqualTo("127.0.0.1"); assertThat(moveTarget.getPort()).isEqualTo(6381); @@ -137,7 +138,8 @@ void shouldParseMovedTargetCorrectly() { void shouldParseMovedTargetWithoutHostnameCorrectly() { Partitions partitions = new Partitions(); - partitions.add(new RedisClusterNode(RedisURI.create("redis://1.2.3.4:6381"), "foo", false,null,0,0,0,Collections.emptyList(), Collections.emptySet())); + partitions.add(new RedisClusterNode(RedisURI.create("redis://1.2.3.4:6381"), "foo", false, null, 0, 0, 0, + Collections.emptyList(), Collections.emptySet())); HostAndPort moveTarget = ClusterDistributionChannelWriter.getMoveTarget(partitions, "MOVED 1234 :6381"); assertThat(moveTarget.getHostText()).isEqualTo("1.2.3.4"); @@ -148,7 +150,8 @@ void shouldParseMovedTargetWithoutHostnameCorrectly() { void shouldParseMovedTargetWithoutHostnameUsingSlotFallbackCorrectly() { Partitions partitions = new Partitions(); - partitions.add(new RedisClusterNode(RedisURI.create("redis://1.2.3.4:5678"), "foo", false,null,0,0,0, Collections.singletonList(1234), Collections.emptySet())); + partitions.add(new RedisClusterNode(RedisURI.create("redis://1.2.3.4:5678"), "foo", false, null, 0, 0, 0, + Collections.singletonList(1234), Collections.emptySet())); HostAndPort moveTarget = ClusterDistributionChannelWriter.getMoveTarget(partitions, "MOVED 1234 :6381"); assertThat(moveTarget.getHostText()).isEqualTo("1.2.3.4"); @@ -158,7 +161,8 @@ void shouldParseMovedTargetWithoutHostnameUsingSlotFallbackCorrectly() { @Test void shouldParseIPv6MovedTargetCorrectly() { - HostAndPort moveTarget = ClusterDistributionChannelWriter.getMoveTarget(new Partitions(), "MOVED 1234-2020 1:2:3:4::6:6381"); + HostAndPort moveTarget = ClusterDistributionChannelWriter.getMoveTarget(new Partitions(), + "MOVED 1234-2020 1:2:3:4::6:6381"); assertThat(moveTarget.getHostText()).isEqualTo("1:2:3:4::6"); assertThat(moveTarget.getPort()).isEqualTo(6381); @@ -167,7 +171,8 @@ void shouldParseIPv6MovedTargetCorrectly() { @Test void shouldReturnIntentForWriteCommand() { - ClusterDistributionChannelWriter writer = new ClusterDistributionChannelWriter(clusterDistributionChannelWriter, clientOptions, clusterEventListener); + ClusterDistributionChannelWriter writer = new ClusterDistributionChannelWriter(clusterDistributionChannelWriter, + clientOptions, clusterEventListener); RedisCommand set = new Command<>(CommandType.SET, null); RedisCommand mset = new Command<>(CommandType.MSET, null); @@ -180,7 +185,8 @@ void shouldReturnIntentForWriteCommand() { @Test void shouldReturnDefaultIntentForNoCommands() { - ClusterDistributionChannelWriter writer = new ClusterDistributionChannelWriter(clusterDistributionChannelWriter, clientOptions, clusterEventListener); + ClusterDistributionChannelWriter writer = new ClusterDistributionChannelWriter(clusterDistributionChannelWriter, + clientOptions, clusterEventListener); assertThat(writer.getIntent(Collections.emptyList())).isEqualTo(ConnectionIntent.WRITE); } @@ -188,7 +194,8 @@ void shouldReturnDefaultIntentForNoCommands() { @Test void shouldReturnIntentForReadCommand() { - ClusterDistributionChannelWriter writer = new ClusterDistributionChannelWriter(clusterDistributionChannelWriter, clientOptions, clusterEventListener); + ClusterDistributionChannelWriter writer = new ClusterDistributionChannelWriter(clusterDistributionChannelWriter, + clientOptions, clusterEventListener); RedisCommand get = new Command<>(CommandType.GET, null); RedisCommand mget = new Command<>(CommandType.MGET, null); @@ -201,7 +208,8 @@ void shouldReturnIntentForReadCommand() { @Test void shouldReturnIntentForMixedCommands() { - ClusterDistributionChannelWriter writer = new ClusterDistributionChannelWriter(clusterDistributionChannelWriter, clientOptions, clusterEventListener); + ClusterDistributionChannelWriter writer = new ClusterDistributionChannelWriter(clusterDistributionChannelWriter, + clientOptions, clusterEventListener); RedisCommand set = new Command<>(CommandType.SET, null); RedisCommand mget = new Command<>(CommandType.MGET, null); @@ -265,4 +273,5 @@ private void verifyWriteCommandCountWhenRedirecting(boolean isMoved) { verify(clusterNodeEndpoint, never()).write(ArgumentMatchers.> any()); } } + } diff --git a/src/test/java/io/lettuce/core/cluster/ClusterNodeEndpointUnitTests.java b/src/test/java/io/lettuce/core/cluster/ClusterNodeEndpointUnitTests.java index a8da42cca2..524526457d 100644 --- a/src/test/java/io/lettuce/core/cluster/ClusterNodeEndpointUnitTests.java +++ b/src/test/java/io/lettuce/core/cluster/ClusterNodeEndpointUnitTests.java @@ -145,4 +145,5 @@ private void prepareNewEndpoint() { sut = new ClusterNodeEndpoint(clientOptions, clientResources, clusterChannelWriter); disconnectedBuffer = (Queue) ReflectionTestUtils.getField(sut, "disconnectedBuffer"); } + } diff --git a/src/test/java/io/lettuce/core/cluster/ClusterPartiallyDownIntegrationTests.java b/src/test/java/io/lettuce/core/cluster/ClusterPartiallyDownIntegrationTests.java index 6adee0f591..8f103c0861 100644 --- a/src/test/java/io/lettuce/core/cluster/ClusterPartiallyDownIntegrationTests.java +++ b/src/test/java/io/lettuce/core/cluster/ClusterPartiallyDownIntegrationTests.java @@ -32,13 +32,19 @@ class ClusterPartiallyDownIntegrationTests extends TestSupport { private static ClientResources clientResources; private static int port1 = 7579; + private static int port2 = 7580; + private static int port3 = 7581; + private static int port4 = 7582; private static final RedisURI URI_1 = RedisURI.create(TestSettings.host(), port1); + private static final RedisURI URI_2 = RedisURI.create(TestSettings.host(), port2); + private static final RedisURI URI_3 = RedisURI.create(TestSettings.host(), port3); + private static final RedisURI URI_4 = RedisURI.create(TestSettings.host(), port4); private RedisClusterClient redisClusterClient; @@ -120,4 +126,5 @@ void partitionNodesAreOffline() { assertThat(e).hasRootCauseInstanceOf(IOException.class); } } + } diff --git a/src/test/java/io/lettuce/core/cluster/ClusterReactiveCommandIntegrationTests.java b/src/test/java/io/lettuce/core/cluster/ClusterReactiveCommandIntegrationTests.java index 80cd5bebbc..74ddc18d0d 100644 --- a/src/test/java/io/lettuce/core/cluster/ClusterReactiveCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/cluster/ClusterReactiveCommandIntegrationTests.java @@ -25,7 +25,9 @@ class ClusterReactiveCommandIntegrationTests { private final RedisClusterClient clusterClient; + private final RedisClusterReactiveCommands reactive; + private final RedisClusterCommands sync; @Inject @@ -94,4 +96,5 @@ void clusterSlaves() { assertThat(result.size()).isGreaterThan(0); } + } diff --git a/src/test/java/io/lettuce/core/cluster/ClusterSetup.java b/src/test/java/io/lettuce/core/cluster/ClusterSetup.java index da8f75cd13..9bfb500591 100644 --- a/src/test/java/io/lettuce/core/cluster/ClusterSetup.java +++ b/src/test/java/io/lettuce/core/cluster/ClusterSetup.java @@ -117,8 +117,7 @@ public static void setupMasterWithReplica(ClusterTestHelper clusterHelper) { Wait.untilTrue(clusterHelper::isStable).waitOrTimeout(); TestFutures.awaitOrTimeout(connection.getConnection(ClusterTestSettings.host, ClusterTestSettings.port6) - .clusterReplicate( - node1.clusterMyId())); + .clusterReplicate(node1.clusterMyId())); clusterHelper.getClusterClient().reloadPartitions(); @@ -131,8 +130,7 @@ public static void setupMasterWithReplica(ClusterTestHelper clusterHelper) { Wait.untilEquals(1L, () -> { clusterHelper.getClusterClient().reloadPartitions(); return partitionStream(clusterHelper) - .filter(redisClusterNode -> redisClusterNode.is(RedisClusterNode.NodeFlag.REPLICA)) - .count(); + .filter(redisClusterNode -> redisClusterNode.is(RedisClusterNode.NodeFlag.REPLICA)).count(); }).waitOrTimeout(); connection.getStatefulConnection().close(); diff --git a/src/test/java/io/lettuce/core/cluster/ClusterTestHelper.java b/src/test/java/io/lettuce/core/cluster/ClusterTestHelper.java index a526b0355c..4383d5fb38 100644 --- a/src/test/java/io/lettuce/core/cluster/ClusterTestHelper.java +++ b/src/test/java/io/lettuce/core/cluster/ClusterTestHelper.java @@ -45,13 +45,15 @@ class ClusterTestHelper { private final RedisClusterClient clusterClient; + private final Map> connectionCache = new HashMap<>(); public ClusterTestHelper(RedisClusterClient clusterClient, int... ports) { this.clusterClient = clusterClient; for (int port : ports) { - RedisAsyncCommands connection = clusterClient.connectToNode(new InetSocketAddress("localhost", port)).async(); + RedisAsyncCommands connection = clusterClient + .connectToNode(new InetSocketAddress("localhost", port)).async(); connectionCache.put(port, connection); } } @@ -140,8 +142,8 @@ private void onAllConnections(Function, Futu } } - private void await(List> futures, boolean ignoreExecutionException) throws InterruptedException, - java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException { + private void await(List> futures, boolean ignoreExecutionException) + throws InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException { for (Future future : futures) { try { future.get(10, TimeUnit.SECONDS); @@ -152,4 +154,5 @@ private void await(List> futures, boolean ignoreExecutionException) th } } } + } diff --git a/src/test/java/io/lettuce/core/cluster/ClusterTestSettings.java b/src/test/java/io/lettuce/core/cluster/ClusterTestSettings.java index 261f686080..dc28e5b54a 100644 --- a/src/test/java/io/lettuce/core/cluster/ClusterTestSettings.java +++ b/src/test/java/io/lettuce/core/cluster/ClusterTestSettings.java @@ -11,22 +11,30 @@ public abstract class ClusterTestSettings extends TestSupport { public static final String host = TestSettings.hostAddr(); public static final int SLOT_A = SlotHash.getSlot("a".getBytes()); + public static final int SLOT_B = SlotHash.getSlot("b".getBytes()); // default test cluster 2 masters + 2 slaves public static final int port1 = TestSettings.port(900); + public static final int port2 = port1 + 1; + public static final int port3 = port1 + 2; + public static final int port4 = port1 + 3; // master+replica or master+master public static final int port5 = port1 + 4; + public static final int port6 = port1 + 5; // auth cluster public static final int port7 = port1 + 6; + public static final String KEY_A = "a"; + public static final String KEY_B = "b"; + public static final String KEY_D = "d"; /** diff --git a/src/test/java/io/lettuce/core/cluster/ClusterTestUtil.java b/src/test/java/io/lettuce/core/cluster/ClusterTestUtil.java index 26c3ca8956..b59be06b82 100644 --- a/src/test/java/io/lettuce/core/cluster/ClusterTestUtil.java +++ b/src/test/java/io/lettuce/core/cluster/ClusterTestUtil.java @@ -75,9 +75,9 @@ public static RedisCommands redisCommandsOverCluster( StatefulRedisClusterConnection connection) { StatefulRedisClusterConnectionImpl clusterConnection = (StatefulRedisClusterConnectionImpl) connection; - InvocationHandler h = new RoutingInvocationHandler(connection.async(), - clusterConnection.syncInvocationHandler()); + InvocationHandler h = new RoutingInvocationHandler(connection.async(), clusterConnection.syncInvocationHandler()); return (RedisCommands) Proxy.newProxyInstance(ClusterTestUtil.class.getClassLoader(), new Class[] { RedisCommands.class }, h); } + } diff --git a/src/test/java/io/lettuce/core/cluster/ClusterTopologyRefreshSchedulerUnitTests.java b/src/test/java/io/lettuce/core/cluster/ClusterTopologyRefreshSchedulerUnitTests.java index 4e6907564a..6872005898 100644 --- a/src/test/java/io/lettuce/core/cluster/ClusterTopologyRefreshSchedulerUnitTests.java +++ b/src/test/java/io/lettuce/core/cluster/ClusterTopologyRefreshSchedulerUnitTests.java @@ -273,4 +273,5 @@ void shouldRetrievePartitionsViaAdaptiveRefreshTriggeredEvent() { assertThat(capture.getPartitions()).isSameAs(partitions); } + } diff --git a/src/test/java/io/lettuce/core/cluster/CommandSetIntegrationTests.java b/src/test/java/io/lettuce/core/cluster/CommandSetIntegrationTests.java index a29bdcb0f8..05c2c32263 100644 --- a/src/test/java/io/lettuce/core/cluster/CommandSetIntegrationTests.java +++ b/src/test/java/io/lettuce/core/cluster/CommandSetIntegrationTests.java @@ -48,5 +48,7 @@ enum UnknownCommand implements ProtocolKeyword { public byte[] getBytes() { return name().getBytes(); } + } + } diff --git a/src/test/java/io/lettuce/core/cluster/HealthyMajorityPartitionsConsensusUnitTests.java b/src/test/java/io/lettuce/core/cluster/HealthyMajorityPartitionsConsensusUnitTests.java index 588db9bdc4..2fa3597cd0 100644 --- a/src/test/java/io/lettuce/core/cluster/HealthyMajorityPartitionsConsensusUnitTests.java +++ b/src/test/java/io/lettuce/core/cluster/HealthyMajorityPartitionsConsensusUnitTests.java @@ -21,9 +21,13 @@ class HealthyMajorityPartitionsConsensusUnitTests { private RedisClusterNode node1 = createNode(1); + private RedisClusterNode node2 = createNode(2); + private RedisClusterNode node3 = createNode(3); + private RedisClusterNode node4 = createNode(4); + private RedisClusterNode node5 = createNode(5); @Test @@ -94,4 +98,5 @@ void splitUnhealthyNodeViewShouldDecideForHealthyNodes() { assertThat(Arrays.asList(partitions1, partitions3)).contains(result); } + } diff --git a/src/test/java/io/lettuce/core/cluster/KnownMajorityPartitionsConsensusUnitTests.java b/src/test/java/io/lettuce/core/cluster/KnownMajorityPartitionsConsensusUnitTests.java index dc2dcc9932..95af7f54f6 100644 --- a/src/test/java/io/lettuce/core/cluster/KnownMajorityPartitionsConsensusUnitTests.java +++ b/src/test/java/io/lettuce/core/cluster/KnownMajorityPartitionsConsensusUnitTests.java @@ -20,9 +20,13 @@ class KnownMajorityPartitionsConsensusUnitTests { private RedisClusterNode node1 = createNode(1); + private RedisClusterNode node2 = createNode(2); + private RedisClusterNode node3 = createNode(3); + private RedisClusterNode node4 = createNode(4); + private RedisClusterNode node5 = createNode(5); @Test @@ -120,4 +124,5 @@ void strangeClusterSplitViewShouldDecideForKnownMajority() { assertThat(Arrays.asList(partitions1, partitions2, partitions3)).contains(result); } + } diff --git a/src/test/java/io/lettuce/core/cluster/NodeSelectionAsyncIntegrationTests.java b/src/test/java/io/lettuce/core/cluster/NodeSelectionAsyncIntegrationTests.java index 9ded3df028..ec2faf90d8 100644 --- a/src/test/java/io/lettuce/core/cluster/NodeSelectionAsyncIntegrationTests.java +++ b/src/test/java/io/lettuce/core/cluster/NodeSelectionAsyncIntegrationTests.java @@ -43,6 +43,7 @@ class NodeSelectionAsyncIntegrationTests extends TestSupport { private final RedisClusterClient clusterClient; + private final RedisAdvancedClusterAsyncCommands commands; @Inject @@ -120,15 +121,15 @@ void testNodeSelectionCount() { assertThat(commands.slaves().size()).isEqualTo(2); assertThat(commands.masters().size()).isEqualTo(2); - assertThat(commands.nodes(redisClusterNode -> redisClusterNode.is(RedisClusterNode.NodeFlag.MYSELF)).size()).isEqualTo( - 1); + assertThat(commands.nodes(redisClusterNode -> redisClusterNode.is(RedisClusterNode.NodeFlag.MYSELF)).size()) + .isEqualTo(1); } @Test void testNodeSelection() { - AsyncNodeSelection onlyMe = commands.nodes(redisClusterNode -> redisClusterNode.getFlags().contains( - RedisClusterNode.NodeFlag.MYSELF)); + AsyncNodeSelection onlyMe = commands + .nodes(redisClusterNode -> redisClusterNode.getFlags().contains(RedisClusterNode.NodeFlag.MYSELF)); Map> map = onlyMe.asMap(); assertThat(map).hasSize(1); @@ -146,19 +147,19 @@ void testNodeSelection() { void testDynamicNodeSelection() { Partitions partitions = commands.getStatefulConnection().getPartitions(); - partitions.forEach(redisClusterNode -> redisClusterNode.setFlags(Collections - .singleton(RedisClusterNode.NodeFlag.UPSTREAM))); + partitions.forEach( + redisClusterNode -> redisClusterNode.setFlags(Collections.singleton(RedisClusterNode.NodeFlag.UPSTREAM))); - AsyncNodeSelection selection = commands.nodes( - redisClusterNode -> redisClusterNode.getFlags().contains(RedisClusterNode.NodeFlag.MYSELF), true); + AsyncNodeSelection selection = commands + .nodes(redisClusterNode -> redisClusterNode.getFlags().contains(RedisClusterNode.NodeFlag.MYSELF), true); assertThat(selection.asMap()).hasSize(0); - partitions.getPartition(0).setFlags( - LettuceSets.unmodifiableSet(RedisClusterNode.NodeFlag.MYSELF, RedisClusterNode.NodeFlag.UPSTREAM)); + partitions.getPartition(0) + .setFlags(LettuceSets.unmodifiableSet(RedisClusterNode.NodeFlag.MYSELF, RedisClusterNode.NodeFlag.UPSTREAM)); assertThat(selection.asMap()).hasSize(1); - partitions.getPartition(1).setFlags( - LettuceSets.unmodifiableSet(RedisClusterNode.NodeFlag.MYSELF, RedisClusterNode.NodeFlag.UPSTREAM)); + partitions.getPartition(1) + .setFlags(LettuceSets.unmodifiableSet(RedisClusterNode.NodeFlag.MYSELF, RedisClusterNode.NodeFlag.UPSTREAM)); assertThat(selection.asMap()).hasSize(2); clusterClient.reloadPartitions(); @@ -167,8 +168,8 @@ void testDynamicNodeSelection() { @Test void testNodeSelectionAsyncPing() { - AsyncNodeSelection onlyMe = commands.nodes(redisClusterNode -> redisClusterNode.getFlags().contains( - RedisClusterNode.NodeFlag.MYSELF)); + AsyncNodeSelection onlyMe = commands + .nodes(redisClusterNode -> redisClusterNode.getFlags().contains(RedisClusterNode.NodeFlag.MYSELF)); Map> map = onlyMe.asMap(); assertThat(map).hasSize(1); @@ -212,8 +213,8 @@ void testDispatchWithArgs() { @Test void testStaticNodeSelection() { - AsyncNodeSelection selection = commands.nodes( - redisClusterNode -> redisClusterNode.getFlags().contains(RedisClusterNode.NodeFlag.MYSELF), false); + AsyncNodeSelection selection = commands + .nodes(redisClusterNode -> redisClusterNode.getFlags().contains(RedisClusterNode.NodeFlag.MYSELF), false); assertThat(selection.asMap()).hasSize(1); @@ -225,12 +226,11 @@ void testStaticNodeSelection() { clusterClient.reloadPartitions(); } - @Test void testReplicaReadWrite() { - AsyncNodeSelection nodes = commands.nodes(redisClusterNode -> redisClusterNode.getFlags().contains( - RedisClusterNode.NodeFlag.REPLICA)); + AsyncNodeSelection nodes = commands + .nodes(redisClusterNode -> redisClusterNode.getFlags().contains(RedisClusterNode.NodeFlag.REPLICA)); assertThat(nodes.size()).isEqualTo(2); @@ -255,8 +255,8 @@ void testReplicaReadWrite() { @Test void testReplicasWithReadOnly() { - AsyncNodeSelection nodes = commands.replicas(redisClusterNode -> redisClusterNode - .is(RedisClusterNode.NodeFlag.REPLICA)); + AsyncNodeSelection nodes = commands + .replicas(redisClusterNode -> redisClusterNode.is(RedisClusterNode.NodeFlag.REPLICA)); assertThat(nodes.size()).isEqualTo(2); @@ -285,8 +285,7 @@ void waitForReplication(String key, int port) { waitForReplication(commands, key, port); } - static void waitForReplication(RedisAdvancedClusterAsyncCommands commands, String key, int port) - { + static void waitForReplication(RedisAdvancedClusterAsyncCommands commands, String key, int port) { AsyncNodeSelection selection = commands .replicas(redisClusterNode -> redisClusterNode.getUri().getPort() == port); @@ -303,4 +302,5 @@ static void waitForReplication(RedisAdvancedClusterAsyncCommands return null; }).waitOrTimeout(); } + } diff --git a/src/test/java/io/lettuce/core/cluster/PartitionsConsensusTestSupport.java b/src/test/java/io/lettuce/core/cluster/PartitionsConsensusTestSupport.java index 340b3a787e..a8187aa8fc 100644 --- a/src/test/java/io/lettuce/core/cluster/PartitionsConsensusTestSupport.java +++ b/src/test/java/io/lettuce/core/cluster/PartitionsConsensusTestSupport.java @@ -12,7 +12,7 @@ class PartitionsConsensusTestSupport { static RedisClusterNode createNode(int nodeId) { - return new RedisClusterNode(RedisURI.create("localhost", 6379-2020 + nodeId), "" + nodeId, true, "", 0, 0, 0, + return new RedisClusterNode(RedisURI.create("localhost", 6379 - 2020 + nodeId), "" + nodeId, true, "", 0, 0, 0, Collections.emptyList(), new HashSet<>()); } @@ -34,4 +34,5 @@ static Map createMap(Partitions... partitionses) { return partitionsMap; } + } diff --git a/src/test/java/io/lettuce/core/cluster/PipelinedRedisFutureUnitTests.java b/src/test/java/io/lettuce/core/cluster/PipelinedRedisFutureUnitTests.java index 95d3549e70..578201423b 100644 --- a/src/test/java/io/lettuce/core/cluster/PipelinedRedisFutureUnitTests.java +++ b/src/test/java/io/lettuce/core/cluster/PipelinedRedisFutureUnitTests.java @@ -38,4 +38,5 @@ void testCompleteExceptionally() { assertThat(TestFutures.getOrTimeout(sut.toCompletableFuture())).isEqualTo(other); assertThat(sut.getError()).isNull(); } + } diff --git a/src/test/java/io/lettuce/core/cluster/PooledClusterConnectionProviderUnitTests.java b/src/test/java/io/lettuce/core/cluster/PooledClusterConnectionProviderUnitTests.java index 78901e1b4a..52ae370cc9 100644 --- a/src/test/java/io/lettuce/core/cluster/PooledClusterConnectionProviderUnitTests.java +++ b/src/test/java/io/lettuce/core/cluster/PooledClusterConnectionProviderUnitTests.java @@ -109,10 +109,10 @@ void before() { List slots1 = IntStream.range(0, 8192).boxed().collect(Collectors.toList()); List slots2 = IntStream.range(8192, SlotHash.SLOT_COUNT).boxed().collect(Collectors.toList()); - partitions.add(new RedisClusterNode(RedisURI.create("localhost", 1), "1", true, null, 0, 0, 0, slots1, Collections - .singleton(RedisClusterNode.NodeFlag.UPSTREAM))); - partitions.add(new RedisClusterNode(RedisURI.create("localhost", 2), "2", true, "1", 0, 0, 0, slots2, Collections - .singleton(RedisClusterNode.NodeFlag.REPLICA))); + partitions.add(new RedisClusterNode(RedisURI.create("localhost", 1), "1", true, null, 0, 0, 0, slots1, + Collections.singleton(RedisClusterNode.NodeFlag.UPSTREAM))); + partitions.add(new RedisClusterNode(RedisURI.create("localhost", 2), "2", true, "1", 0, 0, 0, slots2, + Collections.singleton(RedisClusterNode.NodeFlag.REPLICA))); sut.setPartitions(partitions); @@ -123,8 +123,7 @@ void before() { void shouldObtainConnection() { when(clientMock.connectToNodeAsync(eq(StringCodec.UTF8), eq("localhost:1"), any(), any())) - .thenReturn( - ConnectionFuture.from(socketAddressMock, CompletableFuture.completedFuture(nodeConnectionMock))); + .thenReturn(ConnectionFuture.from(socketAddressMock, CompletableFuture.completedFuture(nodeConnectionMock))); StatefulRedisConnection connection = sut.getConnection(ConnectionIntent.READ, 1); @@ -138,8 +137,7 @@ void shouldObtainConnection() { void shouldReuseMasterConnectionForReadFromMaster() { when(clientMock.connectToNodeAsync(eq(StringCodec.UTF8), eq("localhost:1"), any(), any())) - .thenReturn( - ConnectionFuture.from(socketAddressMock, CompletableFuture.completedFuture(nodeConnectionMock))); + .thenReturn(ConnectionFuture.from(socketAddressMock, CompletableFuture.completedFuture(nodeConnectionMock))); sut.setReadFrom(ReadFrom.UPSTREAM); @@ -186,7 +184,8 @@ void shouldAvoidReplicaWithReplOffsetZero() { sut.setReadFrom(ReadFrom.REPLICA); - assertThatExceptionOfType(PartitionSelectorException.class).isThrownBy(() -> sut.getConnection(ConnectionIntent.READ, 1)); + assertThatExceptionOfType(PartitionSelectorException.class) + .isThrownBy(() -> sut.getConnection(ConnectionIntent.READ, 1)); } @Test @@ -388,10 +387,12 @@ void shouldNotifyListerOnUncoveredReadSlot() { void shouldNotifyListerOnUncoveredReadSlotAfterSelection() { sut.setReadFrom(new ReadFrom() { + @Override public List select(Nodes nodes) { return Collections.emptyList(); } + }); sut.getConnectionAsync(ConnectionIntent.READ, 2); @@ -418,7 +419,8 @@ void shouldCloseConnections() { @Test void shouldRejectConnectionsToUnknownNodeId() { - assertThatThrownBy(() -> sut.getConnection(ConnectionIntent.READ, "foobar")).isInstanceOf(UnknownPartitionException.class); + assertThatThrownBy(() -> sut.getConnection(ConnectionIntent.READ, "foobar")) + .isInstanceOf(UnknownPartitionException.class); verify(clusterEventListener).onUnknownNode(); } @@ -431,4 +433,5 @@ void shouldRejectConnectionsToUnknownNodeHostAndPort() { verify(clusterEventListener).onUnknownNode(); } + } diff --git a/src/test/java/io/lettuce/core/cluster/ReadFromUnitTests.java b/src/test/java/io/lettuce/core/cluster/ReadFromUnitTests.java index 89888646c3..3ee0b59450 100644 --- a/src/test/java/io/lettuce/core/cluster/ReadFromUnitTests.java +++ b/src/test/java/io/lettuce/core/cluster/ReadFromUnitTests.java @@ -47,8 +47,11 @@ class ReadFromUnitTests { private Partitions sut = new Partitions(); + private RedisClusterNode nearest = new RedisClusterNode(); + private RedisClusterNode master = new RedisClusterNode(); + private RedisClusterNode replica = new RedisClusterNode(); @BeforeEach @@ -259,6 +262,7 @@ void valueOfRegex() { private ReadFrom.Nodes getNodes() { return new ReadFrom.Nodes() { + @Override public List getNodes() { return (List) sut.getPartitions(); @@ -268,6 +272,7 @@ public List getNodes() { public Iterator iterator() { return getNodes().iterator(); } + }; } diff --git a/src/test/java/io/lettuce/core/cluster/RedisClusterClientFactoryTests.java b/src/test/java/io/lettuce/core/cluster/RedisClusterClientFactoryTests.java index f55a4cad56..f8741e0a78 100644 --- a/src/test/java/io/lettuce/core/cluster/RedisClusterClientFactoryTests.java +++ b/src/test/java/io/lettuce/core/cluster/RedisClusterClientFactoryTests.java @@ -19,7 +19,9 @@ class RedisClusterClientFactoryTests { private static final String URI = "redis://" + TestSettings.host() + ":" + TestSettings.port(); + private static final RedisURI REDIS_URI = RedisURI.create(URI); + private static final List REDIS_URIS = LettuceLists.newList(REDIS_URI); @Test @@ -49,8 +51,8 @@ void withUriIterable() { @Test void withUriIterableNull() { - assertThatThrownBy(() -> RedisClusterClient.create((Iterable) null)).isInstanceOf( - IllegalArgumentException.class); + assertThatThrownBy(() -> RedisClusterClient.create((Iterable) null)) + .isInstanceOf(IllegalArgumentException.class); } @Test @@ -60,8 +62,8 @@ void clientResourcesWithStringUri() { @Test void clientResourcesWithStringUriNull() { - assertThatThrownBy(() -> RedisClusterClient.create(TestClientResources.get(), (String) null)).isInstanceOf( - IllegalArgumentException.class); + assertThatThrownBy(() -> RedisClusterClient.create(TestClientResources.get(), (String) null)) + .isInstanceOf(IllegalArgumentException.class); } @Test @@ -76,8 +78,8 @@ void clientResourcesWithUri() { @Test void clientResourcesWithUriNull() { - assertThatThrownBy(() -> RedisClusterClient.create(TestClientResources.get(), (RedisURI) null)).isInstanceOf( - IllegalArgumentException.class); + assertThatThrownBy(() -> RedisClusterClient.create(TestClientResources.get(), (RedisURI) null)) + .isInstanceOf(IllegalArgumentException.class); } @Test @@ -92,8 +94,8 @@ void clientResourcesWithUriIterable() { @Test void clientResourcesWithUriIterableNull() { - assertThatThrownBy(() -> RedisClusterClient.create(TestClientResources.get(), (Iterable) null)).isInstanceOf( - IllegalArgumentException.class); + assertThatThrownBy(() -> RedisClusterClient.create(TestClientResources.get(), (Iterable) null)) + .isInstanceOf(IllegalArgumentException.class); } @Test @@ -103,16 +105,16 @@ void clientResourcesNullWithUriIterable() { @Test void clientWithDifferentSslSettings() { - assertThatThrownBy( - () -> RedisClusterClient.create(Arrays.asList(RedisURI.create("redis://host1"), - RedisURI.create("redis+ssl://host1")))).isInstanceOf(IllegalArgumentException.class); + assertThatThrownBy(() -> RedisClusterClient + .create(Arrays.asList(RedisURI.create("redis://host1"), RedisURI.create("redis+ssl://host1")))) + .isInstanceOf(IllegalArgumentException.class); } @Test void clientWithDifferentTlsSettings() { - assertThatThrownBy( - () -> RedisClusterClient.create(Arrays.asList(RedisURI.create("rediss://host1"), - RedisURI.create("redis+tls://host1")))).isInstanceOf(IllegalArgumentException.class); + assertThatThrownBy(() -> RedisClusterClient + .create(Arrays.asList(RedisURI.create("rediss://host1"), RedisURI.create("redis+tls://host1")))) + .isInstanceOf(IllegalArgumentException.class); } @Test @@ -123,4 +125,5 @@ void clientWithDifferentVerifyPeerSettings() { assertThatThrownBy(() -> RedisClusterClient.create(Arrays.asList(redisURI, RedisURI.create("rediss://host1")))) .isInstanceOf(IllegalArgumentException.class); } + } diff --git a/src/test/java/io/lettuce/core/cluster/RedisClusterPasswordSecuredSslIntegrationTests.java b/src/test/java/io/lettuce/core/cluster/RedisClusterPasswordSecuredSslIntegrationTests.java index 59e0ee55dd..4d02a8fa5c 100644 --- a/src/test/java/io/lettuce/core/cluster/RedisClusterPasswordSecuredSslIntegrationTests.java +++ b/src/test/java/io/lettuce/core/cluster/RedisClusterPasswordSecuredSslIntegrationTests.java @@ -32,13 +32,16 @@ class RedisClusterPasswordSecuredSslIntegrationTests extends TestSupport { private static final int CLUSTER_PORT_SSL_1 = 7442; private static final int CLUSTER_PORT_SSL_2 = 7444; // replica cannot replicate properly with upstream + private static final int CLUSTER_PORT_SSL_3 = 7445; private static final String SLOT_1_KEY = "8HMdi"; + private static final String SLOT_16352_KEY = "UyAa4KqoWgPGKa"; private static RedisURI redisURI = RedisURI.Builder.redis(host(), CLUSTER_PORT_SSL_1).withPassword("foobared").withSsl(true) .withVerifyPeer(false).build(); + private static RedisClusterClient redisClient = RedisClusterClient.create(TestClientResources.get(), redisURI); @BeforeEach @@ -157,4 +160,5 @@ void clusterNodeRefreshWorksForMultipleIterations() { redisClient.reloadPartitions(); redisClient.reloadPartitions(); } + } diff --git a/src/test/java/io/lettuce/core/cluster/RedisClusterReadFromIntegrationTests.java b/src/test/java/io/lettuce/core/cluster/RedisClusterReadFromIntegrationTests.java index b6e05ed1f9..d3543b7c40 100644 --- a/src/test/java/io/lettuce/core/cluster/RedisClusterReadFromIntegrationTests.java +++ b/src/test/java/io/lettuce/core/cluster/RedisClusterReadFromIntegrationTests.java @@ -45,7 +45,9 @@ class RedisClusterReadFromIntegrationTests extends TestSupport { private final RedisClusterClient clusterClient; + private StatefulRedisClusterConnection connection; + private RedisAdvancedClusterCommands sync; @Inject diff --git a/src/test/java/io/lettuce/core/cluster/RedisClusterSetupTest.java b/src/test/java/io/lettuce/core/cluster/RedisClusterSetupTest.java index dd02aece4e..ce956e0dea 100644 --- a/src/test/java/io/lettuce/core/cluster/RedisClusterSetupTest.java +++ b/src/test/java/io/lettuce/core/cluster/RedisClusterSetupTest.java @@ -83,10 +83,13 @@ public class RedisClusterSetupTest extends TestSupport { .enablePeriodicRefresh(Duration.ofSeconds(1)).dynamicRefreshSources(false).build(); private static RedisClusterClient clusterClient; + private static RedisClient client = DefaultRedisClient.get(); + private static ClusterTestHelper clusterHelper; private RedisCommands redis1; + private RedisCommands redis2; @BeforeAll @@ -309,8 +312,8 @@ public void disconnectedConnectionRejectTest() throws Exception { assertRoutedExecution(clusterConnection); RedisClusterNode partition1 = getOwnPartition(redis1); - RedisClusterAsyncCommands node1Connection = clusterConnection.getConnection(partition1.getUri() - .getHost(), partition1.getUri().getPort()); + RedisClusterAsyncCommands node1Connection = clusterConnection + .getConnection(partition1.getUri().getHost(), partition1.getUri().getPort()); shiftAllSlotsToNode1(); @@ -321,7 +324,7 @@ public void disconnectedConnectionRejectTest() throws Exception { set.await(5, TimeUnit.SECONDS); assertThatThrownBy(() -> TestFutures.awaitOrTimeout(set)).hasRootCauseInstanceOf(RedisException.class); - clusterConnection.getStatefulConnection().close(); + clusterConnection.getStatefulConnection().close(); } @Test @@ -336,11 +339,11 @@ public void atLeastOnceForgetNodeFailover() throws Exception { RedisClusterNode partition1 = getOwnPartition(redis1); RedisClusterNode partition2 = getOwnPartition(redis2); - RedisClusterAsyncCommands node1Connection = clusterConnection.getConnection(partition1.getUri() - .getHost(), partition1.getUri().getPort()); + RedisClusterAsyncCommands node1Connection = clusterConnection + .getConnection(partition1.getUri().getHost(), partition1.getUri().getPort()); - RedisClusterAsyncCommands node2Connection = clusterConnection.getConnection(partition2.getUri() - .getHost(), partition2.getUri().getPort()); + RedisClusterAsyncCommands node2Connection = clusterConnection + .getConnection(partition2.getUri().getHost(), partition2.getUri().getPort()); shiftAllSlotsToNode1(); @@ -447,7 +450,8 @@ public void expireStaleNodeIdConnections() { ClusterSetup.setup2Masters(clusterHelper); - PooledClusterConnectionProvider clusterConnectionProvider = getPooledClusterConnectionProvider(clusterConnection); + PooledClusterConnectionProvider clusterConnectionProvider = getPooledClusterConnectionProvider( + clusterConnection); assertThat(clusterConnectionProvider.getConnectionCount()).isEqualTo(0); @@ -490,7 +494,8 @@ public void doNotExpireStaleNodeIdConnections() throws Exception { ClusterSetup.setup2Masters(clusterHelper); - PooledClusterConnectionProvider clusterConnectionProvider = getPooledClusterConnectionProvider(clusterConnection); + PooledClusterConnectionProvider clusterConnectionProvider = getPooledClusterConnectionProvider( + clusterConnection); assertThat(clusterConnectionProvider.getConnectionCount()).isEqualTo(0); @@ -528,7 +533,8 @@ public void expireStaleHostAndPortConnections() throws Exception { ClusterSetup.setup2Masters(clusterHelper); - final PooledClusterConnectionProvider clusterConnectionProvider = getPooledClusterConnectionProvider(clusterConnection); + final PooledClusterConnectionProvider clusterConnectionProvider = getPooledClusterConnectionProvider( + clusterConnection); assertThat(clusterConnectionProvider.getConnectionCount()).isEqualTo(0); @@ -634,6 +640,7 @@ private void shiftAllSlotsToNode1() { RedisClusterNode redis2Partition = getOwnPartition(redis2); Wait.untilTrue(new Supplier() { + @Override public Boolean get() { Partitions partitions = ClusterPartitionParser.parse(redis1.clusterNodes()); @@ -653,6 +660,7 @@ private void removeRemaining(RedisClusterNode partition) { // ignore } } + }).waitOrTimeout(); redis1.clusterAddSlots(createSlots(12000, 16384)); @@ -668,4 +676,5 @@ private int[] toIntArray(List list) { private void waitForSlots(RedisClusterCommands connection, int slotCount) { Wait.untilEquals(slotCount, () -> getOwnPartition(connection).getSlots().size()).waitOrTimeout(); } + } diff --git a/src/test/java/io/lettuce/core/cluster/RedisClusterStressScenariosTest.java b/src/test/java/io/lettuce/core/cluster/RedisClusterStressScenariosTest.java index 521b05c8a5..5887a7edc8 100644 --- a/src/test/java/io/lettuce/core/cluster/RedisClusterStressScenariosTest.java +++ b/src/test/java/io/lettuce/core/cluster/RedisClusterStressScenariosTest.java @@ -59,18 +59,23 @@ public class RedisClusterStressScenariosTest extends TestSupport { private static final String host = TestSettings.hostAddr(); private static RedisClient client; + private static RedisClusterClient clusterClient; + private static ClusterTestHelper clusterHelper; private Logger log = LogManager.getLogger(getClass()); private StatefulRedisConnection redis5; + private StatefulRedisConnection redis6; private RedisCommands redissync5; + private RedisCommands redissync6; protected String key = "key"; + protected String value = "value"; @BeforeAll diff --git a/src/test/java/io/lettuce/core/cluster/RedisClusterURIUtilUnitTests.java b/src/test/java/io/lettuce/core/cluster/RedisClusterURIUtilUnitTests.java index 801417cef2..e0e707eecc 100644 --- a/src/test/java/io/lettuce/core/cluster/RedisClusterURIUtilUnitTests.java +++ b/src/test/java/io/lettuce/core/cluster/RedisClusterURIUtilUnitTests.java @@ -94,4 +94,5 @@ void testSslWithPasswordMultipleHosts() { assertThat(host2.getHost()).isEqualTo("host2"); assertThat(host2.getPort()).isEqualTo(6380); } + } diff --git a/src/test/java/io/lettuce/core/cluster/RedisReactiveClusterClientIntegrationTests.java b/src/test/java/io/lettuce/core/cluster/RedisReactiveClusterClientIntegrationTests.java index ad96ced7ed..0ab13d2b0c 100644 --- a/src/test/java/io/lettuce/core/cluster/RedisReactiveClusterClientIntegrationTests.java +++ b/src/test/java/io/lettuce/core/cluster/RedisReactiveClusterClientIntegrationTests.java @@ -24,6 +24,7 @@ class RedisReactiveClusterClientIntegrationTests extends TestSupport { private final RedisAdvancedClusterCommands sync; + private final RedisAdvancedClusterReactiveCommands reactive; @Inject @@ -50,10 +51,10 @@ void getKeysInSlot() { sync.set(ClusterTestSettings.KEY_A, value); sync.set(ClusterTestSettings.KEY_B, value); - StepVerifier.create(reactive.clusterGetKeysInSlot(ClusterTestSettings.SLOT_A, 10)) - .expectNext(ClusterTestSettings.KEY_A).verifyComplete(); - StepVerifier.create(reactive.clusterGetKeysInSlot(ClusterTestSettings.SLOT_B, 10)) - .expectNext(ClusterTestSettings.KEY_B).verifyComplete(); + StepVerifier.create(reactive.clusterGetKeysInSlot(ClusterTestSettings.SLOT_A, 10)).expectNext(ClusterTestSettings.KEY_A) + .verifyComplete(); + StepVerifier.create(reactive.clusterGetKeysInSlot(ClusterTestSettings.SLOT_B, 10)).expectNext(ClusterTestSettings.KEY_B) + .verifyComplete(); } @Test @@ -97,4 +98,5 @@ void testClusterSetConfigEpoch() { assertThat(e).hasMessageContaining("ERR The user can assign a config epoch only"); }).verify(); } + } diff --git a/src/test/java/io/lettuce/core/cluster/RoundRobinSocketAddressSupplierUnitTests.java b/src/test/java/io/lettuce/core/cluster/RoundRobinSocketAddressSupplierUnitTests.java index 8b9ca68d38..f19a3ec4ff 100644 --- a/src/test/java/io/lettuce/core/cluster/RoundRobinSocketAddressSupplierUnitTests.java +++ b/src/test/java/io/lettuce/core/cluster/RoundRobinSocketAddressSupplierUnitTests.java @@ -50,15 +50,23 @@ class RoundRobinSocketAddressSupplierUnitTests { private static RedisURI hap1 = new RedisURI("127.0.0.1", 1, Duration.ofSeconds(1)); + private static RedisURI hap2 = new RedisURI("127.0.0.1", 2, Duration.ofSeconds(1)); + private static RedisURI hap3 = new RedisURI("127.0.0.1", 3, Duration.ofSeconds(1)); + private static RedisURI hap4 = new RedisURI("127.0.0.1", 4, Duration.ofSeconds(1)); + private static RedisURI hap5 = new RedisURI("127.0.0.0", 5, Duration.ofSeconds(1)); private static InetSocketAddress addr1 = new InetSocketAddress(hap1.getHost(), hap1.getPort()); + private static InetSocketAddress addr2 = new InetSocketAddress(hap2.getHost(), hap2.getPort()); + private static InetSocketAddress addr3 = new InetSocketAddress(hap3.getHost(), hap3.getPort()); + private static InetSocketAddress addr4 = new InetSocketAddress(hap4.getHost(), hap4.getPort()); + private static InetSocketAddress addr5 = new InetSocketAddress(hap5.getHost(), hap5.getPort()); private static Partitions partitions; @@ -66,7 +74,6 @@ class RoundRobinSocketAddressSupplierUnitTests { @Mock private ClientResources clientResourcesMock; - @BeforeEach void before() { @@ -145,4 +152,5 @@ void partitionTableChangesNodeRemoved() { assertThat(sut.get()).isEqualTo(addr2); assertThat(sut.get()).isEqualTo(addr1); } + } diff --git a/src/test/java/io/lettuce/core/cluster/ScanIteratorIntegrationTests.java b/src/test/java/io/lettuce/core/cluster/ScanIteratorIntegrationTests.java index 966878a7b6..67524a46f8 100644 --- a/src/test/java/io/lettuce/core/cluster/ScanIteratorIntegrationTests.java +++ b/src/test/java/io/lettuce/core/cluster/ScanIteratorIntegrationTests.java @@ -53,6 +53,7 @@ class ScanIteratorIntegrationTests extends TestSupport { private final StatefulRedisClusterConnection connection; + private final RedisClusterCommands redis; @Inject @@ -149,8 +150,7 @@ void hscanNovaluesShouldThrowNoSuchElementExceptionOnEmpty() { redis.mset(KeysAndValues.MAP); - ScanIterator scan = ScanIterator.hscanNovalues(redis, "none", - ScanArgs.Builder.limit(50).match("key-foo")); + ScanIterator scan = ScanIterator.hscanNovalues(redis, "none", ScanArgs.Builder.limit(50).match("key-foo")); assertThat(scan.hasNext()).isFalse(); try { @@ -185,8 +185,7 @@ void hashNovaluesSinglePass() { redis.hmset(key, KeysAndValues.MAP); - ScanIterator scan = ScanIterator.hscanNovalues(redis, key, - ScanArgs.Builder.limit(50).match("key-11*")); + ScanIterator scan = ScanIterator.hscanNovalues(redis, key, ScanArgs.Builder.limit(50).match("key-11*")); for (int i = 0; i < 11; i++) { assertThat(scan.hasNext()).isTrue(); @@ -322,4 +321,5 @@ void zsetMultiPass() { assertThat(values).containsAll(values); } + } diff --git a/src/test/java/io/lettuce/core/cluster/ScanStreamIntegrationTests.java b/src/test/java/io/lettuce/core/cluster/ScanStreamIntegrationTests.java index 090a36f63b..621ddb1b19 100644 --- a/src/test/java/io/lettuce/core/cluster/ScanStreamIntegrationTests.java +++ b/src/test/java/io/lettuce/core/cluster/ScanStreamIntegrationTests.java @@ -21,6 +21,7 @@ class ScanStreamIntegrationTests extends TestSupport { private final StatefulRedisClusterConnection connection; + private final RedisClusterCommands redis; @Inject @@ -43,4 +44,5 @@ void shouldScanIteratively() { .verifyComplete(); StepVerifier.create(ScanStream.scan(reactive)).expectNextCount(1000).verifyComplete(); } + } diff --git a/src/test/java/io/lettuce/core/cluster/SingleThreadedReactiveClusterClientIntegrationTests.java b/src/test/java/io/lettuce/core/cluster/SingleThreadedReactiveClusterClientIntegrationTests.java index cd0afa6bae..fcf4fdbbd7 100644 --- a/src/test/java/io/lettuce/core/cluster/SingleThreadedReactiveClusterClientIntegrationTests.java +++ b/src/test/java/io/lettuce/core/cluster/SingleThreadedReactiveClusterClientIntegrationTests.java @@ -55,4 +55,5 @@ void shouldPropagateAsynchronousConnections() { assertThat(keys).contains("key", "foo"); } + } diff --git a/src/test/java/io/lettuce/core/cluster/SlotHashUnitTests.java b/src/test/java/io/lettuce/core/cluster/SlotHashUnitTests.java index d65e166ab2..b7b26c029a 100644 --- a/src/test/java/io/lettuce/core/cluster/SlotHashUnitTests.java +++ b/src/test/java/io/lettuce/core/cluster/SlotHashUnitTests.java @@ -13,6 +13,7 @@ class SlotHashUnitTests { private static final byte[] BYTES = "123456789".getBytes(); + private static final byte[] TAGGED = "key{123456789}a".getBytes(); @Test @@ -42,4 +43,5 @@ void testHashWithHash() { int result = SlotHash.getSlot((ByteBuffer) ByteBuffer.allocateDirect(TAGGED.length).put(TAGGED).flip()); assertThat(result).isEqualTo(0x31C3); } + } diff --git a/src/test/java/io/lettuce/core/cluster/commands/ListClusterCommandIntegrationTests.java b/src/test/java/io/lettuce/core/cluster/commands/ListClusterCommandIntegrationTests.java index 9da426849e..145278a491 100644 --- a/src/test/java/io/lettuce/core/cluster/commands/ListClusterCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/cluster/commands/ListClusterCommandIntegrationTests.java @@ -27,7 +27,6 @@ class ListClusterCommandIntegrationTests extends ListCommandIntegrationTests { this.redis = connection.sync(); } - // re-implementation because keys have to be on the same slot @Test void brpoplpush() { @@ -39,7 +38,6 @@ void brpoplpush() { assertThat(redis.lrange("br7EPz9bbj", 0, -1)).isEqualTo(list("2", "3", "4")); } - @Test void brpoplpushTimeout() { assertThat(redis.brpoplpush(1, "UKPDHs8Zlp", "br7EPz9bbj")).isNull(); @@ -90,4 +88,5 @@ void rpoplpush() { assertThat(redis.lrange("UKPDHs8Zlp", 0, -1)).isEqualTo(list("1")); assertThat(redis.lrange("br7EPz9bbj", 0, -1)).isEqualTo(list("2", "3", "4")); } + } diff --git a/src/test/java/io/lettuce/core/cluster/commands/reactive/HashClusterReactiveCommandIntegrationTests.java b/src/test/java/io/lettuce/core/cluster/commands/reactive/HashClusterReactiveCommandIntegrationTests.java index b1040875a9..6da2e608d0 100644 --- a/src/test/java/io/lettuce/core/cluster/commands/reactive/HashClusterReactiveCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/cluster/commands/reactive/HashClusterReactiveCommandIntegrationTests.java @@ -30,4 +30,5 @@ public void hgetall() { public void hgetallStreaming() { } + } diff --git a/src/test/java/io/lettuce/core/cluster/commands/reactive/StringClusterReactiveCommandIntegrationTests.java b/src/test/java/io/lettuce/core/cluster/commands/reactive/StringClusterReactiveCommandIntegrationTests.java index 492c1070ae..651bd529b2 100644 --- a/src/test/java/io/lettuce/core/cluster/commands/reactive/StringClusterReactiveCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/cluster/commands/reactive/StringClusterReactiveCommandIntegrationTests.java @@ -24,6 +24,7 @@ class StringClusterReactiveCommandIntegrationTests extends StringCommandIntegrationTests { private final StatefulRedisClusterConnection connection; + private final RedisClusterCommands redis; @Inject @@ -58,4 +59,5 @@ void mget() { Flux> mget = reactive.mget(key, "key1", "key2"); StepVerifier.create(mget.next()).expectNext(KeyValue.just(key, value)).verifyComplete(); } + } diff --git a/src/test/java/io/lettuce/core/cluster/models/partitions/RedisClusterNodeUnitTests.java b/src/test/java/io/lettuce/core/cluster/models/partitions/RedisClusterNodeUnitTests.java index fa694b9c2d..4c0d02fc53 100644 --- a/src/test/java/io/lettuce/core/cluster/models/partitions/RedisClusterNodeUnitTests.java +++ b/src/test/java/io/lettuce/core/cluster/models/partitions/RedisClusterNodeUnitTests.java @@ -54,4 +54,5 @@ void testToString() { assertThat(node.toString()).contains(RedisClusterNode.class.getSimpleName()); } + } diff --git a/src/test/java/io/lettuce/core/cluster/models/slots/ClusterSlotsParserUnitTests.java b/src/test/java/io/lettuce/core/cluster/models/slots/ClusterSlotsParserUnitTests.java index a67ec113fe..9a47ad0894 100644 --- a/src/test/java/io/lettuce/core/cluster/models/slots/ClusterSlotsParserUnitTests.java +++ b/src/test/java/io/lettuce/core/cluster/models/slots/ClusterSlotsParserUnitTests.java @@ -116,4 +116,5 @@ void testModel() { assertThat(range.toString()).contains(ClusterSlotRange.class.getSimpleName()); } + } diff --git a/src/test/java/io/lettuce/core/cluster/pubsub/RedisClusterPubSubConnectionIntegrationTests.java b/src/test/java/io/lettuce/core/cluster/pubsub/RedisClusterPubSubConnectionIntegrationTests.java index c4a808fad9..bae62bc55f 100644 --- a/src/test/java/io/lettuce/core/cluster/pubsub/RedisClusterPubSubConnectionIntegrationTests.java +++ b/src/test/java/io/lettuce/core/cluster/pubsub/RedisClusterPubSubConnectionIntegrationTests.java @@ -99,10 +99,10 @@ void testRegularClientPubSubShardChannels() { pubSubConnection.sync().ssubscribe(shardChannel); Integer clusterKeyslot = connection.sync().clusterKeyslot(shardChannel).intValue(); - RedisCommands rightSlot = - connection.sync().nodes(node -> node.getSlots().contains(clusterKeyslot)).commands(0); - RedisCommands wrongSlot = - connection.sync().nodes(node -> !node.getSlots().contains(clusterKeyslot)).commands(0); + RedisCommands rightSlot = connection.sync().nodes(node -> node.getSlots().contains(clusterKeyslot)) + .commands(0); + RedisCommands wrongSlot = connection.sync().nodes(node -> !node.getSlots().contains(clusterKeyslot)) + .commands(0); List channelsOnSubscribedNode = rightSlot.pubsubShardChannels(); assertThat(channelsOnSubscribedNode).hasSize(1); @@ -113,7 +113,7 @@ void testRegularClientPubSubShardChannels() { @Test @EnabledOnCommand("SSUBSCRIBE") - void subscribeToShardChannel(){ + void subscribeToShardChannel() { pubSubConnection.sync().ssubscribe(shardChannel); Wait.untilEquals(1L, connectionListener.getShardCounts()::poll).waitOrTimeout(); @@ -126,8 +126,8 @@ void subscribeToShardChannelViaReplica() { int clusterKeyslot = connection.sync().clusterKeyslot(shardChannel).intValue(); String thisNode = connection.getPartitions().getPartitionBySlot(clusterKeyslot).getNodeId(); - RedisPubSubAsyncCommands replica = - pubSubConnection.async().nodes(node -> thisNode.equals(node.getSlaveOf())).commands(0); + RedisPubSubAsyncCommands replica = pubSubConnection.async() + .nodes(node -> thisNode.equals(node.getSlaveOf())).commands(0); replica.ssubscribe(shardChannel); Wait.untilEquals(shardChannel, connectionListener.getShardChannels()::poll).waitOrTimeout(); diff --git a/src/test/java/io/lettuce/core/cluster/topology/RequestsUnitTests.java b/src/test/java/io/lettuce/core/cluster/topology/RequestsUnitTests.java index 5a96533a3e..fcf3f0e8dd 100644 --- a/src/test/java/io/lettuce/core/cluster/topology/RequestsUnitTests.java +++ b/src/test/java/io/lettuce/core/cluster/topology/RequestsUnitTests.java @@ -86,4 +86,5 @@ private TimedAsyncCommand getCommand(String response) { timedAsyncCommand.complete(); return timedAsyncCommand; } + } diff --git a/src/test/java/io/lettuce/core/cluster/topology/TopologyComparatorsUnitTests.java b/src/test/java/io/lettuce/core/cluster/topology/TopologyComparatorsUnitTests.java index c1a69cefa1..5e027077d7 100644 --- a/src/test/java/io/lettuce/core/cluster/topology/TopologyComparatorsUnitTests.java +++ b/src/test/java/io/lettuce/core/cluster/topology/TopologyComparatorsUnitTests.java @@ -43,7 +43,9 @@ class TopologyComparatorsUnitTests { private RedisClusterNodeSnapshot node1 = createNode("1"); + private RedisClusterNodeSnapshot node2 = createNode("2"); + private RedisClusterNodeSnapshot node3 = createNode("3"); private static RedisClusterNodeSnapshot createNode(String nodeId) { @@ -367,4 +369,5 @@ void runTest(Map map, List expectation, assertThat(result).containsExactly(expectation.toArray(new RedisClusterNodeSnapshot[expectation.size()])); } + } diff --git a/src/test/java/io/lettuce/core/codec/CipherCodecUnitTests.java b/src/test/java/io/lettuce/core/codec/CipherCodecUnitTests.java index a05bdc6392..c6f8c1e654 100644 --- a/src/test/java/io/lettuce/core/codec/CipherCodecUnitTests.java +++ b/src/test/java/io/lettuce/core/codec/CipherCodecUnitTests.java @@ -30,10 +30,13 @@ class CipherCodecUnitTests { private final SecretKeySpec key = new SecretKeySpec("1234567890123456".getBytes(), "AES"); + private final IvParameterSpec iv = new IvParameterSpec("1234567890123456".getBytes()); + private final String transform = "AES/CBC/PKCS5Padding"; CipherCodec.CipherSupplier encrypt = new CipherCodec.CipherSupplier() { + @Override public Cipher get(CipherCodec.KeyDescriptor keyDescriptor) throws GeneralSecurityException { @@ -46,6 +49,7 @@ public Cipher get(CipherCodec.KeyDescriptor keyDescriptor) throws GeneralSecurit public CipherCodec.KeyDescriptor encryptionKey() { return CipherCodec.KeyDescriptor.create("foobar", 142); } + }; CipherCodec.CipherSupplier decrypt = (CipherCodec.KeyDescriptor keyDescriptor) -> { @@ -106,8 +110,8 @@ void shouldDecryptValue() { RedisCodec crypto = CipherCodec.forValues(StringCodec.UTF8, encrypt, decrypt); - ByteBuffer encrypted = ByteBuffer.wrap(new byte[] { 36, 43, 48, 36, -99, -39, 126, -106, -7, -88, 118, -74, 42, 98, - 117, 81, 37, -124, 26, -88 });// crypto.encodeValue("foobar"); + ByteBuffer encrypted = ByteBuffer.wrap( + new byte[] { 36, 43, 48, 36, -99, -39, 126, -106, -7, -88, 118, -74, 42, 98, 117, 81, 37, -124, 26, -88 });// crypto.encodeValue("foobar"); String result = crypto.decodeValue(encrypted); assertThat(result).isEqualTo("foobar"); @@ -123,6 +127,7 @@ void shouldRejectPlusAndDollarKeyNames() { static class CryptoTestArgs { private final int size; + private final String content; public CryptoTestArgs(String content) { @@ -138,5 +143,7 @@ public String toString() { sb.append(']'); return sb.toString(); } + } + } diff --git a/src/test/java/io/lettuce/core/codec/CompressionCodecUnitTests.java b/src/test/java/io/lettuce/core/codec/CompressionCodecUnitTests.java index 1dc1f1213a..0351d9a51a 100644 --- a/src/test/java/io/lettuce/core/codec/CompressionCodecUnitTests.java +++ b/src/test/java/io/lettuce/core/codec/CompressionCodecUnitTests.java @@ -15,9 +15,12 @@ class CompressionCodecUnitTests { private String key = "key"; + private byte[] keyGzipBytes = new byte[] { 31, -117, 8, 0, 0, 0, 0, 0, 0, 0, -53, 78, -83, 4, 0, -87, -85, -112, -118, 3, 0, 0, 0 }; + private byte[] keyDeflateBytes = new byte[] { 120, -100, -53, 78, -83, 4, 0, 2, -121, 1, 74 }; + private String value = "value"; @Test @@ -56,8 +59,7 @@ void wrongCompressionTypeOnDecode() { RedisCodec sut = CompressionCodec.valueCompressor(StringCodec.UTF8, CompressionCodec.CompressionType.DEFLATE); - assertThatThrownBy(() -> sut.decodeValue(ByteBuffer.wrap(keyGzipBytes))) - .isInstanceOf(IllegalStateException.class); + assertThatThrownBy(() -> sut.decodeValue(ByteBuffer.wrap(keyGzipBytes))).isInstanceOf(IllegalStateException.class); } private String toString(ByteBuffer buffer) { @@ -70,4 +72,5 @@ private byte[] toBytes(ByteBuffer buffer) { buffer.get(bytes); return bytes; } + } diff --git a/src/test/java/io/lettuce/core/codec/StringCodecUnitTests.java b/src/test/java/io/lettuce/core/codec/StringCodecUnitTests.java index 0b41407131..8dfdd1ca56 100644 --- a/src/test/java/io/lettuce/core/codec/StringCodecUnitTests.java +++ b/src/test/java/io/lettuce/core/codec/StringCodecUnitTests.java @@ -39,6 +39,7 @@ class StringCodecUnitTests { private String teststring = "hello üäü~∑†®†ª€∂‚¶¢ Wørld"; + private String teststringPlain = "hello uufadsfasdfadssdfadfs"; @Test @@ -129,10 +130,9 @@ void estimateSize() { void sizeOf() { assertThat(new StringCodec(StandardCharsets.UTF_8).sizeOf(teststring, false)) - .isEqualTo(ByteBufUtil.utf8MaxBytes(teststring)); - assertThat(new StringCodec(StandardCharsets.US_ASCII).sizeOf(teststring, false)) - .isEqualTo(teststring.length()); - assertThat(new StringCodec(StandardCharsets.ISO_8859_1).sizeOf(teststring, false)) - .isEqualTo(teststring.length()); + .isEqualTo(ByteBufUtil.utf8MaxBytes(teststring)); + assertThat(new StringCodec(StandardCharsets.US_ASCII).sizeOf(teststring, false)).isEqualTo(teststring.length()); + assertThat(new StringCodec(StandardCharsets.ISO_8859_1).sizeOf(teststring, false)).isEqualTo(teststring.length()); } + } diff --git a/src/test/java/io/lettuce/core/commands/BitCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/BitCommandIntegrationTests.java index 4ecd8d0c40..2752bc813c 100644 --- a/src/test/java/io/lettuce/core/commands/BitCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/BitCommandIntegrationTests.java @@ -53,6 +53,7 @@ public class BitCommandIntegrationTests extends TestSupport { private final RedisClient client; + private final RedisCommands redis; protected RedisCommands bitstring; diff --git a/src/test/java/io/lettuce/core/commands/BitStringCodec.java b/src/test/java/io/lettuce/core/commands/BitStringCodec.java index 002f96e088..e1f7b2cab2 100644 --- a/src/test/java/io/lettuce/core/commands/BitStringCodec.java +++ b/src/test/java/io/lettuce/core/commands/BitStringCodec.java @@ -20,4 +20,5 @@ public String decodeValue(ByteBuffer bytes) { } return bits.toString(); } + } diff --git a/src/test/java/io/lettuce/core/commands/CustomCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/CustomCommandIntegrationTests.java index dac8934922..ceb49722e2 100644 --- a/src/test/java/io/lettuce/core/commands/CustomCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/CustomCommandIntegrationTests.java @@ -72,8 +72,8 @@ void setUp() { @Test void dispatchSet() { - String response = redis.dispatch(MyCommands.SET, new StatusOutput<>(StringCodec.UTF8), new CommandArgs<>( - StringCodec.UTF8).addKey(key).addValue(value)); + String response = redis.dispatch(MyCommands.SET, new StatusOutput<>(StringCodec.UTF8), + new CommandArgs<>(StringCodec.UTF8).addKey(key).addValue(value)); assertThat(response).isEqualTo("OK"); } @@ -106,17 +106,16 @@ void dispatchNoOutputButError() { void dispatchShouldFailForWrongDataType() { redis.hset(key, key, value); - assertThatThrownBy( - () -> redis.dispatch(CommandType.GET, new StatusOutput<>(StringCodec.UTF8), - new CommandArgs<>(StringCodec.UTF8).addKey(key))).isInstanceOf(RedisCommandExecutionException.class); + assertThatThrownBy(() -> redis.dispatch(CommandType.GET, new StatusOutput<>(StringCodec.UTF8), + new CommandArgs<>(StringCodec.UTF8).addKey(key))).isInstanceOf(RedisCommandExecutionException.class); } @Test void dispatchTransactions() { redis.multi(); - String response = redis.dispatch(CommandType.SET, new StatusOutput<>(StringCodec.UTF8), new CommandArgs<>( - StringCodec.UTF8).addKey(key).addValue(value)); + String response = redis.dispatch(CommandType.SET, new StatusOutput<>(StringCodec.UTF8), + new CommandArgs<>(StringCodec.UTF8).addKey(key).addValue(value)); TransactionResult exec = redis.exec(); @@ -201,6 +200,7 @@ private StatefulRedisConnection getStandaloneConnection() { } public enum MyCommands implements ProtocolKeyword { + PING, SET, INFO; private final byte name[]; @@ -214,5 +214,7 @@ public enum MyCommands implements ProtocolKeyword { public byte[] getBytes() { return name; } + } + } diff --git a/src/test/java/io/lettuce/core/commands/HLLCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/HLLCommandIntegrationTests.java index 5adcab1a97..7749a2fd50 100644 --- a/src/test/java/io/lettuce/core/commands/HLLCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/HLLCommandIntegrationTests.java @@ -106,4 +106,5 @@ void pfaddPfmergePfCount() { assertThat(redis.pfcount("key8885")).isEqualTo(3); } + } diff --git a/src/test/java/io/lettuce/core/commands/HashCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/HashCommandIntegrationTests.java index b87102505d..e6431f97a7 100644 --- a/src/test/java/io/lettuce/core/commands/HashCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/HashCommandIntegrationTests.java @@ -63,8 +63,11 @@ @ExtendWith(LettuceExtension.class) @TestInstance(TestInstance.Lifecycle.PER_CLASS) public class HashCommandIntegrationTests extends TestSupport { + public static final String MY_KEY = "hKey"; + public static final String MY_FIELD = "hField"; + public static final String MY_VALUE = "hValue"; private final RedisCommands redis; @@ -82,8 +85,8 @@ void setUp() { @AfterEach void tearDown() { // resets the configuration settings to default, would not be needed once listpack is supported - assertThat(redis.configSet("hash-max-listpack-entries","512")).isEqualTo("OK"); - assertThat(redis.configSet("set-max-listpack-value","64")).isEqualTo("OK"); + assertThat(redis.configSet("hash-max-listpack-entries", "512")).isEqualTo("OK"); + assertThat(redis.configSet("set-max-listpack-value", "64")).isEqualTo("OK"); } @Test @@ -561,8 +564,8 @@ void hscanNoValuesMatch() { void hexpire() { // the below settings are required until the solution is able to support listpack entries // see TODOs in https://github.com/redis/redis/pull/13172 for more details - assertThat(redis.configSet("hash-max-listpack-entries","0")).isEqualTo("OK"); - assertThat(redis.configSet("set-max-listpack-value","0")).isEqualTo("OK"); + assertThat(redis.configSet("hash-max-listpack-entries", "0")).isEqualTo("OK"); + assertThat(redis.configSet("set-max-listpack-value", "0")).isEqualTo("OK"); assertThat(redis.hset(MY_KEY, MY_FIELD, MY_VALUE)).isTrue(); assertThat(redis.hexpire(MY_KEY, 1, MY_FIELD)).isTrue(); @@ -575,8 +578,8 @@ void hexpire() { void hexpireExpireArgs() { // the below settings are required until the solution is able to support listpack entries // see TODOs in https://github.com/redis/redis/pull/13172 for more details - assertThat(redis.configSet("hash-max-listpack-entries","0")).isEqualTo("OK"); - assertThat(redis.configSet("set-max-listpack-value","0")).isEqualTo("OK"); + assertThat(redis.configSet("hash-max-listpack-entries", "0")).isEqualTo("OK"); + assertThat(redis.configSet("set-max-listpack-value", "0")).isEqualTo("OK"); assertThat(redis.hset(MY_KEY, MY_FIELD, MY_VALUE)).isTrue(); assertThat(redis.hexpire(MY_KEY, Duration.ofSeconds(1), ExpireArgs.Builder.nx(), MY_FIELD)).isTrue(); @@ -592,11 +595,11 @@ void hexpireExpireArgs() { void hexpireat() { // the below settings are required until the solution is able to support listpack entries // see TODOs in https://github.com/redis/redis/pull/13172 for more details - assertThat(redis.configSet("hash-max-listpack-entries","0")).isEqualTo("OK"); - assertThat(redis.configSet("set-max-listpack-value","0")).isEqualTo("OK"); + assertThat(redis.configSet("hash-max-listpack-entries", "0")).isEqualTo("OK"); + assertThat(redis.configSet("set-max-listpack-value", "0")).isEqualTo("OK"); assertThat(redis.hset(MY_KEY, MY_FIELD, MY_VALUE)).isTrue(); - assertThat(redis.hexpireat(MY_KEY,Instant.now().plusSeconds(1) , MY_FIELD)).isTrue(); + assertThat(redis.hexpireat(MY_KEY, Instant.now().plusSeconds(1), MY_FIELD)).isTrue(); await().until(() -> redis.hget(MY_KEY, MY_FIELD) == null); } @@ -607,8 +610,8 @@ void hexpiretime() { Date expiration = new Date(System.currentTimeMillis() + 10000); // the below settings are required until the solution is able to support listpack entries // see TODOs in https://github.com/redis/redis/pull/13172 for more details - assertThat(redis.configSet("hash-max-listpack-entries","0")).isEqualTo("OK"); - assertThat(redis.configSet("set-max-listpack-value","0")).isEqualTo("OK"); + assertThat(redis.configSet("hash-max-listpack-entries", "0")).isEqualTo("OK"); + assertThat(redis.configSet("set-max-listpack-value", "0")).isEqualTo("OK"); assertThat(redis.hset(MY_KEY, MY_FIELD, MY_VALUE)).isTrue(); assertThat(redis.hexpireat(MY_KEY, expiration, MY_FIELD)).isTrue(); @@ -621,8 +624,8 @@ void hexpiretime() { void persist() { // the below settings are required until the solution is able to support listpack entries // see TODOs in https://github.com/redis/redis/pull/13172 for more details - assertThat(redis.configSet("hash-max-listpack-entries","0")).isEqualTo("OK"); - assertThat(redis.configSet("set-max-listpack-value","0")).isEqualTo("OK"); + assertThat(redis.configSet("hash-max-listpack-entries", "0")).isEqualTo("OK"); + assertThat(redis.configSet("set-max-listpack-value", "0")).isEqualTo("OK"); assertThat(redis.hpersist(MY_KEY, MY_FIELD)).isFalse(); assertThat(redis.hset(MY_KEY, MY_FIELD, MY_VALUE)).isTrue(); @@ -638,4 +641,5 @@ void setup100KeyValues(Map expect) { redis.hmset(key, expect); } + } diff --git a/src/test/java/io/lettuce/core/commands/NumericCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/NumericCommandIntegrationTests.java index 0bf5779e0c..6a2a7c1000 100644 --- a/src/test/java/io/lettuce/core/commands/NumericCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/NumericCommandIntegrationTests.java @@ -83,4 +83,5 @@ void incrbyfloat() { assertThat(redis.incrbyfloat(key, 3.0)).isEqualTo(3.0, offset(0.1)); assertThat(redis.incrbyfloat(key, 0.2)).isEqualTo(3.2, offset(0.1)); } + } diff --git a/src/test/java/io/lettuce/core/commands/RunOnlyOnceServerCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/RunOnlyOnceServerCommandIntegrationTests.java index bf158e033e..25d75291de 100644 --- a/src/test/java/io/lettuce/core/commands/RunOnlyOnceServerCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/RunOnlyOnceServerCommandIntegrationTests.java @@ -32,7 +32,9 @@ class RunOnlyOnceServerCommandIntegrationTests extends TestSupport { private final RedisClient client; + private final StatefulRedisConnection connection; + private final RedisCommands redis; @Inject @@ -94,8 +96,8 @@ void migrateCopyReplace() { String result = redis.migrate("localhost", TestSettings.port(2), 0, 10, MigrateArgs.Builder.keys(key).copy().replace()); assertThat(result).isEqualTo("OK"); - result = redis.migrate("localhost", TestSettings.port(2), 0, 10, MigrateArgs.Builder - .keys(Arrays.asList("key1", "key2")).replace()); + result = redis.migrate("localhost", TestSettings.port(2), 0, 10, + MigrateArgs.Builder.keys(Arrays.asList("key1", "key2")).replace()); assertThat(result).isEqualTo("OK"); } @@ -122,4 +124,5 @@ void shutdown() { commands.getStatefulConnection().close(); } } + } diff --git a/src/test/java/io/lettuce/core/commands/ServerCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/ServerCommandIntegrationTests.java index e9e8e35f61..610079abf0 100644 --- a/src/test/java/io/lettuce/core/commands/ServerCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/ServerCommandIntegrationTests.java @@ -208,7 +208,7 @@ void clientListExtended() { } @Test - @EnabledOnCommand("EVAL_RO") // Redis 7.0 + @EnabledOnCommand("EVAL_RO") // Redis 7.0 void clientNoEvict() { assertThat(redis.clientNoEvict(true)).isEqualTo("OK"); assertThat(redis.clientNoEvict(false)).isEqualTo("OK"); @@ -338,7 +338,7 @@ void configGet() { } @Test - @EnabledOnCommand("EVAL_RO") // Redis 7.0 + @EnabledOnCommand("EVAL_RO") // Redis 7.0 void configGetMultipleParameters() { assertThat(redis.configGet("maxmemory", "*max-*-entries*")).containsEntry("maxmemory", "0") .containsEntry("hash-max-listpack-entries", "512"); @@ -361,7 +361,7 @@ void configSet() { } @Test - @EnabledOnCommand("EVAL_RO") // Redis 7.0 + @EnabledOnCommand("EVAL_RO") // Redis 7.0 void configSetMultipleParameters() { Map original = redis.configGet("maxmemory", "hash-max-listpack-entries"); Map config = new HashMap<>(); diff --git a/src/test/java/io/lettuce/core/commands/SetCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/SetCommandIntegrationTests.java index 413b9f3b66..9f0d579eac 100644 --- a/src/test/java/io/lettuce/core/commands/SetCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/SetCommandIntegrationTests.java @@ -241,7 +241,7 @@ void sremEmpty() { @Test void sremNulls() { - assertThatThrownBy(() -> redis.srem(key, new String[0])).isInstanceOf(IllegalArgumentException. class); + assertThatThrownBy(() -> redis.srem(key, new String[0])).isInstanceOf(IllegalArgumentException.class); } @Test @@ -252,7 +252,7 @@ void sunion() { @Test void sunionEmpty() { - assertThatThrownBy(() -> redis.sunion()).isInstanceOf(IllegalArgumentException. class); + assertThatThrownBy(() -> redis.sunion()).isInstanceOf(IllegalArgumentException.class); } @Test diff --git a/src/test/java/io/lettuce/core/commands/StringCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/StringCommandIntegrationTests.java index 95539e5e5d..0bee9425fd 100644 --- a/src/test/java/io/lettuce/core/commands/StringCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/StringCommandIntegrationTests.java @@ -230,12 +230,12 @@ void setKeepTTL() { @Test void setNegativeEX() { - assertThatThrownBy(() -> redis.set(key, value, ex(-10))).isInstanceOf(RedisException. class); + assertThatThrownBy(() -> redis.set(key, value, ex(-10))).isInstanceOf(RedisException.class); } @Test void setNegativePX() { - assertThatThrownBy(() -> redis.set(key, value, px(-1000))).isInstanceOf(RedisException. class); + assertThatThrownBy(() -> redis.set(key, value, px(-1000))).isInstanceOf(RedisException.class); } @Test @@ -309,13 +309,11 @@ void time() { @EnabledOnCommand("STRALGO") void strAlgo() { - StringMatchResult matchResult = redis.stralgoLcs(StrAlgoArgs.Builder - .strings("ohmytext", "mynewtext")); + StringMatchResult matchResult = redis.stralgoLcs(StrAlgoArgs.Builder.strings("ohmytext", "mynewtext")); assertThat(matchResult.getMatchString()).isEqualTo("mytext"); // STRALGO LCS STRINGS a b - matchResult = redis.stralgoLcs(StrAlgoArgs.Builder - .strings("a", "b").minMatchLen(4).withIdx().withMatchLen()); + matchResult = redis.stralgoLcs(StrAlgoArgs.Builder.strings("a", "b").minMatchLen(4).withIdx().withMatchLen()); assertThat(matchResult.getMatchString()).isNullOrEmpty(); assertThat(matchResult.getLen()).isEqualTo(0); } @@ -340,8 +338,7 @@ void strAlgoUsingKeys() { @EnabledOnCommand("STRALGO") void strAlgoJustLen() { - StringMatchResult matchResult = redis.stralgoLcs(StrAlgoArgs.Builder - .strings("ohmytext", "mynewtext").justLen()); + StringMatchResult matchResult = redis.stralgoLcs(StrAlgoArgs.Builder.strings("ohmytext", "mynewtext").justLen()); assertThat(matchResult.getLen()).isEqualTo(6); } @@ -350,8 +347,7 @@ void strAlgoJustLen() { @EnabledOnCommand("STRALGO") void strAlgoWithMinMatchLen() { - StringMatchResult matchResult = redis.stralgoLcs(StrAlgoArgs.Builder - .strings("ohmytext", "mynewtext").minMatchLen(4)); + StringMatchResult matchResult = redis.stralgoLcs(StrAlgoArgs.Builder.strings("ohmytext", "mynewtext").minMatchLen(4)); assertThat(matchResult.getMatchString()).isEqualTo("mytext"); } @@ -361,8 +357,8 @@ void strAlgoWithMinMatchLen() { void strAlgoWithIdx() { // STRALGO LCS STRINGS ohmytext mynewtext IDX MINMATCHLEN 4 WITHMATCHLEN - StringMatchResult matchResult = redis.stralgoLcs(StrAlgoArgs.Builder - .strings("ohmytext", "mynewtext").minMatchLen(4).withIdx().withMatchLen()); + StringMatchResult matchResult = redis + .stralgoLcs(StrAlgoArgs.Builder.strings("ohmytext", "mynewtext").minMatchLen(4).withIdx().withMatchLen()); assertThat(matchResult.getMatches()).hasSize(1); assertThat(matchResult.getMatches().get(0).getMatchLen()).isEqualTo(4); @@ -376,4 +372,5 @@ void strAlgoWithIdx() { assertThat(b.getEnd()).isEqualTo(8); assertThat(matchResult.getLen()).isEqualTo(6); } + } diff --git a/src/test/java/io/lettuce/core/commands/TransactionCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/TransactionCommandIntegrationTests.java index fc74c044d2..df8d6adf86 100644 --- a/src/test/java/io/lettuce/core/commands/TransactionCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/TransactionCommandIntegrationTests.java @@ -42,6 +42,7 @@ public class TransactionCommandIntegrationTests extends TestSupport { private final RedisClient client; + private final RedisCommands redis; @Inject @@ -140,16 +141,17 @@ void errorInMulti() { @Test void execWithoutMulti() { - assertThatThrownBy(redis::exec).isInstanceOf(RedisCommandExecutionException.class).hasMessageContaining( - "ERR EXEC without MULTI"); + assertThatThrownBy(redis::exec).isInstanceOf(RedisCommandExecutionException.class) + .hasMessageContaining("ERR EXEC without MULTI"); } @Test void multiCalledTwiceShouldFail() { redis.multi(); - assertThatThrownBy(redis::multi).isInstanceOf(RedisCommandExecutionException.class).hasMessageContaining( - "ERR MULTI calls can not be nested"); + assertThatThrownBy(redis::multi).isInstanceOf(RedisCommandExecutionException.class) + .hasMessageContaining("ERR MULTI calls can not be nested"); redis.discard(); } + } diff --git a/src/test/java/io/lettuce/core/commands/reactive/BitReactiveCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/reactive/BitReactiveCommandIntegrationTests.java index 57ebd996b1..ed5c30f36d 100644 --- a/src/test/java/io/lettuce/core/commands/reactive/BitReactiveCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/reactive/BitReactiveCommandIntegrationTests.java @@ -90,10 +90,11 @@ void bitfieldIncrBy() { @Test void bitfieldOverflow() { - BitFieldArgs bitFieldArgs = BitFieldArgs.Builder.overflow(FAIL).set(signed(8), 9, 5) - .incrBy(signed(8), Integer.MAX_VALUE); + BitFieldArgs bitFieldArgs = BitFieldArgs.Builder.overflow(FAIL).set(signed(8), 9, 5).incrBy(signed(8), + Integer.MAX_VALUE); StepVerifier.create(reactive.bitfield(key, bitFieldArgs)).expectNext(Value.just(0L)).expectNext(Value.empty()) .verifyComplete(); } + } diff --git a/src/test/java/io/lettuce/core/commands/reactive/CustomReactiveCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/reactive/CustomReactiveCommandIntegrationTests.java index 81a678156f..6e82d20391 100644 --- a/src/test/java/io/lettuce/core/commands/reactive/CustomReactiveCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/reactive/CustomReactiveCommandIntegrationTests.java @@ -38,8 +38,8 @@ void dispatchGetAndSet() { redis.set(key, value); RedisReactiveCommands reactive = redis.getStatefulConnection().reactive(); - Flux flux = reactive.dispatch(CommandType.GET, new ValueOutput<>(StringCodec.UTF8), new CommandArgs<>( - StringCodec.UTF8).addKey(key)); + Flux flux = reactive.dispatch(CommandType.GET, new ValueOutput<>(StringCodec.UTF8), + new CommandArgs<>(StringCodec.UTF8).addKey(key)); StepVerifier.create(flux).expectNext(value).verifyComplete(); } @@ -50,9 +50,10 @@ void dispatchList() { redis.rpush(key, "a", "b", "c"); RedisReactiveCommands reactive = redis.getStatefulConnection().reactive(); - Flux flux = reactive.dispatch(CommandType.LRANGE, new ValueListOutput<>(StringCodec.UTF8), new CommandArgs<>( - StringCodec.UTF8).addKey(key).add(0).add(-1)); + Flux flux = reactive.dispatch(CommandType.LRANGE, new ValueListOutput<>(StringCodec.UTF8), + new CommandArgs<>(StringCodec.UTF8).addKey(key).add(0).add(-1)); StepVerifier.create(flux).expectNext("a", "b", "c").verifyComplete(); } + } diff --git a/src/test/java/io/lettuce/core/commands/reactive/GeoReactiveCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/reactive/GeoReactiveCommandIntegrationTests.java index 757d53604e..da0975c0b2 100644 --- a/src/test/java/io/lettuce/core/commands/reactive/GeoReactiveCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/reactive/GeoReactiveCommandIntegrationTests.java @@ -50,4 +50,5 @@ public void geopos() { @Override public void geoposInTransaction() { } + } diff --git a/src/test/java/io/lettuce/core/commands/reactive/HLLReactiveCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/reactive/HLLReactiveCommandIntegrationTests.java index 7587539885..fe4d90d746 100644 --- a/src/test/java/io/lettuce/core/commands/reactive/HLLReactiveCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/reactive/HLLReactiveCommandIntegrationTests.java @@ -15,4 +15,5 @@ class HLLReactiveCommandIntegrationTests extends HLLCommandIntegrationTests { HLLReactiveCommandIntegrationTests(StatefulRedisConnection connection) { super(ReactiveSyncInvocationHandler.sync(connection)); } + } diff --git a/src/test/java/io/lettuce/core/commands/reactive/HashReactiveCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/reactive/HashReactiveCommandIntegrationTests.java index 458fb5c384..cca4947dca 100644 --- a/src/test/java/io/lettuce/core/commands/reactive/HashReactiveCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/reactive/HashReactiveCommandIntegrationTests.java @@ -48,4 +48,5 @@ public void hgetall() { public void hgetallStreaming() { } + } diff --git a/src/test/java/io/lettuce/core/commands/reactive/KeyReactiveCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/reactive/KeyReactiveCommandIntegrationTests.java index 3343e6a69c..134f4ce1a6 100644 --- a/src/test/java/io/lettuce/core/commands/reactive/KeyReactiveCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/reactive/KeyReactiveCommandIntegrationTests.java @@ -15,4 +15,5 @@ class KeyReactiveCommandIntegrationTests extends KeyCommandIntegrationTests { KeyReactiveCommandIntegrationTests(StatefulRedisConnection connection) { super(ReactiveSyncInvocationHandler.sync(connection)); } + } diff --git a/src/test/java/io/lettuce/core/commands/reactive/ListReactiveCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/reactive/ListReactiveCommandIntegrationTests.java index ca322ad8d3..58e4f43d35 100644 --- a/src/test/java/io/lettuce/core/commands/reactive/ListReactiveCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/reactive/ListReactiveCommandIntegrationTests.java @@ -15,4 +15,5 @@ class ListReactiveCommandIntegrationTests extends ListCommandIntegrationTests { ListReactiveCommandIntegrationTests(StatefulRedisConnection connection) { super(ReactiveSyncInvocationHandler.sync(connection)); } + } diff --git a/src/test/java/io/lettuce/core/commands/reactive/NumericReactiveCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/reactive/NumericReactiveCommandIntegrationTests.java index 4e8971a188..39a0fb78e1 100644 --- a/src/test/java/io/lettuce/core/commands/reactive/NumericReactiveCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/reactive/NumericReactiveCommandIntegrationTests.java @@ -15,4 +15,5 @@ class NumericReactiveCommandIntegrationTests extends NumericCommandIntegrationTe NumericReactiveCommandIntegrationTests(StatefulRedisConnection connection) { super(ReactiveSyncInvocationHandler.sync(connection)); } + } diff --git a/src/test/java/io/lettuce/core/commands/reactive/ScriptingReactiveCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/reactive/ScriptingReactiveCommandIntegrationTests.java index d9257066e6..fcd5a574d4 100644 --- a/src/test/java/io/lettuce/core/commands/reactive/ScriptingReactiveCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/reactive/ScriptingReactiveCommandIntegrationTests.java @@ -16,4 +16,5 @@ class ScriptingReactiveCommandIntegrationTests extends ScriptingCommandIntegrati ScriptingReactiveCommandIntegrationTests(RedisClient client, StatefulRedisConnection connection) { super(client, ReactiveSyncInvocationHandler.sync(connection)); } + } diff --git a/src/test/java/io/lettuce/core/commands/reactive/SetReactiveCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/reactive/SetReactiveCommandIntegrationTests.java index 85c383800a..8bef010797 100644 --- a/src/test/java/io/lettuce/core/commands/reactive/SetReactiveCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/reactive/SetReactiveCommandIntegrationTests.java @@ -15,4 +15,5 @@ class SetReactiveCommandIntegrationTests extends SetCommandIntegrationTests { SetReactiveCommandIntegrationTests(StatefulRedisConnection connection) { super(ReactiveSyncInvocationHandler.sync(connection)); } + } diff --git a/src/test/java/io/lettuce/core/commands/reactive/SortReactiveCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/reactive/SortReactiveCommandIntegrationTests.java index 88a3fb21a1..6e7bcc95e6 100644 --- a/src/test/java/io/lettuce/core/commands/reactive/SortReactiveCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/reactive/SortReactiveCommandIntegrationTests.java @@ -15,4 +15,5 @@ class SortReactiveCommandIntegrationTests extends SortCommandIntegrationTests { SortReactiveCommandIntegrationTests(StatefulRedisConnection connection) { super(ReactiveSyncInvocationHandler.sync(connection)); } + } diff --git a/src/test/java/io/lettuce/core/commands/reactive/SortedSetReactiveCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/reactive/SortedSetReactiveCommandIntegrationTests.java index b2deb0e28b..71ab51524a 100644 --- a/src/test/java/io/lettuce/core/commands/reactive/SortedSetReactiveCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/reactive/SortedSetReactiveCommandIntegrationTests.java @@ -41,4 +41,5 @@ public void zmscore() { assertThat(actual).isEqualTo(list(1.0, null, 2.0)); }).verifyComplete(); } + } diff --git a/src/test/java/io/lettuce/core/commands/reactive/StreamReactiveCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/reactive/StreamReactiveCommandIntegrationTests.java index 7491eae769..218bd4e412 100644 --- a/src/test/java/io/lettuce/core/commands/reactive/StreamReactiveCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/reactive/StreamReactiveCommandIntegrationTests.java @@ -15,4 +15,5 @@ class StreamReactiveCommandIntegrationTests extends StreamCommandIntegrationTest StreamReactiveCommandIntegrationTests(StatefulRedisConnection connection) { super(ReactiveSyncInvocationHandler.sync(connection)); } + } diff --git a/src/test/java/io/lettuce/core/commands/reactive/StringReactiveCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/reactive/StringReactiveCommandIntegrationTests.java index 889eb156a2..ea81cebd85 100644 --- a/src/test/java/io/lettuce/core/commands/reactive/StringReactiveCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/reactive/StringReactiveCommandIntegrationTests.java @@ -19,6 +19,7 @@ class StringReactiveCommandIntegrationTests extends StringCommandIntegrationTests { private final RedisCommands redis; + private final RedisReactiveCommands reactive; @Inject @@ -47,4 +48,5 @@ void mgetEmpty() { Flux> mget = reactive.mget("unknown"); StepVerifier.create(mget.next()).expectNext(KeyValue.empty("unknown")).verifyComplete(); } + } diff --git a/src/test/java/io/lettuce/core/commands/transactional/BitTxCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/transactional/BitTxCommandIntegrationTests.java index b1156d8f27..9cdbb9f1e7 100644 --- a/src/test/java/io/lettuce/core/commands/transactional/BitTxCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/transactional/BitTxCommandIntegrationTests.java @@ -15,4 +15,5 @@ class BitTxCommandIntegrationTests extends BitCommandIntegrationTests { BitTxCommandIntegrationTests(RedisClient client, StatefulRedisConnection connection) { super(client, TxSyncInvocationHandler.sync(connection)); } + } diff --git a/src/test/java/io/lettuce/core/commands/transactional/GeoTxCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/transactional/GeoTxCommandIntegrationTests.java index 5566adc511..8d2f19c08d 100644 --- a/src/test/java/io/lettuce/core/commands/transactional/GeoTxCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/transactional/GeoTxCommandIntegrationTests.java @@ -56,4 +56,5 @@ public void geodistInTransaction() { @Override public void geohashInTransaction() { } + } diff --git a/src/test/java/io/lettuce/core/commands/transactional/HLLTxCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/transactional/HLLTxCommandIntegrationTests.java index ca67fc4d7a..c3707fe685 100644 --- a/src/test/java/io/lettuce/core/commands/transactional/HLLTxCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/transactional/HLLTxCommandIntegrationTests.java @@ -14,4 +14,5 @@ class HLLTxCommandIntegrationTests extends HLLCommandIntegrationTests { HLLTxCommandIntegrationTests(StatefulRedisConnection connection) { super(TxSyncInvocationHandler.sync(connection)); } + } diff --git a/src/test/java/io/lettuce/core/commands/transactional/HashTxCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/transactional/HashTxCommandIntegrationTests.java index de8d21a4a0..12965fd2c3 100644 --- a/src/test/java/io/lettuce/core/commands/transactional/HashTxCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/transactional/HashTxCommandIntegrationTests.java @@ -14,4 +14,5 @@ class HashTxCommandIntegrationTests extends HashCommandIntegrationTests { HashTxCommandIntegrationTests(StatefulRedisConnection connection) { super(TxSyncInvocationHandler.sync(connection)); } + } diff --git a/src/test/java/io/lettuce/core/commands/transactional/KeyTxCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/transactional/KeyTxCommandIntegrationTests.java index 4b9c2620de..cc9e298302 100644 --- a/src/test/java/io/lettuce/core/commands/transactional/KeyTxCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/transactional/KeyTxCommandIntegrationTests.java @@ -21,4 +21,5 @@ public class KeyTxCommandIntegrationTests extends KeyCommandIntegrationTests { @Override public void move() { } + } diff --git a/src/test/java/io/lettuce/core/commands/transactional/ListTxCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/transactional/ListTxCommandIntegrationTests.java index e57f86e2e6..b86291b0f6 100644 --- a/src/test/java/io/lettuce/core/commands/transactional/ListTxCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/transactional/ListTxCommandIntegrationTests.java @@ -14,4 +14,5 @@ class ListTxCommandIntegrationTests extends ListCommandIntegrationTests { ListTxCommandIntegrationTests(StatefulRedisConnection connection) { super(TxSyncInvocationHandler.sync(connection)); } + } diff --git a/src/test/java/io/lettuce/core/commands/transactional/SetTxCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/transactional/SetTxCommandIntegrationTests.java index ed1053b662..47714e0b87 100644 --- a/src/test/java/io/lettuce/core/commands/transactional/SetTxCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/transactional/SetTxCommandIntegrationTests.java @@ -14,4 +14,5 @@ class SetTxCommandIntegrationTests extends SetCommandIntegrationTests { SetTxCommandIntegrationTests(StatefulRedisConnection connection) { super(TxSyncInvocationHandler.sync(connection)); } + } diff --git a/src/test/java/io/lettuce/core/commands/transactional/SortTxCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/transactional/SortTxCommandIntegrationTests.java index fc2f2d9ca7..8813b5e34f 100644 --- a/src/test/java/io/lettuce/core/commands/transactional/SortTxCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/transactional/SortTxCommandIntegrationTests.java @@ -14,4 +14,5 @@ class SortTxCommandIntegrationTests extends SortCommandIntegrationTests { SortTxCommandIntegrationTests(StatefulRedisConnection connection) { super(TxSyncInvocationHandler.sync(connection)); } + } diff --git a/src/test/java/io/lettuce/core/commands/transactional/SortedSetTxCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/transactional/SortedSetTxCommandIntegrationTests.java index ccbe2c9b59..3d443f6a1e 100644 --- a/src/test/java/io/lettuce/core/commands/transactional/SortedSetTxCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/transactional/SortedSetTxCommandIntegrationTests.java @@ -14,4 +14,5 @@ class SortedSetTxCommandIntegrationTests extends SortedSetCommandIntegrationTest SortedSetTxCommandIntegrationTests(StatefulRedisConnection connection) { super(TxSyncInvocationHandler.sync(connection)); } + } diff --git a/src/test/java/io/lettuce/core/commands/transactional/StringTxCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/transactional/StringTxCommandIntegrationTests.java index 4a033970e3..46e388460e 100644 --- a/src/test/java/io/lettuce/core/commands/transactional/StringTxCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/transactional/StringTxCommandIntegrationTests.java @@ -14,4 +14,5 @@ class StringTxCommandIntegrationTests extends StringCommandIntegrationTests { StringTxCommandIntegrationTests(StatefulRedisConnection connection) { super(TxSyncInvocationHandler.sync(connection)); } + } diff --git a/src/test/java/io/lettuce/core/commands/transactional/TxSyncInvocationHandler.java b/src/test/java/io/lettuce/core/commands/transactional/TxSyncInvocationHandler.java index 7898941960..4cffd56cb8 100644 --- a/src/test/java/io/lettuce/core/commands/transactional/TxSyncInvocationHandler.java +++ b/src/test/java/io/lettuce/core/commands/transactional/TxSyncInvocationHandler.java @@ -18,9 +18,13 @@ class TxSyncInvocationHandler extends AbstractInvocationHandler { private final Object api; + private final Method multi; + private final Method discard; + private final Method exec; + private final Method ping; private TxSyncInvocationHandler(Object api) throws Exception { @@ -100,4 +104,5 @@ public static RedisCommands sync(StatefulRedisConnection conn throw new IllegalStateException(e); } } + } diff --git a/src/test/java/io/lettuce/core/dynamic/BatchExecutableCommandLookupStrategyUnitTests.java b/src/test/java/io/lettuce/core/dynamic/BatchExecutableCommandLookupStrategyUnitTests.java index 68c11d5bed..7163785b42 100644 --- a/src/test/java/io/lettuce/core/dynamic/BatchExecutableCommandLookupStrategyUnitTests.java +++ b/src/test/java/io/lettuce/core/dynamic/BatchExecutableCommandLookupStrategyUnitTests.java @@ -30,6 +30,7 @@ class BatchExecutableCommandLookupStrategyUnitTests { @Mock private RedisCommandsMetadata metadata; + @Mock private StatefulRedisConnection connection; @@ -73,8 +74,8 @@ void shouldNotAllowTimeoutParameter() { @Test void shouldNotAllowSynchronousReturnTypes() { - assertThatThrownBy(() -> sut.resolveCommandMethod(getMethod("withReturnType"), metadata)).isInstanceOf( - IllegalArgumentException.class); + assertThatThrownBy(() -> sut.resolveCommandMethod(getMethod("withReturnType"), metadata)) + .isInstanceOf(IllegalArgumentException.class); } private CommandMethod getMethod(String name, Class... parameterTypes) throws NoSuchMethodException { @@ -90,5 +91,7 @@ private static interface BatchingCommands { String withReturnType(); void justVoid(); + } + } diff --git a/src/test/java/io/lettuce/core/dynamic/CommandSegmentCommandFactoryUnitTests.java b/src/test/java/io/lettuce/core/dynamic/CommandSegmentCommandFactoryUnitTests.java index 38dce41b95..1b962d1f7b 100644 --- a/src/test/java/io/lettuce/core/dynamic/CommandSegmentCommandFactoryUnitTests.java +++ b/src/test/java/io/lettuce/core/dynamic/CommandSegmentCommandFactoryUnitTests.java @@ -188,6 +188,7 @@ private interface Commands { @Command("XYZ") boolean unknownCommand(); + } private static interface MethodsWithTimeout { @@ -195,5 +196,7 @@ private static interface MethodsWithTimeout { Future async(String key, Timeout timeout); String sync(String key, Timeout timeout); + } + } diff --git a/src/test/java/io/lettuce/core/dynamic/ConversionServiceUnitTests.java b/src/test/java/io/lettuce/core/dynamic/ConversionServiceUnitTests.java index cf35802afa..3a684a5882 100644 --- a/src/test/java/io/lettuce/core/dynamic/ConversionServiceUnitTests.java +++ b/src/test/java/io/lettuce/core/dynamic/ConversionServiceUnitTests.java @@ -56,17 +56,21 @@ void convert() { } private class FluxToObservableConverter implements Function, Observable> { + @Override public Observable apply(Flux source) { return null; } + } private class MonoToObservableConverter implements Function, Observable> { + @Override public Observable apply(Mono source) { return Observable.just("world"); } + } } diff --git a/src/test/java/io/lettuce/core/dynamic/DeclaredCommandMethodUnitTests.java b/src/test/java/io/lettuce/core/dynamic/DeclaredCommandMethodUnitTests.java index 22ab75580b..c60efd0973 100644 --- a/src/test/java/io/lettuce/core/dynamic/DeclaredCommandMethodUnitTests.java +++ b/src/test/java/io/lettuce/core/dynamic/DeclaredCommandMethodUnitTests.java @@ -52,5 +52,7 @@ private interface MyInterface { Future getFuture(); Flux getFlux(); + } + } diff --git a/src/test/java/io/lettuce/core/dynamic/DefaultCommandMethodVerifierUnitTests.java b/src/test/java/io/lettuce/core/dynamic/DefaultCommandMethodVerifierUnitTests.java index 67d6303d54..8ad6f2e84d 100644 --- a/src/test/java/io/lettuce/core/dynamic/DefaultCommandMethodVerifierUnitTests.java +++ b/src/test/java/io/lettuce/core/dynamic/DefaultCommandMethodVerifierUnitTests.java @@ -132,5 +132,7 @@ private static interface MyInterface { void lpop(@Param("key") String key); void rpop(String key1, String key2); + } + } diff --git a/src/test/java/io/lettuce/core/dynamic/ParameterBinderUnitTests.java b/src/test/java/io/lettuce/core/dynamic/ParameterBinderUnitTests.java index 776e409735..bb065be03e 100644 --- a/src/test/java/io/lettuce/core/dynamic/ParameterBinderUnitTests.java +++ b/src/test/java/io/lettuce/core/dynamic/ParameterBinderUnitTests.java @@ -25,6 +25,7 @@ class ParameterBinderUnitTests { private ParameterBinder binder = new ParameterBinder(); + private CommandSegments segments = new CommandSegments(Collections.singletonList(CommandSegment.constant("set"))); @Test @@ -137,28 +138,27 @@ void rejectsStringUpperValue() { @Test void bindsValueRangeCorrectly() { - CommandMethod commandMethod = DeclaredCommandMethod.create(ReflectionUtils.findMethod(MyCommands.class, "valueRange", - Range.class)); + CommandMethod commandMethod = DeclaredCommandMethod + .create(ReflectionUtils.findMethod(MyCommands.class, "valueRange", Range.class)); CommandArgs args = bind(commandMethod, Range.from(Range.Boundary.including("lower"), Range.Boundary.excluding("upper"))); - assertThat(args.toCommandString()).isEqualTo( - String.format("%s %s", Base64.getEncoder().encodeToString("[lower".getBytes()), + assertThat(args.toCommandString()) + .isEqualTo(String.format("%s %s", Base64.getEncoder().encodeToString("[lower".getBytes()), Base64.getEncoder().encodeToString("(upper".getBytes()))); } @Test void bindsUnboundedValueRangeCorrectly() { - CommandMethod commandMethod = DeclaredCommandMethod.create(ReflectionUtils.findMethod(MyCommands.class, "valueRange", - Range.class)); + CommandMethod commandMethod = DeclaredCommandMethod + .create(ReflectionUtils.findMethod(MyCommands.class, "valueRange", Range.class)); CommandArgs args = bind(commandMethod, Range.unbounded()); - assertThat(args.toCommandString()).isEqualTo( - String.format("%s %s", Base64.getEncoder().encodeToString("-".getBytes()), - Base64.getEncoder().encodeToString("+".getBytes()))); + assertThat(args.toCommandString()).isEqualTo(String.format("%s %s", Base64.getEncoder().encodeToString("-".getBytes()), + Base64.getEncoder().encodeToString("+".getBytes()))); } @Test @@ -179,8 +179,7 @@ void bindsProtocolKeywordCorrectly() { private CommandArgs bind(Object object) { CommandMethod commandMethod = DeclaredCommandMethod - .create(ReflectionUtils.findMethod(MyCommands.class, "justObject", - Object.class)); + .create(ReflectionUtils.findMethod(MyCommands.class, "justObject", Object.class)); return bind(commandMethod, object); } @@ -199,5 +198,7 @@ private interface MyCommands { void justObject(Object object); void valueRange(@io.lettuce.core.dynamic.annotation.Value Range value); + } + } diff --git a/src/test/java/io/lettuce/core/dynamic/ReactiveCommandSegmentCommandFactoryUnitTests.java b/src/test/java/io/lettuce/core/dynamic/ReactiveCommandSegmentCommandFactoryUnitTests.java index 85266f8fe6..11bd196489 100644 --- a/src/test/java/io/lettuce/core/dynamic/ReactiveCommandSegmentCommandFactoryUnitTests.java +++ b/src/test/java/io/lettuce/core/dynamic/ReactiveCommandSegmentCommandFactoryUnitTests.java @@ -81,5 +81,7 @@ private static interface ReactiveWithTimeout { Mono getOne(String key); Flux getMany(String key); + } + } diff --git a/src/test/java/io/lettuce/core/dynamic/ReactiveTypeAdaptersUnitTests.java b/src/test/java/io/lettuce/core/dynamic/ReactiveTypeAdaptersUnitTests.java index 8cefbc82e0..151d8ddbe4 100644 --- a/src/test/java/io/lettuce/core/dynamic/ReactiveTypeAdaptersUnitTests.java +++ b/src/test/java/io/lettuce/core/dynamic/ReactiveTypeAdaptersUnitTests.java @@ -244,4 +244,5 @@ void toWrapperShouldConvertMonoToFlux() { Mono foo = Mono.just("foo"); assertThat(conversionService.convert(foo, Flux.class)).isInstanceOf(Flux.class); } + } diff --git a/src/test/java/io/lettuce/core/dynamic/ReactiveTypeAdaptionIntegrationTests.java b/src/test/java/io/lettuce/core/dynamic/ReactiveTypeAdaptionIntegrationTests.java index f1788c74a8..3bcb712b50 100644 --- a/src/test/java/io/lettuce/core/dynamic/ReactiveTypeAdaptionIntegrationTests.java +++ b/src/test/java/io/lettuce/core/dynamic/ReactiveTypeAdaptionIntegrationTests.java @@ -25,7 +25,9 @@ class ReactiveTypeAdaptionIntegrationTests extends TestSupport { private final RedisCommands redis; private final RxJava1Types rxjava1; + private final RxJava2Types rxjava2; + private final RxJava3Types rxjava3; @Inject @@ -121,6 +123,7 @@ static interface RxJava1Types extends Commands { @Command("GET") Observable getRxJava1Observable(String key); + } static interface RxJava2Types extends Commands { @@ -136,6 +139,7 @@ static interface RxJava2Types extends Commands { @Command("GET") io.reactivex.Flowable getRxJava2Flowable(String key); + } static interface RxJava3Types extends Commands { @@ -151,5 +155,7 @@ static interface RxJava3Types extends Commands { @Command("GET") io.reactivex.rxjava3.core.Flowable getRxJava3Flowable(String key); + } + } diff --git a/src/test/java/io/lettuce/core/dynamic/RedisCommandsAsyncIntegrationTests.java b/src/test/java/io/lettuce/core/dynamic/RedisCommandsAsyncIntegrationTests.java index 087ebad012..df94daa623 100644 --- a/src/test/java/io/lettuce/core/dynamic/RedisCommandsAsyncIntegrationTests.java +++ b/src/test/java/io/lettuce/core/dynamic/RedisCommandsAsyncIntegrationTests.java @@ -40,6 +40,9 @@ void async() { } static interface MultipleExecutionModels extends Commands { + Future set(String key, String value); + } + } diff --git a/src/test/java/io/lettuce/core/dynamic/RedisCommandsBatchingIntegrationTests.java b/src/test/java/io/lettuce/core/dynamic/RedisCommandsBatchingIntegrationTests.java index ee36d8b237..b786eb62c5 100644 --- a/src/test/java/io/lettuce/core/dynamic/RedisCommandsBatchingIntegrationTests.java +++ b/src/test/java/io/lettuce/core/dynamic/RedisCommandsBatchingIntegrationTests.java @@ -218,6 +218,7 @@ static interface Batching extends Commands { @Command("LLEN") RedisFuture llenAsync(String key); + } static interface SelectiveBatching extends Commands, BatchExecutor { diff --git a/src/test/java/io/lettuce/core/dynamic/RedisCommandsClusterIntegrationTests.java b/src/test/java/io/lettuce/core/dynamic/RedisCommandsClusterIntegrationTests.java index 90ce8e0a3f..d430f8b485 100644 --- a/src/test/java/io/lettuce/core/dynamic/RedisCommandsClusterIntegrationTests.java +++ b/src/test/java/io/lettuce/core/dynamic/RedisCommandsClusterIntegrationTests.java @@ -86,6 +86,7 @@ interface SynchronousCommands extends Commands { @Command("MGET") List> mgetAsValues(String... keys); + } } diff --git a/src/test/java/io/lettuce/core/dynamic/RedisCommandsIntegrationTests.java b/src/test/java/io/lettuce/core/dynamic/RedisCommandsIntegrationTests.java index aa5d1b7731..351989f03f 100644 --- a/src/test/java/io/lettuce/core/dynamic/RedisCommandsIntegrationTests.java +++ b/src/test/java/io/lettuce/core/dynamic/RedisCommandsIntegrationTests.java @@ -34,6 +34,7 @@ class RedisCommandsIntegrationTests extends TestSupport { private final RedisClient client; + private final RedisCommands redis; @Inject @@ -95,8 +96,8 @@ void verifierShouldCatchTooFewParametersDeclarations() { @Test void shouldWorkWithPooledConnection() throws Exception { - GenericObjectPool> pool = ConnectionPoolSupport.createGenericObjectPool( - client::connect, new GenericObjectPoolConfig<>()); + GenericObjectPool> pool = ConnectionPoolSupport + .createGenericObjectPool(client::connect, new GenericObjectPoolConfig<>()); try (StatefulRedisConnection connection = pool.borrowObject()) { @@ -126,14 +127,21 @@ void shouldWorkWithAsyncPooledConnection() { } private interface SimpleCommands extends Commands { + String get(String key); + } private interface TooFewParameters extends Commands { + String get(); + } private interface WithTypo extends Commands { + String gat(String key); + } + } diff --git a/src/test/java/io/lettuce/core/dynamic/RedisCommandsReactiveIntegrationTests.java b/src/test/java/io/lettuce/core/dynamic/RedisCommandsReactiveIntegrationTests.java index 2685b2ee6f..d394bb10bb 100644 --- a/src/test/java/io/lettuce/core/dynamic/RedisCommandsReactiveIntegrationTests.java +++ b/src/test/java/io/lettuce/core/dynamic/RedisCommandsReactiveIntegrationTests.java @@ -94,5 +94,7 @@ interface MultipleExecutionModels extends Commands { @Command("GET") Maybe getRxJava(String key); + } + } diff --git a/src/test/java/io/lettuce/core/dynamic/RedisCommandsSyncIntegrationTests.java b/src/test/java/io/lettuce/core/dynamic/RedisCommandsSyncIntegrationTests.java index 796deaeeb0..37181b0460 100644 --- a/src/test/java/io/lettuce/core/dynamic/RedisCommandsSyncIntegrationTests.java +++ b/src/test/java/io/lettuce/core/dynamic/RedisCommandsSyncIntegrationTests.java @@ -30,6 +30,7 @@ class RedisCommandsSyncIntegrationTests extends TestSupport { private final RedisClient client; + private final RedisCommands redis; @Inject @@ -118,6 +119,7 @@ static int someStaticMethod() { @Command("MGET") List> mgetAsValues(String... keys); + } } diff --git a/src/test/java/io/lettuce/core/dynamic/SimpleBatcherUnitTests.java b/src/test/java/io/lettuce/core/dynamic/SimpleBatcherUnitTests.java index 404d92f9ff..11f425b2d1 100644 --- a/src/test/java/io/lettuce/core/dynamic/SimpleBatcherUnitTests.java +++ b/src/test/java/io/lettuce/core/dynamic/SimpleBatcherUnitTests.java @@ -127,4 +127,5 @@ void shouldBatchWithBatchControlFlush() { private static RedisCommand createCommand() { return new AsyncCommand<>(new Command<>(CommandType.COMMAND, null, null)); } + } diff --git a/src/test/java/io/lettuce/core/dynamic/codec/AnnotationRedisCodecResolverUnitTests.java b/src/test/java/io/lettuce/core/dynamic/codec/AnnotationRedisCodecResolverUnitTests.java index 5f3bec050b..7c86802307 100644 --- a/src/test/java/io/lettuce/core/dynamic/codec/AnnotationRedisCodecResolverUnitTests.java +++ b/src/test/java/io/lettuce/core/dynamic/codec/AnnotationRedisCodecResolverUnitTests.java @@ -147,6 +147,7 @@ private static interface CommandMethods { String withWrappers(@Value Range range, @Value io.lettuce.core.Value value); String withMap(Map map); + } } diff --git a/src/test/java/io/lettuce/core/dynamic/codec/ParameterWrappersUnitTests.java b/src/test/java/io/lettuce/core/dynamic/codec/ParameterWrappersUnitTests.java index 4358b41337..3eadb15d3d 100644 --- a/src/test/java/io/lettuce/core/dynamic/codec/ParameterWrappersUnitTests.java +++ b/src/test/java/io/lettuce/core/dynamic/codec/ParameterWrappersUnitTests.java @@ -127,6 +127,7 @@ String withWrappers(Range range, io.lettuce.core.Value value, String withList(List map); String withMap(Map map); + } } diff --git a/src/test/java/io/lettuce/core/dynamic/intercept/InvocationProxyFactoryUnitTests.java b/src/test/java/io/lettuce/core/dynamic/intercept/InvocationProxyFactoryUnitTests.java index d5e78fdb37..afaabf21fb 100644 --- a/src/test/java/io/lettuce/core/dynamic/intercept/InvocationProxyFactoryUnitTests.java +++ b/src/test/java/io/lettuce/core/dynamic/intercept/InvocationProxyFactoryUnitTests.java @@ -49,6 +49,7 @@ void shouldCallInterceptorsInOrder() { private interface TargetWithBooleanMethod { Boolean someMethod(); + } private static class ReturnValue implements MethodInterceptor { @@ -63,11 +64,13 @@ private static class ReturnValue implements MethodInterceptor { public Object invoke(MethodInvocation invocation) { return value; } + } private interface TargetWithStringMethod { String run(); + } private static class StringAppendingMethodInterceptor implements MethodInterceptor { @@ -82,5 +85,7 @@ private static class StringAppendingMethodInterceptor implements MethodIntercept public Object invoke(MethodInvocation invocation) throws Throwable { return invocation.proceed().toString() + toAppend; } + } + } diff --git a/src/test/java/io/lettuce/core/dynamic/output/CodecAwareOutputResolverUnitTests.java b/src/test/java/io/lettuce/core/dynamic/output/CodecAwareOutputResolverUnitTests.java index c3b58c68b3..f20e53badf 100644 --- a/src/test/java/io/lettuce/core/dynamic/output/CodecAwareOutputResolverUnitTests.java +++ b/src/test/java/io/lettuce/core/dynamic/output/CodecAwareOutputResolverUnitTests.java @@ -96,6 +96,7 @@ private static interface CommandMethods { String string(); ByteBuffer byteBuffer(); + } private static class ByteBufferAndStringCodec implements RedisCodec { @@ -119,5 +120,7 @@ public ByteBuffer encodeKey(ByteBuffer key) { public ByteBuffer encodeValue(String value) { return null; } + } + } diff --git a/src/test/java/io/lettuce/core/dynamic/output/OutputRegistryCommandOutputFactoryResolverUnitTests.java b/src/test/java/io/lettuce/core/dynamic/output/OutputRegistryCommandOutputFactoryResolverUnitTests.java index 33b9e8cdcd..c6486cabb5 100644 --- a/src/test/java/io/lettuce/core/dynamic/output/OutputRegistryCommandOutputFactoryResolverUnitTests.java +++ b/src/test/java/io/lettuce/core/dynamic/output/OutputRegistryCommandOutputFactoryResolverUnitTests.java @@ -141,8 +141,10 @@ void stringWildcardValueCollectionIsAssignableFromOutputs() { CommandOutput getCommandOutput(String methodName) { OutputSelector outputSelector = getOutputSelector(methodName); - CommandOutputFactory factory = resolver.resolveCommandOutput(Publisher.class.isAssignableFrom(outputSelector - .getOutputType().getRawClass()) ? unwrapReactiveType(outputSelector) : outputSelector); + CommandOutputFactory factory = resolver + .resolveCommandOutput(Publisher.class.isAssignableFrom(outputSelector.getOutputType().getRawClass()) + ? unwrapReactiveType(outputSelector) + : outputSelector); return factory.create(new StringCodec()); } @@ -196,5 +198,7 @@ private interface CommandMethods { List boolList(); ListOfMapsOutput listOfMapsOutput(); + } + } diff --git a/src/test/java/io/lettuce/core/dynamic/output/OutputRegistryUnitTests.java b/src/test/java/io/lettuce/core/dynamic/output/OutputRegistryUnitTests.java index e3e4aa3655..0d20f3401c 100644 --- a/src/test/java/io/lettuce/core/dynamic/output/OutputRegistryUnitTests.java +++ b/src/test/java/io/lettuce/core/dynamic/output/OutputRegistryUnitTests.java @@ -93,6 +93,7 @@ private static abstract class IntermediateOutput extends CommandOutput codec, V1 output) { super(codec, null); } + } private static class KeyTypedOutput extends IntermediateOutput { @@ -100,5 +101,7 @@ private static class KeyTypedOutput extends IntermediateOutput codec) { super(codec, null); } + } + } diff --git a/src/test/java/io/lettuce/core/dynamic/segment/AnnotationCommandSegmentFactoryUnitTests.java b/src/test/java/io/lettuce/core/dynamic/segment/AnnotationCommandSegmentFactoryUnitTests.java index cdde59c4cb..7363bb45b3 100644 --- a/src/test/java/io/lettuce/core/dynamic/segment/AnnotationCommandSegmentFactoryUnitTests.java +++ b/src/test/java/io/lettuce/core/dynamic/segment/AnnotationCommandSegmentFactoryUnitTests.java @@ -22,8 +22,8 @@ class AnnotationCommandSegmentFactoryUnitTests { @Test void notAnnotatedDotAsIs() { - CommandMethod commandMethod = DeclaredCommandMethod.create(ReflectionUtils.findMethod(CommandMethods.class, - "notAnnotated")); + CommandMethod commandMethod = DeclaredCommandMethod + .create(ReflectionUtils.findMethod(CommandMethods.class, "notAnnotated")); CommandSegments commandSegments = factory.createCommandSegments(commandMethod); @@ -34,8 +34,8 @@ void notAnnotatedDotAsIs() { @Test void uppercaseDot() { - CommandMethod commandMethod = DeclaredCommandMethod.create(ReflectionUtils - .findMethod(CommandMethods.class, "upperCase")); + CommandMethod commandMethod = DeclaredCommandMethod + .create(ReflectionUtils.findMethod(CommandMethods.class, "upperCase")); CommandSegments commandSegments = factory.createCommandSegments(commandMethod); @@ -46,8 +46,8 @@ void uppercaseDot() { @Test void methodNameAsIs() { - CommandMethod commandMethod = DeclaredCommandMethod.create(ReflectionUtils.findMethod(CommandMethods.class, - "methodName")); + CommandMethod commandMethod = DeclaredCommandMethod + .create(ReflectionUtils.findMethod(CommandMethods.class, "methodName")); CommandSegments commandSegments = factory.createCommandSegments(commandMethod); @@ -58,8 +58,8 @@ void methodNameAsIs() { @Test void splitAsIs() { - CommandMethod commandMethod = DeclaredCommandMethod.create(ReflectionUtils.findMethod(CommandMethods.class, - "clientSetname")); + CommandMethod commandMethod = DeclaredCommandMethod + .create(ReflectionUtils.findMethod(CommandMethods.class, "clientSetname")); CommandSegments commandSegments = factory.createCommandSegments(commandMethod); @@ -70,8 +70,8 @@ void splitAsIs() { @Test void commandAnnotation() { - CommandMethod commandMethod = DeclaredCommandMethod.create(ReflectionUtils - .findMethod(CommandMethods.class, "atCommand")); + CommandMethod commandMethod = DeclaredCommandMethod + .create(ReflectionUtils.findMethod(CommandMethods.class, "atCommand")); CommandSegments commandSegments = factory.createCommandSegments(commandMethod); @@ -107,10 +107,13 @@ private static interface CommandMethods { @Command("HELLO WORLD") void atCommand(); + } private static interface Defaulted { void clientSetname(); + } + } diff --git a/src/test/java/io/lettuce/core/dynamic/support/ParametrizedTypeInformationUnitTests.java b/src/test/java/io/lettuce/core/dynamic/support/ParametrizedTypeInformationUnitTests.java index f1e0b2940b..7b98b1dcbf 100644 --- a/src/test/java/io/lettuce/core/dynamic/support/ParametrizedTypeInformationUnitTests.java +++ b/src/test/java/io/lettuce/core/dynamic/support/ParametrizedTypeInformationUnitTests.java @@ -93,6 +93,7 @@ private static interface TestType { List anything(); List numberOrSubtype(); + } private static interface ListOfNumber extends List { @@ -122,4 +123,5 @@ private static interface ListOfString extends List { private static interface ListOfInteger extends List { } + } diff --git a/src/test/java/io/lettuce/core/dynamic/support/WildcardTypeInformationUnitTests.java b/src/test/java/io/lettuce/core/dynamic/support/WildcardTypeInformationUnitTests.java index 652751169a..fe20304f66 100644 --- a/src/test/java/io/lettuce/core/dynamic/support/WildcardTypeInformationUnitTests.java +++ b/src/test/java/io/lettuce/core/dynamic/support/WildcardTypeInformationUnitTests.java @@ -95,5 +95,7 @@ private static interface GenericReturnTypes { List exactFloat(); List atLeastNumber(); + } + } diff --git a/src/test/java/io/lettuce/core/event/ConnectionEventsTriggeredIntegrationTests.java b/src/test/java/io/lettuce/core/event/ConnectionEventsTriggeredIntegrationTests.java index 54933a026e..ab91f9bd7f 100644 --- a/src/test/java/io/lettuce/core/event/ConnectionEventsTriggeredIntegrationTests.java +++ b/src/test/java/io/lettuce/core/event/ConnectionEventsTriggeredIntegrationTests.java @@ -37,4 +37,5 @@ void testConnectionEvents() { FastShutdown.shutdown(client); } + } diff --git a/src/test/java/io/lettuce/core/event/DefaultEventBusUnitTests.java b/src/test/java/io/lettuce/core/event/DefaultEventBusUnitTests.java index 3de1f9cebc..5d39762010 100644 --- a/src/test/java/io/lettuce/core/event/DefaultEventBusUnitTests.java +++ b/src/test/java/io/lettuce/core/event/DefaultEventBusUnitTests.java @@ -45,4 +45,5 @@ void publishToMultipleSubscribers() throws Exception { assertThat(arrayQueue.take()).isEqualTo(event); disposable1.dispose(); } + } diff --git a/src/test/java/io/lettuce/core/event/DefaultEventPublisherOptionsUnitTests.java b/src/test/java/io/lettuce/core/event/DefaultEventPublisherOptionsUnitTests.java index 6a3a9e3872..cdc9790fad 100644 --- a/src/test/java/io/lettuce/core/event/DefaultEventPublisherOptionsUnitTests.java +++ b/src/test/java/io/lettuce/core/event/DefaultEventPublisherOptionsUnitTests.java @@ -36,4 +36,5 @@ void testBuilder() { assertThat(sut.eventEmitInterval()).isEqualTo(Duration.ofSeconds(1)); } + } diff --git a/src/test/java/io/lettuce/core/internal/AbstractInvocationHandlerUnitTests.java b/src/test/java/io/lettuce/core/internal/AbstractInvocationHandlerUnitTests.java index 2392f58f85..6b1f2c17f7 100644 --- a/src/test/java/io/lettuce/core/internal/AbstractInvocationHandlerUnitTests.java +++ b/src/test/java/io/lettuce/core/internal/AbstractInvocationHandlerUnitTests.java @@ -57,10 +57,13 @@ static class InvocationHandler extends AbstractInvocationHandler { protected Object handleInvocation(Object proxy, Method method, Object[] args) { return 1; } + } static interface ReturnOne { + int returnOne(); + } } diff --git a/src/test/java/io/lettuce/core/internal/FuturesUnitTests.java b/src/test/java/io/lettuce/core/internal/FuturesUnitTests.java index 01e0f86ad5..1e3ec41789 100644 --- a/src/test/java/io/lettuce/core/internal/FuturesUnitTests.java +++ b/src/test/java/io/lettuce/core/internal/FuturesUnitTests.java @@ -55,4 +55,5 @@ void awaitAllShouldSetInterruptedBit() { assertThat(Thread.currentThread().isInterrupted()).isTrue(); } + } diff --git a/src/test/java/io/lettuce/core/internal/HostAndPortUnitTests.java b/src/test/java/io/lettuce/core/internal/HostAndPortUnitTests.java index 101f2ec3b8..273e8cae67 100644 --- a/src/test/java/io/lettuce/core/internal/HostAndPortUnitTests.java +++ b/src/test/java/io/lettuce/core/internal/HostAndPortUnitTests.java @@ -168,4 +168,5 @@ private static void checkFromCompatCase(String hpString, String expectHost, int assertThat(hostAndPort.getPort()).isEqualTo(expectPort); } + } diff --git a/src/test/java/io/lettuce/core/internal/TimeoutProviderUnitTests.java b/src/test/java/io/lettuce/core/internal/TimeoutProviderUnitTests.java index eaed022952..f14ae94ffc 100644 --- a/src/test/java/io/lettuce/core/internal/TimeoutProviderUnitTests.java +++ b/src/test/java/io/lettuce/core/internal/TimeoutProviderUnitTests.java @@ -50,4 +50,5 @@ void shouldReturnNoTimeout() { assertThat(timeout).isEqualTo(0); } + } diff --git a/src/test/java/io/lettuce/core/masterreplica/ConnectionsUnitTests.java b/src/test/java/io/lettuce/core/masterreplica/ConnectionsUnitTests.java index a315a4cbb1..2c32c0c019 100644 --- a/src/test/java/io/lettuce/core/masterreplica/ConnectionsUnitTests.java +++ b/src/test/java/io/lettuce/core/masterreplica/ConnectionsUnitTests.java @@ -44,4 +44,5 @@ void shouldCloseConnectionCompletingAfterCloseSignal() { verify(connection1).closeAsync(); } + } diff --git a/src/test/java/io/lettuce/core/masterreplica/CustomCommandIntegrationTests.java b/src/test/java/io/lettuce/core/masterreplica/CustomCommandIntegrationTests.java index 7c7fc56edb..5d0702d15d 100644 --- a/src/test/java/io/lettuce/core/masterreplica/CustomCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/masterreplica/CustomCommandIntegrationTests.java @@ -31,6 +31,7 @@ class CustomCommandIntegrationTests extends TestSupport { private final RedisClient redisClient; private StatefulRedisConnection connection; + private RedisCommands redis; @Inject @@ -141,6 +142,7 @@ private StatefulRedisConnection getStandaloneConnection() { } public enum MyCommands implements ProtocolKeyword { + PING, SET, INFO; private final byte name[]; @@ -154,5 +156,7 @@ public enum MyCommands implements ProtocolKeyword { public byte[] getBytes() { return name; } + } + } diff --git a/src/test/java/io/lettuce/core/masterreplica/MasterReplicaChannelWriterUnitTests.java b/src/test/java/io/lettuce/core/masterreplica/MasterReplicaChannelWriterUnitTests.java index a52af6a72f..fead0e6a8f 100644 --- a/src/test/java/io/lettuce/core/masterreplica/MasterReplicaChannelWriterUnitTests.java +++ b/src/test/java/io/lettuce/core/masterreplica/MasterReplicaChannelWriterUnitTests.java @@ -72,11 +72,9 @@ void shouldReturnIntentForWriteCommand() { RedisCommand set = new Command<>(CommandType.SET, null); RedisCommand mset = new Command<>(CommandType.MSET, null); - assertThat(writer.getIntent(Arrays.asList(set, mset))) - .isEqualTo(ConnectionIntent.WRITE); + assertThat(writer.getIntent(Arrays.asList(set, mset))).isEqualTo(ConnectionIntent.WRITE); - assertThat(writer.getIntent(Collections.singletonList(set))) - .isEqualTo(ConnectionIntent.WRITE); + assertThat(writer.getIntent(Collections.singletonList(set))).isEqualTo(ConnectionIntent.WRITE); } @Test @@ -84,8 +82,7 @@ void shouldReturnDefaultIntentForNoCommands() { MasterReplicaChannelWriter writer = new MasterReplicaChannelWriter(connectionProvider, clientResources, clientOptions); - assertThat(writer.getIntent(Collections.emptyList())) - .isEqualTo(ConnectionIntent.WRITE); + assertThat(writer.getIntent(Collections.emptyList())).isEqualTo(ConnectionIntent.WRITE); } @Test @@ -96,11 +93,9 @@ void shouldReturnIntentForReadCommand() { RedisCommand get = new Command<>(CommandType.GET, null); RedisCommand mget = new Command<>(CommandType.MGET, null); - assertThat(writer.getIntent(Arrays.asList(get, mget))) - .isEqualTo(ConnectionIntent.READ); + assertThat(writer.getIntent(Arrays.asList(get, mget))).isEqualTo(ConnectionIntent.READ); - assertThat(writer.getIntent(Collections.singletonList(get))) - .isEqualTo(ConnectionIntent.READ); + assertThat(writer.getIntent(Collections.singletonList(get))).isEqualTo(ConnectionIntent.READ); } @Test @@ -111,11 +106,9 @@ void shouldReturnIntentForMixedCommands() { RedisCommand set = new Command<>(CommandType.SET, null); RedisCommand mget = new Command<>(CommandType.MGET, null); - assertThat(writer.getIntent(Arrays.asList(set, mget))) - .isEqualTo(ConnectionIntent.WRITE); + assertThat(writer.getIntent(Arrays.asList(set, mget))).isEqualTo(ConnectionIntent.WRITE); - assertThat(writer.getIntent(Collections.singletonList(set))) - .isEqualTo(ConnectionIntent.WRITE); + assertThat(writer.getIntent(Collections.singletonList(set))).isEqualTo(ConnectionIntent.WRITE); } @Test @@ -202,4 +195,5 @@ void shouldDeriveIntentFromCommandBatchTypeAfterDiscardedTransaction() { private static Command mockCommand(CommandType multi) { return new Command<>(multi, new StatusOutput<>(StringCodec.UTF8)); } + } diff --git a/src/test/java/io/lettuce/core/masterreplica/MasterReplicaSentinelSslIntegrationTests.java b/src/test/java/io/lettuce/core/masterreplica/MasterReplicaSentinelSslIntegrationTests.java index 807faacdb6..5e19c1a679 100644 --- a/src/test/java/io/lettuce/core/masterreplica/MasterReplicaSentinelSslIntegrationTests.java +++ b/src/test/java/io/lettuce/core/masterreplica/MasterReplicaSentinelSslIntegrationTests.java @@ -56,4 +56,5 @@ void testMasterReplicaSentinelBasic() { FastShutdown.shutdown(client); } + } diff --git a/src/test/java/io/lettuce/core/masterreplica/MasterReplicaTest.java b/src/test/java/io/lettuce/core/masterreplica/MasterReplicaTest.java index d0fe107460..97c3d27a8c 100644 --- a/src/test/java/io/lettuce/core/masterreplica/MasterReplicaTest.java +++ b/src/test/java/io/lettuce/core/masterreplica/MasterReplicaTest.java @@ -38,9 +38,11 @@ class MasterReplicaTest extends AbstractRedisClientTest { private StatefulRedisMasterReplicaConnection connection; private RedisURI upstream; + private RedisURI replica; private RedisCommands connection1; + private RedisCommands connection2; @BeforeEach @@ -151,10 +153,12 @@ void testConnectToReplica() { void noReplicaForRead() { connection.setReadFrom(new ReadFrom() { + @Override public List select(Nodes nodes) { return Collections.emptyList(); } + }); assertThatThrownBy(() -> replicaCall(connection)).isInstanceOf(RedisException.class); @@ -188,4 +192,5 @@ void testConnectToReplicaWithAcl() { static String replicaCall(StatefulRedisMasterReplicaConnection connection) { return connection.sync().info("replication"); } + } diff --git a/src/test/java/io/lettuce/core/masterreplica/MasterReplicaTopologyProviderUnitTests.java b/src/test/java/io/lettuce/core/masterreplica/MasterReplicaTopologyProviderUnitTests.java index 328dc74ee7..dc354e4175 100644 --- a/src/test/java/io/lettuce/core/masterreplica/MasterReplicaTopologyProviderUnitTests.java +++ b/src/test/java/io/lettuce/core/masterreplica/MasterReplicaTopologyProviderUnitTests.java @@ -103,7 +103,6 @@ void shouldParseIPv6UpstreamAddress() { List result = sut.getNodesFromInfo(info); assertThat(result).hasSize(2); - RedisNodeDescription replica = result.get(0); assertThat(replica.getRole().isReplica()).isTrue(); @@ -164,8 +163,7 @@ void shouldParseReplicas() { void shouldParseIPv6SlaveAddress() { String info = "# Replication\r\n" + "role:master\r\n" - + "slave0:ip=::20f8:1400:0:0,port=6483,state=online,offset=56276,lag=0\r\n" - + "master_repl_offset:56276\r\n" + + "slave0:ip=::20f8:1400:0:0,port=6483,state=online,offset=56276,lag=0\r\n" + "master_repl_offset:56276\r\n" + "repl_backlog_active:1\r\n"; List result = sut.getNodesFromInfo(info); @@ -177,4 +175,5 @@ void shouldParseIPv6SlaveAddress() { assertThat(replica1.getUri().getHost()).isEqualTo("::20f8:1400:0:0"); assertThat(replica1.getUri().getPort()).isEqualTo(6483); } + } diff --git a/src/test/java/io/lettuce/core/masterreplica/MasterReplicaTopologyRefreshUnitTests.java b/src/test/java/io/lettuce/core/masterreplica/MasterReplicaTopologyRefreshUnitTests.java index 3ba3071c10..ee305db84c 100644 --- a/src/test/java/io/lettuce/core/masterreplica/MasterReplicaTopologyRefreshUnitTests.java +++ b/src/test/java/io/lettuce/core/masterreplica/MasterReplicaTopologyRefreshUnitTests.java @@ -78,8 +78,7 @@ void tearDown() { @Test void shouldRetrieveTopology() { - MasterReplicaTopologyRefresh refresh = new MasterReplicaTopologyRefresh(connectionFactory, executorService, - provider); + MasterReplicaTopologyRefresh refresh = new MasterReplicaTopologyRefresh(connectionFactory, executorService, provider); CompletableFuture> master = CompletableFuture.completedFuture(connection); CompletableFuture> replica = CompletableFuture.completedFuture(connection); @@ -97,8 +96,7 @@ void shouldRetrieveTopology() { @Test void shouldRetrieveTopologyWithFailedNode() { - MasterReplicaTopologyRefresh refresh = new MasterReplicaTopologyRefresh(connectionFactory, executorService, - provider); + MasterReplicaTopologyRefresh refresh = new MasterReplicaTopologyRefresh(connectionFactory, executorService, provider); CompletableFuture> connected = CompletableFuture.completedFuture(connection); CompletableFuture> pending = new CompletableFuture<>(); @@ -112,4 +110,5 @@ void shouldRetrieveTopologyWithFailedNode() { assertThat(nodes).hasSize(1).containsOnly(UPSTREAM); } + } diff --git a/src/test/java/io/lettuce/core/masterreplica/MasterReplicaUtilsUnitTests.java b/src/test/java/io/lettuce/core/masterreplica/MasterReplicaUtilsUnitTests.java index 78b15067a8..107bd5f6bd 100644 --- a/src/test/java/io/lettuce/core/masterreplica/MasterReplicaUtilsUnitTests.java +++ b/src/test/java/io/lettuce/core/masterreplica/MasterReplicaUtilsUnitTests.java @@ -85,4 +85,5 @@ void isChangedShouldReturnTrueBecauseRolesSwitched() { assertThat(ReplicaUtils.isChanged(Arrays.asList(upstream, replica), Arrays.asList(newupstream, newslave))).isTrue(); assertThat(ReplicaUtils.isChanged(Arrays.asList(upstream, replica), Arrays.asList(newslave, newupstream))).isTrue(); } + } diff --git a/src/test/java/io/lettuce/core/masterreplica/SentinelTopologyRefreshUnitTests.java b/src/test/java/io/lettuce/core/masterreplica/SentinelTopologyRefreshUnitTests.java index a8e1d74453..ba1b95148c 100644 --- a/src/test/java/io/lettuce/core/masterreplica/SentinelTopologyRefreshUnitTests.java +++ b/src/test/java/io/lettuce/core/masterreplica/SentinelTopologyRefreshUnitTests.java @@ -48,6 +48,7 @@ class SentinelTopologyRefreshUnitTests { private static final RedisURI host1 = RedisURI.create("localhost", 1234); + private static final RedisURI host2 = RedisURI.create("localhost", 3456); @Mock @@ -76,8 +77,8 @@ class SentinelTopologyRefreshUnitTests { @BeforeEach void before() { - when(redisClient.connectPubSubAsync(any(StringCodec.class), eq(host1))).thenReturn( - ConnectionFuture.completed(null, connection)); + when(redisClient.connectPubSubAsync(any(StringCodec.class), eq(host1))) + .thenReturn(ConnectionFuture.completed(null, connection)); when(clientResources.eventExecutorGroup()).thenReturn(eventExecutors); when(redisClient.getResources()).thenReturn(clientResources); when(connection.async()).thenReturn(pubSubAsyncCommands); @@ -111,8 +112,8 @@ void bindWithSecondSentinelFails() { sut = new SentinelTopologyRefresh(redisClient, "mymaster", Arrays.asList(host1, host2)); - when(redisClient.connectPubSubAsync(any(StringCodec.class), eq(host2))).thenReturn( - ConnectionFuture.from(null, Futures.failed(new RedisConnectionException("err")))); + when(redisClient.connectPubSubAsync(any(StringCodec.class), eq(host2))) + .thenReturn(ConnectionFuture.from(null, Futures.failed(new RedisConnectionException("err")))); sut.bind(refreshRunnable); @@ -136,9 +137,9 @@ void bindWithSentinelRecovery() { sut = new SentinelTopologyRefresh(redisClient, "mymaster", Arrays.asList(host1, host2)); - when(redisClient.connectPubSubAsync(any(StringCodec.class), eq(host2))).thenReturn( - ConnectionFuture.from(null, Futures.failed(new RedisConnectionException("err")))).thenReturn( - ConnectionFuture.completed(null, connection2)); + when(redisClient.connectPubSubAsync(any(StringCodec.class), eq(host2))) + .thenReturn(ConnectionFuture.from(null, Futures.failed(new RedisConnectionException("err")))) + .thenReturn(ConnectionFuture.completed(null, connection2)); sut.bind(refreshRunnable); @@ -382,4 +383,5 @@ void shouldNotProcessIfExecutorIsShuttingDown() { private PubSubMessageHandler getMessageHandler() { return ReflectionTestUtils.getField(sut, "messageHandler"); } + } diff --git a/src/test/java/io/lettuce/core/masterreplica/StaticMasterReplicaTest.java b/src/test/java/io/lettuce/core/masterreplica/StaticMasterReplicaTest.java index 3b12a81e9e..0828ddfab2 100644 --- a/src/test/java/io/lettuce/core/masterreplica/StaticMasterReplicaTest.java +++ b/src/test/java/io/lettuce/core/masterreplica/StaticMasterReplicaTest.java @@ -33,9 +33,11 @@ class StaticMasterReplicaTest extends AbstractRedisClientTest { private StatefulRedisMasterReplicaConnection connection; private RedisURI upstream; + private RedisURI replica; private RedisCommands connection1; + private RedisCommands connection2; @BeforeEach @@ -208,4 +210,5 @@ MasterReplicaConnectionProvider getConnectionProvider() { MasterReplicaChannelWriter writer = ((StatefulRedisMasterReplicaConnectionImpl) connection).getChannelWriter(); return writer.getUpstreamReplicaConnectionProvider(); } + } diff --git a/src/test/java/io/lettuce/core/masterslave/MasterSlaveSentinelIntegrationTests.java b/src/test/java/io/lettuce/core/masterslave/MasterSlaveSentinelIntegrationTests.java index ca8ec06d03..9a0a5b603a 100644 --- a/src/test/java/io/lettuce/core/masterslave/MasterSlaveSentinelIntegrationTests.java +++ b/src/test/java/io/lettuce/core/masterslave/MasterSlaveSentinelIntegrationTests.java @@ -28,6 +28,7 @@ class MasterSlaveSentinelIntegrationTests extends TestSupport { private final Pattern pattern = Pattern.compile("role:(\\w+)"); + private final RedisClient redisClient; @Inject @@ -133,4 +134,5 @@ private void assertThatServerIs(String server, String expectation) { assertThat(matcher.find()).isTrue(); assertThat(matcher.group(1)).isEqualTo(expectation); } + } diff --git a/src/test/java/io/lettuce/core/masterslave/MasterSlaveTest.java b/src/test/java/io/lettuce/core/masterslave/MasterSlaveTest.java index 645bbd66e9..009bc24536 100644 --- a/src/test/java/io/lettuce/core/masterslave/MasterSlaveTest.java +++ b/src/test/java/io/lettuce/core/masterslave/MasterSlaveTest.java @@ -36,9 +36,11 @@ class MasterSlaveTest extends AbstractRedisClientTest { private StatefulRedisMasterSlaveConnection connection; private RedisURI upstream; + private RedisURI replica; private RedisCommands connection1; + private RedisCommands connection2; @BeforeEach @@ -149,10 +151,12 @@ void testConnectToSlave() { void noSlaveForRead() { connection.setReadFrom(new ReadFrom() { + @Override public List select(Nodes nodes) { return Collections.emptyList(); } + }); assertThatThrownBy(() -> slaveCall(connection)).isInstanceOf(RedisException.class); diff --git a/src/test/java/io/lettuce/core/masterslave/StaticMasterSlaveTest.java b/src/test/java/io/lettuce/core/masterslave/StaticMasterSlaveTest.java index 19f590186e..91d0ea4f4f 100644 --- a/src/test/java/io/lettuce/core/masterslave/StaticMasterSlaveTest.java +++ b/src/test/java/io/lettuce/core/masterslave/StaticMasterSlaveTest.java @@ -30,9 +30,11 @@ class StaticMasterSlaveTest extends AbstractRedisClientTest { private StatefulRedisMasterSlaveConnection connection; private RedisURI upstream; + private RedisURI replica; private RedisCommands connection1; + private RedisCommands connection2; @BeforeEach diff --git a/src/test/java/io/lettuce/core/metrics/CommandLatencyCollectorOptionsUnitTests.java b/src/test/java/io/lettuce/core/metrics/CommandLatencyCollectorOptionsUnitTests.java index 79611b6afd..91734cd678 100644 --- a/src/test/java/io/lettuce/core/metrics/CommandLatencyCollectorOptionsUnitTests.java +++ b/src/test/java/io/lettuce/core/metrics/CommandLatencyCollectorOptionsUnitTests.java @@ -33,10 +33,11 @@ class CommandLatencyCollectorOptionsUnitTests { @Test void testBuilder() { - CommandLatencyCollectorOptions sut = CommandLatencyCollectorOptions.builder() - .targetUnit(TimeUnit.HOURS).targetPercentiles(new double[] { 1, 2, 3 }).build(); + CommandLatencyCollectorOptions sut = CommandLatencyCollectorOptions.builder().targetUnit(TimeUnit.HOURS) + .targetPercentiles(new double[] { 1, 2, 3 }).build(); assertThat(sut.targetPercentiles()).hasSize(3); assertThat(sut.targetUnit()).isEqualTo(TimeUnit.HOURS); } + } diff --git a/src/test/java/io/lettuce/core/metrics/CommandLatencyIdUnitTests.java b/src/test/java/io/lettuce/core/metrics/CommandLatencyIdUnitTests.java index e4e0b3704f..f6f32247b3 100644 --- a/src/test/java/io/lettuce/core/metrics/CommandLatencyIdUnitTests.java +++ b/src/test/java/io/lettuce/core/metrics/CommandLatencyIdUnitTests.java @@ -57,5 +57,7 @@ public byte[] getBytes() { public String name() { return name; } + } + } diff --git a/src/test/java/io/lettuce/core/metrics/DefaultCommandLatencyCollectorOptionsUnitTests.java b/src/test/java/io/lettuce/core/metrics/DefaultCommandLatencyCollectorOptionsUnitTests.java index 2d6c1880b8..84c99a9241 100644 --- a/src/test/java/io/lettuce/core/metrics/DefaultCommandLatencyCollectorOptionsUnitTests.java +++ b/src/test/java/io/lettuce/core/metrics/DefaultCommandLatencyCollectorOptionsUnitTests.java @@ -31,10 +31,11 @@ void testDisabled() { @Test void testBuilder() { - DefaultCommandLatencyCollectorOptions sut = DefaultCommandLatencyCollectorOptions.builder() - .targetUnit(TimeUnit.HOURS).targetPercentiles(new double[] { 1, 2, 3 }).build(); + DefaultCommandLatencyCollectorOptions sut = DefaultCommandLatencyCollectorOptions.builder().targetUnit(TimeUnit.HOURS) + .targetPercentiles(new double[] { 1, 2, 3 }).build(); assertThat(sut.targetPercentiles()).hasSize(3); assertThat(sut.targetUnit()).isEqualTo(TimeUnit.HOURS); } + } diff --git a/src/test/java/io/lettuce/core/metrics/DefaultCommandLatencyCollectorUnitTests.java b/src/test/java/io/lettuce/core/metrics/DefaultCommandLatencyCollectorUnitTests.java index 6456551c13..3fba67c3dc 100644 --- a/src/test/java/io/lettuce/core/metrics/DefaultCommandLatencyCollectorUnitTests.java +++ b/src/test/java/io/lettuce/core/metrics/DefaultCommandLatencyCollectorUnitTests.java @@ -96,8 +96,7 @@ void shutdownShouldReleasePauseDetector() { @Test void verifyMetrics() { - sut = new DefaultCommandLatencyCollector(DefaultCommandLatencyCollectorOptions - .builder().usePauseDetector().build()); + sut = new DefaultCommandLatencyCollector(DefaultCommandLatencyCollectorOptions.builder().usePauseDetector().build()); setupData(); @@ -118,8 +117,8 @@ void verifyMetrics() { assertThat(metrics.getFirstResponse().getMax()).isBetween(290000L, 310000L); assertThat(metrics.getCompletion().getPercentiles()).containsKey(50.0d); - assertThat(metrics.getFirstResponse().getPercentiles().get(50d)).isLessThanOrEqualTo( - metrics.getCompletion().getPercentiles().get(50d)); + assertThat(metrics.getFirstResponse().getPercentiles().get(50d)) + .isLessThanOrEqualTo(metrics.getCompletion().getPercentiles().get(50d)); assertThat(metrics.getTimeUnit()).isEqualTo(MICROSECONDS); @@ -131,9 +130,8 @@ void verifyMetrics() { @Test void verifyCummulativeMetrics() { - sut = new DefaultCommandLatencyCollector(DefaultCommandLatencyCollectorOptions.builder() - .usePauseDetector() - .resetLatenciesAfterEvent(false).build()); + sut = new DefaultCommandLatencyCollector( + DefaultCommandLatencyCollectorOptions.builder().usePauseDetector().resetLatenciesAfterEvent(false).build()); setupData(); @@ -151,4 +149,5 @@ private void setupData() { sut.recordCommandLatency(LocalAddress.ANY, LocalAddress.ANY, CommandType.BGSAVE, MILLISECONDS.toNanos(300), MILLISECONDS.toNanos(1000)); } + } diff --git a/src/test/java/io/lettuce/core/metrics/MicrometerCommandLatencyRecorderUnitTests.java b/src/test/java/io/lettuce/core/metrics/MicrometerCommandLatencyRecorderUnitTests.java index 167e3d07de..edd1f63656 100644 --- a/src/test/java/io/lettuce/core/metrics/MicrometerCommandLatencyRecorderUnitTests.java +++ b/src/test/java/io/lettuce/core/metrics/MicrometerCommandLatencyRecorderUnitTests.java @@ -69,14 +69,12 @@ void verifyMetrics() { assertThat(meterRegistry.find(METRIC_FIRST_RESPONSE).timers()).hasSize(2); assertThat(meterRegistry.find(METRIC_FIRST_RESPONSE).tag(LABEL_COMMAND, CommandType.BGSAVE.name()).timers()).hasSize(1) .element(0).extracting(Timer::takeSnapshot).hasFieldOrPropertyWithValue("count", 3L) - .hasFieldOrPropertyWithValue("max", 300.0) - .hasFieldOrPropertyWithValue("total", 600.0); + .hasFieldOrPropertyWithValue("max", 300.0).hasFieldOrPropertyWithValue("total", 600.0); assertThat(meterRegistry.find(METRIC_COMPLETION).timers()).hasSize(2); assertThat(meterRegistry.find(METRIC_COMPLETION).tag(LABEL_COMMAND, CommandType.BGSAVE.name()).timers()).hasSize(1) .element(0).extracting(Timer::takeSnapshot).hasFieldOrPropertyWithValue("count", 3L) - .hasFieldOrPropertyWithValue("max", 1500.0) - .hasFieldOrPropertyWithValue("total", 3000.0); + .hasFieldOrPropertyWithValue("max", 1500.0).hasFieldOrPropertyWithValue("total", 3000.0); } @Test @@ -186,7 +184,8 @@ void enabledCommandsNotEmpty() { assertThat(meterRegistry.find(METRIC_FIRST_RESPONSE).timers()).hasSize(1); assertThat(meterRegistry.find(METRIC_COMPLETION).tag(LABEL_COMMAND, CommandType.CLUSTER.name()).timers()).hasSize(1); - assertThat(meterRegistry.find(METRIC_FIRST_RESPONSE).tag(LABEL_COMMAND, CommandType.CLUSTER.name()).timers()).hasSize(1); + assertThat(meterRegistry.find(METRIC_FIRST_RESPONSE).tag(LABEL_COMMAND, CommandType.CLUSTER.name()).timers()) + .hasSize(1); } } diff --git a/src/test/java/io/lettuce/core/models/role/RoleParserUnitTests.java b/src/test/java/io/lettuce/core/models/role/RoleParserUnitTests.java index ef3ec549b7..ddd7440502 100644 --- a/src/test/java/io/lettuce/core/models/role/RoleParserUnitTests.java +++ b/src/test/java/io/lettuce/core/models/role/RoleParserUnitTests.java @@ -17,7 +17,9 @@ class RoleParserUnitTests { private static final long REPLICATION_OFFSET_1 = 3167038L; + private static final long REPLICATION_OFFSET_2 = 3167039L; + private static final String LOCALHOST = "127.0.0.1"; @Test @@ -32,8 +34,8 @@ void emptyList() { @Test void invalidFirstElement() { - assertThatThrownBy(() -> RoleParser.parse(LettuceLists.newList(new Object()))).isInstanceOf( - IllegalArgumentException.class); + assertThatThrownBy(() -> RoleParser.parse(LettuceLists.newList(new Object()))) + .isInstanceOf(IllegalArgumentException.class); } @Test @@ -90,7 +92,8 @@ void replica() { @Test void sentinel() { - List input = LettuceLists.newList("sentinel", LettuceLists.newList("resque-master", "html-fragments-master", "stats-master")); + List input = LettuceLists.newList("sentinel", + LettuceLists.newList("resque-master", "html-fragments-master", "stats-master")); RedisInstance result = RoleParser.parse(input); @@ -152,4 +155,5 @@ void testModelTest() { assertThat(partner.toString()).contains(ReplicationPartner.class.getSimpleName()); } + } diff --git a/src/test/java/io/lettuce/core/models/stream/PendingParserUnitTests.java b/src/test/java/io/lettuce/core/models/stream/PendingParserUnitTests.java index c00e0a0c0a..cdcddf71d5 100644 --- a/src/test/java/io/lettuce/core/models/stream/PendingParserUnitTests.java +++ b/src/test/java/io/lettuce/core/models/stream/PendingParserUnitTests.java @@ -20,8 +20,7 @@ class PendingParserUnitTests { void shouldParseXpendingWithRangeOutput() { List result = PendingParser - .parseRange(Collections.singletonList(Arrays.asList("foo", "consumer", 1L, - 2L))); + .parseRange(Collections.singletonList(Arrays.asList("foo", "consumer", 1L, 2L))); assertThat(result).hasSize(1); @@ -37,11 +36,12 @@ void shouldParseXpendingWithRangeOutput() { @Test void shouldParseXpendingOutput() { - PendingMessages result = PendingParser.parse(Arrays.asList(16L, "from", "to", - Collections.singletonList(Arrays.asList("consumer", 17L)))); + PendingMessages result = PendingParser + .parse(Arrays.asList(16L, "from", "to", Collections.singletonList(Arrays.asList("consumer", 17L)))); assertThat(result.getCount()).isEqualTo(16); assertThat(result.getMessageIds()).isEqualTo(Range.create("from", "to")); assertThat(result.getConsumerMessageCount()).containsEntry("consumer", 17L); } + } diff --git a/src/test/java/io/lettuce/core/output/BooleanListOutputUnitTests.java b/src/test/java/io/lettuce/core/output/BooleanListOutputUnitTests.java index 6ae5cb0392..f3406b867a 100644 --- a/src/test/java/io/lettuce/core/output/BooleanListOutputUnitTests.java +++ b/src/test/java/io/lettuce/core/output/BooleanListOutputUnitTests.java @@ -36,4 +36,5 @@ void setByteNotImplemented() { assertThatThrownBy(() -> sut.set(ByteBuffer.wrap("4.567".getBytes()))) .isInstanceOf(UnsupportedOperationException.class); } + } diff --git a/src/test/java/io/lettuce/core/output/GeoCoordinatesListOutputUnitTests.java b/src/test/java/io/lettuce/core/output/GeoCoordinatesListOutputUnitTests.java index fb6a9352cf..6f14c5271b 100644 --- a/src/test/java/io/lettuce/core/output/GeoCoordinatesListOutputUnitTests.java +++ b/src/test/java/io/lettuce/core/output/GeoCoordinatesListOutputUnitTests.java @@ -31,4 +31,5 @@ void commandOutputCorrectlyDecoded() { assertThat(sut.get()).contains(new GeoCoordinates(1.234, 4.567)); } + } diff --git a/src/test/java/io/lettuce/core/output/GeoCoordinatesValueListOutputUnitTests.java b/src/test/java/io/lettuce/core/output/GeoCoordinatesValueListOutputUnitTests.java index 3208af1666..085dcc90b3 100644 --- a/src/test/java/io/lettuce/core/output/GeoCoordinatesValueListOutputUnitTests.java +++ b/src/test/java/io/lettuce/core/output/GeoCoordinatesValueListOutputUnitTests.java @@ -37,4 +37,5 @@ void commandOutputCorrectlyDecoded() { assertThat(sut.get()).contains(Value.just(new GeoCoordinates(1.234, 4.567))); } + } diff --git a/src/test/java/io/lettuce/core/output/GeoWithinListOutputUnitTests.java b/src/test/java/io/lettuce/core/output/GeoWithinListOutputUnitTests.java index bf0f5d5bbd..b173391f19 100644 --- a/src/test/java/io/lettuce/core/output/GeoWithinListOutputUnitTests.java +++ b/src/test/java/io/lettuce/core/output/GeoWithinListOutputUnitTests.java @@ -88,4 +88,5 @@ void commandOutputKeyAndCoordinatesDecoded() { assertThat(sut.get()).contains(new GeoWithin<>("key", null, null, new GeoCoordinates(1.234, 4.567))); } + } diff --git a/src/test/java/io/lettuce/core/output/ListOutputUnitTests.java b/src/test/java/io/lettuce/core/output/ListOutputUnitTests.java index 004504a084..8c1831f192 100644 --- a/src/test/java/io/lettuce/core/output/ListOutputUnitTests.java +++ b/src/test/java/io/lettuce/core/output/ListOutputUnitTests.java @@ -63,8 +63,11 @@ void setValueShouldConvert(Fixture fixture) { static class Fixture { final CommandOutput> commandOutput; + final StreamingOutput streamingOutput; + final byte[] valueBytes; + final Object value; Fixture(CommandOutput commandOutput, StreamingOutput streamingOutput, byte[] valueBytes, Object value) { @@ -79,5 +82,7 @@ static class Fixture { public String toString() { return commandOutput.getClass().getSimpleName() + "/" + value; } + } + } diff --git a/src/test/java/io/lettuce/core/output/MultiOutputUnitTests.java b/src/test/java/io/lettuce/core/output/MultiOutputUnitTests.java index 02e00deeb8..a7b9792d09 100644 --- a/src/test/java/io/lettuce/core/output/MultiOutputUnitTests.java +++ b/src/test/java/io/lettuce/core/output/MultiOutputUnitTests.java @@ -60,4 +60,5 @@ void shouldFailMulti() { assertThat(command.getOutput().getError()).isNull(); assertThat(output.getError()).isEqualTo("Fail"); } + } diff --git a/src/test/java/io/lettuce/core/output/ObjectOutputTests.java b/src/test/java/io/lettuce/core/output/ObjectOutputTests.java index b26c6e4fd3..87c0fa9813 100644 --- a/src/test/java/io/lettuce/core/output/ObjectOutputTests.java +++ b/src/test/java/io/lettuce/core/output/ObjectOutputTests.java @@ -23,147 +23,70 @@ class ObjectOutputTests { void shouldParseHelloWithModules() { String in = "%7\r\n" - // 1 - + "$6\r\n" - + "server\r\n" - + "$5\r\n" - + "redis\r\n" + // 1 + + "$6\r\n" + "server\r\n" + "$5\r\n" + "redis\r\n" // 2 - + "$7\r\n" - + "version\r\n" - + "$5\r\n" - + "7.2.0\r\n" + + "$7\r\n" + "version\r\n" + "$5\r\n" + "7.2.0\r\n" // 3 - + "$5\r\n" - + "proto\r\n" - + ":3\r\n" + + "$5\r\n" + "proto\r\n" + ":3\r\n" // 4 - + "$2\r\n" - + "id\r\n" - + ":3\r\n" + + "$2\r\n" + "id\r\n" + ":3\r\n" // 5 - + "$4\r\n" - + "mode\r\n" - + "$7\r\n" - + "cluster\r\n" + + "$4\r\n" + "mode\r\n" + "$7\r\n" + "cluster\r\n" // 6 - + "$4\r\n" - + "role\r\n" - + "$6\r\n" - + "master\r\n" + + "$4\r\n" + "role\r\n" + "$6\r\n" + "master\r\n" // 7 - + "$7\r\n" - + "modules\r\n" + + "$7\r\n" + "modules\r\n" // list + "*4\r\n" // map + "%4\r\n" - + "$4\r\n" - + "name\r\n" - + "$10\r\n" - + "timeseries\r\n" + + "$4\r\n" + "name\r\n" + "$10\r\n" + "timeseries\r\n" - + "$3\r\n" - + "ver\r\n" - + ":11001\r\n" + + "$3\r\n" + "ver\r\n" + ":11001\r\n" - + "$4\r\n" - + "path\r\n" - + "$19\r\n" - + "/enterprise-managed\r\n" + + "$4\r\n" + "path\r\n" + "$19\r\n" + "/enterprise-managed\r\n" - + "$4\r\n" - + "args\r\n" - + "*0\r\n" + + "$4\r\n" + "args\r\n" + "*0\r\n" // elem 1 + "%4\r\n" - + "$4\r\n" - + "name\r\n" - + "$11\r\n" - + "searchlight\r\n" + + "$4\r\n" + "name\r\n" + "$11\r\n" + "searchlight\r\n" - + "$3\r\n" - + "ver\r\n" - + ":20803\r\n" + + "$3\r\n" + "ver\r\n" + ":20803\r\n" - + "$4\r\n" - + "path\r\n" - + "$19\r\n" - + "/enterprise-managed\r\n" + + "$4\r\n" + "path\r\n" + "$19\r\n" + "/enterprise-managed\r\n" - + "$4\r\n" - + "args\r\n" + + "$4\r\n" + "args\r\n" + "*10\r\n" // 1 - + "$23\r\n" - + "FORK_GC_CLEAN_THRESHOLD\r\n" - + "$3\r\n" - + "100\r\n" + + "$23\r\n" + "FORK_GC_CLEAN_THRESHOLD\r\n" + "$3\r\n" + "100\r\n" // 2 - + "$19\r\n" - + "MAXAGGREGATERESULTS\r\n" - + "$5\r\n" - + "10000\r\n" + + "$19\r\n" + "MAXAGGREGATERESULTS\r\n" + "$5\r\n" + "10000\r\n" // 3 - + "$16\r\n" - + "MAXSEARCHRESULTS\r\n" - + "$5\r\n" - + "10000\r\n" + + "$16\r\n" + "MAXSEARCHRESULTS\r\n" + "$5\r\n" + "10000\r\n" // 4 - + "$7\r\n" - + "MT_MODE\r\n" - + "$26\r\n" - + "MT_MODE_ONLY_ON_OPERATIONS\r\n" + + "$7\r\n" + "MT_MODE\r\n" + "$26\r\n" + "MT_MODE_ONLY_ON_OPERATIONS\r\n" // 5 - + "$14\r\n" - + "WORKER_THREADS\r\n" - + "$1\r\n" - + "4\r\n" + + "$14\r\n" + "WORKER_THREADS\r\n" + "$1\r\n" + "4\r\n" // 6 - + "%4\r\n" - + "$4\r\n" - + "name\r\n" - + "$6\r\n" - + "ReJSON\r\n" - + "$3\r\n" - + "ver\r\n" - + ":20602\r\n" - + "$4\r\n" - + "path\r\n" - + "$19\r\n" - + "/enterprise-managed\r\n" - + "$4\r\n" - + "args\r\n" - + "*0\r\n" + + "%4\r\n" + "$4\r\n" + "name\r\n" + "$6\r\n" + "ReJSON\r\n" + "$3\r\n" + "ver\r\n" + ":20602\r\n" + "$4\r\n" + + "path\r\n" + "$19\r\n" + "/enterprise-managed\r\n" + "$4\r\n" + "args\r\n" + "*0\r\n" - + "%4\r\n" - + "$4\r\n" - + "name\r\n" - + "$2\r\n" - + "bf\r\n" - + "$3\r\n" - + "ver\r\n" - + ":20601\r\n" - + "$4\r\n" - + "path\r\n" - + "$19\r\n" - + "/enterprise-managed\r\n" - + "$4\r\n" - + "args\r\n" - + "*0\r\n"; + + "%4\r\n" + "$4\r\n" + "name\r\n" + "$2\r\n" + "bf\r\n" + "$3\r\n" + "ver\r\n" + ":20601\r\n" + "$4\r\n" + + "path\r\n" + "$19\r\n" + "/enterprise-managed\r\n" + "$4\r\n" + "args\r\n" + "*0\r\n"; RedisStateMachine rsm = new RedisStateMachine(ByteBufAllocator.DEFAULT); ObjectOutput output = new ObjectOutput<>(StringCodec.UTF8); @@ -183,4 +106,5 @@ void shouldParseHelloWithModules() { List args = (List) searchlight.get("args"); assertThat(args).containsSequence("MAXSEARCHRESULTS", "10000"); } + } diff --git a/src/test/java/io/lettuce/core/output/ReplayOutputUnitTests.java b/src/test/java/io/lettuce/core/output/ReplayOutputUnitTests.java index e55a82df9b..c6c3dee693 100644 --- a/src/test/java/io/lettuce/core/output/ReplayOutputUnitTests.java +++ b/src/test/java/io/lettuce/core/output/ReplayOutputUnitTests.java @@ -64,4 +64,5 @@ void shouldDecodeErrorResponse() { assertThat(replay.getError()).isEqualTo("foo"); assertThat(target.getError()).isEqualTo("foo"); } + } diff --git a/src/test/java/io/lettuce/core/output/ScoredValueListOutputUnitTests.java b/src/test/java/io/lettuce/core/output/ScoredValueListOutputUnitTests.java index 2990b83393..2b357b6b1b 100644 --- a/src/test/java/io/lettuce/core/output/ScoredValueListOutputUnitTests.java +++ b/src/test/java/io/lettuce/core/output/ScoredValueListOutputUnitTests.java @@ -38,4 +38,5 @@ void commandOutputCorrectlyDecoded() { assertThat(sut.get()).contains(ScoredValue.just(4.567, "key")); } + } diff --git a/src/test/java/io/lettuce/core/output/SocketAddressOutputUnitTests.java b/src/test/java/io/lettuce/core/output/SocketAddressOutputUnitTests.java index 5573da7d46..dcb741abdc 100644 --- a/src/test/java/io/lettuce/core/output/SocketAddressOutputUnitTests.java +++ b/src/test/java/io/lettuce/core/output/SocketAddressOutputUnitTests.java @@ -26,4 +26,5 @@ void shouldReportSocketAddress() { assertThat(output.get()).isNotNull().isInstanceOf(InetSocketAddress.class); } + } diff --git a/src/test/java/io/lettuce/core/output/StreamReadOutputUnitTests.java b/src/test/java/io/lettuce/core/output/StreamReadOutputUnitTests.java index 29d14f4aee..3b9eddee7c 100644 --- a/src/test/java/io/lettuce/core/output/StreamReadOutputUnitTests.java +++ b/src/test/java/io/lettuce/core/output/StreamReadOutputUnitTests.java @@ -175,4 +175,5 @@ void shouldDecodeFromTwoStreams() { assertThat(streamMessage2.getStream()).isEqualTo("stream2"); assertThat(streamMessage2.getBody()).hasSize(1).containsEntry("key2", "value2"); } + } diff --git a/src/test/java/io/lettuce/core/protocol/AsyncCommandUnitTests.java b/src/test/java/io/lettuce/core/protocol/AsyncCommandUnitTests.java index 6b5e43c40b..6e85a0a49a 100644 --- a/src/test/java/io/lettuce/core/protocol/AsyncCommandUnitTests.java +++ b/src/test/java/io/lettuce/core/protocol/AsyncCommandUnitTests.java @@ -28,7 +28,9 @@ public class AsyncCommandUnitTests { private RedisCodec codec = StringCodec.UTF8; + private Command internal; + private AsyncCommand sut; @BeforeEach @@ -84,8 +86,7 @@ void awaitWithExecutionException() { @Test void awaitWithCancelledCommand() { sut.cancel(); - assertThatThrownBy(() -> Futures.awaitOrCancel(sut, 5, TimeUnit.SECONDS)) - .isInstanceOf(CancellationException.class); + assertThatThrownBy(() -> Futures.awaitOrCancel(sut, 5, TimeUnit.SECONDS)).isInstanceOf(CancellationException.class); } @Test @@ -177,10 +178,12 @@ void awaitInterrupted2() { @Test void outputSubclassOverride1() { CommandOutput output = new CommandOutput(codec, null) { + @Override public String get() throws RedisException { return null; } + }; assertThatThrownBy(() -> output.set(null)).isInstanceOf(UnsupportedOperationException.class); } @@ -188,10 +191,12 @@ public String get() throws RedisException { @Test void outputSubclassOverride2() { CommandOutput output = new CommandOutput(codec, null) { + @Override public String get() throws RedisException { return null; } + }; assertThatThrownBy(() -> output.set(0)).isInstanceOf(UnsupportedOperationException.class); } @@ -203,11 +208,14 @@ void sillyTestsForEmmaCoverage() { } private enum MyKeywords implements ProtocolKeyword { + DUMMY; @Override public byte[] getBytes() { return name().getBytes(); } + } + } diff --git a/src/test/java/io/lettuce/core/protocol/CommandArgsUnitTests.java b/src/test/java/io/lettuce/core/protocol/CommandArgsUnitTests.java index 1f33fb83d4..910461962b 100644 --- a/src/test/java/io/lettuce/core/protocol/CommandArgsUnitTests.java +++ b/src/test/java/io/lettuce/core/protocol/CommandArgsUnitTests.java @@ -181,4 +181,5 @@ void addKeyUsingByteCodec() { assertThat(buffer.toString(StandardCharsets.US_ASCII)).isEqualTo(expected.toString(StandardCharsets.US_ASCII)); } + } diff --git a/src/test/java/io/lettuce/core/protocol/CommandUnitTests.java b/src/test/java/io/lettuce/core/protocol/CommandUnitTests.java index 2ce36ce495..f40b5fac13 100644 --- a/src/test/java/io/lettuce/core/protocol/CommandUnitTests.java +++ b/src/test/java/io/lettuce/core/protocol/CommandUnitTests.java @@ -113,10 +113,12 @@ void getWithTimeout() { @Test void outputSubclassOverride1() { CommandOutput output = new CommandOutput(StringCodec.UTF8, null) { + @Override public String get() throws RedisException { return null; } + }; assertThatThrownBy(() -> output.set(null)).isInstanceOf(UnsupportedOperationException.class); } @@ -124,10 +126,12 @@ public String get() throws RedisException { @Test void outputSubclassOverride2() { CommandOutput output = new CommandOutput(StringCodec.UTF8, null) { + @Override public String get() throws RedisException { return null; } + }; assertThatThrownBy(() -> output.set(0)).isInstanceOf(UnsupportedOperationException.class); } @@ -139,11 +143,14 @@ void sillyTestsForEmmaCoverage() { } private enum MyKeywords implements ProtocolKeyword { + DUMMY; @Override public byte[] getBytes() { return name().getBytes(); } + } + } diff --git a/src/test/java/io/lettuce/core/protocol/CommandWrapperUnitTests.java b/src/test/java/io/lettuce/core/protocol/CommandWrapperUnitTests.java index 53372a3871..b25706a2d4 100644 --- a/src/test/java/io/lettuce/core/protocol/CommandWrapperUnitTests.java +++ b/src/test/java/io/lettuce/core/protocol/CommandWrapperUnitTests.java @@ -21,6 +21,7 @@ class CommandWrapperUnitTests { private RedisCodec codec = StringCodec.UTF8; + private Command sut; @BeforeEach @@ -114,4 +115,5 @@ void shouldPropagateCallbacksToDelegate() { assertThat(counter).hasValue(1); } + } diff --git a/src/test/java/io/lettuce/core/protocol/ConnectionFailureIntegrationTests.java b/src/test/java/io/lettuce/core/protocol/ConnectionFailureIntegrationTests.java index 92ef7364e2..38f759c371 100644 --- a/src/test/java/io/lettuce/core/protocol/ConnectionFailureIntegrationTests.java +++ b/src/test/java/io/lettuce/core/protocol/ConnectionFailureIntegrationTests.java @@ -45,6 +45,7 @@ class ConnectionFailureIntegrationTests extends TestSupport { private final RedisClient client; + private final RedisURI defaultRedisUri = RedisURI.Builder.redis(TestSettings.host(), TestSettings.port()).build(); @Inject @@ -132,8 +133,7 @@ void failOnReconnect() throws Exception { @Test void failOnReconnectShouldSendEvents() throws Exception { - client.setOptions( - ClientOptions.builder().suspendReconnectOnProtocolFailure(false).build()); + client.setOptions(ClientOptions.builder().suspendReconnectOnProtocolFailure(false).build()); RandomResponseServer ts = getRandomResponseServer(); @@ -181,8 +181,7 @@ void failOnReconnectShouldSendEvents() throws Exception { @Test void cancelCommandsOnReconnectFailure() throws Exception { - client.setOptions( - ClientOptions.builder().cancelCommandsOnReconnectFailure(true).build()); + client.setOptions(ClientOptions.builder().cancelCommandsOnReconnectFailure(true).build()); RandomResponseServer ts = getRandomResponseServer(); @@ -288,10 +287,12 @@ void pingOnConnectFailureShouldCloseConnection() throws Exception { AtomicReference ref = new AtomicReference<>(); ClientResources clientResources = ClientResources.builder().nettyCustomizer(new NettyCustomizer() { + @Override public void afterChannelInitialized(Channel channel) { ref.set(channel); } + }).build(); // Cluster node with auth @@ -318,10 +319,12 @@ void pingOnConnectFailureShouldCloseConnectionOnReconnect() throws Exception { BlockingQueue ref = new LinkedBlockingQueue<>(); ClientResources clientResources = ClientResources.builder().nettyCustomizer(new NettyCustomizer() { + @Override public void afterChannelInitialized(Channel channel) { ref.add(channel); } + }).build(); RedisURI redisUri = RedisURI.create(TestSettings.host(), TestSettings.port()); @@ -392,4 +395,5 @@ RandomResponseServer getRandomResponseServer() throws InterruptedException { ts.initialize(TestSettings.nonexistentPort()); return ts; } + } diff --git a/src/test/java/io/lettuce/core/protocol/DefaultEndpointUnitTests.java b/src/test/java/io/lettuce/core/protocol/DefaultEndpointUnitTests.java index 4a6422e026..8080848920 100644 --- a/src/test/java/io/lettuce/core/protocol/DefaultEndpointUnitTests.java +++ b/src/test/java/io/lettuce/core/protocol/DefaultEndpointUnitTests.java @@ -381,11 +381,9 @@ void shouldNotReplayActivationCommands() { when(channel.isActive()).thenReturn(true); ConnectionTestUtil.getDisconnectedBuffer(sut) - .add(new ActivationCommand<>( - new Command<>(CommandType.SELECT, new StatusOutput<>(StringCodec.UTF8)))); + .add(new ActivationCommand<>(new Command<>(CommandType.SELECT, new StatusOutput<>(StringCodec.UTF8)))); ConnectionTestUtil.getDisconnectedBuffer(sut).add(new LatencyMeteredCommand<>( - new ActivationCommand<>( - new Command<>(CommandType.SUBSCRIBE, new StatusOutput<>(StringCodec.UTF8))))); + new ActivationCommand<>(new Command<>(CommandType.SUBSCRIBE, new StatusOutput<>(StringCodec.UTF8))))); doAnswer(i -> { diff --git a/src/test/java/io/lettuce/core/protocol/RatioDecodeBufferPolicyTest.java b/src/test/java/io/lettuce/core/protocol/RatioDecodeBufferPolicyTest.java index 3654ea4815..b48a86dc45 100644 --- a/src/test/java/io/lettuce/core/protocol/RatioDecodeBufferPolicyTest.java +++ b/src/test/java/io/lettuce/core/protocol/RatioDecodeBufferPolicyTest.java @@ -67,4 +67,5 @@ void shouldDiscardReadBytesWhenReachedUsageRatio() { verify(buffer).readerIndex(); verify(buffer).discardReadBytes(); } + } diff --git a/src/test/java/io/lettuce/core/protocol/RedisStateMachineResp2UnitTests.java b/src/test/java/io/lettuce/core/protocol/RedisStateMachineResp2UnitTests.java index d05d7ff3bd..a31c20bea1 100644 --- a/src/test/java/io/lettuce/core/protocol/RedisStateMachineResp2UnitTests.java +++ b/src/test/java/io/lettuce/core/protocol/RedisStateMachineResp2UnitTests.java @@ -53,8 +53,11 @@ class RedisStateMachineResp2UnitTests { private RedisCodec codec = StringCodec.UTF8; + private Charset charset = StandardCharsets.UTF_8; + private CommandOutput output; + private RedisStateMachine rsm; @BeforeAll @@ -196,4 +199,5 @@ void sillyTestsForEmmaCoverage() { ByteBuf buffer(String content) { return Unpooled.copiedBuffer(content, charset); } + } diff --git a/src/test/java/io/lettuce/core/protocol/RedisStateMachineResp3UnitTests.java b/src/test/java/io/lettuce/core/protocol/RedisStateMachineResp3UnitTests.java index 3b7a356272..f00c27b8ba 100644 --- a/src/test/java/io/lettuce/core/protocol/RedisStateMachineResp3UnitTests.java +++ b/src/test/java/io/lettuce/core/protocol/RedisStateMachineResp3UnitTests.java @@ -54,8 +54,11 @@ class RedisStateMachineResp3UnitTests { private RedisCodec codec = StringCodec.UTF8; + private Charset charset = StandardCharsets.UTF_8; + private CommandOutput output; + private RedisStateMachine rsm; @BeforeAll @@ -141,11 +144,9 @@ void booleanValue() { @Test void hello() { CommandOutput> output = new GenericMapOutput<>(codec); - assertThat( - rsm.decode(buffer("%7\r\n" + "$6\r\nserver\r\n$5\r\nredis\r\n" + "$7\r\nversion\r\n$11\r\n999.999.999\r\n" - + "$5\r\nproto\r\n:3\r\n" + "$2\r\nid\r\n:184\r\n" + "$4\r\nmode\r\n$10\r\nstandalone\r\n" - + "$4\r\nrole\r\n$6\r\nmaster\r\n" + "$7\r\nmodules\r\n*0\r\n"), - output)).isTrue(); + assertThat(rsm.decode(buffer("%7\r\n" + "$6\r\nserver\r\n$5\r\nredis\r\n" + "$7\r\nversion\r\n$11\r\n999.999.999\r\n" + + "$5\r\nproto\r\n:3\r\n" + "$2\r\nid\r\n:184\r\n" + "$4\r\nmode\r\n$10\r\nstandalone\r\n" + + "$4\r\nrole\r\n$6\r\nmaster\r\n" + "$7\r\nmodules\r\n*0\r\n"), output)).isTrue(); assertThat(output.get()).containsEntry("mode", "standalone"); } @@ -234,4 +235,5 @@ void sillyTestsForEmmaCoverage() { ByteBuf buffer(String content) { return Unpooled.copiedBuffer(content, charset); } + } diff --git a/src/test/java/io/lettuce/core/protocol/StateMachineUnitTests.java b/src/test/java/io/lettuce/core/protocol/StateMachineUnitTests.java index ff0164f567..54b3de051d 100644 --- a/src/test/java/io/lettuce/core/protocol/StateMachineUnitTests.java +++ b/src/test/java/io/lettuce/core/protocol/StateMachineUnitTests.java @@ -47,8 +47,11 @@ * @author Mark Paluch */ class StateMachineUnitTests { + private RedisCodec codec = StringCodec.UTF8; + private CommandOutput output; + private RedisStateMachine rsm; @BeforeAll @@ -189,4 +192,5 @@ void sillyTestsForEmmaCoverage() { ByteBuf buffer(String content) { return Unpooled.copiedBuffer(content, StandardCharsets.UTF_8); } + } diff --git a/src/test/java/io/lettuce/core/protocol/TransactionalCommandUnitTests.java b/src/test/java/io/lettuce/core/protocol/TransactionalCommandUnitTests.java index d6633a13ed..838d3498a7 100644 --- a/src/test/java/io/lettuce/core/protocol/TransactionalCommandUnitTests.java +++ b/src/test/java/io/lettuce/core/protocol/TransactionalCommandUnitTests.java @@ -24,4 +24,5 @@ void shouldCompleteOnException() { assertThat(command).isCompletedExceptionally(); } + } diff --git a/src/test/java/io/lettuce/core/pubsub/PubSubCommandHandlerUnitTests.java b/src/test/java/io/lettuce/core/pubsub/PubSubCommandHandlerUnitTests.java index 6a7aeae260..871915adae 100644 --- a/src/test/java/io/lettuce/core/pubsub/PubSubCommandHandlerUnitTests.java +++ b/src/test/java/io/lettuce/core/pubsub/PubSubCommandHandlerUnitTests.java @@ -316,4 +316,5 @@ void shouldCompleteWithChunkedResponseInterleavedSending() throws Exception { private static ByteBuf responseBytes(String s) { return Unpooled.wrappedBuffer(s.getBytes()); } + } diff --git a/src/test/java/io/lettuce/core/pubsub/PubSubEndpointUnitTests.java b/src/test/java/io/lettuce/core/pubsub/PubSubEndpointUnitTests.java index b3a3a143e0..bf109ee0bb 100644 --- a/src/test/java/io/lettuce/core/pubsub/PubSubEndpointUnitTests.java +++ b/src/test/java/io/lettuce/core/pubsub/PubSubEndpointUnitTests.java @@ -80,19 +80,23 @@ void listenerNotificationShouldFailGracefully() { AtomicInteger notified = new AtomicInteger(); sut.addListener(new RedisPubSubAdapter() { + @Override public void message(byte[] channel, byte[] message) { notified.incrementAndGet(); throw new UnsupportedOperationException(); } + }); sut.addListener(new RedisPubSubAdapter() { + @Override public void message(byte[] channel, byte[] message) { notified.incrementAndGet(); } + }); sut.notifyMessage(createMessage("message", "channel1", ByteArrayCodec.INSTANCE)); @@ -109,4 +113,5 @@ private static PubSubOutput createMessage(String action, String cha return output; } + } diff --git a/src/test/java/io/lettuce/core/pubsub/PubSubReactiveTest.java b/src/test/java/io/lettuce/core/pubsub/PubSubReactiveTest.java index 86a96a2562..4ebcf3ec5f 100644 --- a/src/test/java/io/lettuce/core/pubsub/PubSubReactiveTest.java +++ b/src/test/java/io/lettuce/core/pubsub/PubSubReactiveTest.java @@ -56,17 +56,25 @@ class PubSubReactiveTest extends AbstractRedisClientTest implements RedisPubSubListener { private RedisPubSubReactiveCommands pubsub; + private RedisPubSubReactiveCommands pubsub2; private BlockingQueue channels; + private BlockingQueue shardChannels; + private BlockingQueue patterns; + private BlockingQueue messages; + private BlockingQueue counts; private String shardChannel = "shard-channel"; + private String channel = "channel0"; + private String pattern = "channel*"; + private String message = "msg!"; @BeforeEach @@ -275,7 +283,7 @@ void pubsubShardMultipleChannels() { // StepVerifier.create(pubsub.ssubscribe(channel, "channel1", "channel3")).verifyComplete(); // StepVerifier.create(pubsub2.pubsubShardChannels().collectList()) - // .consumeNextWith(actual -> assertThat(actual).contains(channel, "channel1", "channel3")).verifyComplete(); + // .consumeNextWith(actual -> assertThat(actual).contains(channel, "channel1", "channel3")).verifyComplete(); } @Test @@ -283,7 +291,8 @@ void pubsubShardMultipleChannels() { void pubsubShardChannelsWithArg() { /// TODO : uncomment after SSUBSCRIBE is implemented // StepVerifier.create(pubsub.ssubscribe(channel)).verifyComplete(); - // Wait.untilTrue(() -> mono(pubsub2.pubsubShardChannels(pattern).filter(s -> channel.equals(s))) != null).waitOrTimeout(); + // Wait.untilTrue(() -> mono(pubsub2.pubsubShardChannels(pattern).filter(s -> channel.equals(s))) != + /// null).waitOrTimeout(); String result = mono(pubsub2.pubsubShardChannels(pattern).filter(s -> channel.equals(s))); // assertThat(result).isEqualToIgnoringCase(channel); @@ -314,6 +323,7 @@ void pubsubNumpat() { Long result = block(pubsub2.pubsubNumpat()); assertThat(result.longValue()).isGreaterThan(0); } + @Test void punsubscribe() throws Exception { @@ -420,6 +430,7 @@ void adapter() throws Exception { final BlockingQueue localCounts = LettuceFactories.newBlockingQueue(); RedisPubSubAdapter adapter = new RedisPubSubAdapter() { + @Override public void subscribed(String channel, long count) { super.subscribed(channel, count); @@ -431,6 +442,7 @@ public void unsubscribed(String channel, long count) { super.unsubscribed(channel, count); localCounts.add(count); } + }; pubsub.getStatefulConnection().addListener(adapter); @@ -519,4 +531,5 @@ T mono(Flux flux) { List all(Flux flux) { return flux.collectList().block(); } + } diff --git a/src/test/java/io/lettuce/core/pubsub/RedisPubSubAsyncCommandsImplUnitTests.java b/src/test/java/io/lettuce/core/pubsub/RedisPubSubAsyncCommandsImplUnitTests.java index 8eebf685fa..65b0a960aa 100644 --- a/src/test/java/io/lettuce/core/pubsub/RedisPubSubAsyncCommandsImplUnitTests.java +++ b/src/test/java/io/lettuce/core/pubsub/RedisPubSubAsyncCommandsImplUnitTests.java @@ -22,8 +22,10 @@ class RedisPubSubAsyncCommandsImplUnitTests { - private RedisPubSubAsyncCommandsImpl commands; + private RedisPubSubAsyncCommandsImpl commands; + private StatefulRedisPubSubConnection mockedConnection; + private final RedisCodec codec = StringCodec.UTF8; @BeforeEach @@ -35,12 +37,13 @@ void setup() { @Test void psubscribe() throws ExecutionException, InterruptedException { String pattern = "channelPattern"; - AsyncCommand dispachedMock = mock (AsyncCommand.class); + AsyncCommand dispachedMock = mock(AsyncCommand.class); when(mockedConnection.dispatch((RedisCommand) any())).thenReturn(dispachedMock); commands.psubscribe(pattern).get(); - ArgumentCaptor capturedCommand = ArgumentCaptor.forClass(AsyncCommand.class);; + ArgumentCaptor capturedCommand = ArgumentCaptor.forClass(AsyncCommand.class); + ; verify(mockedConnection).dispatch(capturedCommand.capture()); assertThat(capturedCommand.getValue().getType()).isEqualTo(PSUBSCRIBE); @@ -53,12 +56,13 @@ void psubscribe() throws ExecutionException, InterruptedException { @Test void punsubscribe() throws ExecutionException, InterruptedException { String pattern = "channelPattern"; - AsyncCommand dispachedMock = mock (AsyncCommand.class); + AsyncCommand dispachedMock = mock(AsyncCommand.class); when(mockedConnection.dispatch((RedisCommand) any())).thenReturn(dispachedMock); commands.punsubscribe(pattern).get(); - ArgumentCaptor capturedCommand = ArgumentCaptor.forClass(AsyncCommand.class);; + ArgumentCaptor capturedCommand = ArgumentCaptor.forClass(AsyncCommand.class); + ; verify(mockedConnection).dispatch(capturedCommand.capture()); assertThat(capturedCommand.getValue().getType()).isEqualTo(PUNSUBSCRIBE); @@ -71,12 +75,13 @@ void punsubscribe() throws ExecutionException, InterruptedException { @Test void subscribe() throws ExecutionException, InterruptedException { String pattern = "channelPattern"; - AsyncCommand dispachedMock = mock (AsyncCommand.class); + AsyncCommand dispachedMock = mock(AsyncCommand.class); when(mockedConnection.dispatch((RedisCommand) any())).thenReturn(dispachedMock); commands.subscribe(pattern).get(); - ArgumentCaptor capturedCommand = ArgumentCaptor.forClass(AsyncCommand.class);; + ArgumentCaptor capturedCommand = ArgumentCaptor.forClass(AsyncCommand.class); + ; verify(mockedConnection).dispatch(capturedCommand.capture()); assertThat(capturedCommand.getValue().getType()).isEqualTo(SUBSCRIBE); @@ -89,12 +94,13 @@ void subscribe() throws ExecutionException, InterruptedException { @Test void unsubscribe() throws ExecutionException, InterruptedException { String pattern = "channelPattern"; - AsyncCommand dispachedMock = mock (AsyncCommand.class); + AsyncCommand dispachedMock = mock(AsyncCommand.class); when(mockedConnection.dispatch((RedisCommand) any())).thenReturn(dispachedMock); commands.unsubscribe(pattern).get(); - ArgumentCaptor capturedCommand = ArgumentCaptor.forClass(AsyncCommand.class);; + ArgumentCaptor capturedCommand = ArgumentCaptor.forClass(AsyncCommand.class); + ; verify(mockedConnection).dispatch(capturedCommand.capture()); assertThat(capturedCommand.getValue().getType()).isEqualTo(UNSUBSCRIBE); @@ -109,12 +115,13 @@ void publish() throws ExecutionException, InterruptedException { String channel = "acmeChannel"; String message = "acmeMessage"; - AsyncCommand dispachedMock = mock (AsyncCommand.class); + AsyncCommand dispachedMock = mock(AsyncCommand.class); when(mockedConnection.dispatch((RedisCommand) any())).thenReturn(dispachedMock); commands.publish(channel, message).get(); - ArgumentCaptor capturedCommand = ArgumentCaptor.forClass(AsyncCommand.class);; + ArgumentCaptor capturedCommand = ArgumentCaptor.forClass(AsyncCommand.class); + ; verify(mockedConnection).dispatch(capturedCommand.capture()); assertThat(capturedCommand.getValue().getType()).isEqualTo(PUBLISH); @@ -128,12 +135,13 @@ void publish() throws ExecutionException, InterruptedException { void pubsubChannels() throws ExecutionException, InterruptedException { String pattern = "channelPattern"; - AsyncCommand dispachedMock = mock (AsyncCommand.class); + AsyncCommand dispachedMock = mock(AsyncCommand.class); when(mockedConnection.dispatch((RedisCommand) any())).thenReturn(dispachedMock); commands.pubsubChannels(pattern).get(); - ArgumentCaptor capturedCommand = ArgumentCaptor.forClass(AsyncCommand.class);; + ArgumentCaptor capturedCommand = ArgumentCaptor.forClass(AsyncCommand.class); + ; verify(mockedConnection).dispatch(capturedCommand.capture()); assertThat(capturedCommand.getValue().getType()).isEqualTo(PUBSUB); @@ -147,12 +155,13 @@ void pubsubChannels() throws ExecutionException, InterruptedException { void pubsubNumsub() throws ExecutionException, InterruptedException { String pattern = "channelPattern"; - AsyncCommand dispachedMock = mock (AsyncCommand.class); + AsyncCommand dispachedMock = mock(AsyncCommand.class); when(mockedConnection.dispatch((RedisCommand) any())).thenReturn(dispachedMock); commands.pubsubNumsub(pattern).get(); - ArgumentCaptor capturedCommand = ArgumentCaptor.forClass(AsyncCommand.class);; + ArgumentCaptor capturedCommand = ArgumentCaptor.forClass(AsyncCommand.class); + ; verify(mockedConnection).dispatch(capturedCommand.capture()); assertThat(capturedCommand.getValue().getType()).isEqualTo(PUBSUB); @@ -166,12 +175,13 @@ void pubsubNumsub() throws ExecutionException, InterruptedException { void pubsubShardChannels() throws ExecutionException, InterruptedException { String pattern = "channelPattern"; - AsyncCommand dispachedMock = mock (AsyncCommand.class); + AsyncCommand dispachedMock = mock(AsyncCommand.class); when(mockedConnection.dispatch((RedisCommand) any())).thenReturn(dispachedMock); commands.pubsubShardChannels(pattern).get(); - ArgumentCaptor capturedCommand = ArgumentCaptor.forClass(AsyncCommand.class);; + ArgumentCaptor capturedCommand = ArgumentCaptor.forClass(AsyncCommand.class); + ; verify(mockedConnection).dispatch(capturedCommand.capture()); assertThat(capturedCommand.getValue().getType()).isEqualTo(PUBSUB); @@ -185,12 +195,13 @@ void pubsubShardChannels() throws ExecutionException, InterruptedException { void pubsubShardNumsub() throws ExecutionException, InterruptedException { String pattern = "channelPattern"; - AsyncCommand dispachedMock = mock (AsyncCommand.class); + AsyncCommand dispachedMock = mock(AsyncCommand.class); when(mockedConnection.dispatch((RedisCommand) any())).thenReturn(dispachedMock); commands.pubsubShardNumsub(pattern).get(); - ArgumentCaptor capturedCommand = ArgumentCaptor.forClass(AsyncCommand.class);; + ArgumentCaptor capturedCommand = ArgumentCaptor.forClass(AsyncCommand.class); + ; verify(mockedConnection).dispatch(capturedCommand.capture()); assertThat(capturedCommand.getValue().getType()).isEqualTo(PUBSUB); @@ -209,7 +220,7 @@ void ssubscribe() throws ExecutionException, InterruptedException { commands.ssubscribe(pattern).get(); ArgumentCaptor capturedCommand = ArgumentCaptor.forClass(AsyncCommand.class); - + verify(mockedConnection).dispatch(capturedCommand.capture()); assertThat(capturedCommand.getValue().getType()).isEqualTo(SSUBSCRIBE); @@ -218,4 +229,5 @@ void ssubscribe() throws ExecutionException, InterruptedException { assertNotEquals(capturedCommand.getValue(), dispachedMock); } + } diff --git a/src/test/java/io/lettuce/core/pubsub/StatefulRedisPubSubConnectionImplUnitTests.java b/src/test/java/io/lettuce/core/pubsub/StatefulRedisPubSubConnectionImplUnitTests.java index 08f6fea6f4..160a601125 100644 --- a/src/test/java/io/lettuce/core/pubsub/StatefulRedisPubSubConnectionImplUnitTests.java +++ b/src/test/java/io/lettuce/core/pubsub/StatefulRedisPubSubConnectionImplUnitTests.java @@ -24,6 +24,7 @@ class StatefulRedisPubSubConnectionImplUnitTests { private StatefulRedisPubSubConnectionImpl connection; private final RedisCodec codec = StringCodec.UTF8; + private final Duration timeout = Duration.ofSeconds(5); PubSubEndpoint mockedEndpoint; @@ -44,7 +45,6 @@ void setup() { connection = new StatefulRedisPubSubConnectionImpl(mockedEndpoint, mockedWriter, codec, timeout); } - @Test void addListener() { RedisPubSubListener listener = mock(RedisPubSubListener.class); @@ -83,7 +83,7 @@ void resubscribeChannelSubscription() { RedisFuture commandFuture = subscriptions.get(0); assertEquals(1, subscriptions.size()); - assertInstanceOf( AsyncCommand.class, commandFuture); + assertInstanceOf(AsyncCommand.class, commandFuture); } @Test @@ -93,11 +93,11 @@ void resubscribeChannelAndPatternSubscription() { when(mockedEndpoint.hasPatternSubscriptions()).thenReturn(true); when(mockedEndpoint.getPatterns()).thenReturn(new HashSet<>(Arrays.asList(new String[] { "bcast*", "echo" }))); - List> subscriptions = connection.resubscribe(); assertEquals(2, subscriptions.size()); - assertInstanceOf( AsyncCommand.class, subscriptions.get(0)); - assertInstanceOf( AsyncCommand.class, subscriptions.get(1)); + assertInstanceOf(AsyncCommand.class, subscriptions.get(0)); + assertInstanceOf(AsyncCommand.class, subscriptions.get(1)); } + } diff --git a/src/test/java/io/lettuce/core/reactive/RedisPublisherVerification.java b/src/test/java/io/lettuce/core/reactive/RedisPublisherVerification.java index 88e0a4c625..a1b779aa00 100644 --- a/src/test/java/io/lettuce/core/reactive/RedisPublisherVerification.java +++ b/src/test/java/io/lettuce/core/reactive/RedisPublisherVerification.java @@ -33,6 +33,7 @@ public class RedisPublisherVerification extends PublisherVerification { private static RedisClient client; + private static StatefulRedisConnection connection; public RedisPublisherVerification() { diff --git a/src/test/java/io/lettuce/core/reactive/ScanStreamVerification.java b/src/test/java/io/lettuce/core/reactive/ScanStreamVerification.java index 37f7be1fd9..d182ed06c4 100644 --- a/src/test/java/io/lettuce/core/reactive/ScanStreamVerification.java +++ b/src/test/java/io/lettuce/core/reactive/ScanStreamVerification.java @@ -28,6 +28,7 @@ public class ScanStreamVerification extends PublisherVerification { private static final int ELEMENT_COUNT = 10000; private static RedisClient client; + private static StatefulRedisConnection connection; public ScanStreamVerification() { @@ -64,7 +65,7 @@ public Publisher createPublisher(long elements) { String element = "ScanStreamVerification-" + i; map.put(element, element); - if (i % 1000-2020 == 0 && !map.isEmpty()) { + if (i % 1000 - 2020 == 0 && !map.isEmpty()) { sync.mset(map); map.clear(); } diff --git a/src/test/java/io/lettuce/core/reliability/AtLeastOnceTest.java b/src/test/java/io/lettuce/core/reliability/AtLeastOnceTest.java index 68e96ae0aa..b290075057 100644 --- a/src/test/java/io/lettuce/core/reliability/AtLeastOnceTest.java +++ b/src/test/java/io/lettuce/core/reliability/AtLeastOnceTest.java @@ -128,8 +128,8 @@ void commandFailsWhenFailOnEncode() { RedisCommands verificationConnection = client.connect().sync(); connection.set(key, "1"); - AsyncCommand working = new AsyncCommand<>(new Command<>(CommandType.INCR, new IntegerOutput( - StringCodec.UTF8), new CommandArgs<>(StringCodec.UTF8).addKey(key))); + AsyncCommand working = new AsyncCommand<>(new Command<>(CommandType.INCR, + new IntegerOutput(StringCodec.UTF8), new CommandArgs<>(StringCodec.UTF8).addKey(key))); channelWriter.write(working); assertThat(working.await(2, TimeUnit.SECONDS)).isTrue(); assertThat(connection.get(key)).isEqualTo("2"); @@ -141,6 +141,7 @@ void commandFailsWhenFailOnEncode() { public void encode(ByteBuf buf) { throw new IllegalStateException("I want to break free"); } + }; channelWriter.write(command); @@ -258,6 +259,7 @@ public void encode(ByteBuf buf) { } super.encode(buf); } + }; } @@ -270,8 +272,8 @@ void commandFailsDuringDecode() { connection.set(key, "1"); - AsyncCommand command = new AsyncCommand(new Command<>(CommandType.INCR, new StatusOutput<>( - StringCodec.UTF8), new CommandArgs<>(StringCodec.UTF8).addKey(key))); + AsyncCommand command = new AsyncCommand(new Command<>(CommandType.INCR, + new StatusOutput<>(StringCodec.UTF8), new CommandArgs<>(StringCodec.UTF8).addKey(key))); channelWriter.write(command); diff --git a/src/test/java/io/lettuce/core/reliability/AtMostOnceTest.java b/src/test/java/io/lettuce/core/reliability/AtMostOnceTest.java index 9414ed5836..7963d5a98e 100644 --- a/src/test/java/io/lettuce/core/reliability/AtMostOnceTest.java +++ b/src/test/java/io/lettuce/core/reliability/AtMostOnceTest.java @@ -143,6 +143,7 @@ void commandNotExecutedFailsOnEncode() { public void encode(ByteBuf buf) { throw new IllegalStateException("I want to break free"); } + }; channelWriter.write(command); @@ -190,6 +191,7 @@ public void encode(ByteBuf buf) { } super.encode(buf); } + }; channelWriter.write(command); @@ -304,4 +306,5 @@ private Throwable getException(RedisFuture command) { } return null; } + } diff --git a/src/test/java/io/lettuce/core/resource/ConstantDelayUnitTests.java b/src/test/java/io/lettuce/core/resource/ConstantDelayUnitTests.java index 263aa9370c..7a171b4891 100644 --- a/src/test/java/io/lettuce/core/resource/ConstantDelayUnitTests.java +++ b/src/test/java/io/lettuce/core/resource/ConstantDelayUnitTests.java @@ -35,4 +35,5 @@ void shouldCreateConstantDelay() { assertThat(delay.createDelay(0)).isEqualTo(Duration.ofMillis(100)); assertThat(delay.createDelay(5)).isEqualTo(Duration.ofMillis(100)); } + } diff --git a/src/test/java/io/lettuce/core/resource/DecorrelatedJitterDelayUnitTests.java b/src/test/java/io/lettuce/core/resource/DecorrelatedJitterDelayUnitTests.java index 7677d790bb..3c0d3faf0e 100644 --- a/src/test/java/io/lettuce/core/resource/DecorrelatedJitterDelayUnitTests.java +++ b/src/test/java/io/lettuce/core/resource/DecorrelatedJitterDelayUnitTests.java @@ -35,14 +35,14 @@ class DecorrelatedJitterDelayUnitTests { @Test void shouldNotCreateIfLowerBoundIsNegative() { - assertThatThrownBy(() -> Delay.decorrelatedJitter(-1, 100, 0, TimeUnit.MILLISECONDS)).isInstanceOf( - IllegalArgumentException.class); + assertThatThrownBy(() -> Delay.decorrelatedJitter(-1, 100, 0, TimeUnit.MILLISECONDS)) + .isInstanceOf(IllegalArgumentException.class); } @Test void shouldNotCreateIfLowerBoundIsSameAsUpperBound() { - assertThatThrownBy(() -> Delay.decorrelatedJitter(100, 100, 1, TimeUnit.MILLISECONDS)).isInstanceOf( - IllegalArgumentException.class); + assertThatThrownBy(() -> Delay.decorrelatedJitter(100, 100, 1, TimeUnit.MILLISECONDS)) + .isInstanceOf(IllegalArgumentException.class); } @Test @@ -81,4 +81,5 @@ void testDefaultDelays() { assertThat(delay.createDelay(Integer.MAX_VALUE).toMillis()).isBetween(0L, 30000L); } } + } diff --git a/src/test/java/io/lettuce/core/resource/DefaultEventLoopGroupProviderUnitTests.java b/src/test/java/io/lettuce/core/resource/DefaultEventLoopGroupProviderUnitTests.java index 8f3d530d7e..cd274cb681 100644 --- a/src/test/java/io/lettuce/core/resource/DefaultEventLoopGroupProviderUnitTests.java +++ b/src/test/java/io/lettuce/core/resource/DefaultEventLoopGroupProviderUnitTests.java @@ -36,4 +36,5 @@ void getAfterShutdown() { TestFutures.awaitOrTimeout(sut.shutdown(10, 10, TimeUnit.MILLISECONDS)); assertThatThrownBy(() -> sut.allocate(NioEventLoopGroup.class)).isInstanceOf(IllegalStateException.class); } + } diff --git a/src/test/java/io/lettuce/core/resource/DirContextDnsResolverTests.java b/src/test/java/io/lettuce/core/resource/DirContextDnsResolverTests.java index 6618f56af4..412ebaa28b 100644 --- a/src/test/java/io/lettuce/core/resource/DirContextDnsResolverTests.java +++ b/src/test/java/io/lettuce/core/resource/DirContextDnsResolverTests.java @@ -177,4 +177,5 @@ void shouldWorkWithIpv6Addresses() throws Exception { assertThat(resolved[0]).isInstanceOf(Inet6Address.class); assertThat(resolved[0].getHostAddress()).isEqualTo("2a00:1450:4001:816:0:0:0:200e"); } + } diff --git a/src/test/java/io/lettuce/core/resource/EqualJitterDelayUnitTests.java b/src/test/java/io/lettuce/core/resource/EqualJitterDelayUnitTests.java index 2df3c480aa..12885548e9 100644 --- a/src/test/java/io/lettuce/core/resource/EqualJitterDelayUnitTests.java +++ b/src/test/java/io/lettuce/core/resource/EqualJitterDelayUnitTests.java @@ -35,14 +35,14 @@ class EqualJitterDelayUnitTests { @Test void shouldNotCreateIfLowerBoundIsNegative() { - assertThatThrownBy(() -> Delay.equalJitter(-1, 100, 1, TimeUnit.MILLISECONDS)).isInstanceOf( - IllegalArgumentException.class); + assertThatThrownBy(() -> Delay.equalJitter(-1, 100, 1, TimeUnit.MILLISECONDS)) + .isInstanceOf(IllegalArgumentException.class); } @Test void shouldNotCreateIfLowerBoundIsSameAsUpperBound() { - assertThatThrownBy(() -> Delay.equalJitter(100, 100, 1, TimeUnit.MILLISECONDS)).isInstanceOf( - IllegalArgumentException.class); + assertThatThrownBy(() -> Delay.equalJitter(100, 100, 1, TimeUnit.MILLISECONDS)) + .isInstanceOf(IllegalArgumentException.class); } @Test @@ -85,4 +85,5 @@ void testDefaultDelays() { assertThat(delay.createDelay(17).toMillis()).isBetween(0L, 30000L); assertThat(delay.createDelay(Integer.MAX_VALUE).toMillis()).isBetween(0L, 30000L); } + } diff --git a/src/test/java/io/lettuce/core/resource/ExponentialDelayUnitTests.java b/src/test/java/io/lettuce/core/resource/ExponentialDelayUnitTests.java index 5449234b49..9a4b6dfe9b 100644 --- a/src/test/java/io/lettuce/core/resource/ExponentialDelayUnitTests.java +++ b/src/test/java/io/lettuce/core/resource/ExponentialDelayUnitTests.java @@ -14,20 +14,20 @@ class ExponentialDelayUnitTests { @Test void shouldNotCreateIfLowerBoundIsNegative() { - assertThatThrownBy(() -> Delay.exponential(-1, 100, TimeUnit.MILLISECONDS, 10)).isInstanceOf( - IllegalArgumentException.class); + assertThatThrownBy(() -> Delay.exponential(-1, 100, TimeUnit.MILLISECONDS, 10)) + .isInstanceOf(IllegalArgumentException.class); } @Test void shouldNotCreateIfLowerBoundIsSameAsUpperBound() { - assertThatThrownBy(() -> Delay.exponential(100, 100, TimeUnit.MILLISECONDS, 10)).isInstanceOf( - IllegalArgumentException.class); + assertThatThrownBy(() -> Delay.exponential(100, 100, TimeUnit.MILLISECONDS, 10)) + .isInstanceOf(IllegalArgumentException.class); } @Test void shouldNotCreateIfPowerIsOne() { - assertThatThrownBy(() -> Delay.exponential(100, 1000, TimeUnit.MILLISECONDS, 1)).isInstanceOf( - IllegalArgumentException.class); + assertThatThrownBy(() -> Delay.exponential(100, 1000, TimeUnit.MILLISECONDS, 1)) + .isInstanceOf(IllegalArgumentException.class); } @Test @@ -83,4 +83,5 @@ void testPow10Delays() { assertThat(delay.createDelay(5).toMillis()).isEqualTo(10000); assertThat(delay.createDelay(Integer.MAX_VALUE).toMillis()).isEqualTo(10000); } + } diff --git a/src/test/java/io/lettuce/core/resource/FullJitterDelayUnitTests.java b/src/test/java/io/lettuce/core/resource/FullJitterDelayUnitTests.java index ffdf19609d..440b4f219d 100644 --- a/src/test/java/io/lettuce/core/resource/FullJitterDelayUnitTests.java +++ b/src/test/java/io/lettuce/core/resource/FullJitterDelayUnitTests.java @@ -35,14 +35,14 @@ class FullJitterDelayUnitTests { @Test void shouldNotCreateIfLowerBoundIsNegative() { - assertThatThrownBy(() -> Delay.fullJitter(-1, 100, 1, TimeUnit.MILLISECONDS)).isInstanceOf( - IllegalArgumentException.class); + assertThatThrownBy(() -> Delay.fullJitter(-1, 100, 1, TimeUnit.MILLISECONDS)) + .isInstanceOf(IllegalArgumentException.class); } @Test void shouldNotCreateIfLowerBoundIsSameAsUpperBound() { - assertThatThrownBy(() -> Delay.fullJitter(100, 100, 1, TimeUnit.MILLISECONDS)).isInstanceOf( - IllegalArgumentException.class); + assertThatThrownBy(() -> Delay.fullJitter(100, 100, 1, TimeUnit.MILLISECONDS)) + .isInstanceOf(IllegalArgumentException.class); } @Test @@ -85,4 +85,5 @@ void testDefaultDelays() { assertThat(delay.createDelay(17).toMillis()).isBetween(15000L, 30000L); assertThat(delay.createDelay(Integer.MAX_VALUE).toMillis()).isBetween(15000L, 30000L); } + } diff --git a/src/test/java/io/lettuce/core/resource/MappingSocketAddressResolverUnitTests.java b/src/test/java/io/lettuce/core/resource/MappingSocketAddressResolverUnitTests.java index 8657cd2983..50c79ed570 100644 --- a/src/test/java/io/lettuce/core/resource/MappingSocketAddressResolverUnitTests.java +++ b/src/test/java/io/lettuce/core/resource/MappingSocketAddressResolverUnitTests.java @@ -59,4 +59,5 @@ void shouldMapHostAndPort() { assertThat(resolve.getPort()).isEqualTo(RedisURI.DEFAULT_REDIS_PORT + 100); assertThat(resolve.getHostString()).isEqualTo("localhost-foo"); } + } diff --git a/src/test/java/io/lettuce/core/sentinel/SentinelCommandIntegrationTests.java b/src/test/java/io/lettuce/core/sentinel/SentinelCommandIntegrationTests.java index e71ec2133e..4dc95d7c58 100644 --- a/src/test/java/io/lettuce/core/sentinel/SentinelCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/sentinel/SentinelCommandIntegrationTests.java @@ -35,7 +35,9 @@ public class SentinelCommandIntegrationTests extends TestSupport { private final RedisClient redisClient; + private StatefulRedisSentinelConnection connection; + private RedisSentinelCommands sentinel; @Inject @@ -50,7 +52,8 @@ void before() { this.sentinel = getSyncConnection(this.connection); } - protected RedisSentinelCommands getSyncConnection(StatefulRedisSentinelConnection connection) { + protected RedisSentinelCommands getSyncConnection( + StatefulRedisSentinelConnection connection) { return connection.sync(); } @@ -206,4 +209,5 @@ void set() { String result = sentinel.set(SentinelTestSettings.MASTER_ID, "down-after-milliseconds", "1000"); assertThat(result).isEqualTo("OK"); } + } diff --git a/src/test/java/io/lettuce/core/sentinel/SentinelConnectionIntegrationTests.java b/src/test/java/io/lettuce/core/sentinel/SentinelConnectionIntegrationTests.java index a0f5bab26a..9f269fe9be 100644 --- a/src/test/java/io/lettuce/core/sentinel/SentinelConnectionIntegrationTests.java +++ b/src/test/java/io/lettuce/core/sentinel/SentinelConnectionIntegrationTests.java @@ -32,8 +32,11 @@ public class SentinelConnectionIntegrationTests extends TestSupport { private final RedisClient redisClient; + private StatefulRedisSentinelConnection connection; + private RedisSentinelCommands sentinel; + private RedisSentinelAsyncCommands sentinelAsync; @Inject @@ -49,7 +52,8 @@ void before() { this.sentinelAsync = this.connection.async(); } - protected RedisSentinelCommands getSyncConnection(StatefulRedisSentinelConnection connection) { + protected RedisSentinelCommands getSyncConnection( + StatefulRedisSentinelConnection connection) { return connection.sync(); } @@ -140,8 +144,8 @@ void connectToOneNode() { @Test void connectWithByteCodec() { - RedisSentinelCommands connection = redisClient.connectSentinel(new ByteArrayCodec(), - SentinelTestSettings.SENTINEL_URI).sync(); + RedisSentinelCommands connection = redisClient + .connectSentinel(new ByteArrayCodec(), SentinelTestSettings.SENTINEL_URI).sync(); assertThat(connection.master(SentinelTestSettings.MASTER_ID.getBytes())).isNotNull(); connection.getStatefulConnection().close(); } diff --git a/src/test/java/io/lettuce/core/sentinel/SentinelServerCommandIntegrationTests.java b/src/test/java/io/lettuce/core/sentinel/SentinelServerCommandIntegrationTests.java index a4bef94e69..e67abc5cfc 100644 --- a/src/test/java/io/lettuce/core/sentinel/SentinelServerCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/sentinel/SentinelServerCommandIntegrationTests.java @@ -49,7 +49,9 @@ public class SentinelServerCommandIntegrationTests extends TestSupport { private final RedisClient redisClient; + private StatefulRedisSentinelConnection connection; + private RedisSentinelCommands sentinel; @Inject diff --git a/src/test/java/io/lettuce/core/sentinel/SentinelSslIntegrationTests.java b/src/test/java/io/lettuce/core/sentinel/SentinelSslIntegrationTests.java index a4baa6a6f5..7adc3221bc 100644 --- a/src/test/java/io/lettuce/core/sentinel/SentinelSslIntegrationTests.java +++ b/src/test/java/io/lettuce/core/sentinel/SentinelSslIntegrationTests.java @@ -83,4 +83,5 @@ void shouldConnectToMasterUsingSentinel() { connection.close(); FastShutdown.shutdown(client); } + } diff --git a/src/test/java/io/lettuce/core/sentinel/SentinelTestSettings.java b/src/test/java/io/lettuce/core/sentinel/SentinelTestSettings.java index 2f9bb41829..5dd9383cba 100644 --- a/src/test/java/io/lettuce/core/sentinel/SentinelTestSettings.java +++ b/src/test/java/io/lettuce/core/sentinel/SentinelTestSettings.java @@ -11,8 +11,10 @@ public abstract class SentinelTestSettings extends TestSupport { public static final RedisURI SENTINEL_URI = RedisURI.Builder.sentinel(TestSettings.host(), SentinelTestSettings.MASTER_ID) .build(); + public static final String MASTER_ID = "mymaster"; private SentinelTestSettings() { } + } diff --git a/src/test/java/io/lettuce/core/sentinel/reactive/SentinelReactiveCommandTest.java b/src/test/java/io/lettuce/core/sentinel/reactive/SentinelReactiveCommandTest.java index b843a78ac0..03ecca13c9 100644 --- a/src/test/java/io/lettuce/core/sentinel/reactive/SentinelReactiveCommandTest.java +++ b/src/test/java/io/lettuce/core/sentinel/reactive/SentinelReactiveCommandTest.java @@ -20,7 +20,9 @@ public SentinelReactiveCommandTest(RedisClient redisClient) { } @Override - protected RedisSentinelCommands getSyncConnection(StatefulRedisSentinelConnection connection) { + protected RedisSentinelCommands getSyncConnection( + StatefulRedisSentinelConnection connection) { return ReactiveSyncInvocationHandler.sync(connection); } + } diff --git a/src/test/java/io/lettuce/core/sentinel/reactive/SentinelServerReactiveCommandTest.java b/src/test/java/io/lettuce/core/sentinel/reactive/SentinelServerReactiveCommandTest.java index 72b3b68de3..759ce65bca 100644 --- a/src/test/java/io/lettuce/core/sentinel/reactive/SentinelServerReactiveCommandTest.java +++ b/src/test/java/io/lettuce/core/sentinel/reactive/SentinelServerReactiveCommandTest.java @@ -23,4 +23,5 @@ protected RedisSentinelCommands getSyncConnection( StatefulRedisSentinelConnection connection) { return ReactiveSyncInvocationHandler.sync(connection); } + } diff --git a/src/test/java/io/lettuce/core/support/AsyncConnectionPoolSupportIntegrationTests.java b/src/test/java/io/lettuce/core/support/AsyncConnectionPoolSupportIntegrationTests.java index 50f4991255..798d16c4b5 100644 --- a/src/test/java/io/lettuce/core/support/AsyncConnectionPoolSupportIntegrationTests.java +++ b/src/test/java/io/lettuce/core/support/AsyncConnectionPoolSupportIntegrationTests.java @@ -33,7 +33,9 @@ class AsyncConnectionPoolSupportIntegrationTests extends TestSupport { private static RedisClient client; + private static Set channels; + private static RedisURI uri = RedisURI.Builder.redis(host, port).build(); @BeforeAll @@ -53,8 +55,8 @@ static void afterClass() { @Test void asyncPoolShouldWorkWithWrappedConnections() { - BoundedAsyncPool> pool = AsyncConnectionPoolSupport.createBoundedObjectPool( - () -> client.connectAsync(StringCodec.ASCII, uri), BoundedPoolConfig.create()); + BoundedAsyncPool> pool = AsyncConnectionPoolSupport + .createBoundedObjectPool(() -> client.connectAsync(StringCodec.ASCII, uri), BoundedPoolConfig.create()); borrowAndReturn(pool); borrowAndClose(pool); @@ -122,8 +124,8 @@ void asyncPoolShouldCloseConnectionsAboveMaxIdleSize() { @Test void asyncPoolShouldWorkWithPlainConnections() { - AsyncPool> pool = AsyncConnectionPoolSupport.createBoundedObjectPool( - () -> client.connectAsync(StringCodec.ASCII, uri), BoundedPoolConfig.create(), false); + AsyncPool> pool = AsyncConnectionPoolSupport + .createBoundedObjectPool(() -> client.connectAsync(StringCodec.ASCII, uri), BoundedPoolConfig.create(), false); borrowAndReturn(pool); @@ -137,8 +139,8 @@ void asyncPoolShouldWorkWithPlainConnections() { @Test void asyncPoolUsingWrappingShouldPropagateExceptionsCorrectly() { - AsyncPool> pool = AsyncConnectionPoolSupport.createBoundedObjectPool( - () -> client.connectAsync(StringCodec.ASCII, uri), BoundedPoolConfig.create()); + AsyncPool> pool = AsyncConnectionPoolSupport + .createBoundedObjectPool(() -> client.connectAsync(StringCodec.ASCII, uri), BoundedPoolConfig.create()); StatefulRedisConnection connection = TestFutures.getOrTimeout(pool.acquire()); RedisCommands sync = connection.sync(); @@ -158,20 +160,20 @@ void asyncPoolUsingWrappingShouldPropagateExceptionsCorrectly() { @Test void wrappedConnectionShouldUseWrappers() { - AsyncPool> pool = AsyncConnectionPoolSupport.createBoundedObjectPool( - () -> client.connectAsync(StringCodec.ASCII, uri), BoundedPoolConfig.create()); + AsyncPool> pool = AsyncConnectionPoolSupport + .createBoundedObjectPool(() -> client.connectAsync(StringCodec.ASCII, uri), BoundedPoolConfig.create()); StatefulRedisConnection connection = TestFutures.getOrTimeout(pool.acquire()); RedisCommands sync = connection.sync(); - assertThat(connection).isInstanceOf(StatefulRedisConnection.class).isNotInstanceOf( - StatefulRedisClusterConnectionImpl.class); + assertThat(connection).isInstanceOf(StatefulRedisConnection.class) + .isNotInstanceOf(StatefulRedisClusterConnectionImpl.class); assertThat(Proxy.isProxyClass(connection.getClass())).isTrue(); assertThat(sync).isInstanceOf(RedisCommands.class); assertThat(connection.async()).isInstanceOf(RedisAsyncCommands.class).isNotInstanceOf(RedisAsyncCommandsImpl.class); - assertThat(connection.reactive()).isInstanceOf(RedisReactiveCommands.class).isNotInstanceOf( - RedisReactiveCommandsImpl.class); + assertThat(connection.reactive()).isInstanceOf(RedisReactiveCommands.class) + .isNotInstanceOf(RedisReactiveCommandsImpl.class); assertThat(sync.getStatefulConnection()).isInstanceOf(StatefulRedisConnection.class) .isNotInstanceOf(StatefulRedisConnectionImpl.class).isSameAs(connection); @@ -182,8 +184,8 @@ void wrappedConnectionShouldUseWrappers() { @Test void wrappedObjectClosedAfterReturn() { - AsyncPool> pool = AsyncConnectionPoolSupport.createBoundedObjectPool( - () -> client.connectAsync(StringCodec.ASCII, uri), BoundedPoolConfig.create(), true); + AsyncPool> pool = AsyncConnectionPoolSupport + .createBoundedObjectPool(() -> client.connectAsync(StringCodec.ASCII, uri), BoundedPoolConfig.create(), true); StatefulRedisConnection connection = TestFutures.getOrTimeout(pool.acquire()); RedisCommands sync = connection.sync(); @@ -204,8 +206,8 @@ void wrappedObjectClosedAfterReturn() { @Test void shouldPropagateAsyncFlow() { - AsyncPool> pool = AsyncConnectionPoolSupport.createBoundedObjectPool( - () -> client.connectAsync(StringCodec.ASCII, uri), BoundedPoolConfig.create()); + AsyncPool> pool = AsyncConnectionPoolSupport + .createBoundedObjectPool(() -> client.connectAsync(StringCodec.ASCII, uri), BoundedPoolConfig.create()); CompletableFuture pingResponse = pool.acquire().thenCompose(c -> { return c.async().ping().whenComplete((s, throwable) -> pool.release(c)); @@ -246,4 +248,5 @@ private void borrowAndCloseAsync(AsyncPool pool = new BoundedAsyncPool<>(factory, BoundedPoolConfig.builder().maxTotal(20).minIdle(5) - .build()); + BoundedAsyncPool pool = new BoundedAsyncPool<>(factory, + BoundedPoolConfig.builder().maxTotal(20).minIdle(5).build()); assertThat(pool.getIdle()).isEqualTo(5); @@ -322,8 +322,8 @@ void shouldDisposeIdleObjects() { mockCreation(); - BoundedAsyncPool pool = new BoundedAsyncPool<>(factory, BoundedPoolConfig.builder().maxTotal(20).maxIdle(5) - .minIdle(5).build()); + BoundedAsyncPool pool = new BoundedAsyncPool<>(factory, + BoundedPoolConfig.builder().maxTotal(20).maxIdle(5).minIdle(5).build()); assertThat(pool.getIdle()).isEqualTo(5); @@ -334,4 +334,5 @@ void shouldDisposeIdleObjects() { verify(factory).destroy(object); } + } diff --git a/src/test/java/io/lettuce/core/support/CdiIntegrationTests.java b/src/test/java/io/lettuce/core/support/CdiIntegrationTests.java index d26e5220c5..9edefdb1c0 100644 --- a/src/test/java/io/lettuce/core/support/CdiIntegrationTests.java +++ b/src/test/java/io/lettuce/core/support/CdiIntegrationTests.java @@ -83,4 +83,5 @@ void testInjection() { injectedClient.pingRedis(); } + } diff --git a/src/test/java/io/lettuce/core/support/CommonsPool2ConfigConverterUnitTests.java b/src/test/java/io/lettuce/core/support/CommonsPool2ConfigConverterUnitTests.java index 2d13294312..757156e7d7 100644 --- a/src/test/java/io/lettuce/core/support/CommonsPool2ConfigConverterUnitTests.java +++ b/src/test/java/io/lettuce/core/support/CommonsPool2ConfigConverterUnitTests.java @@ -81,4 +81,5 @@ static void booleanTester(boolean value, BiConsumer, assertThat(targetExtractor.apply(result)).isEqualTo(value); } + } diff --git a/src/test/java/io/lettuce/core/support/ConnectionPoolSupportIntegrationTests.java b/src/test/java/io/lettuce/core/support/ConnectionPoolSupportIntegrationTests.java index 2932f55d14..05b98024c8 100644 --- a/src/test/java/io/lettuce/core/support/ConnectionPoolSupportIntegrationTests.java +++ b/src/test/java/io/lettuce/core/support/ConnectionPoolSupportIntegrationTests.java @@ -43,6 +43,7 @@ class ConnectionPoolSupportIntegrationTests extends TestSupport { private static RedisClient client; + private static Set channels; @BeforeAll @@ -61,8 +62,8 @@ static void afterClass() { @Test void genericPoolShouldWorkWithWrappedConnections() throws Exception { - GenericObjectPool> pool = ConnectionPoolSupport.createGenericObjectPool( - () -> client.connect(), new GenericObjectPoolConfig<>()); + GenericObjectPool> pool = ConnectionPoolSupport + .createGenericObjectPool(() -> client.connect(), new GenericObjectPoolConfig<>()); borrowAndReturn(pool); borrowAndClose(pool); @@ -86,8 +87,8 @@ void genericPoolShouldCloseConnectionsAboveMaxIdleSize() throws Exception { GenericObjectPoolConfig> poolConfig = new GenericObjectPoolConfig<>(); poolConfig.setMaxIdle(2); - GenericObjectPool> pool = ConnectionPoolSupport.createGenericObjectPool( - () -> client.connect(), poolConfig); + GenericObjectPool> pool = ConnectionPoolSupport + .createGenericObjectPool(() -> client.connect(), poolConfig); borrowAndReturn(pool); borrowAndClose(pool); @@ -115,8 +116,8 @@ void genericPoolShouldCloseConnectionsAboveMaxIdleSize() throws Exception { @Test void genericPoolShouldWorkWithPlainConnections() throws Exception { - GenericObjectPool> pool = ConnectionPoolSupport.createGenericObjectPool( - () -> client.connect(), new GenericObjectPoolConfig<>(), false); + GenericObjectPool> pool = ConnectionPoolSupport + .createGenericObjectPool(() -> client.connect(), new GenericObjectPoolConfig<>(), false); borrowAndReturn(pool); @@ -146,8 +147,8 @@ void softReferencePoolShouldWorkWithPlainConnections() throws Exception { @Test void genericPoolUsingWrappingShouldPropagateExceptionsCorrectly() throws Exception { - GenericObjectPool> pool = ConnectionPoolSupport.createGenericObjectPool( - () -> client.connect(), new GenericObjectPoolConfig<>()); + GenericObjectPool> pool = ConnectionPoolSupport + .createGenericObjectPool(() -> client.connect(), new GenericObjectPoolConfig<>()); StatefulRedisConnection connection = pool.borrowObject(); RedisCommands sync = connection.sync(); @@ -167,20 +168,20 @@ void genericPoolUsingWrappingShouldPropagateExceptionsCorrectly() throws Excepti @Test void wrappedConnectionShouldUseWrappers() throws Exception { - GenericObjectPool> pool = ConnectionPoolSupport.createGenericObjectPool( - () -> client.connect(), new GenericObjectPoolConfig<>()); + GenericObjectPool> pool = ConnectionPoolSupport + .createGenericObjectPool(() -> client.connect(), new GenericObjectPoolConfig<>()); StatefulRedisConnection connection = pool.borrowObject(); RedisCommands sync = connection.sync(); - assertThat(connection).isInstanceOf(StatefulRedisConnection.class).isNotInstanceOf( - StatefulRedisClusterConnectionImpl.class); + assertThat(connection).isInstanceOf(StatefulRedisConnection.class) + .isNotInstanceOf(StatefulRedisClusterConnectionImpl.class); assertThat(Proxy.isProxyClass(connection.getClass())).isTrue(); assertThat(sync).isInstanceOf(RedisCommands.class); assertThat(connection.async()).isInstanceOf(RedisAsyncCommands.class).isNotInstanceOf(RedisAsyncCommandsImpl.class); - assertThat(connection.reactive()).isInstanceOf(RedisReactiveCommands.class).isNotInstanceOf( - RedisReactiveCommandsImpl.class); + assertThat(connection.reactive()).isInstanceOf(RedisReactiveCommands.class) + .isNotInstanceOf(RedisReactiveCommandsImpl.class); assertThat(sync.getStatefulConnection()).isInstanceOf(StatefulRedisConnection.class) .isNotInstanceOf(StatefulRedisConnectionImpl.class).isSameAs(connection); @@ -203,8 +204,8 @@ void wrappedMasterSlaveConnectionShouldUseWrappers() throws Exception { assertThat(sync).isInstanceOf(RedisCommands.class); assertThat(connection.async()).isInstanceOf(RedisAsyncCommands.class).isNotInstanceOf(RedisAsyncCommandsImpl.class); - assertThat(connection.reactive()).isInstanceOf(RedisReactiveCommands.class).isNotInstanceOf( - RedisReactiveCommandsImpl.class); + assertThat(connection.reactive()).isInstanceOf(RedisReactiveCommands.class) + .isNotInstanceOf(RedisReactiveCommandsImpl.class); assertThat(sync.getStatefulConnection()).isInstanceOf(StatefulRedisConnection.class) .isNotInstanceOf(StatefulRedisConnectionImpl.class).isSameAs(connection); @@ -218,21 +219,21 @@ void wrappedClusterConnectionShouldUseWrappers() throws Exception { RedisClusterClient redisClusterClient = RedisClusterClient.create(TestClientResources.get(), RedisURI.create(TestSettings.host(), 7379)); - GenericObjectPool> pool = ConnectionPoolSupport.createGenericObjectPool( - redisClusterClient::connect, new GenericObjectPoolConfig<>()); + GenericObjectPool> pool = ConnectionPoolSupport + .createGenericObjectPool(redisClusterClient::connect, new GenericObjectPoolConfig<>()); StatefulRedisClusterConnection connection = pool.borrowObject(); RedisAdvancedClusterCommands sync = connection.sync(); - assertThat(connection).isInstanceOf(StatefulRedisClusterConnection.class).isNotInstanceOf( - StatefulRedisClusterConnectionImpl.class); + assertThat(connection).isInstanceOf(StatefulRedisClusterConnection.class) + .isNotInstanceOf(StatefulRedisClusterConnectionImpl.class); assertThat(Proxy.isProxyClass(connection.getClass())).isTrue(); assertThat(sync).isInstanceOf(RedisAdvancedClusterCommands.class); - assertThat(connection.async()).isInstanceOf(RedisAdvancedClusterAsyncCommands.class).isNotInstanceOf( - RedisAdvancedClusterAsyncCommandsImpl.class); - assertThat(connection.reactive()).isInstanceOf(RedisAdvancedClusterReactiveCommands.class).isNotInstanceOf( - RedisAdvancedClusterReactiveCommandsImpl.class); + assertThat(connection.async()).isInstanceOf(RedisAdvancedClusterAsyncCommands.class) + .isNotInstanceOf(RedisAdvancedClusterAsyncCommandsImpl.class); + assertThat(connection.reactive()).isInstanceOf(RedisAdvancedClusterReactiveCommands.class) + .isNotInstanceOf(RedisAdvancedClusterReactiveCommandsImpl.class); assertThat(sync.getStatefulConnection()).isInstanceOf(StatefulRedisClusterConnection.class) .isNotInstanceOf(StatefulRedisClusterConnectionImpl.class).isSameAs(connection); @@ -245,22 +246,22 @@ void wrappedClusterConnectionShouldUseWrappers() throws Exception { @Test void plainConnectionShouldNotUseWrappers() throws Exception { - GenericObjectPool> pool = ConnectionPoolSupport.createGenericObjectPool( - () -> client.connect(), new GenericObjectPoolConfig<>(), false); + GenericObjectPool> pool = ConnectionPoolSupport + .createGenericObjectPool(() -> client.connect(), new GenericObjectPoolConfig<>(), false); StatefulRedisConnection connection = pool.borrowObject(); RedisCommands sync = connection.sync(); - assertThat(connection).isInstanceOf(StatefulRedisConnection.class).isNotInstanceOf( - StatefulRedisClusterConnectionImpl.class); + assertThat(connection).isInstanceOf(StatefulRedisConnection.class) + .isNotInstanceOf(StatefulRedisClusterConnectionImpl.class); assertThat(Proxy.isProxyClass(connection.getClass())).isFalse(); assertThat(sync).isInstanceOf(RedisCommands.class); assertThat(connection.async()).isInstanceOf(RedisAsyncCommands.class).isInstanceOf(RedisAsyncCommandsImpl.class); - assertThat(connection.reactive()).isInstanceOf(RedisReactiveCommands.class).isInstanceOf( - RedisReactiveCommandsImpl.class); - assertThat(sync.getStatefulConnection()).isInstanceOf(StatefulRedisConnection.class).isInstanceOf( - StatefulRedisConnectionImpl.class); + assertThat(connection.reactive()).isInstanceOf(RedisReactiveCommands.class) + .isInstanceOf(RedisReactiveCommandsImpl.class); + assertThat(sync.getStatefulConnection()).isInstanceOf(StatefulRedisConnection.class) + .isInstanceOf(StatefulRedisConnectionImpl.class); pool.returnObject(connection); pool.close(); @@ -290,8 +291,8 @@ void softRefPoolShouldWorkWithWrappedConnections() throws Exception { @Test void wrappedObjectClosedAfterReturn() throws Exception { - GenericObjectPool> pool = ConnectionPoolSupport.createGenericObjectPool( - () -> client.connect(), new GenericObjectPoolConfig<>(), true); + GenericObjectPool> pool = ConnectionPoolSupport + .createGenericObjectPool(() -> client.connect(), new GenericObjectPoolConfig<>(), true); StatefulRedisConnection connection = pool.borrowObject(); RedisCommands sync = connection.sync(); @@ -312,8 +313,8 @@ void wrappedObjectClosedAfterReturn() throws Exception { @Test void tryWithResourcesReturnsConnectionToPool() throws Exception { - GenericObjectPool> pool = ConnectionPoolSupport.createGenericObjectPool( - () -> client.connect(), new GenericObjectPoolConfig<>()); + GenericObjectPool> pool = ConnectionPoolSupport + .createGenericObjectPool(() -> client.connect(), new GenericObjectPoolConfig<>()); StatefulRedisConnection usedConnection = null; try (StatefulRedisConnection connection = pool.borrowObject()) { @@ -388,4 +389,5 @@ private void borrowAndClose(ObjectPool> connection.close(); } } + } diff --git a/src/test/java/io/lettuce/core/support/InjectedClient.java b/src/test/java/io/lettuce/core/support/InjectedClient.java index 3d96246c4b..035d9d4bef 100644 --- a/src/test/java/io/lettuce/core/support/InjectedClient.java +++ b/src/test/java/io/lettuce/core/support/InjectedClient.java @@ -45,4 +45,5 @@ public void preDestroy() { connection.getStatefulConnection().close(); } } + } diff --git a/src/test/java/io/lettuce/core/support/PubSubTestListener.java b/src/test/java/io/lettuce/core/support/PubSubTestListener.java index d89c9a7810..5fa54bf3f2 100644 --- a/src/test/java/io/lettuce/core/support/PubSubTestListener.java +++ b/src/test/java/io/lettuce/core/support/PubSubTestListener.java @@ -30,10 +30,15 @@ public class PubSubTestListener implements RedisPubSubListener { private BlockingQueue channels = LettuceFactories.newBlockingQueue(); + private BlockingQueue patterns = LettuceFactories.newBlockingQueue(); + private BlockingQueue messages = LettuceFactories.newBlockingQueue(); + private BlockingQueue counts = LettuceFactories.newBlockingQueue(); + private BlockingQueue shardChannels = LettuceFactories.newBlockingQueue(); + private BlockingQueue shardCounts = LettuceFactories.newBlockingQueue(); // RedisPubSubListener implementation @@ -116,4 +121,5 @@ public void clear() { counts.clear(); shardCounts.clear(); } + } diff --git a/src/test/java/io/lettuce/core/support/caching/ClientsideCachingIntegrationTests.java b/src/test/java/io/lettuce/core/support/caching/ClientsideCachingIntegrationTests.java index a6650c9a67..bb598e5ea7 100644 --- a/src/test/java/io/lettuce/core/support/caching/ClientsideCachingIntegrationTests.java +++ b/src/test/java/io/lettuce/core/support/caching/ClientsideCachingIntegrationTests.java @@ -68,12 +68,14 @@ void clientCachingResp2() { commands.clientTracking(TrackingArgs.Builder.enabled().redirect(pubSub.sync().clientId())); pubSub.addListener(new RedisPubSubAdapter() { + @Override public void message(String channel, String message) { if (channel.equals("__redis__:invalidate")) { invalidations.add(message); } } + }); pubSub.sync().subscribe("__redis__:invalidate"); diff --git a/src/test/java/io/lettuce/core/tracing/BraveTracingUnitTests.java b/src/test/java/io/lettuce/core/tracing/BraveTracingUnitTests.java index 90bf1e6f28..5940314e51 100644 --- a/src/test/java/io/lettuce/core/tracing/BraveTracingUnitTests.java +++ b/src/test/java/io/lettuce/core/tracing/BraveTracingUnitTests.java @@ -33,6 +33,7 @@ class BraveTracingUnitTests extends TestSupport { private static Tracing clientTracing; + private static Queue spans = new LinkedBlockingQueue<>(); @BeforeAll @@ -89,8 +90,8 @@ void shouldReportCustomServiceName() { @Test void shouldCustomizeEndpoint() { - BraveTracing tracing = BraveTracing.builder().tracing(clientTracing) - .endpointCustomizer(it -> it.serviceName("foo-bar")).build(); + BraveTracing tracing = BraveTracing.builder().tracing(clientTracing).endpointCustomizer(it -> it.serviceName("foo-bar")) + .build(); BraveTracing.BraveEndpoint endpoint = (BraveTracing.BraveEndpoint) tracing .createEndpoint(new DomainSocketAddress("foo")); @@ -111,4 +112,5 @@ void shouldCustomizeSpan() { assertThat(tags).contains("cmd", "AUTH"); } + } diff --git a/src/test/java/io/lettuce/examples/ConnectToElastiCacheMaster.java b/src/test/java/io/lettuce/examples/ConnectToElastiCacheMaster.java index 18df596c51..c587aff1d5 100644 --- a/src/test/java/io/lettuce/examples/ConnectToElastiCacheMaster.java +++ b/src/test/java/io/lettuce/examples/ConnectToElastiCacheMaster.java @@ -26,4 +26,5 @@ public static void main(String[] args) { connection.close(); redisClient.shutdown(); } + } diff --git a/src/test/java/io/lettuce/examples/ConnectToMasterSlaveUsingElastiCacheCluster.java b/src/test/java/io/lettuce/examples/ConnectToMasterSlaveUsingElastiCacheCluster.java index 2d15b4d54e..32303bdfaa 100644 --- a/src/test/java/io/lettuce/examples/ConnectToMasterSlaveUsingElastiCacheCluster.java +++ b/src/test/java/io/lettuce/examples/ConnectToMasterSlaveUsingElastiCacheCluster.java @@ -32,4 +32,5 @@ public static void main(String[] args) { connection.close(); redisClient.shutdown(); } + } diff --git a/src/test/java/io/lettuce/examples/ConnectToMasterSlaveUsingRedisSentinel.java b/src/test/java/io/lettuce/examples/ConnectToMasterSlaveUsingRedisSentinel.java index fea0941ed7..d08200e224 100644 --- a/src/test/java/io/lettuce/examples/ConnectToMasterSlaveUsingRedisSentinel.java +++ b/src/test/java/io/lettuce/examples/ConnectToMasterSlaveUsingRedisSentinel.java @@ -25,4 +25,5 @@ public static void main(String[] args) { connection.close(); redisClient.shutdown(); } + } diff --git a/src/test/java/io/lettuce/examples/ConnectToRedis.java b/src/test/java/io/lettuce/examples/ConnectToRedis.java index 5ae347792d..84c7920de6 100644 --- a/src/test/java/io/lettuce/examples/ConnectToRedis.java +++ b/src/test/java/io/lettuce/examples/ConnectToRedis.java @@ -40,4 +40,5 @@ public static void main(String[] args) { connection.close(); redisClient.shutdown(); } + } diff --git a/src/test/java/io/lettuce/examples/ConnectToRedisCluster.java b/src/test/java/io/lettuce/examples/ConnectToRedisCluster.java index fba7f2efd7..6ae86d8772 100644 --- a/src/test/java/io/lettuce/examples/ConnectToRedisCluster.java +++ b/src/test/java/io/lettuce/examples/ConnectToRedisCluster.java @@ -41,4 +41,5 @@ public static void main(String[] args) { connection.close(); redisClient.shutdown(); } + } diff --git a/src/test/java/io/lettuce/examples/ConnectToRedisClusterSSL.java b/src/test/java/io/lettuce/examples/ConnectToRedisClusterSSL.java index 63f3543359..693ec6cec4 100644 --- a/src/test/java/io/lettuce/examples/ConnectToRedisClusterSSL.java +++ b/src/test/java/io/lettuce/examples/ConnectToRedisClusterSSL.java @@ -23,4 +23,5 @@ public static void main(String[] args) { connection.close(); redisClient.shutdown(); } + } diff --git a/src/test/java/io/lettuce/examples/ConnectToRedisClusterWithTopologyRefreshing.java b/src/test/java/io/lettuce/examples/ConnectToRedisClusterWithTopologyRefreshing.java index bfcdfc3174..13a78aea83 100644 --- a/src/test/java/io/lettuce/examples/ConnectToRedisClusterWithTopologyRefreshing.java +++ b/src/test/java/io/lettuce/examples/ConnectToRedisClusterWithTopologyRefreshing.java @@ -35,4 +35,5 @@ public static void main(String[] args) { connection.close(); redisClient.shutdown(); } + } diff --git a/src/test/java/io/lettuce/examples/ConnectToRedisSSL.java b/src/test/java/io/lettuce/examples/ConnectToRedisSSL.java index fa7f780b9a..28b0ce059f 100644 --- a/src/test/java/io/lettuce/examples/ConnectToRedisSSL.java +++ b/src/test/java/io/lettuce/examples/ConnectToRedisSSL.java @@ -21,4 +21,5 @@ public static void main(String[] args) { connection.close(); redisClient.shutdown(); } + } diff --git a/src/test/java/io/lettuce/examples/ConnectToRedisUsingRedisSentinel.java b/src/test/java/io/lettuce/examples/ConnectToRedisUsingRedisSentinel.java index 2e4a8edcec..24a032e925 100644 --- a/src/test/java/io/lettuce/examples/ConnectToRedisUsingRedisSentinel.java +++ b/src/test/java/io/lettuce/examples/ConnectToRedisUsingRedisSentinel.java @@ -20,4 +20,5 @@ public static void main(String[] args) { connection.close(); redisClient.shutdown(); } + } diff --git a/src/test/java/io/lettuce/examples/ReadWriteExample.java b/src/test/java/io/lettuce/examples/ReadWriteExample.java index 3c4f3d8d37..f9a2c28470 100644 --- a/src/test/java/io/lettuce/examples/ReadWriteExample.java +++ b/src/test/java/io/lettuce/examples/ReadWriteExample.java @@ -28,4 +28,5 @@ public static void main(String[] args) { connection.close(); redisClient.shutdown(); } + } diff --git a/src/test/java/io/lettuce/test/CanConnect.java b/src/test/java/io/lettuce/test/CanConnect.java index dc116682b0..3e53d19e6b 100644 --- a/src/test/java/io/lettuce/test/CanConnect.java +++ b/src/test/java/io/lettuce/test/CanConnect.java @@ -40,4 +40,5 @@ private static boolean to(SocketAddress socketAddress) { return false; } } + } diff --git a/src/test/java/io/lettuce/test/CliParser.java b/src/test/java/io/lettuce/test/CliParser.java index 3665ea9e6d..0beac0e3b4 100644 --- a/src/test/java/io/lettuce/test/CliParser.java +++ b/src/test/java/io/lettuce/test/CliParser.java @@ -51,6 +51,7 @@ public static Command> parse(String command) { if (type == null) { String typeName = buffer.toString(); type = new ProtocolKeyword() { + @Override public byte[] getBytes() { return name().getBytes(StandardCharsets.UTF_8); @@ -60,6 +61,7 @@ public byte[] getBytes() { public String name() { return typeName; } + }; } else { args.addKey(buffer.toString()); @@ -70,4 +72,5 @@ public String name() { return new Command<>(type, new ArrayOutput<>(StringCodec.UTF8), args); } + } diff --git a/src/test/java/io/lettuce/test/ConnectionDecoratingInvocationHandler.java b/src/test/java/io/lettuce/test/ConnectionDecoratingInvocationHandler.java index 5920e22905..49d7f4326e 100644 --- a/src/test/java/io/lettuce/test/ConnectionDecoratingInvocationHandler.java +++ b/src/test/java/io/lettuce/test/ConnectionDecoratingInvocationHandler.java @@ -47,4 +47,5 @@ protected Object handleInvocation(Object proxy, Method method, Object[] args) th return result; } + } diff --git a/src/test/java/io/lettuce/test/ConnectionTestUtil.java b/src/test/java/io/lettuce/test/ConnectionTestUtil.java index d8e87d416d..a5beb02eae 100644 --- a/src/test/java/io/lettuce/test/ConnectionTestUtil.java +++ b/src/test/java/io/lettuce/test/ConnectionTestUtil.java @@ -148,4 +148,5 @@ public static String getConnectionState(StatefulConnection connection) { return ""; } + } diff --git a/src/test/java/io/lettuce/test/Delay.java b/src/test/java/io/lettuce/test/Delay.java index b6da1056b0..c8e08539ee 100644 --- a/src/test/java/io/lettuce/test/Delay.java +++ b/src/test/java/io/lettuce/test/Delay.java @@ -24,4 +24,5 @@ public static void delay(Duration duration) { throw new IllegalStateException(e); } } + } diff --git a/src/test/java/io/lettuce/test/KeyValueStreamingAdapter.java b/src/test/java/io/lettuce/test/KeyValueStreamingAdapter.java index 64b02198b2..3dc99cea58 100644 --- a/src/test/java/io/lettuce/test/KeyValueStreamingAdapter.java +++ b/src/test/java/io/lettuce/test/KeyValueStreamingAdapter.java @@ -29,4 +29,5 @@ public void onKeyValue(K key, V value) { public Map getMap() { return map; } + } diff --git a/src/test/java/io/lettuce/test/KeysAndValues.java b/src/test/java/io/lettuce/test/KeysAndValues.java index 33bbfe390a..e2c0cb61f8 100644 --- a/src/test/java/io/lettuce/test/KeysAndValues.java +++ b/src/test/java/io/lettuce/test/KeysAndValues.java @@ -49,4 +49,5 @@ public class KeysAndValues { VALUES = Collections.unmodifiableList(values); MAP = Collections.unmodifiableMap(map); } + } diff --git a/src/test/java/io/lettuce/test/LettuceExtension.java b/src/test/java/io/lettuce/test/LettuceExtension.java index 1d1474fc43..852b4bdbba 100644 --- a/src/test/java/io/lettuce/test/LettuceExtension.java +++ b/src/test/java/io/lettuce/test/LettuceExtension.java @@ -88,9 +88,9 @@ public class LettuceExtension implements ParameterResolver, AfterAllCallback, Af private final ExtensionContext.Namespace LETTUCE = ExtensionContext.Namespace.create("lettuce.parameters"); - private static final Set> SUPPORTED_INJECTABLE_TYPES = new HashSet<>(Arrays.asList(StatefulRedisConnection.class, - StatefulRedisPubSubConnection.class, RedisCommands.class, RedisClient.class, ClientResources.class, - StatefulRedisClusterConnection.class, RedisClusterClient.class)); + private static final Set> SUPPORTED_INJECTABLE_TYPES = new HashSet<>( + Arrays.asList(StatefulRedisConnection.class, StatefulRedisPubSubConnection.class, RedisCommands.class, + RedisClient.class, ClientResources.class, StatefulRedisClusterConnection.class, RedisClusterClient.class)); private static final Set> CLOSE_AFTER_EACH = new HashSet<>(Arrays.asList(StatefulRedisConnection.class, StatefulRedisPubSubConnection.class, StatefulRedisClusterConnection.class)); @@ -147,8 +147,8 @@ public Object resolveParameter(ParameterContext parameterContext, ExtensionConte private Object doGetInstance(Type parameterizedType) { Optional resourceFunction = findFunction(parameterizedType); - return resourceFunction.map(it -> it.function.apply(findSupplier(it.dependsOn.getType()).get())).orElseGet( - () -> findSupplier(parameterizedType).get()); + return resourceFunction.map(it -> it.function.apply(findSupplier(it.dependsOn.getType()).get())) + .orElseGet(() -> findSupplier(parameterizedType).get()); } /** @@ -249,7 +249,9 @@ private static Optional findFunction(Type type) { @Target(ElementType.PARAMETER) @Retention(RetentionPolicy.RUNTIME) public @interface Connection { + boolean requiresNew() default false; + } static class CloseAfterTest extends ArrayList { @@ -258,7 +260,9 @@ static class CloseAfterTest extends ArrayList { static class ResourceFunction { final ResolvableType dependsOn; + final ResolvableType provides; + final Function function; public ResourceFunction(ResolvableType dependsOn, ResolvableType provides, Function function) { @@ -266,6 +270,7 @@ public ResourceFunction(ResolvableType dependsOn, ResolvableType provides, Funct this.provides = provides; this.function = (Function) function; } + } enum ClientResourcesSupplier implements Supplier { @@ -276,6 +281,7 @@ enum ClientResourcesSupplier implements Supplier { public ClientResources get() { return TestClientResources.get(); } + } enum RedisClientSupplier implements Supplier { @@ -286,6 +292,7 @@ enum RedisClientSupplier implements Supplier { public RedisClient get() { return DefaultRedisClient.get(); } + } enum RedisClusterClientSupplier implements Supplier { @@ -296,6 +303,7 @@ enum RedisClusterClientSupplier implements Supplier { public RedisClusterClient get() { return DefaultRedisClusterClient.get(); } + } enum StatefulRedisConnectionSupplier implements Supplier> { @@ -306,6 +314,7 @@ enum StatefulRedisConnectionSupplier implements Supplier get() { return RedisClientSupplier.INSTANCE.get().connect(); } + } enum StatefulRedisPubSubConnectionSupplier implements Supplier> { @@ -316,6 +325,7 @@ enum StatefulRedisPubSubConnectionSupplier implements Supplier get() { return RedisClientSupplier.INSTANCE.get().connectPubSub(); } + } enum StatefulRedisClusterConnectionSupplier implements Supplier> { @@ -326,14 +336,18 @@ enum StatefulRedisClusterConnectionSupplier implements Supplier get() { return RedisClusterClientSupplier.INSTANCE.get().connect(); } + } enum RedisCommandsFunction implements Function, RedisCommands> { + INSTANCE; @Override public RedisCommands apply(StatefulRedisConnection connection) { return connection.sync(); } + } + } diff --git a/src/test/java/io/lettuce/test/ListStreamingAdapter.java b/src/test/java/io/lettuce/test/ListStreamingAdapter.java index a04d452f70..520071e57d 100644 --- a/src/test/java/io/lettuce/test/ListStreamingAdapter.java +++ b/src/test/java/io/lettuce/test/ListStreamingAdapter.java @@ -16,8 +16,9 @@ * @param Value-Type. * @since 3.0 */ -public class ListStreamingAdapter implements KeyStreamingChannel, ValueStreamingChannel, - ScoredValueStreamingChannel { +public class ListStreamingAdapter + implements KeyStreamingChannel, ValueStreamingChannel, ScoredValueStreamingChannel { + private final List list = new Vector<>(); @Override @@ -39,4 +40,5 @@ public List getList() { public void onValue(ScoredValue value) { list.add(value.getValue()); } + } diff --git a/src/test/java/io/lettuce/test/ReactiveSyncInvocationHandler.java b/src/test/java/io/lettuce/test/ReactiveSyncInvocationHandler.java index 8a7edb0a29..758327e356 100644 --- a/src/test/java/io/lettuce/test/ReactiveSyncInvocationHandler.java +++ b/src/test/java/io/lettuce/test/ReactiveSyncInvocationHandler.java @@ -51,8 +51,7 @@ protected Object handleInvocation(Object proxy, Method method, Object[] args) th Flux flux = (Flux) result; if (!method.getName().equals("exec") && !method.getName().equals("multi")) { - if (connection instanceof StatefulRedisConnection && ((StatefulRedisConnection) connection) - .isMulti()) { + if (connection instanceof StatefulRedisConnection && ((StatefulRedisConnection) connection).isMulti()) { flux.subscribe(); return null; } @@ -113,4 +112,5 @@ public static RedisSentinelCommands sync(StatefulRedisSentinelConne return (RedisSentinelCommands) Proxy.newProxyInstance(handler.getClass().getClassLoader(), new Class[] { RedisSentinelCommands.class }, handler); } + } diff --git a/src/test/java/io/lettuce/test/RoutingInvocationHandler.java b/src/test/java/io/lettuce/test/RoutingInvocationHandler.java index 6c7b55ba8b..a6e97fff42 100644 --- a/src/test/java/io/lettuce/test/RoutingInvocationHandler.java +++ b/src/test/java/io/lettuce/test/RoutingInvocationHandler.java @@ -24,4 +24,5 @@ protected Object handleInvocation(Object proxy, Method method, Object[] args) th return delegate.invoke(proxy, method, args); } + } diff --git a/src/test/java/io/lettuce/test/Wait.java b/src/test/java/io/lettuce/test/Wait.java index 38b6f6a277..8cd3560607 100644 --- a/src/test/java/io/lettuce/test/Wait.java +++ b/src/test/java/io/lettuce/test/Wait.java @@ -147,17 +147,23 @@ public static WaitBuilder untilEquals(T expectation, Supplier actualSu @FunctionalInterface interface WaitCondition { + boolean isSatisfied() throws Exception; + } @FunctionalInterface public interface VoidWaitCondition { + void test(); + } @FunctionalInterface public interface Sleeper { + void sleep() throws InterruptedException; + } static class ThreadSleep implements Sleeper { @@ -171,6 +177,7 @@ static class ThreadSleep implements Sleeper { public void sleep() throws InterruptedException { Thread.sleep(period.toMillis()); } + } /** @@ -182,10 +189,15 @@ public void sleep() throws InterruptedException { public static class WaitBuilder { private Duration duration = Duration.ofSeconds(10); + private Sleeper sleeper = new ThreadSleep(Duration.ofMillis(10)); + private Function messageFunction; + private Supplier supplier; + private Predicate check; + private WaitCondition waitCondition; public WaitBuilder during(Duration duration) { @@ -212,6 +224,7 @@ public void waitOrTimeout() { waiter.waitOrTimeout(supplier, check); } } + } /** @@ -220,7 +233,9 @@ public void waitOrTimeout() { private static class Waiter { private Duration duration; + private Sleeper sleeper; + private Function messageFunction; private void waitOrTimeout(Supplier supplier, Predicate check) { @@ -271,11 +286,13 @@ private boolean success(WaitCondition condition, Timeout timeout) throws Excepti return false; } + } static class Timeout { private static final Clock clock = Clock.systemDefaultZone(); + private final Instant timeout; private Timeout(Instant timeout) { @@ -295,5 +312,7 @@ public static Timeout create(Duration duration) { boolean hasExpired() { return clock.instant().isAfter(timeout); } + } + } diff --git a/src/test/java/io/lettuce/test/WithPassword.java b/src/test/java/io/lettuce/test/WithPassword.java index de0a804723..ff5957ae36 100644 --- a/src/test/java/io/lettuce/test/WithPassword.java +++ b/src/test/java/io/lettuce/test/WithPassword.java @@ -113,6 +113,9 @@ public static void disableAuthentication(RedisCommands commands) } public interface ThrowingCallable { + void call() throws Throwable; + } + } diff --git a/src/test/java/io/lettuce/test/condition/EnabledOnCommand.java b/src/test/java/io/lettuce/test/condition/EnabledOnCommand.java index 71ed6c4fc3..44b777290c 100644 --- a/src/test/java/io/lettuce/test/condition/EnabledOnCommand.java +++ b/src/test/java/io/lettuce/test/condition/EnabledOnCommand.java @@ -24,4 +24,5 @@ * @return */ String value(); + } diff --git a/src/test/java/io/lettuce/test/condition/EnabledOnCommandCondition.java b/src/test/java/io/lettuce/test/condition/EnabledOnCommandCondition.java index 6b54c5ee1a..9a44eccec5 100644 --- a/src/test/java/io/lettuce/test/condition/EnabledOnCommandCondition.java +++ b/src/test/java/io/lettuce/test/condition/EnabledOnCommandCondition.java @@ -35,10 +35,12 @@ public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext con RedisConditions conditions = RedisConditions.of(connection); boolean hasCommand = conditions.hasCommand(command); - return hasCommand ? enabled("Enabled on command " + command) : disabled("Disabled, command " + command - + " not available on Redis version " + conditions.getRedisVersion()); + return hasCommand ? enabled("Enabled on command " + command) + : disabled( + "Disabled, command " + command + " not available on Redis version " + conditions.getRedisVersion()); } return ENABLED_BY_DEFAULT; } + } diff --git a/src/test/java/io/lettuce/test/condition/RedisConditions.java b/src/test/java/io/lettuce/test/condition/RedisConditions.java index a3aa6b42e6..94616db306 100644 --- a/src/test/java/io/lettuce/test/condition/RedisConditions.java +++ b/src/test/java/io/lettuce/test/condition/RedisConditions.java @@ -25,14 +25,15 @@ public class RedisConditions { private final Map commands; + private final Version version; private RedisConditions(RedisClusterCommands commands) { List result = CommandDetailParser.parse(commands.command()); - this.commands = result.stream().collect( - Collectors.toMap(commandDetail -> commandDetail.getName().toUpperCase(), CommandDetail::getArity)); + this.commands = result.stream() + .collect(Collectors.toMap(commandDetail -> commandDetail.getName().toUpperCase(), CommandDetail::getArity)); String info = commands.info("server"); @@ -122,8 +123,11 @@ public static class Version implements Comparable { private static final String VERSION_PARSE_ERROR = "Invalid version string! Could not parse segment %s within %s."; private final int major; + private final int minor; + private final int bugfix; + private final int build; /** @@ -229,7 +233,6 @@ public boolean isLessThanOrEqualTo(Version version) { /* * (non-Javadoc) - * * @see java.lang.Comparable#compareTo(java.lang.Object) */ public int compareTo(Version that) { @@ -259,7 +262,6 @@ public int compareTo(Version that) { /* * (non-Javadoc) - * * @see java.lang.Object#equals(java.lang.Object) */ @Override @@ -281,7 +283,6 @@ public boolean equals(Object obj) { /* * (non-Javadoc) - * * @see java.lang.Object#hashCode() */ @Override @@ -297,7 +298,6 @@ public int hashCode() { /* * (non-Javadoc) - * * @see java.lang.Object#toString() */ @Override @@ -317,5 +317,7 @@ public String toString() { return digits.stream().map(Object::toString).collect(Collectors.joining(".")); } + } + } diff --git a/src/test/java/io/lettuce/test/resource/DefaultRedisClient.java b/src/test/java/io/lettuce/test/resource/DefaultRedisClient.java index 799219cba4..ec87599a9c 100644 --- a/src/test/java/io/lettuce/test/resource/DefaultRedisClient.java +++ b/src/test/java/io/lettuce/test/resource/DefaultRedisClient.java @@ -18,10 +18,12 @@ public class DefaultRedisClient { private DefaultRedisClient() { redisClient = RedisClient.create(RedisURI.Builder.redis(TestSettings.host(), TestSettings.port()).build()); Runtime.getRuntime().addShutdownHook(new Thread() { + @Override public void run() { FastShutdown.shutdown(redisClient); } + }); } @@ -34,4 +36,5 @@ public static RedisClient get() { instance.redisClient.setDefaultTimeout(60, TimeUnit.SECONDS); return instance.redisClient; } + } diff --git a/src/test/java/io/lettuce/test/resource/DefaultRedisClusterClient.java b/src/test/java/io/lettuce/test/resource/DefaultRedisClusterClient.java index 35a3b8301d..8fd1ebd13b 100644 --- a/src/test/java/io/lettuce/test/resource/DefaultRedisClusterClient.java +++ b/src/test/java/io/lettuce/test/resource/DefaultRedisClusterClient.java @@ -15,13 +15,15 @@ public class DefaultRedisClusterClient { private RedisClusterClient redisClient; private DefaultRedisClusterClient() { - redisClient = RedisClusterClient.create(RedisURI.Builder.redis(TestSettings.host(), TestSettings.port(900)) - .withClientName("my-client").build()); + redisClient = RedisClusterClient.create( + RedisURI.Builder.redis(TestSettings.host(), TestSettings.port(900)).withClientName("my-client").build()); Runtime.getRuntime().addShutdownHook(new Thread() { + @Override public void run() { FastShutdown.shutdown(redisClient); } + }); } @@ -34,4 +36,5 @@ public static RedisClusterClient get() { instance.redisClient.setOptions(ClusterClientOptions.create()); return instance.redisClient; } + } diff --git a/src/test/java/io/lettuce/test/resource/FastShutdown.java b/src/test/java/io/lettuce/test/resource/FastShutdown.java index 0d2e633c15..4f4f3434dc 100644 --- a/src/test/java/io/lettuce/test/resource/FastShutdown.java +++ b/src/test/java/io/lettuce/test/resource/FastShutdown.java @@ -27,4 +27,5 @@ public static void shutdown(AbstractRedisClient redisClient) { public static void shutdown(ClientResources clientResources) { clientResources.shutdown(0, 10, TimeUnit.MILLISECONDS); } + } diff --git a/src/test/java/io/lettuce/test/resource/TestClientResources.java b/src/test/java/io/lettuce/test/resource/TestClientResources.java index 2704e4f183..251ca7e36c 100644 --- a/src/test/java/io/lettuce/test/resource/TestClientResources.java +++ b/src/test/java/io/lettuce/test/resource/TestClientResources.java @@ -6,8 +6,8 @@ import io.lettuce.core.resource.DefaultClientResources; /** - * Client-Resources suitable for testing. Uses {@link TestEventLoopGroupProvider} to preserve the event loop - * groups between tests. Every time a new {@link TestClientResources} instance is created, shutdown hook is added + * Client-Resources suitable for testing. Uses {@link TestEventLoopGroupProvider} to preserve the event loop groups between + * tests. Every time a new {@link TestClientResources} instance is created, shutdown hook is added * {@link Runtime#addShutdownHook(Thread)}. * * @author Mark Paluch @@ -15,6 +15,7 @@ public class TestClientResources { private static final TestClientResources instance = new TestClientResources(); + private ClientResources clientResources = create(); /** @@ -37,6 +38,7 @@ public static ClientResources create() { .eventLoopGroupProvider(new TestEventLoopGroupProvider()).build(); Runtime.getRuntime().addShutdownHook(new Thread() { + @Override public void run() { try { @@ -45,6 +47,7 @@ public void run() { e.printStackTrace(); } } + }); return resources; diff --git a/src/test/java/io/lettuce/test/resource/TestEventLoopGroupProvider.java b/src/test/java/io/lettuce/test/resource/TestEventLoopGroupProvider.java index 01aee66de4..ad90105e63 100644 --- a/src/test/java/io/lettuce/test/resource/TestEventLoopGroupProvider.java +++ b/src/test/java/io/lettuce/test/resource/TestEventLoopGroupProvider.java @@ -20,6 +20,7 @@ class TestEventLoopGroupProvider extends DefaultEventLoopGroupProvider { public TestEventLoopGroupProvider() { super(10); Runtime.getRuntime().addShutdownHook(new Thread() { + @Override public void run() { try { @@ -28,6 +29,7 @@ public void run() { e.printStackTrace(); } } + }); } @@ -38,4 +40,5 @@ public Promise release(EventExecutorGroup eventLoopGroup, long quietPer return result; } + } diff --git a/src/test/java/io/lettuce/test/server/MockTcpServer.java b/src/test/java/io/lettuce/test/server/MockTcpServer.java index baa57ee4ed..0f2249af51 100644 --- a/src/test/java/io/lettuce/test/server/MockTcpServer.java +++ b/src/test/java/io/lettuce/test/server/MockTcpServer.java @@ -20,8 +20,11 @@ public class MockTcpServer { private EventLoopGroup bossGroup; + private EventLoopGroup workerGroup; + private Channel channel; + private List> handlers = new ArrayList<>(); public void addHandler(Supplier supplier) { @@ -36,6 +39,7 @@ public void initialize(int port) throws InterruptedException { ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class).option(ChannelOption.SO_BACKLOG, 100) .childHandler(new ChannelInitializer() { + @Override public void initChannel(SocketChannel ch) { ChannelPipeline p = ch.pipeline(); @@ -45,6 +49,7 @@ public void initChannel(SocketChannel ch) { p.addLast(handler.get()); } } + }); // Start the server. @@ -60,6 +65,7 @@ public void shutdown() { private static class Resources { private static final EventLoopGroup bossGroup; + private static final EventLoopGroup workerGroup; static { @@ -74,4 +80,5 @@ private static class Resources { } } + } diff --git a/src/test/java/io/lettuce/test/server/RandomResponseServer.java b/src/test/java/io/lettuce/test/server/RandomResponseServer.java index bb8d8e3c71..c57d2f58e3 100644 --- a/src/test/java/io/lettuce/test/server/RandomResponseServer.java +++ b/src/test/java/io/lettuce/test/server/RandomResponseServer.java @@ -10,4 +10,5 @@ public class RandomResponseServer extends MockTcpServer { public RandomResponseServer() { addHandler(RandomServerHandler::new); } + } diff --git a/src/test/java/io/lettuce/test/server/RandomServerHandler.java b/src/test/java/io/lettuce/test/server/RandomServerHandler.java index 9915d53aee..817ec119f6 100644 --- a/src/test/java/io/lettuce/test/server/RandomServerHandler.java +++ b/src/test/java/io/lettuce/test/server/RandomServerHandler.java @@ -49,4 +49,5 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { cause.printStackTrace(); ctx.close(); } + }