Skip to content

Commit 6fc7745

Browse files
committed
Updated libraries and test
updated libraries and fixed broken test
1 parent 019a5a6 commit 6fc7745

File tree

8 files changed

+89
-90
lines changed

8 files changed

+89
-90
lines changed

pom.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,27 @@
2626
<dependency>
2727
<groupId>com.datastax.oss</groupId>
2828
<artifactId>java-driver-core</artifactId>
29-
<version>4.11.3</version>
29+
<version>4.17.0</version>
3030
<scope>provided</scope>
3131
</dependency>
3232
<dependency>
3333
<groupId>software.aws.mcs</groupId>
3434
<artifactId>aws-sigv4-auth-cassandra-java-driver-plugin</artifactId>
35-
<version>4.0.4</version>
35+
<version>4.0.9</version>
3636
<scope>test</scope>
3737
</dependency>
3838
<dependency>
39-
<groupId>junit</groupId>
40-
<artifactId>junit</artifactId>
41-
<version>4.13.2</version>
39+
<groupId>org.junit.jupiter</groupId>
40+
<artifactId>junit-jupiter</artifactId>
41+
<version>5.9.2</version>
4242
<scope>test</scope>
4343
</dependency>
4444

4545

4646
<dependency>
4747
<groupId>ch.qos.logback</groupId>
4848
<artifactId>logback-classic</artifactId>
49-
<version>1.2.3</version>
49+
<version>1.5.18</version>
5050
<scope>test</scope>
5151
</dependency>
5252
</dependencies>

src/test/java/com/aws/ssa/keyspaces/loadbalancing/AmazonKeyspacesLoadbalancingPolicyTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import com.datastax.oss.driver.internal.core.config.typesafe.DefaultProgrammaticDriverConfigLoaderBuilder;
1010
import com.datastax.oss.driver.internal.core.context.DefaultDriverContext;
1111
import com.datastax.oss.driver.internal.core.util.collection.QueryPlan;
12-
import org.junit.Assert;
13-
import org.junit.Test;
12+
import org.junit.jupiter.api.Test;
13+
import static org.junit.jupiter.api.Assertions.*;
1414

1515
import java.util.Arrays;
1616
import java.util.Queue;
@@ -24,15 +24,15 @@ public void emptyQueryPlan() {
2424
DriverContext context = new DefaultDriverContext(new DefaultProgrammaticDriverConfigLoaderBuilder().build(), ProgrammaticArguments.builder().build());
2525
AmazonKeyspacesRoundRobinLoadBalancingPolicy st = new AmazonKeyspacesRoundRobinLoadBalancingPolicy(context, "default");
2626

27-
Assert.assertEquals(QueryPlan.EMPTY, st.newQueryPlan(null, null, new Node[0]));
27+
assertEquals(QueryPlan.EMPTY, st.newQueryPlan(null, null, new Node[0]));
2828
}
2929
@Test
3030
public void notEmptyQueryPlanExceed() {
3131

3232
DriverContext context = new DefaultDriverContext(new DefaultProgrammaticDriverConfigLoaderBuilder().build(), ProgrammaticArguments.builder().build());
3333
AmazonKeyspacesRoundRobinLoadBalancingPolicy st = new AmazonKeyspacesRoundRobinLoadBalancingPolicy(context, "default");
3434

35-
Assert.assertNotEquals(QueryPlan.EMPTY, st.newQueryPlan(null, null, new Node[1]));
35+
assertNotEquals(QueryPlan.EMPTY, st.newQueryPlan(null, null, new Node[1]));
3636

3737
}
3838
@Test
@@ -51,8 +51,8 @@ public void twoNodeShuffle() {
5151

5252
Queue<Node> queryPlan = st.newQueryPlan(null, null, original);
5353

54-
Assert.assertTrue(original.length == clone.length);
55-
Assert.assertNotEquals(QueryPlan.EMPTY, queryPlan);
54+
assertEquals(original.length, clone.length);
55+
assertNotEquals(QueryPlan.EMPTY, queryPlan);
5656

5757
}
5858
@Test
@@ -71,8 +71,8 @@ public void largeShuffle() {
7171

7272
Queue<Node> queryPlan = st.newQueryPlan(null, null, original);
7373

74-
Assert.assertFalse(Arrays.deepEquals(original,clone));
75-
Assert.assertNotEquals(QueryPlan.EMPTY, queryPlan);
74+
assertFalse(Arrays.deepEquals(original,clone));
75+
assertNotEquals(QueryPlan.EMPTY, queryPlan);
7676
}
7777
@Test
7878
public void testShuffleAlgorithm() {
@@ -90,13 +90,13 @@ public void testShuffleAlgorithm() {
9090

9191
AmazonKeyspacesRoundRobinLoadBalancingPolicy.reverseDurstenfeldShuffle(original, ThreadLocalRandom.current());
9292

93-
Assert.assertFalse(Arrays.deepEquals(original,clone));
93+
assertFalse(Arrays.deepEquals(original,clone));
9494
}
9595

9696

9797
@Test
9898
public void testConfig() {
99-
Assert.assertEquals("us-east-1", DriverConfigLoader.fromClasspath("loadbalancer-example").getInitialConfig().getDefaultProfile().getString(DefaultDriverOption.LOAD_BALANCING_LOCAL_DATACENTER));
99+
assertEquals("us-east-1", DriverConfigLoader.fromClasspath("loadbalancer-example").getInitialConfig().getDefaultProfile().getString(DefaultDriverOption.LOAD_BALANCING_LOCAL_DATACENTER));
100100
}
101101

102102
}

