Skip to content

Commit 0d5e8f3

Browse files
Vanshita-Gosainclaude
andcommitted
Extend @category profiles to all remaining profiles; remove properties file
Annotate all test classes in the catalina, coyote, performance, tribes, buildutil, and integration profiles with their corresponding @category marker. CategoryScanner discovers annotated classes at build time so no file list needs to be maintained anywhere. Remove test-profiles.properties.default: all profiles are now annotation-driven and the properties file has no remaining entries. Remove the property file load statements from build.xml and update the set-profile-pattern macro to map each profile name to its category class. The special build-time flags (test.includeBuildutil, test.includeTribes, test.includeIntegration, test.excludePerformance) are still set by -test-profile-init so the existing batchtest exclusions continue to work. Update BUILDING.txt with per-profile annotation instructions. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent 2ede375 commit 0d5e8f3

442 files changed

Lines changed: 1670 additions & 124 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.

‎BUILDING.txt‎

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -623,28 +623,36 @@ Usage:
623623
ant test -Dtest.profile=smoke
624624
ant test -Dtest.profile=catalina
625625

626-
Pattern-based profile definitions are in test-profiles.properties.default and
627-
can be overridden by creating a test-profiles.properties file at the project
628-
root. The smoke profile is annotation-driven; see section (7.5.1) below.
626+
Profile membership is declared via @Category annotations directly on test
627+
classes. CategoryScanner discovers matching tests at build time by scanning
628+
compiled classes and feeds the result into the standard Ant batchtest
629+
mechanism so each test still runs in its own JVM.
629630

630-
(7.5.1) The smoke profile and JUnit @Category
631+
(7.5.1) Adding a test to a profile
631632

632-
The smoke profile selects tests via the @Category(SmokeTest.class)
633-
annotation rather than a file list in the properties file. At build time,
634-
CategoryScanner scans the compiled test classes, finds all classes annotated
635-
with @Category(SmokeTest.class), and feeds the result into the standard Ant
636-
batchtest mechanism so each test still runs in its own JVM.
633+
Annotate the test class with the appropriate category and add the
634+
corresponding import:
637635

638-
ant test -Dtest.profile=smoke
636+
Profile Category class
637+
------- --------------
638+
smoke SmokeTest
639+
catalina CatalinaTest
640+
coyote CoyoteTest
641+
tribes TribesTest (also add CatalinaTest for catalina coverage)
642+
performance PerformanceTest
643+
buildutil BuildutilTest
644+
integration IntegrationTest
639645

640-
To add a test to the smoke profile, annotate the test class:
646+
Example — adding a test to the catalina profile:
641647

642648
import org.junit.experimental.categories.Category;
643-
import org.apache.tomcat.categories.SmokeTest;
649+
import org.apache.tomcat.categories.CatalinaTest;
644650

645-
@Category(SmokeTest.class)
651+
@Category(CatalinaTest.class)
646652
public class MyNewTest { ... }
647653

654+
All category interfaces are in the org.apache.tomcat.categories package.
655+
648656
(7.6) Running httpd integration tests
649657

650658
Tomcat includes integration tests that verify Tomcat's behavior when

‎build.xml‎

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1998,62 +1998,53 @@
19981998

19991999
<!-- ==================== Test Profile System ==================== -->
20002000
<!--
2001-
Property-based test profiles for convenient, selective test execution.
2001+
Annotation-based test profiles for convenient, selective test execution.
20022002
20032003
Usage: ant test -Dtest.profile=<profile-name>
20042004
20052005
Precedence: test.entry > test.profile > default
20062006
If test.entry is set, the profile is ignored to maintain backward compatibility.
20072007
2008-
Profile patterns are defined in test-profiles.properties test.profile properties
2009-
to keep this file readable.
2008+
Profile membership is declared via @Category annotations on test classes.
2009+
CategoryScanner discovers matching tests at build time by scanning compiled
2010+
classes, so no separate file list needs to be maintained.
20102011
-->
20112012

2012-
<!-- ================= Initialize Test Profile Property Values ================ -->
2013-
2014-
<!-- We read test profile definitions from "test-profiles.properties.default" -->
2015-
<!-- and also from "test-profiles.properties" if it exists. -->
2016-
<!-- The values in "test-profiles.properties" have stronger preference. -->
2017-
<!-- If you want to customize your build, you can either change the values -->
2018-
<!-- directly in the default file, or create a new test-profiles.properties and -->
2019-
<!-- set the values there. This way you don't have to change a file which -->
2020-
<!-- is part of the original project source code. -->
2021-
<!-- See "test-profiles.properties.default" in the top level directory for some -->
2022-
<!-- property values you may customize. -->
2023-
<property file="${user.home}/test-profiles.properties"/>
2024-
<property file="test-profiles.properties"/>
2025-
<property file="test-profiles.properties.default"/>
2026-
20272013
<!-- Macro to set test pattern based on profile name -->
20282014
<macrodef name="set-profile-pattern">
20292015
<attribute name="profile"/>
20302016
<sequential>
20312017
<!-- Set test.name property based on the profile attribute -->
20322018

