Skip to content

Commit 316759f

Browse files
committed
Consolidate Java 21 specific tests in a separate Maven module.
Motivation: Java 21 specific tests are still remaining in vertx-core tests using reflection and assume statements. We should group all of that in a java 21 Maven module that run those tests. Changes: Rename vertx-core-jackson-v3 to vertx-core-java21-tests. Move Java 21 tests there.
1 parent 53650c4 commit 316759f

63 files changed

Lines changed: 244 additions & 3444 deletions

File tree

Some content is hidden

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

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
<modules>
8282
<module>vertx-core-logging</module>
8383
<module>vertx-core</module>
84-
<module>vertx-core-jackson-v3</module>
84+
<module>vertx-core-java21-tests</module>
8585
</modules>
8686
</profile>
8787

vertx-core-jackson-v3/src/test/java/module-info.java

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<version>5.1.0-SNAPSHOT</version>
2121
</parent>
2222

23-
<artifactId>vertx-core-jackson-v3</artifactId>
23+
<artifactId>vertx-core-java21-it</artifactId>
2424
<version>5.1.0-SNAPSHOT</version>
2525

2626
<name>Vert.x Core Jackson v3 plugin</name>
@@ -83,16 +83,46 @@
8383
<plugin>
8484
<groupId>org.apache.maven.plugins</groupId>
8585
<artifactId>maven-surefire-plugin</artifactId>
86-
<version>3.5.3</version>
87-
<configuration>
88-
<excludes>
89-
<exclude>io/vertx/it/**</exclude>
90-
</excludes>
91-
<classpathDependencyExcludes>
92-
<classpathDependencyExclude>com.fasterxml.jackson.core:jackson-core</classpathDependencyExclude>
93-
<classpathDependencyExclude>com.fasterxml.jackson.core:jackson-databind</classpathDependencyExclude>
94-
</classpathDependencyExcludes>
95-
</configuration>
86+
<executions>
87+
<execution>
88+
<id>default-test</id>
89+
<configuration>
90+
<includes>
91+
<include>io/vertx/tests/virtualthread/**</include>
92+
</includes>
93+
</configuration>
94+
</execution>
95+
<execution>
96+
<id>jacksonv2-test</id>
97+
<configuration>
98+
<classpathDependencyExcludes>
99+
<classpathDependencyExclude>tools.jackson.core:jackson-core</classpathDependencyExclude>
100+
<classpathDependencyExclude>tools.jackson.core:jackson-databind</classpathDependencyExclude>
101+
</classpathDependencyExcludes>
102+
<includes>
103+
<include>io/vertx/tests/jacksonv2/**</include>
104+
</includes>
105+
</configuration>
106+
<goals>
107+
<goal>test</goal>
108+
</goals>
109+
</execution>
110+
<execution>
111+
<id>jacksonv3-test</id>
112+
<configuration>
113+
<classpathDependencyExcludes>
114+
<classpathDependencyExclude>com.fasterxml.jackson.core:jackson-core</classpathDependencyExclude>
115+
<classpathDependencyExclude>com.fasterxml.jackson.core:jackson-databind</classpathDependencyExclude>
116+
</classpathDependencyExcludes>
117+
<includes>
118+
<include>io/vertx/tests/jacksonv3/**</include>
119+
</includes>
120+
</configuration>
121+
<goals>
122+
<goal>test</goal>
123+
</goals>
124+
</execution>
125+
</executions>
96126
</plugin>
97127
<plugin>
98128
<groupId>org.apache.maven.plugins</groupId>

vertx-core-jackson-v3/src/test/java/io/vertx/it/jacksonv3/JacksonReadConstraintsOverrideTest.java renamed to vertx-core-java21-tests/src/test/java/io/vertx/it/jacksonv3/JacksonReadConstraintsOverrideTest.java

File renamed without changes.

vertx-core-jackson-v3/src/test/java/io/vertx/it/jacksonv3/JacksonV2PresenceTest.java renamed to vertx-core-java21-tests/src/test/java/io/vertx/it/jacksonv3/JacksonV2PresenceTest.java

File renamed without changes.

vertx-core-jackson-v3/src/test/java/io/vertx/it/jacksonv3/JacksonV3DatabindAbsenceTest.java renamed to vertx-core-java21-tests/src/test/java/io/vertx/it/jacksonv3/JacksonV3DatabindAbsenceTest.java

File renamed without changes.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package io.vertx.tests.jacksonv2;
2+
3+
import com.fasterxml.jackson.core.util.BufferRecycler;
4+
import io.vertx.core.json.jackson.HybridJacksonPool;
5+
import org.junit.Assume;
6+
import org.junit.Test;
7+
8+
import java.util.concurrent.CountDownLatch;
9+
10+
import static org.junit.Assert.*;
11+
12+
public class HybridJacksonPoolTest {
13+
14+
@Test
15+
public void testVirtualThreadPoolWithMultipleThreads() {
16+
int stripesCount = 4;
17+
HybridJacksonPool.StripedLockFreePool virtualPool = new HybridJacksonPool.StripedLockFreePool(stripesCount);
18+
int nThreads = 100;
19+
BufferRecycler[] resources = new BufferRecycler[nThreads];
20+
CountDownLatch latch = new CountDownLatch(nThreads);
21+
22+
for (int i = 0; i < nThreads; i++) {
23+
int threadIndex = i;
24+
Thread.startVirtualThread(() -> {
25+
resources[threadIndex] = virtualPool.acquirePooled();
26+
latch.countDown();
27+
});
28+
}
29+
30+
try {
31+
latch.await();
32+
} catch (InterruptedException e) {
33+
throw new RuntimeException(e);
34+
}
35+
assertEquals(0, virtualPool.size());
36+
37+
for (int i = 0; i < nThreads; i++) {
38+
virtualPool.releasePooled(resources[i]);
39+
}
40+
41+
// check that all resources have been released back to the pool
42+
assertEquals(nThreads, virtualPool.size());
43+
44+
int avgResourcesNrPerStripe = nThreads / stripesCount;
45+
int minResourcesNrPerStripe = avgResourcesNrPerStripe / 2;
46+
int maxResourcesNrPerStripe = avgResourcesNrPerStripe * 2;
47+
48+
// check that all the stripes in the pool are reasonably balanced
49+
int[] poolStats = virtualPool.stackStats();
50+
for (int i = 0; i < stripesCount; i++) {
51+
assertTrue(poolStats[i] >= minResourcesNrPerStripe);
52+
assertTrue(poolStats[i] <= maxResourcesNrPerStripe);
53+
}
54+
}
55+
}

vertx-core-jackson-v3/src/test/java/io/vertx/tests/jacksonv3/HybridJacksonPoolTest.java renamed to vertx-core-java21-tests/src/test/java/io/vertx/tests/jacksonv3/HybridJacksonPoolTest.java

File renamed without changes.

vertx-core-jackson-v3/src/test/java/io/vertx/tests/jacksonv3/JacksonCodecTest.java renamed to vertx-core-java21-tests/src/test/java/io/vertx/tests/jacksonv3/JacksonCodecTest.java

File renamed without changes.

vertx-core-jackson-v3/src/test/java/io/vertx/tests/jacksonv3/JacksonDatabindTest.java renamed to vertx-core-java21-tests/src/test/java/io/vertx/tests/jacksonv3/JacksonDatabindTest.java

File renamed without changes.

0 commit comments

Comments
 (0)