src/test/java/com/aws/ssa/keyspaces/retry/AmazonKeyspacesExponentialRetryPolicyTest.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
import com.datastax.oss.driver.api.core.session.ProgrammaticArguments;
1111
import com.datastax.oss.driver.internal.core.config.typesafe.DefaultProgrammaticDriverConfigLoaderBuilder;
1212
import com.datastax.oss.driver.internal.core.context.DefaultDriverContext;
13-
import org.junit.Assert;
14-
import org.junit.Test;
13+
import org.junit.jupiter.api.Test;
14+
import static org.junit.jupiter.api.Assertions.*;
1515
import com.datastax.oss.driver.shaded.guava.common.base.Stopwatch;
1616

1717
import java.time.Duration;
@@ -24,7 +24,7 @@ public void determineRetryDecisionExceed() {
2424
DriverContext context = new DefaultDriverContext(new DefaultProgrammaticDriverConfigLoaderBuilder().build(), ProgrammaticArguments.builder().build());
2525
AmazonKeyspacesExponentialRetryPolicy st = new AmazonKeyspacesExponentialRetryPolicy(context, 3, Duration.ofMillis(10), Duration.ofMillis(50));
2626

27-
Assert.assertEquals(RetryDecision.RETHROW, st.determineRetryDecision(4));
27+
assertEquals(RetryDecision.RETHROW, st.determineRetryDecision(4));
2828

2929
}
3030
@Test
@@ -42,7 +42,7 @@ public void determineRetryTimeToMinWhenRetry() {
4242

4343
long millsObserved = stopwatch.elapsed().toMillis();
4444

45-
Assert.assertTrue(millsObserved > 1 && millsObserved < 21);
45+
assertTrue(millsObserved > 1 && millsObserved < 21);
4646

4747
}
4848
@Test
@@ -62,7 +62,7 @@ public void determineRetryTimeToMinWhenNotRetry() {
6262

6363
System.out.println(millsObserved);
6464

65-
Assert.assertTrue(millsObserved >= 0 && millsObserved < 5);
65+
assertTrue(millsObserved >= 0 && millsObserved < 5);
6666

6767
}
6868
@Test
@@ -81,7 +81,7 @@ public void determineRetryTimeToMinWait() {
8181
long millsObserved = stopwatch.elapsed().toMillis();
8282

8383

84-
Assert.assertTrue(String.format("Asset %s", millsObserved), millsObserved > 1 && millsObserved < 20);
84+
assertTrue(millsObserved > 1 && millsObserved < 20, String.format("Asset %s", millsObserved));
8585

8686
}
8787
@Test
@@ -99,7 +99,7 @@ public void determineRetryTimeToWaitMax() {
9999

100100
long millsObserved = stopwatch.elapsed().toMillis();
101101

102-
Assert.assertTrue(String.format("millsObserved: %d",millsObserved), millsObserved > 10 && millsObserved < 100);
102+
assertTrue(millsObserved > 10 && millsObserved < 100, String.format("millsObserved: %d",millsObserved));
103103

104104
}
105105

@@ -108,7 +108,7 @@ public void determineRetryDecisionMin() {
108108
DriverContext context = new DefaultDriverContext(new DefaultProgrammaticDriverConfigLoaderBuilder().build(), ProgrammaticArguments.builder().build());
109109
AmazonKeyspacesExponentialRetryPolicy st = new AmazonKeyspacesExponentialRetryPolicy(context, 3);
110110

111-
Assert.assertEquals(RetryDecision.RETRY_SAME, st.determineRetryDecision(0));
111+
assertEquals(RetryDecision.RETRY_SAME, st.determineRetryDecision(0));
112112

113113
}
114114

