Skip to content

Commit b09770f

Browse files
committed
upgrade to apache commons collections' junit5 test suite
1 parent 70f5cf8 commit b09770f

File tree

13 files changed

+104
-137
lines changed

13 files changed

+104
-137
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ workflows:
161161
- caffeine:strongKeysAndSoftValuesSyncCaffeineTest
162162
- caffeine:weakKeysAndWeakValuesSyncCaffeineTest
163163
- caffeine:weakKeysAndSoftValuesSyncCaffeineTest
164+
- caffeine:junitJupiterTest
164165
- caffeine:standaloneTest
165166
- caffeine:lincheckTest
166167
- caffeine:isolatedTest

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ jobs:
106106
- caffeine:strongKeysAndSoftValuesSyncCaffeineTest
107107
- caffeine:weakKeysAndWeakValuesSyncCaffeineTest
108108
- caffeine:weakKeysAndSoftValuesSyncCaffeineTest
109+
- caffeine:junitJupiterTest
109110
- caffeine:standaloneTest
110111
- caffeine:lincheckTest
111112
- caffeine:isolatedTest

caffeine/build.gradle.kts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ sourceSets {
2222
}
2323
}
2424

25+
val jar by tasks.existing(Jar::class)
2526
val compileJavaPoetJava by tasks.existing
2627
val jammAgent: Configuration by configurations.creating
2728
val collections4Sources: Configuration by configurations.creating
@@ -197,30 +198,30 @@ val fuzzTest = tasks.register<Test>("fuzzTest") {
197198
group = "Verification"
198199
description = "Fuzz tests"
199200
include("com/github/benmanes/caffeine/fuzz/**")
200-
201201
environment("JAZZER_FUZZ", "1")
202-
testLogging.events("started")
203202
useJUnitPlatform()
204203
failFast = true
205204
forkEvery = 1
206205
}
207206

208-
val junitTest = tasks.register<Test>("junitTest") {
207+
val junitJupiterTest = tasks.register<Test>("junitJupiterTest") {
209208
group = "Verification"
210-
description = "JUnit tests"
209+
description = "JUnit Jupiter tests"
211210
exclude("com/github/benmanes/caffeine/fuzz/**")
211+
useJUnitPlatform()
212+
}
212213

213-
val jar by tasks.existing(Jar::class)
214-
dependsOn(jar)
215-
214+
val junitTest = tasks.register<Test>("junitTest") {
215+
group = "Verification"
216+
description = "JUnit classic tests"
216217
systemProperty("caffeine.osgi.jar", relativePath(jar.get().archiveFile.get().asFile.path))
217-
maxHeapSize = "2g"
218-
failFast = true
218+
dependsOn(jar)
219219
useJUnit()
220220
}
221221

222222
tasks.test.configure {
223223
exclude("com/github/benmanes/caffeine/**")
224+
dependsOn(junitJupiterTest)
224225
dependsOn(standaloneTest)
225226
dependsOn(isolatedTest)
226227
dependsOn(lincheckTest)

caffeine/src/test/java/com/github/benmanes/caffeine/apache/BoundedMapTest.java

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* Copyright 2022 Ben Manes. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.github.benmanes.caffeine.apache;
17+
18+
import java.time.Duration;
19+
import java.util.concurrent.ConcurrentMap;
20+
21+
import org.apache.commons.collections4.map.AbstractMapTest;
22+
import org.junit.jupiter.api.Nested;
23+
24+
import com.github.benmanes.caffeine.cache.Cache;
25+
import com.github.benmanes.caffeine.cache.Caffeine;
26+
27+
/**
28+
* Apache Commons Collections' map tests for the {@link Cache#asMap()} view.
29+
*
30+
* @author ben.manes@gmail.com (Ben Manes)
31+
*/
32+
@SuppressWarnings("PMD.MissingStaticMethodInNonInstantiatableClass")
33+
public final class CaffeineMapTest {
34+
35+
private CaffeineMapTest() {}
36+
37+
@Nested
38+
static final class BoundedSyncMapTest extends AbstractConcurrentMapTest {
39+
@Override public ConcurrentMap<Object, Object> makeObject() {
40+
return Caffeine.newBuilder()
41+
.expireAfterWrite(Duration.ofNanos(Long.MAX_VALUE))
42+
.maximumSize(Long.MAX_VALUE)
43+
.build().asMap();
44+
}
45+
}
46+
47+
@Nested
48+
static final class BoundedAsyncMapTest extends AbstractConcurrentMapTest {
49+
@Override public ConcurrentMap<Object, Object> makeObject() {
50+
return Caffeine.newBuilder()
51+
.expireAfterWrite(Duration.ofNanos(Long.MAX_VALUE))
52+
.maximumSize(Long.MAX_VALUE)
53+
.buildAsync().synchronous().asMap();
54+
}
55+
}
56+
57+
@Nested
58+
static final class UnboundedSyncMapTest extends AbstractConcurrentMapTest {
59+
@Override public ConcurrentMap<Object, Object> makeObject() {
60+
return Caffeine.newBuilder().build().asMap();
61+
}
62+
}
63+
64+
@Nested
65+
static final class UnboundedAsyncMapTest extends AbstractConcurrentMapTest {
66+
@Override public ConcurrentMap<Object, Object> makeObject() {
67+
return Caffeine.newBuilder().buildAsync().synchronous().asMap();
68+
}
69+
}
70+
71+
abstract static class AbstractConcurrentMapTest
72+
extends AbstractMapTest<ConcurrentMap<Object, Object>, Object, Object> {
73+
74+
@Override public boolean isAllowNullKey() {
75+
return false;
76+
}
77+
@Override public boolean isAllowNullValueGet() {
78+
return false;
79+
}
80+
@Override public boolean isAllowNullValuePut() {
81+
return false;
82+
}
83+
@Override public boolean isTestSerialization() {
84+
return false;
85+
}
86+
}
87+
}

caffeine/src/test/java/com/github/benmanes/caffeine/apache/CaffeineMapTestCase.java

Lines changed: 0 additions & 52 deletions
This file was deleted.

caffeine/src/test/java/com/github/benmanes/caffeine/apache/UnboundedMapTest.java

Lines changed: 0 additions & 34 deletions
This file was deleted.

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ cache2k = "2.6.1.Final"
99
caffeine = "3.1.8"
1010
checkstyle = "10.21.1"
1111
coherence = "24.09"
12-
commons-collections4 = "4.4"
12+
commons-collections4 = "4.5.0-M3"
1313
commons-compress = "1.27.1"
1414
commons-io = "2.18.0"
1515
commons-lang3 = "3.17.0"

gradle/plugins/src/main/kotlin/lifecycle/testing.caffeine.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ dependencies {
2020
testImplementation(platform(libs.junit5.bom))
2121

2222
testRuntimeOnly(libs.junit5.launcher)
23-
testRuntimeOnly(libs.bundles.junit.engines)
2423

2524
mockitoAgent(libs.mockito) {
2625
isTransitive = false

gradle/plugins/src/main/kotlin/lifecycle/versions.caffeine.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ tasks.named<DependencyUpdatesTask>("dependencyUpdates").configure {
2222
}
2323
}
2424
}
25-
force(libs.commons.collections4)
2625
}
2726
}
2827

0 commit comments

Comments
 (0)