Skip to content

Commit

Permalink
upgrade to apache commons collections' junit5 test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-manes committed Jan 6, 2025
1 parent 70f5cf8 commit b09770f
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 137 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ workflows:
- caffeine:strongKeysAndSoftValuesSyncCaffeineTest
- caffeine:weakKeysAndWeakValuesSyncCaffeineTest
- caffeine:weakKeysAndSoftValuesSyncCaffeineTest
- caffeine:junitJupiterTest
- caffeine:standaloneTest
- caffeine:lincheckTest
- caffeine:isolatedTest
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ jobs:
- caffeine:strongKeysAndSoftValuesSyncCaffeineTest
- caffeine:weakKeysAndWeakValuesSyncCaffeineTest
- caffeine:weakKeysAndSoftValuesSyncCaffeineTest
- caffeine:junitJupiterTest
- caffeine:standaloneTest
- caffeine:lincheckTest
- caffeine:isolatedTest
Expand Down
19 changes: 10 additions & 9 deletions caffeine/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ sourceSets {
}
}

val jar by tasks.existing(Jar::class)
val compileJavaPoetJava by tasks.existing
val jammAgent: Configuration by configurations.creating
val collections4Sources: Configuration by configurations.creating
Expand Down Expand Up @@ -197,30 +198,30 @@ val fuzzTest = tasks.register<Test>("fuzzTest") {
group = "Verification"
description = "Fuzz tests"
include("com/github/benmanes/caffeine/fuzz/**")

environment("JAZZER_FUZZ", "1")
testLogging.events("started")
useJUnitPlatform()
failFast = true
forkEvery = 1
}

val junitTest = tasks.register<Test>("junitTest") {
val junitJupiterTest = tasks.register<Test>("junitJupiterTest") {
group = "Verification"
description = "JUnit tests"
description = "JUnit Jupiter tests"
exclude("com/github/benmanes/caffeine/fuzz/**")
useJUnitPlatform()
}

val jar by tasks.existing(Jar::class)
dependsOn(jar)

val junitTest = tasks.register<Test>("junitTest") {
group = "Verification"
description = "JUnit classic tests"
systemProperty("caffeine.osgi.jar", relativePath(jar.get().archiveFile.get().asFile.path))
maxHeapSize = "2g"
failFast = true
dependsOn(jar)
useJUnit()
}

tasks.test.configure {
exclude("com/github/benmanes/caffeine/**")
dependsOn(junitJupiterTest)
dependsOn(standaloneTest)
dependsOn(isolatedTest)
dependsOn(lincheckTest)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* Copyright 2022 Ben Manes. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.benmanes.caffeine.apache;

import java.time.Duration;
import java.util.concurrent.ConcurrentMap;

import org.apache.commons.collections4.map.AbstractMapTest;
import org.junit.jupiter.api.Nested;

import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;

/**
* Apache Commons Collections' map tests for the {@link Cache#asMap()} view.
*
* @author [email protected] (Ben Manes)
*/
@SuppressWarnings("PMD.MissingStaticMethodInNonInstantiatableClass")
public final class CaffeineMapTest {

private CaffeineMapTest() {}

@Nested
static final class BoundedSyncMapTest extends AbstractConcurrentMapTest {
@Override public ConcurrentMap<Object, Object> makeObject() {
return Caffeine.newBuilder()
.expireAfterWrite(Duration.ofNanos(Long.MAX_VALUE))
.maximumSize(Long.MAX_VALUE)
.build().asMap();
}
}

@Nested
static final class BoundedAsyncMapTest extends AbstractConcurrentMapTest {
@Override public ConcurrentMap<Object, Object> makeObject() {
return Caffeine.newBuilder()
.expireAfterWrite(Duration.ofNanos(Long.MAX_VALUE))
.maximumSize(Long.MAX_VALUE)
.buildAsync().synchronous().asMap();
}
}

@Nested
static final class UnboundedSyncMapTest extends AbstractConcurrentMapTest {
@Override public ConcurrentMap<Object, Object> makeObject() {
return Caffeine.newBuilder().build().asMap();
}
}

@Nested
static final class UnboundedAsyncMapTest extends AbstractConcurrentMapTest {
@Override public ConcurrentMap<Object, Object> makeObject() {
return Caffeine.newBuilder().buildAsync().synchronous().asMap();
}
}

abstract static class AbstractConcurrentMapTest
extends AbstractMapTest<ConcurrentMap<Object, Object>, Object, Object> {

@Override public boolean isAllowNullKey() {
return false;
}
@Override public boolean isAllowNullValueGet() {
return false;
}
@Override public boolean isAllowNullValuePut() {
return false;
}
@Override public boolean isTestSerialization() {
return false;
}
}
}

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ cache2k = "2.6.1.Final"
caffeine = "3.1.8"
checkstyle = "10.21.1"
coherence = "24.09"
commons-collections4 = "4.4"
commons-collections4 = "4.5.0-M3"
commons-compress = "1.27.1"
commons-io = "2.18.0"
commons-lang3 = "3.17.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ dependencies {
testImplementation(platform(libs.junit5.bom))

testRuntimeOnly(libs.junit5.launcher)
testRuntimeOnly(libs.bundles.junit.engines)

mockitoAgent(libs.mockito) {
isTransitive = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ tasks.named<DependencyUpdatesTask>("dependencyUpdates").configure {
}
}
}
force(libs.commons.collections4)
}
}

Expand Down
1 change: 1 addition & 0 deletions guava/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dependencies {
testImplementation(libs.bundles.osgi.test.compile)

testRuntimeOnly(libs.bundles.osgi.test.runtime)
testRuntimeOnly(libs.bundles.junit.engines)
}

tasks.named<JavaCompile>("compileJava").configure {
Expand Down
1 change: 1 addition & 0 deletions jcache/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ dependencies {
}

testRuntimeOnly(libs.bundles.osgi.test.runtime)
testRuntimeOnly(libs.bundles.junit.engines)

jcacheJavadoc(libs.jcache) {
artifact { classifier = "javadoc" }
Expand Down
2 changes: 2 additions & 0 deletions simulator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ dependencies {
implementation(libs.bundles.slf4j.jdk)
implementation(libs.univocity.parsers)
implementation(libs.zero.allocation.hashing)

testRuntimeOnly(libs.bundles.junit.engines)
}

application {
Expand Down

0 comments on commit b09770f

Please sign in to comment.