@@ -117,7 +117,7 @@ public void determineRetryDecisionMid() {
117117
DriverContext context = new DefaultDriverContext(new DefaultProgrammaticDriverConfigLoaderBuilder().build(), ProgrammaticArguments.builder().build());
118118
AmazonKeyspacesExponentialRetryPolicy st = new AmazonKeyspacesExponentialRetryPolicy(context, 3);
119119

120-
Assert.assertEquals(RetryDecision.RETRY_SAME, st.determineRetryDecision(1));
120+
assertEquals(RetryDecision.RETRY_SAME, st.determineRetryDecision(1));
121121

122122
}
123123

@@ -126,7 +126,7 @@ public void onWriteTimeout() {
126126
DriverContext context = new DefaultDriverContext(new DefaultProgrammaticDriverConfigLoaderBuilder().build(), ProgrammaticArguments.builder().build());
127127
AmazonKeyspacesExponentialRetryPolicy st = new AmazonKeyspacesExponentialRetryPolicy(context, 3);
128128

129-
Assert.assertEquals(RetryDecision.RETRY_SAME, st.onWriteTimeout(null, ConsistencyLevel.LOCAL_QUORUM, WriteType.SIMPLE, 2, 0, 1));
129+
assertEquals(RetryDecision.RETRY_SAME, st.onWriteTimeout(null, ConsistencyLevel.LOCAL_QUORUM, WriteType.SIMPLE, 2, 0, 1));
130130

131131
}
132132

@@ -135,7 +135,7 @@ public void onWriteTimeoutExceed() {
135135
DriverContext context = new DefaultDriverContext(new DefaultProgrammaticDriverConfigLoaderBuilder().build(), ProgrammaticArguments.builder().build());
136136
AmazonKeyspacesExponentialRetryPolicy st = new AmazonKeyspacesExponentialRetryPolicy(context, 3);
137137

138-
Assert.assertEquals(RetryDecision.RETHROW, st.onWriteTimeout(null, ConsistencyLevel.LOCAL_QUORUM, WriteType.SIMPLE, 2, 0, 4));
138+
assertEquals(RetryDecision.RETHROW, st.onWriteTimeout(null, ConsistencyLevel.LOCAL_QUORUM, WriteType.SIMPLE, 2, 0, 4));
139139

140140
}
141141

@@ -144,7 +144,7 @@ public void onReadTimeout() {
144144
DriverContext context = new DefaultDriverContext(new DefaultProgrammaticDriverConfigLoaderBuilder().build(), ProgrammaticArguments.builder().build());
145145
AmazonKeyspacesExponentialRetryPolicy st = new AmazonKeyspacesExponentialRetryPolicy(context, 3);
146146

147-
Assert.assertEquals(RetryDecision.RETRY_SAME, st.onReadTimeout(null, ConsistencyLevel.LOCAL_QUORUM, 2, 0, false, 1));
147+
assertEquals(RetryDecision.RETRY_SAME, st.onReadTimeout(null, ConsistencyLevel.LOCAL_QUORUM, 2, 0, false, 1));
148148

149149
}
150150

@@ -153,7 +153,7 @@ public void onReadTimeoutExceed() {
153153
DriverContext context = new DefaultDriverContext(new DefaultProgrammaticDriverConfigLoaderBuilder().build(), ProgrammaticArguments.builder().build());
154154
AmazonKeyspacesExponentialRetryPolicy st = new AmazonKeyspacesExponentialRetryPolicy(context, 3);
155155

156-
Assert.assertEquals(RetryDecision.RETHROW, st.onReadTimeout(null, ConsistencyLevel.LOCAL_QUORUM, 2, 0, false, 4));
156+
assertEquals(RetryDecision.RETHROW, st.onReadTimeout(null, ConsistencyLevel.LOCAL_QUORUM, 2, 0, false, 4));
157157

158158
}
159159

@@ -162,7 +162,7 @@ public void oneError() {
162162
DriverContext context = new DefaultDriverContext(new DefaultProgrammaticDriverConfigLoaderBuilder().build(), ProgrammaticArguments.builder().build());
163163
AmazonKeyspacesExponentialRetryPolicy st = new AmazonKeyspacesExponentialRetryPolicy(context, 3);
164164

165-
Assert.assertEquals(RetryDecision.RETRY_SAME, st.onErrorResponse(null, new WriteFailureException(null, ConsistencyLevel.LOCAL_QUORUM, 0, 2, WriteType.SIMPLE, 1, null), 2));
165+
assertEquals(RetryDecision.RETRY_SAME, st.onErrorResponse(null, new WriteFailureException(null, ConsistencyLevel.LOCAL_QUORUM, 0, 2, WriteType.SIMPLE, 1, null), 2));
166166

167167
}
168168

