Skip to content

Commit

Permalink
Improvements to the testing bits (#3012)
Browse files Browse the repository at this point in the history
* Use tags for tests identification

* Remove imports that are not needed
  • Loading branch information
tishun authored Oct 18, 2024
1 parent aec0887 commit 1de2116
Show file tree
Hide file tree
Showing 307 changed files with 1,023 additions and 49 deletions.
32 changes: 32 additions & 0 deletions src/test/java/io/lettuce/TestTags.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2024, Redis Ltd. and Contributors
* All rights reserved.
*
* Licensed under the MIT License.
*/

package io.lettuce;

/**
* Test tags for the different types of tests.
*/
public class TestTags {

/**
* Tag for unit tests (run in isolation)
*/
public static final String UNIT_TEST = "unit";

/**
* Tag for integration tests (require a running environment)
*/
public static final String INTEGRATION_TEST = "integration";

/**
* Tag for tests that generate the different types of APIs.
*
* @see io.lettuce.apigenerator
*/
public static final String API_GENERATOR = "api_generator";

}
4 changes: 4 additions & 0 deletions src/test/java/io/lettuce/apigenerator/CreateAsyncApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.function.Function;
import java.util.function.Supplier;

import org.junit.jupiter.api.Tag;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

Expand All @@ -35,6 +36,8 @@

import io.lettuce.core.internal.LettuceSets;

import static io.lettuce.TestTags.API_GENERATOR;

/**
* Create async API based on the templates.
*
Expand Down Expand Up @@ -76,6 +79,7 @@ Supplier<List<String>> importSupplier() {

@ParameterizedTest
@MethodSource("arguments")
@Tag(API_GENERATOR)
void createInterface(String argument) throws Exception {
createFactory(argument).createInterface();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.junit.jupiter.api.Tag;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

Expand All @@ -37,6 +38,8 @@

import io.lettuce.core.internal.LettuceSets;

import static io.lettuce.TestTags.API_GENERATOR;

/**
* Create async API based on the templates.
*
Expand Down Expand Up @@ -91,6 +94,7 @@ Supplier<List<String>> importSupplier() {

@ParameterizedTest
@MethodSource("arguments")
@Tag(API_GENERATOR)
void createInterface(String argument) throws Exception {
createFactory(argument).createInterface();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
package io.lettuce.apigenerator;

import static io.lettuce.TestTags.API_GENERATOR;
import static io.lettuce.apigenerator.Constants.KOTLIN_SOURCES;
import static io.lettuce.apigenerator.Constants.TEMPLATES;

Expand All @@ -28,6 +29,7 @@
import java.util.function.Function;
import java.util.function.Supplier;

import org.junit.jupiter.api.Tag;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

Expand Down Expand Up @@ -59,6 +61,7 @@ Function<String, String> commentInjector() {

@ParameterizedTest
@MethodSource("arguments")
@Tag(API_GENERATOR)
void createInterface(String argument) throws Exception {
createFactory(argument).create();
}
Expand Down
4 changes: 4 additions & 0 deletions src/test/java/io/lettuce/apigenerator/CreateReactiveApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.function.Function;
import java.util.function.Supplier;

import org.junit.jupiter.api.Tag;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

Expand All @@ -44,6 +45,8 @@

import io.lettuce.core.internal.LettuceSets;

import static io.lettuce.TestTags.API_GENERATOR;

/**
* Create reactive API based on the templates.
*
Expand Down Expand Up @@ -193,6 +196,7 @@ Supplier<List<String>> importSupplier() {

@ParameterizedTest
@MethodSource("arguments")
@Tag(API_GENERATOR)
void createInterface(String argument) throws Exception {
createFactory(argument).createInterface();
}
Expand Down
4 changes: 4 additions & 0 deletions src/test/java/io/lettuce/apigenerator/CreateSyncApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.function.Predicate;
import java.util.function.Supplier;

import org.junit.jupiter.api.Tag;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

Expand All @@ -36,6 +37,8 @@

import io.lettuce.core.internal.LettuceSets;

import static io.lettuce.TestTags.API_GENERATOR;

/**
* Create sync API based on the templates.
*
Expand Down Expand Up @@ -84,6 +87,7 @@ Supplier<List<String>> importSupplier() {

@ParameterizedTest
@MethodSource("arguments")
@Tag(API_GENERATOR)
void createInterface(String argument) throws Exception {
createFactory(argument).createInterface();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.junit.jupiter.api.Tag;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

Expand All @@ -38,6 +39,9 @@

import io.lettuce.core.internal.LettuceSets;

import static io.lettuce.TestTags.API_GENERATOR;
import static io.lettuce.TestTags.UNIT_TEST;

/**
* Create sync API based on the templates.
*
Expand Down Expand Up @@ -97,6 +101,7 @@ Supplier<List<String>> importSupplier() {

@ParameterizedTest
@MethodSource("arguments")
@Tag(API_GENERATOR)
void createInterface(String argument) throws Exception {
createFactory(argument).createInterface();
}
Expand Down
3 changes: 3 additions & 0 deletions src/test/java/io/lettuce/codec/CRC16UnitTests.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package io.lettuce.codec;

import static io.lettuce.TestTags.UNIT_TEST;
import static org.assertj.core.api.Assertions.assertThat;

import java.util.ArrayList;
import java.util.List;

import org.junit.jupiter.api.Tag;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

Expand All @@ -13,6 +15,7 @@
/**
* @author Mark Paluch
*/
@Tag(UNIT_TEST)
class CRC16UnitTests {

static List<Fixture> parameters() {
Expand Down
3 changes: 3 additions & 0 deletions src/test/java/io/lettuce/core/AclSetuserArgsUnitTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
*/
package io.lettuce.core;

import static io.lettuce.TestTags.UNIT_TEST;
import static org.assertj.core.api.Assertions.*;

import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

import io.lettuce.core.codec.StringCodec;
Expand All @@ -33,6 +35,7 @@
* @author Mark Paluch
* @author Rohan Nagar
*/
@Tag(UNIT_TEST)
class AclSetuserArgsUnitTests {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
package io.lettuce.core;

import static io.lettuce.TestTags.INTEGRATION_TEST;
import static org.assertj.core.api.Assertions.assertThat;

import java.time.Duration;
Expand All @@ -29,6 +30,7 @@

import javax.inject.Inject;

import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

Expand All @@ -43,6 +45,7 @@
* @author Will Glozer
* @author Mark Paluch
*/
@Tag(INTEGRATION_TEST)
@ExtendWith(LettuceExtension.class)
class AsyncConnectionIntegrationTests extends TestSupport {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package io.lettuce.core;

import static io.lettuce.TestTags.INTEGRATION_TEST;
import static org.assertj.core.api.Assertions.*;

import javax.inject.Inject;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

Expand All @@ -24,6 +26,7 @@
*
* @author Mark Paluch
*/
@Tag(INTEGRATION_TEST)
@ExtendWith(LettuceExtension.class)
@EnabledOnCommand("ACL")
class AuthenticationIntegrationTests extends TestSupport {
Expand Down
3 changes: 3 additions & 0 deletions src/test/java/io/lettuce/core/ClientIntegrationTests.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.lettuce.core;

import static io.lettuce.TestTags.INTEGRATION_TEST;
import static org.assertj.core.api.Assertions.*;

import java.net.SocketAddress;
Expand All @@ -10,6 +11,7 @@
import javax.enterprise.inject.New;
import javax.inject.Inject;

import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

Expand All @@ -28,6 +30,7 @@
* @author Will Glozer
* @author Mark Paluch
*/
@Tag(INTEGRATION_TEST)
@ExtendWith(LettuceExtension.class)
class ClientIntegrationTests extends TestSupport {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package io.lettuce.core;

import static io.lettuce.TestTags.INTEGRATION_TEST;
import static org.assertj.core.api.Assertions.assertThat;

import java.util.Collection;
import java.util.concurrent.LinkedBlockingQueue;

import javax.inject.Inject;

import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import io.lettuce.test.ReflectionTestUtils;
Expand All @@ -23,6 +25,7 @@
/**
* @author Mark Paluch
*/
@Tag(INTEGRATION_TEST)
@ExtendWith(LettuceExtension.class)
class ClientMetricsIntegrationTests extends TestSupport {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
package io.lettuce.core;

import static io.lettuce.TestTags.INTEGRATION_TEST;
import static io.lettuce.test.ConnectionTestUtil.getChannel;
import static io.lettuce.test.ConnectionTestUtil.getConnectionWatchdog;
import static io.lettuce.test.ConnectionTestUtil.getStack;
Expand All @@ -36,6 +37,7 @@

import javax.inject.Inject;

import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

Expand All @@ -60,6 +62,7 @@
*
* @author Mark Paluch
*/
@Tag(INTEGRATION_TEST)
@ExtendWith(LettuceExtension.class)
class ClientOptionsIntegrationTests extends TestSupport {

Expand Down
3 changes: 3 additions & 0 deletions src/test/java/io/lettuce/core/ClientOptionsUnitTests.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.lettuce.core;

import static io.lettuce.TestTags.UNIT_TEST;
import static org.assertj.core.api.Assertions.*;

import java.nio.ByteBuffer;
Expand All @@ -10,6 +11,7 @@
import io.lettuce.core.json.JsonObject;
import io.lettuce.core.json.JsonParser;
import io.lettuce.core.json.JsonValue;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

import io.lettuce.core.protocol.Command;
Expand All @@ -22,6 +24,7 @@
*
* @author Mark Paluch
*/
@Tag(UNIT_TEST)
class ClientOptionsUnitTests {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
package io.lettuce.core;

import static io.lettuce.TestTags.INTEGRATION_TEST;
import static org.assertj.core.api.Assertions.*;

import java.util.ArrayList;
Expand All @@ -27,6 +28,7 @@

import javax.inject.Inject;

import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

Expand All @@ -43,6 +45,7 @@
* @author Mikhael Sokolov
* @author Mark Paluch
*/
@Tag(INTEGRATION_TEST)
@ExtendWith(LettuceExtension.class)
@SuppressWarnings({ "rawtypes", "unchecked" })
public class CommandListenerIntegrationTests extends TestSupport {
Expand Down
Loading

0 comments on commit 1de2116

Please sign in to comment.