2033-
<!-- For category-based profiles, record the category class so that the
2034-
-test-categories target (which runs after test-compile) can run
2035-
CategoryScanner and set test.name. -->
2019+
<!-- All profiles are now annotation-driven. Record the category class so
2020+
that the -test-categories target (which runs after test-compile) can
2021+
invoke CategoryScanner and set test.name. -->
20362022
<condition property="test.category.class"
20372023
value="org.apache.tomcat.categories.SmokeTest">
20382024
<equals arg1="@{profile}" arg2="smoke"/>
20392025
</condition>
2040-
2041-
<condition property="test.name" value="${test.profile.catalina}">
2026+
<condition property="test.category.class"
2027+
value="org.apache.tomcat.categories.CatalinaTest">
20422028
<equals arg1="@{profile}" arg2="catalina"/>
20432029
</condition>
2044-
<condition property="test.name" value="${test.profile.coyote}">
2030+
<condition property="test.category.class"
2031+
value="org.apache.tomcat.categories.CoyoteTest">
20452032
<equals arg1="@{profile}" arg2="coyote"/>
20462033
</condition>
2047-
<condition property="test.name" value="${test.profile.performance}">
2034+
<condition property="test.category.class"
2035+
value="org.apache.tomcat.categories.PerformanceTest">
20482036
<equals arg1="@{profile}" arg2="performance"/>
20492037
</condition>
2050-
<condition property="test.name" value="${test.profile.tribes}">
2038+
<condition property="test.category.class"
2039+
value="org.apache.tomcat.categories.TribesTest">
20512040
<equals arg1="@{profile}" arg2="tribes"/>
20522041
</condition>
2053-
<condition property="test.name" value="${test.profile.buildutil}">
2042+
<condition property="test.category.class"
2043+
value="org.apache.tomcat.categories.BuildutilTest">
20542044
<equals arg1="@{profile}" arg2="buildutil"/>
20552045
</condition>
2056-
<condition property="test.name" value="${test.profile.integration}">
2046+
<condition property="test.category.class"
2047+
value="org.apache.tomcat.categories.IntegrationTest">
20572048
<equals arg1="@{profile}" arg2="integration"/>
20582049
</condition>
20592050
</sequential>

‎test-profiles.properties.default‎

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

‎test/jakarta/el/TesterCompositeELResolverPerformance.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@
1717
package jakarta.el;
1818

1919
import org.junit.Test;
20+
import org.junit.experimental.categories.Category;
21+
22+
import org.apache.tomcat.categories.PerformanceTest;
2023

2124
/*
2225
* This is an absolute performance test. There is no benefit it running it as part of a standard test run so it is
2326
* excluded due to the name starting Tester...
2427
*/
28+
@Category(PerformanceTest.class)
2529
public class TesterCompositeELResolverPerformance {
2630

2731
/*

‎test/jakarta/el/TesterImportHandlerPerformance.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@
1717
package jakarta.el;
1818

1919
import org.junit.Test;
20+
import org.junit.experimental.categories.Category;
21+
22+
import org.apache.tomcat.categories.PerformanceTest;
2023

2124
/*
2225
* This is an absolute performance test. There is no benefit it running it as part of a standard test run so it is
2326
* excluded due to the name starting Tester...
2427
*/
28+
@Category(PerformanceTest.class)
2529
public class TesterImportHandlerPerformance {
2630

2731
/*

‎test/jakarta/servlet/http/TesterHttpServletPerformance.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,18 @@
2121
import jakarta.servlet.ServletException;
2222

2323
import org.junit.Test;
24+
import org.junit.experimental.categories.Category;
2425

2526
import org.apache.catalina.connector.RequestFacade;
2627
import org.apache.catalina.filters.TesterHttpServletResponse;
28+
import org.apache.tomcat.categories.PerformanceTest;
2729

2830

2931
/*
3032
* This is an absolute performance test. There is no benefit it running it as part of a standard test run so it is
3133
* excluded due to the name starting Tester...
3234
*/
35+
@Category(PerformanceTest.class)
3336
public class TesterHttpServletPerformance {
3437

3538
@Test

‎test/jakarta/servlet/jsp/el/TesterScopedAttributeELResolverPerformance.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@
2424
import jakarta.servlet.jsp.TesterPageContext;
2525

2626
import org.junit.Test;
27+
import org.junit.experimental.categories.Category;
28+
29+
import org.apache.tomcat.categories.PerformanceTest;
2730

2831
/*
2932
* This is an absolute performance test. There is no benefit it running it as part of a standard test run so it is
3033
* excluded due to the name starting Tester...
3134
*/
35+
@Category(PerformanceTest.class)
3236
public class TesterScopedAttributeELResolverPerformance {
3337

3438
/*

‎test/jakarta/websocket/TesterContainerProviderPerformance.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,16 @@
2020
import java.util.function.Supplier;
2121

2222
import org.junit.Test;
23+
import org.junit.experimental.categories.Category;
2324

25+
import org.apache.tomcat.categories.PerformanceTest;
2426
import org.apache.tomcat.unittest.TesterThreadedPerformance;
2527

2628
/*
2729
* This is an absolute performance test. There is no benefit in running it as part of a standard test run so it is
2830
* excluded due to the name starting Tester...
2931
*/
32+
@Category(PerformanceTest.class)
3033
public class TesterContainerProviderPerformance {
3134

3235
@Test

‎test/org/apache/catalina/ant/TestDeployTask.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@
2222

2323
import org.junit.Assert;
2424
import org.junit.Test;
25+
import org.junit.experimental.categories.Category;
2526

2627
import org.apache.catalina.startup.Tomcat;
2728
import org.apache.catalina.startup.TomcatBaseTest;
29+
import org.apache.tomcat.categories.CatalinaTest;
2830
import org.apache.tools.ant.BuildException;
2931

32+
@Category(CatalinaTest.class)
3033
public class TestDeployTask extends TomcatBaseTest {
3134

3235
@Test

‎test/org/apache/catalina/ant/jmx/TestJMXAccessorCondition.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@
1818

1919
import org.junit.Assert;
2020
import org.junit.Test;
21+
import org.junit.experimental.categories.Category;
2122

23+
import org.apache.tomcat.categories.CatalinaTest;
2224
import org.apache.tools.ant.BuildException;
2325

26+
@Category(CatalinaTest.class)
2427
public class TestJMXAccessorCondition {
2528

2629
@Test

0 commit comments

Comments
 (0)