@@ -172,7 +172,7 @@ public void oneErrorExceed() {
172172
AmazonKeyspacesExponentialRetryPolicy st = new AmazonKeyspacesExponentialRetryPolicy(context, 3);
173173

174174

175-
Assert.assertEquals(RetryDecision.RETHROW, st.onErrorResponse(null, new WriteFailureException(null, ConsistencyLevel.LOCAL_QUORUM, 0, 2, WriteType.SIMPLE, 1, null), 4));
175+
assertEquals(RetryDecision.RETHROW, st.onErrorResponse(null, new WriteFailureException(null, ConsistencyLevel.LOCAL_QUORUM, 0, 2, WriteType.SIMPLE, 1, null), 4));
176176

177177
}
178178

@@ -181,7 +181,7 @@ public void onUnavailable() {
181181
DriverContext context = new DefaultDriverContext(new DefaultProgrammaticDriverConfigLoaderBuilder().build(), ProgrammaticArguments.builder().build());
182182
AmazonKeyspacesExponentialRetryPolicy st = new AmazonKeyspacesExponentialRetryPolicy(context, 3);
183183

184-
Assert.assertEquals(RetryDecision.RETRY_SAME, st.onUnavailable(null, ConsistencyLevel.LOCAL_QUORUM, 1, 1, 2));
184+
assertEquals(RetryDecision.RETRY_SAME, st.onUnavailable(null, ConsistencyLevel.LOCAL_QUORUM, 1, 1, 2));
185185

186186
}
187187

@@ -191,14 +191,14 @@ public void onUnavailableExceed() {
191191
AmazonKeyspacesExponentialRetryPolicy st = new AmazonKeyspacesExponentialRetryPolicy(context, 3);
192192

193193

194-
Assert.assertEquals(RetryDecision.RETHROW, st.onUnavailable(null, ConsistencyLevel.LOCAL_QUORUM, 1, 1, 4));
194+
assertEquals(RetryDecision.RETHROW, st.onUnavailable(null, ConsistencyLevel.LOCAL_QUORUM, 1, 1, 4));
195195
}
196196

197197
@Test
198198
public void testConfig() {
199-
Assert.assertEquals(3, DriverConfigLoader.fromClasspath("exponential-retry-example").getInitialConfig().getDefaultProfile().getInt(KeyspacesRetryOption.KEYSPACES_RETRY_MAX_ATTEMPTS, KeyspacesRetryOption.DEFAULT_KEYSPACES_RETRY_MAX_ATTEMPTS));
200-
Assert.assertEquals(5, DriverConfigLoader.fromClasspath("exponential-retry-example").getInitialConfig().getDefaultProfile().getDuration(KeyspacesRetryOption.KEYSPACES_RETRY_MIN_WAIT, KeyspacesRetryOption.DEFAULT_KEYSPACES_RETRY_MIN_WAIT).toMillis());
201-
Assert.assertEquals(100, DriverConfigLoader.fromClasspath("exponential-retry-example").getInitialConfig().getDefaultProfile().getDuration(KeyspacesRetryOption.KEYSPACES_RETRY_MAX_WAIT, KeyspacesRetryOption.DEFAULT_KEYSPACES_RETRY_MAX_WAIT).toMillis());
199+
assertEquals(3, DriverConfigLoader.fromClasspath("exponential-retry-example").getInitialConfig().getDefaultProfile().getInt(KeyspacesRetryOption.KEYSPACES_RETRY_MAX_ATTEMPTS, KeyspacesRetryOption.DEFAULT_KEYSPACES_RETRY_MAX_ATTEMPTS));
200+
assertEquals(10, DriverConfigLoader.fromClasspath("exponential-retry-example").getInitialConfig().getDefaultProfile().getDuration(KeyspacesRetryOption.KEYSPACES_RETRY_MIN_WAIT, KeyspacesRetryOption.DEFAULT_KEYSPACES_RETRY_MIN_WAIT).toMillis());
201+
assertEquals(100, DriverConfigLoader.fromClasspath("exponential-retry-example").getInitialConfig().getDefaultProfile().getDuration(KeyspacesRetryOption.KEYSPACES_RETRY_MAX_WAIT, KeyspacesRetryOption.DEFAULT_KEYSPACES_RETRY_MAX_WAIT).toMillis());
202202
}
203203

204204
}

0 commit comments

Comments
 (0)