Skip to content

Commit fd446ce

Browse files
authored
JAVA-3069: Refactor duplicated tests with different requirements to use @BackendRequirement (apache#1667)
Refactor @BackendRequirement test skipping logic into new rule, BackendRequirementRule.
1 parent d94a8f0 commit fd446ce

File tree

80 files changed

+577
-361
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+577
-361
lines changed

integration-tests/src/test/java/com/datastax/dse/driver/api/core/auth/DseGssApiAuthProviderAlternateIT.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
import com.datastax.oss.driver.api.core.CqlSession;
2323
import com.datastax.oss.driver.api.core.config.DefaultDriverOption;
2424
import com.datastax.oss.driver.api.core.cql.Row;
25-
import com.datastax.oss.driver.api.testinfra.DseRequirement;
25+
import com.datastax.oss.driver.api.testinfra.requirement.BackendRequirement;
26+
import com.datastax.oss.driver.api.testinfra.requirement.BackendType;
2627
import com.datastax.oss.driver.api.testinfra.session.SessionUtils;
2728
import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMap;
2829
import com.tngtech.java.junit.dataprovider.DataProvider;
@@ -32,7 +33,10 @@
3233
import org.junit.Test;
3334
import org.junit.runner.RunWith;
3435

35-
@DseRequirement(min = "5.0", description = "Required for DseAuthenticator")
36+
@BackendRequirement(
37+
type = BackendType.DSE,
38+
minInclusive = "5.0",
39+
description = "Required for DseAuthenticator")
3640
@RunWith(DataProviderRunner.class)
3741
public class DseGssApiAuthProviderAlternateIT {
3842
@ClassRule public static EmbeddedAdsRule ads = new EmbeddedAdsRule(true);

integration-tests/src/test/java/com/datastax/dse/driver/api/core/auth/DseGssApiAuthProviderIT.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,19 @@
2424
import com.datastax.oss.driver.api.core.CqlSession;
2525
import com.datastax.oss.driver.api.core.auth.AuthenticationException;
2626
import com.datastax.oss.driver.api.core.cql.ResultSet;
27-
import com.datastax.oss.driver.api.testinfra.DseRequirement;
27+
import com.datastax.oss.driver.api.testinfra.requirement.BackendRequirement;
28+
import com.datastax.oss.driver.api.testinfra.requirement.BackendType;
2829
import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMap;
2930
import java.util.List;
3031
import java.util.Map;
3132
import org.junit.Assume;
3233
import org.junit.ClassRule;
3334
import org.junit.Test;
3435

35-
@DseRequirement(min = "5.0", description = "Required for DseAuthenticator")
36+
@BackendRequirement(
37+
type = BackendType.DSE,
38+
minInclusive = "5.0",
39+
description = "Required for DseAuthenticator")
3640
public class DseGssApiAuthProviderIT {
3741

3842
@ClassRule public static EmbeddedAdsRule ads = new EmbeddedAdsRule();

integration-tests/src/test/java/com/datastax/dse/driver/api/core/auth/DsePlainTextAuthProviderIT.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@
2424
import com.datastax.oss.driver.api.core.Version;
2525
import com.datastax.oss.driver.api.core.auth.AuthenticationException;
2626
import com.datastax.oss.driver.api.core.config.DefaultDriverOption;
27-
import com.datastax.oss.driver.api.testinfra.DseRequirement;
2827
import com.datastax.oss.driver.api.testinfra.ccm.CustomCcmRule;
28+
import com.datastax.oss.driver.api.testinfra.requirement.BackendRequirement;
29+
import com.datastax.oss.driver.api.testinfra.requirement.BackendType;
2930
import com.datastax.oss.driver.api.testinfra.session.SessionUtils;
3031
import com.datastax.oss.driver.internal.core.auth.PlainTextAuthProvider;
3132
import com.datastax.oss.driver.shaded.guava.common.util.concurrent.Uninterruptibles;
@@ -35,7 +36,10 @@
3536
import org.junit.ClassRule;
3637
import org.junit.Test;
3738

38-
@DseRequirement(min = "5.0", description = "Required for DseAuthenticator")
39+
@BackendRequirement(
40+
type = BackendType.DSE,
41+
minInclusive = "5.0",
42+
description = "Required for DseAuthenticator")
3943
public class DsePlainTextAuthProviderIT {
4044

4145
@ClassRule

integration-tests/src/test/java/com/datastax/dse/driver/api/core/auth/DseProxyAuthenticationIT.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
import com.datastax.oss.driver.api.core.cql.ResultSet;
2828
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
2929
import com.datastax.oss.driver.api.core.servererrors.UnauthorizedException;
30-
import com.datastax.oss.driver.api.testinfra.DseRequirement;
30+
import com.datastax.oss.driver.api.testinfra.requirement.BackendRequirement;
31+
import com.datastax.oss.driver.api.testinfra.requirement.BackendType;
3132
import com.datastax.oss.driver.api.testinfra.session.SessionUtils;
3233
import com.datastax.oss.driver.internal.core.auth.PlainTextAuthProvider;
3334
import java.util.List;
@@ -36,7 +37,10 @@
3637
import org.junit.ClassRule;
3738
import org.junit.Test;
3839

39-
@DseRequirement(min = "5.1", description = "Required for DseAuthenticator with proxy")
40+
@BackendRequirement(
41+
type = BackendType.DSE,
42+
minInclusive = "5.1",
43+
description = "Required for DseAuthenticator with proxy")
4044
public class DseProxyAuthenticationIT {
4145
private static String bobPrincipal;
4246
private static String charliePrincipal;

integration-tests/src/test/java/com/datastax/dse/driver/api/core/auth/EmbeddedAdsRule.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,12 @@
1818
import com.datastax.dse.driver.api.core.config.DseDriverOption;
1919
import com.datastax.dse.driver.internal.core.auth.DseGssApiAuthProvider;
2020
import com.datastax.oss.driver.api.core.CqlSession;
21-
import com.datastax.oss.driver.api.core.Version;
2221
import com.datastax.oss.driver.api.core.config.DefaultDriverOption;
23-
import com.datastax.oss.driver.api.testinfra.ccm.CcmBridge;
2422
import com.datastax.oss.driver.api.testinfra.ccm.CustomCcmRule;
25-
import com.datastax.oss.driver.api.testinfra.requirement.BackendType;
26-
import com.datastax.oss.driver.api.testinfra.requirement.VersionRequirement;
23+
import com.datastax.oss.driver.api.testinfra.requirement.BackendRequirementRule;
2724
import com.datastax.oss.driver.api.testinfra.session.SessionUtils;
2825
import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMap;
2926
import java.io.File;
30-
import java.util.Collection;
3127
import java.util.HashMap;
3228
import java.util.Map;
3329
import org.junit.AssumptionViolatedException;
@@ -155,20 +151,15 @@ protected void before() {
155151

156152
@Override
157153
public Statement apply(Statement base, Description description) {
158-
BackendType backend = CcmBridge.DSE_ENABLEMENT ? BackendType.DSE : BackendType.CASSANDRA;
159-
Version version = CcmBridge.VERSION;
160-
161-
Collection<VersionRequirement> requirements = VersionRequirement.fromAnnotations(description);
162-
163-
if (VersionRequirement.meetsAny(requirements, backend, version)) {
154+
if (BackendRequirementRule.meetsDescriptionRequirements(description)) {
164155
return super.apply(base, description);
165156
} else {
166157
// requirements not met, throw reasoning assumption to skip test
167158
return new Statement() {
168159
@Override
169160
public void evaluate() {
170161
throw new AssumptionViolatedException(
171-
VersionRequirement.buildReasonString(requirements, backend, version));
162+
BackendRequirementRule.buildReasonString(description));
172163
}
173164
};
174165
}

integration-tests/src/test/java/com/datastax/dse/driver/api/core/cql/continuous/ContinuousPagingIT.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@
3030
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
3131
import com.datastax.oss.driver.api.core.cql.Statement;
3232
import com.datastax.oss.driver.api.core.metrics.DefaultNodeMetric;
33-
import com.datastax.oss.driver.api.testinfra.DseRequirement;
3433
import com.datastax.oss.driver.api.testinfra.ccm.CcmRule;
34+
import com.datastax.oss.driver.api.testinfra.requirement.BackendRequirement;
35+
import com.datastax.oss.driver.api.testinfra.requirement.BackendType;
3536
import com.datastax.oss.driver.api.testinfra.session.SessionRule;
3637
import com.datastax.oss.driver.api.testinfra.session.SessionUtils;
3738
import com.datastax.oss.driver.categories.ParallelizableTests;
@@ -58,8 +59,9 @@
5859
import org.junit.rules.TestRule;
5960
import org.junit.runner.RunWith;
6061

61-
@DseRequirement(
62-
min = "5.1.0",
62+
@BackendRequirement(
63+
type = BackendType.DSE,
64+
minInclusive = "5.1.0",
6365
description = "Continuous paging is only available from 5.1.0 onwards")
6466
@Category(ParallelizableTests.class)
6567
@RunWith(DataProviderRunner.class)

integration-tests/src/test/java/com/datastax/dse/driver/api/core/cql/continuous/reactive/ContinuousPagingReactiveIT.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@
2727
import com.datastax.oss.driver.api.core.cql.ExecutionInfo;
2828
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
2929
import com.datastax.oss.driver.api.core.metrics.DefaultNodeMetric;
30-
import com.datastax.oss.driver.api.testinfra.DseRequirement;
3130
import com.datastax.oss.driver.api.testinfra.ccm.CcmRule;
31+
import com.datastax.oss.driver.api.testinfra.requirement.BackendRequirement;
32+
import com.datastax.oss.driver.api.testinfra.requirement.BackendType;
3233
import com.datastax.oss.driver.api.testinfra.session.SessionRule;
3334
import com.datastax.oss.driver.api.testinfra.session.SessionUtils;
3435
import com.datastax.oss.driver.categories.ParallelizableTests;
@@ -47,8 +48,9 @@
4748
import org.junit.rules.TestRule;
4849
import org.junit.runner.RunWith;
4950

50-
@DseRequirement(
51-
min = "5.1.0",
51+
@BackendRequirement(
52+
type = BackendType.DSE,
53+
minInclusive = "5.1.0",
5254
description = "Continuous paging is only available from 5.1.0 onwards")
5355
@Category(ParallelizableTests.class)
5456
@RunWith(DataProviderRunner.class)

integration-tests/src/test/java/com/datastax/dse/driver/api/core/data/geometry/LineStringIT.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
import com.datastax.oss.driver.api.core.cql.Row;
2323
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
2424
import com.datastax.oss.driver.api.core.uuid.Uuids;
25-
import com.datastax.oss.driver.api.testinfra.DseRequirement;
2625
import com.datastax.oss.driver.api.testinfra.ccm.CcmRule;
26+
import com.datastax.oss.driver.api.testinfra.requirement.BackendRequirement;
27+
import com.datastax.oss.driver.api.testinfra.requirement.BackendType;
2728
import com.datastax.oss.driver.api.testinfra.session.SessionRule;
2829
import java.util.List;
2930
import java.util.UUID;
@@ -34,7 +35,7 @@
3435
import org.junit.rules.RuleChain;
3536
import org.junit.rules.TestRule;
3637

37-
@DseRequirement(min = "5.0")
38+
@BackendRequirement(type = BackendType.DSE, minInclusive = "5.0")
3839
public class LineStringIT extends GeometryIT<LineString> {
3940

4041
private static CcmRule ccm = CcmRule.getInstance();

integration-tests/src/test/java/com/datastax/dse/driver/api/core/data/geometry/PointIT.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@
1616
package com.datastax.dse.driver.api.core.data.geometry;
1717

1818
import com.datastax.oss.driver.api.core.CqlSession;
19-
import com.datastax.oss.driver.api.testinfra.DseRequirement;
2019
import com.datastax.oss.driver.api.testinfra.ccm.CcmRule;
20+
import com.datastax.oss.driver.api.testinfra.requirement.BackendRequirement;
21+
import com.datastax.oss.driver.api.testinfra.requirement.BackendType;
2122
import com.datastax.oss.driver.api.testinfra.session.SessionRule;
2223
import org.assertj.core.util.Lists;
2324
import org.junit.BeforeClass;
2425
import org.junit.ClassRule;
2526
import org.junit.rules.RuleChain;
2627
import org.junit.rules.TestRule;
2728

28-
@DseRequirement(min = "5.0")
29+
@BackendRequirement(type = BackendType.DSE, minInclusive = "5.0")
2930
public class PointIT extends GeometryIT<Point> {
3031

3132
private static CcmRule ccm = CcmRule.getInstance();

integration-tests/src/test/java/com/datastax/dse/driver/api/core/data/geometry/PolygonIT.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
import com.datastax.oss.driver.api.core.cql.Row;
2323
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
2424
import com.datastax.oss.driver.api.core.uuid.Uuids;
25-
import com.datastax.oss.driver.api.testinfra.DseRequirement;
2625
import com.datastax.oss.driver.api.testinfra.ccm.CcmRule;
26+
import com.datastax.oss.driver.api.testinfra.requirement.BackendRequirement;
27+
import com.datastax.oss.driver.api.testinfra.requirement.BackendType;
2728
import com.datastax.oss.driver.api.testinfra.session.SessionRule;
2829
import java.util.UUID;
2930
import org.assertj.core.util.Lists;
@@ -33,7 +34,7 @@
3334
import org.junit.rules.RuleChain;
3435
import org.junit.rules.TestRule;
3536

36-
@DseRequirement(min = "5.0")
37+
@BackendRequirement(type = BackendType.DSE, minInclusive = "5.0")
3738
public class PolygonIT extends GeometryIT<Polygon> {
3839

3940
private static CcmRule ccm = CcmRule.getInstance();

0 commit comments

Comments
 (0)