Skip to content

Commit 52ec88b

Browse files
committed
Move constants to a new Constants class and mark as EXPERIMENTAL
Issue: #2229
1 parent c7687fc commit 52ec88b

File tree

4 files changed

+59
-28
lines changed

4 files changed

+59
-28
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright 2015-2025 the original author or authors.
3+
*
4+
* All rights reserved. This program and the accompanying materials are
5+
* made available under the terms of the Eclipse Public License v2.0 which
6+
* accompanies this distribution and is available at
7+
*
8+
* https://www.eclipse.org/legal/epl-v20.html
9+
*/
10+
11+
package org.junit.vintage.engine;
12+
13+
import static org.apiguardian.api.API.Status.EXPERIMENTAL;
14+
import static org.apiguardian.api.API.Status.STABLE;
15+
16+
import org.apiguardian.api.API;
17+
18+
/**
19+
* Collection of constants related to the {@link VintageTestEngine}.
20+
*
21+
* @since 5.12
22+
*/
23+
@API(status = STABLE, since = "5.12")
24+
public final class Constants {
25+
26+
/**
27+
* Indicates whether parallel execution is enabled for the JUnit Vintage engine.
28+
*
29+
* <p>Set this property to {@code true} to enable parallel execution of tests.
30+
* Defaults to {@code false}.
31+
*
32+
* @since 5.12
33+
*/
34+
@API(status = EXPERIMENTAL, since = "5.12")
35+
public static final String PARALLEL_EXECUTION_ENABLED = "junit.vintage.execution.parallel.enabled";
36+
37+
/**
38+
* Specifies the size of the thread pool to be used for parallel execution.
39+
*
40+
* <p>Set this property to an integer value to specify the number of threads
41+
* to be used for parallel execution. Defaults to the number of available
42+
* processors.
43+
*
44+
* @since 5.12
45+
*/
46+
@API(status = EXPERIMENTAL, since = "5.12")
47+
public static final String PARALLEL_POOL_SIZE = "junit.vintage.execution.parallel.pool-size";
48+
49+
private Constants() {
50+
/* no-op */
51+
}
52+
53+
}

junit-vintage-engine/src/main/java/org/junit/vintage/engine/VintageTestEngine.java

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
import static org.apiguardian.api.API.Status.INTERNAL;
1414
import static org.junit.platform.engine.TestExecutionResult.successful;
15+
import static org.junit.vintage.engine.Constants.PARALLEL_EXECUTION_ENABLED;
16+
import static org.junit.vintage.engine.Constants.PARALLEL_POOL_SIZE;
1517
import static org.junit.vintage.engine.descriptor.VintageTestDescriptor.ENGINE_ID;
1618

1719
import java.util.ArrayList;
@@ -52,29 +54,6 @@ public final class VintageTestEngine implements TestEngine {
5254
private static final int DEFAULT_THREAD_POOL_SIZE = Runtime.getRuntime().availableProcessors();
5355
private static final int SHUTDOWN_TIMEOUT_SECONDS = 30;
5456

55-
/**
56-
* Indicates whether parallel execution is enabled for the JUnit Vintage engine.
57-
*
58-
* <p>Set this property to {@code true} to enable parallel execution of tests.
59-
* Defaults to {@code false}.
60-
*
61-
* @since 5.12
62-
*/
63-
@API(status = INTERNAL, since = "5.12")
64-
public static final String PARALLEL_EXECUTION_ENABLED = "junit.vintage.execution.parallel.enabled";
65-
66-
/**
67-
* Specifies the size of the thread pool to be used for parallel execution.
68-
*
69-
* <p>Set this property to an integer value to specify the number of threads
70-
* to be used for parallel execution. Defaults to the number of available
71-
* processors.
72-
*
73-
* @since 5.12
74-
*/
75-
@API(status = INTERNAL, since = "5.12")
76-
public static final String PARALLEL_POOL_SIZE = "junit.vintage.execution.parallel.pool-size";
77-
7857
@Override
7958
public String getId() {
8059
return ENGINE_ID;

junit-vintage-engine/src/test/java/org/junit/vintage/engine/execution/ParallelExecutionIntegrationTests.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2024 the original author or authors.
2+
* Copyright 2015-2025 the original author or authors.
33
*
44
* All rights reserved. This program and the accompanying materials are
55
* made available under the terms of the Eclipse Public License v2.0 which
@@ -15,6 +15,8 @@
1515
import static org.junit.platform.testkit.engine.EventConditions.event;
1616
import static org.junit.platform.testkit.engine.EventConditions.finishedSuccessfully;
1717
import static org.junit.platform.testkit.engine.EventConditions.started;
18+
import static org.junit.vintage.engine.Constants.PARALLEL_EXECUTION_ENABLED;
19+
import static org.junit.vintage.engine.Constants.PARALLEL_POOL_SIZE;
1820
import static org.junit.vintage.engine.descriptor.VintageTestDescriptor.SEGMENT_TYPE_RUNNER;
1921
import static org.junit.vintage.engine.samples.junit4.JUnit4ParallelTestCase.AbstractBlockingTestCase;
2022
import static org.junit.vintage.engine.samples.junit4.JUnit4ParallelTestCase.FirstTestCase;
@@ -42,9 +44,6 @@
4244

4345
class ParallelExecutionIntegrationTests {
4446

45-
private static final String PARALLEL_EXECUTION_ENABLED = "junit.vintage.execution.parallel.enabled";
46-
private static final String PARALLEL_POOL_SIZE = "junit.vintage.execution.parallel.pool-size";
47-
4847
@Test
4948
void executesTestClassesInParallel(TestReporter reporter) {
5049
AbstractBlockingTestCase.threadNames.clear();

junit-vintage-engine/src/testFixtures/java/org/junit/vintage/engine/samples/junit4/JUnit4ParallelTestCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2024 the original author or authors.
2+
* Copyright 2015-2025 the original author or authors.
33
*
44
* All rights reserved. This program and the accompanying materials are
55
* made available under the terms of the Eclipse Public License v2.0 which

0 commit comments

Comments
 (0)