Skip to content

Commit a337c19

Browse files
committed
depedency upgrades and test clean ups
1 parent 476394f commit a337c19

20 files changed

Lines changed: 98 additions & 113 deletions

File tree

.github/workflows/dependency-submission.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ jobs:
4343
attempt_limit: 3
4444
attempt_delay: 2000
4545
- name: Submit Dependency Graph
46-
uses: mikepenz/gradle-dependency-submission@v0.7.2
46+
uses: mikepenz/gradle-dependency-submission@v0.8.0
4747
with:
4848
gradle-build-module: |-
4949
:simulator
5050
:caffeine
5151
:jcache
5252
:guava
53+
include-build-environment: true
5354
sub-module-mode: INDIVIDUAL_DEEP
54-
gradle-build-configuration: testCompileClasspath

build.gradle

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ buildscript {
1818

1919
dependencies {
2020
classpath gradlePlugins.values()
21+
classpath platforms.collect { platform(it) }
22+
23+
restrictions.each { module, version ->
24+
constraints.classpath(module).version { require version }
25+
}
2126
}
2227
}
2328

@@ -60,11 +65,12 @@ subprojects {
6065
testImplementation testLibraries.hamcrest
6166
testImplementation testLibraries.awaitility
6267
testImplementation testLibraries.osgiCompile
68+
testImplementation platforms.collect { platform(it) }
6369

6470
testRuntimeOnly testLibraries.osgiRuntime
6571

66-
constraints {
67-
implementation('org.jetbrains.kotlin:kotlin-stdlib:1.7.10+')
72+
restrictions.each { module, version ->
73+
constraints.testImplementation(module).version { require version }
6874
}
6975
}
7076

@@ -104,8 +110,12 @@ def isNonStable = { String version ->
104110
def regex = /^[0-9,.v-]+(-r)?$/
105111
return (!stableKeyword || unstableKeyword) && !(version ==~ regex)
106112
}
107-
dependencyUpdates.rejectVersionIf {
108-
(it.candidate.group == 'javax.json.bind') && isNonStable(it.candidate.version)
113+
dependencyUpdates {
114+
rejectVersionIf {
115+
isNonStable(it.candidate.version) && it.candidate.group in [
116+
'javax.json.bind', 'org.jetbrains.kotlin'
117+
]
118+
}
109119
}
110120

111121
dependencyCheck {

caffeine/src/test/java/com/github/benmanes/caffeine/cache/AsyncTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public final class AsyncTest {
4545
private static final long ONE_MINUTE = TimeUnit.MINUTES.toNanos(1);
4646

4747
@Test
48-
public void reflectivelyConstruct() throws Exception {
48+
public void reflectivelyConstruct() throws ReflectiveOperationException {
4949
var constructor = Async.class.getDeclaredConstructor();
5050
constructor.setAccessible(true);
5151
constructor.newInstance();

caffeine/src/test/java/com/github/benmanes/caffeine/cache/CaffeineTest.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.mockito.Mock;
2929
import org.mockito.MockitoAnnotations;
3030
import org.testng.Assert;
31-
import org.testng.annotations.AfterClass;
3231
import org.testng.annotations.BeforeClass;
3332
import org.testng.annotations.Test;
3433

@@ -57,16 +56,9 @@ public final class CaffeineTest {
5756
@Mock Expiry<Object, Object> expiry;
5857
@Mock CacheLoader<Object, Object> loader;
5958

60-
AutoCloseable mocks;
61-
6259
@BeforeClass
63-
public void beforeClass() {
64-
mocks = MockitoAnnotations.openMocks(this);
65-
}
66-
67-
@AfterClass
68-
public void afterClass() throws Exception {
69-
mocks.close();
60+
public void beforeClass() throws Exception {
61+
MockitoAnnotations.openMocks(this).close();
7062
}
7163

7264
@Test

caffeine/src/test/java/com/github/benmanes/caffeine/cache/LinkedDequeTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public final class LinkedDequeTests extends TestCase {
5050
// cause unexpected mutations. Instead, a different collection type should be used for comparison
5151
static final ThreadLocal<Boolean> useTarget = ThreadLocal.withInitial(() -> false);
5252

53-
public static Test suite() throws Exception {
53+
public static Test suite() {
5454
var suite = new TestSuite();
5555
suite.addTest(suite("AccessOrderDeque", AccessOrderDeque::new));
5656
suite.addTest(suite("WriteOrderDeque", WriteOrderDeque::new));

caffeine/src/test/java/com/github/benmanes/caffeine/cache/LoadingCacheTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ public void refresh_timeout_noLog(CacheContext context) {
915915
@CheckNoEvictions
916916
@Test(dataProvider = "caches")
917917
@CacheSpec(implementation = Implementation.Caffeine, population = Population.EMPTY)
918-
public void refresh_error_log(CacheContext context) throws Exception {
918+
public void refresh_error_log(CacheContext context) {
919919
var expected = new RuntimeException();
920920
CacheLoader<Int, Int> cacheLoader = key -> { throw expected; };
921921
LoadingCache<Int, Int> cache = context.isAsync()
@@ -1104,7 +1104,7 @@ public void asyncLoad() throws Exception {
11041104
public void asyncLoadAll_exception() throws Exception {
11051105
var e = new Exception();
11061106
var loader = new CacheLoader<Int, Int>() {
1107-
@Override public Int load(Int key) throws Exception {
1107+
@Override public Int load(Int key) {
11081108
throw new AssertionError();
11091109
}
11101110
@Override public Map<Int, Int> loadAll(Set<? extends Int> keys) throws Exception {

caffeine/src/test/java/com/github/benmanes/caffeine/cache/MpscGrowableQueueSanityTest.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,20 @@
2424
* @author nitsanw@yahoo.com (Nitsan Wakart)
2525
*/
2626
@RunWith(Parameterized.class)
27-
@SuppressWarnings("deprecation")
2827
public final class MpscGrowableQueueSanityTest extends QueueSanityTest {
2928

30-
public MpscGrowableQueueSanityTest(
31-
org.jctools.queues.spec.ConcurrentQueueSpec spec, Queue<Integer> queue) {
32-
super(spec, queue);
29+
public MpscGrowableQueueSanityTest(Queue<Integer> queue,
30+
Ordering ordering, int capacity, boolean isBounded) {
31+
super(queue, ordering, capacity, isBounded);
3332
}
3433

3534
@Parameterized.Parameters
3635
public static List<Object[]> parameters() {
3736
var list = new ArrayList<Object[]>();
3837
// MPSC size: 1
39-
list.add(makeQueue(0, 1, 4, org.jctools.queues.spec.Ordering.FIFO,
40-
new MpscGrowableArrayQueue<>(2, 4)));
38+
list.add(new Object[] { new MpscGrowableArrayQueue<>(2, 4), Ordering.FIFO, 4, true });
4139
// MPSC size: SIZE
42-
list.add(makeQueue(0, 1, SIZE, org.jctools.queues.spec.Ordering.FIFO,
43-
new MpscGrowableArrayQueue<>(8, SIZE)));
40+
list.add(new Object[] { new MpscGrowableArrayQueue<>(8, SIZE), Ordering.FIFO, SIZE, true });
4441
return list;
4542
}
4643
}

caffeine/src/test/java/com/github/benmanes/caffeine/cache/PacerTest.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
import org.mockito.Mock;
3131
import org.mockito.MockitoAnnotations;
32-
import org.testng.annotations.AfterMethod;
3332
import org.testng.annotations.BeforeMethod;
3433
import org.testng.annotations.Test;
3534

@@ -48,21 +47,15 @@ public final class PacerTest {
4847
@Mock Executor executor;
4948
@Mock Runnable command;
5049
@Mock Future<?> future;
51-
AutoCloseable mocks;
5250

5351
Pacer pacer;
5452

5553
@BeforeMethod
56-
public void beforeMethod() {
57-
mocks = MockitoAnnotations.openMocks(this);
54+
public void beforeMethod() throws Exception {
55+
MockitoAnnotations.openMocks(this).close();
5856
pacer = new Pacer(scheduler);
5957
}
6058

61-
@AfterMethod
62-
public void afterMethod() throws Exception {
63-
mocks.close();
64-
}
65-
6659
@Test
6760
public void schedule_initialize() {
6861
long delay = random.nextInt(Ints.saturatedCast(Pacer.TOLERANCE));

caffeine/src/test/java/com/github/benmanes/caffeine/cache/QueueSanityTest.java

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import java.util.concurrent.atomic.AtomicBoolean;
3131

3232
import org.hamcrest.Matcher;
33-
import org.jctools.queues.atomic.AtomicQueueFactory;
3433
import org.jctools.util.Pow2;
3534
import org.junit.Before;
3635
import org.junit.Test;
@@ -44,12 +43,16 @@ public abstract class QueueSanityTest {
4443
public static final int SIZE = 8192 * 2;
4544

4645
private final Queue<Integer> queue;
47-
private final org.jctools.queues.spec.ConcurrentQueueSpec spec;
46+
private final Ordering ordering;
47+
private final boolean isBounded;
48+
private final int capacity;
4849

49-
protected QueueSanityTest(
50-
org.jctools.queues.spec.ConcurrentQueueSpec spec, Queue<Integer> queue) {
50+
protected QueueSanityTest(Queue<Integer> queue,
51+
Ordering ordering, int capacity, boolean isBounded) {
5152
this.queue = queue;
52-
this.spec = spec;
53+
this.ordering = ordering;
54+
this.capacity = capacity;
55+
this.isBounded = isBounded;
5356
}
5457

5558
@Before
@@ -69,7 +72,7 @@ public void sanity() {
6972
}
7073
int size = i;
7174
assertEquals(size, queue.size());
72-
if (spec.ordering == org.jctools.queues.spec.Ordering.FIFO) {
75+
if (ordering == Ordering.FIFO) {
7376
// expect FIFO
7477
i = 0;
7578
Integer p;
@@ -107,7 +110,7 @@ public void testSizeIsTheNumberOfOffers() {
107110

108111
@Test
109112
public void whenFirstInThenFirstOut() {
110-
assumeThat(spec.ordering, is(org.jctools.queues.spec.Ordering.FIFO));
113+
assumeThat(ordering, is(Ordering.FIFO));
111114

112115
// Arrange
113116
int i = 0;
@@ -157,8 +160,8 @@ public void whenOfferItemAndPollItemThenSameInstanceReturnedAndQueueIsEmpty() {
157160

158161
@Test
159162
public void testPowerOf2Capacity() {
160-
assumeThat(spec.isBounded(), is(true));
161-
int n = Pow2.roundToPowerOfTwo(spec.capacity);
163+
assumeThat(isBounded, is(true));
164+
int n = Pow2.roundToPowerOfTwo(capacity);
162165

163166
for (int i = 0; i < n; i++) {
164167
assertTrue("Failed to insert:" + i, queue.offer(i));
@@ -172,7 +175,7 @@ static final class Val {
172175

173176
@Test
174177
@SuppressWarnings({"rawtypes", "unchecked"})
175-
public void testHappensBefore() throws Exception {
178+
public void testHappensBefore() throws InterruptedException {
176179
final AtomicBoolean stop = new AtomicBoolean();
177180
final Queue q = queue;
178181
final Val fail = new Val();
@@ -217,7 +220,7 @@ public void run() {
217220
}
218221

219222
@Test
220-
public void testSize() throws Exception {
223+
public void testSize() throws InterruptedException {
221224
final AtomicBoolean stop = new AtomicBoolean();
222225
final Queue<Integer> q = queue;
223226
final Val fail = new Val();
@@ -253,7 +256,7 @@ public void run() {
253256
}
254257

255258
@Test
256-
public void testPollAfterIsEmpty() throws Exception {
259+
public void testPollAfterIsEmpty() throws InterruptedException {
257260
final AtomicBoolean stop = new AtomicBoolean();
258261
final Queue<Integer> q = queue;
259262
final Val fail = new Val();
@@ -289,29 +292,11 @@ public void run() {
289292

290293
}
291294

292-
public static Object[] makeQueue(int producers, int consumers, int capacity,
293-
org.jctools.queues.spec.Ordering ordering, Queue<Integer> q) {
294-
org.jctools.queues.spec.ConcurrentQueueSpec spec =
295-
new org.jctools.queues.spec.ConcurrentQueueSpec(
296-
producers, consumers, capacity, ordering, org.jctools.queues.spec.Preference.NONE);
297-
if (q == null) {
298-
q = org.jctools.queues.QueueFactory.newQueue(spec);
299-
}
300-
return new Object[] {spec, q};
301-
}
302-
303-
public static Object[] makeAtomic(int producers, int consumers, int capacity,
304-
org.jctools.queues.spec.Ordering ordering, Queue<Integer> q) {
305-
org.jctools.queues.spec.ConcurrentQueueSpec spec =
306-
new org.jctools.queues.spec.ConcurrentQueueSpec(
307-
producers, consumers, capacity, ordering, org.jctools.queues.spec.Preference.NONE);
308-
if (q == null) {
309-
q = AtomicQueueFactory.newQueue(spec);
310-
}
311-
return new Object[] {spec, q};
312-
}
313-
314295
public static Matcher<Collection<?>> emptyAndZeroSize() {
315296
return allOf(hasSize(0), empty());
316297
}
298+
299+
enum Ordering {
300+
FIFO
301+
}
317302
}

caffeine/src/test/java/com/github/benmanes/caffeine/cache/SchedulerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public void disabledScheduler() {
8383
}
8484

8585
@Test
86-
public void disabledFuture() throws Exception {
86+
public void disabledFuture() {
8787
assertThat(DisabledFuture.INSTANCE.get(0, TimeUnit.SECONDS)).isNull();
8888
assertThat(DisabledFuture.INSTANCE.isCancelled()).isFalse();
8989
assertThat(DisabledFuture.INSTANCE.cancel(false)).isFalse();

0 commit comments

Comments
 (0)