Skip to content

Commit cb5717f

Browse files
Vanshita-Gosainclaude
andcommitted
Add JUnit @Category-based smoke test suite as proof of concept
Introduce SmokeTest category marker interface and SmokeSuite to provide a compile-checked alternative to the property file-based smoke profile. Each smoke test class is annotated with @category(SmokeTest.class); the suite uses JUnit's Categories runner to select them. A new Ant target test-smoke-category runs the suite directly. Also update test-profiles.properties.default to replace the now-deleted TestHostConfigAutomaticDeploymentA/B/C with their refactored successors (Dir, War, Xml). BUILDING.txt is updated with profile usage instructions and an explanation of the category-based approach. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent b5ffcf6 commit cb5717f

63 files changed

Lines changed: 457 additions & 4 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: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,49 @@ NOTE: Cobertura is licensed under GPL v2 with parts of it being under
603603

604604
test.verbose=false
605605

606-
(7.5) Running httpd integration tests
606+
(7.5) Running tests by profile
607+
608+
Tomcat provides named test profiles for running curated subsets of tests
609+
without specifying file patterns manually.
610+
611+
Available profiles:
612+
613+
smoke - Core smoke tests covering key subsystems
614+
catalina - All Catalina servlet container tests
615+
coyote - All Coyote protocol/connector tests
616+
tribes - All Tribes clustering tests
617+
performance - Performance benchmark tests (excluded by default)
618+
buildutil - Build utility tests (excluded by default)
619+
integration - httpd integration tests (excluded by default)
620+
621+
Usage:
622+
623+
ant test -Dtest.profile=smoke
624+
ant test -Dtest.profile=catalina
625+
626+
Profile patterns are defined in test-profiles.properties.default and can
627+
be overridden by creating a test-profiles.properties file at the project root.
628+
629+
(7.5.1) Running smoke tests via JUnit @Category (proof of concept)
630+
631+
As an alternative to the property-based smoke profile, smoke tests can be
632+
executed through the JUnit @Category mechanism:
633+
634+
ant test-smoke-category
635+
636+
This runs org.apache.tomcat.categories.SmokeSuite, which uses JUnit's
637+
Categories runner to select tests annotated with
638+
@Category(SmokeTest.class). The suite class (SmokeSuite.java) contains a
639+
compile-checked list of smoke test classes, which catches class renames or
640+
deletions at build time rather than silently skipping the missing test.
641+
642+
To add a new test to the smoke suite:
643+
1. Annotate the test class:
644+
@Category(SmokeTest.class)
645+
public class MyNewTest { ... }
646+
2. Add the class to the @SuiteClasses list in SmokeSuite.java.
647+
648+
(7.6) Running httpd integration tests
607649

608650
Tomcat includes integration tests that verify Tomcat's behavior when
609651
running behind an Apache HTTP Server (httpd) reverse proxy. These tests

‎build.xml‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2090,6 +2090,60 @@
20902090

20912091
<!-- ==================== End of Test Profile System ==================== -->
20922092

2093+
<!--
2094+
Category-based smoke test target (proof of concept).
2095+
2096+
Runs org.apache.tomcat.categories.SmokeSuite, which uses JUnit @Category
2097+
to select tests annotated with @Category(SmokeTest.class). This is an
2098+
alternative to the property-based smoke profile and produces identical
2099+
test coverage while keeping the test list compile-checked in SmokeSuite.java.
2100+
2101+
Usage: ant test-smoke-category
2102+
-->
2103+
<target name="test-smoke-category"
2104+
description="Runs smoke tests via JUnit @Category (see SmokeSuite.java)"
2105+
depends="test-compile,deploy">
2106+
<mkdir dir="${test.reports}" />
2107+
<junit printsummary="${junit.printsummary}" fork="yes" dir="." showoutput="${junit.showoutput}"
2108+
errorproperty="test.result.error"
2109+
failureproperty="test.result.failure"
2110+
haltonfailure="${test.haltonfailure}">
2111+
<jvmarg value="${test.jvmarg.egd}"/>
2112+
<jvmarg value="-Dfile.encoding=UTF-8"/>
2113+
<jvmarg value="${test.xmx}"/>
2114+
<jvmarg value="${runtests.librarypath}"/>
2115+
<jvmarg value="${test.formatter}"/>
2116+
<jvmarg value="-Djava.net.preferIPv4Stack=${java.net.preferIPv4Stack}"/>
2117+
<jvmarg value="${opens.javalang}"/>
2118+
<jvmarg value="${opens.javaio}"/>
2119+
<jvmarg value="${opens.sunrmi}"/>
2120+
<jvmarg value="${opens.javautil}"/>
2121+
<jvmarg value="${opens.javautilconcurrent}"/>
2122+
<jvmarg value="${native.nativeaccess}"/>
2123+
<jvmarg value="${openssl.ffm.1}"/>
2124+
<jvmarg value="${openssl.ffm.2}"/>
2125+
<jvmarg value="${openssl.ffm.3}"/>
2126+
<classpath refid="tomcat.test.classpath" />
2127+
<sysproperty key="tomcat.test.temp" value="${test.temp}" />
2128+
<sysproperty key="tomcat.test.basedir" value="${test.basedir}" />
2129+
<sysproperty key="tomcat.test.tomcatbuild" value="${tomcat.build}" />
2130+
<sysproperty key="tomcat.test.protocol" value="org.apache.coyote.http11.Http11NioProtocol" />
2131+
<sysproperty key="tomcat.test.accesslog" value="${test.accesslog}" />
2132+
<sysproperty key="tomcat.test.reports" value="${test.reports}" />
2133+
<sysproperty key="tomcat.test.openssl.path" value="${test.openssl.path}" />
2134+
<sysproperty key="tomcat.test.httpd.path" value="${test.httpd.path}" />
2135+
<sysproperty key="tomcat.test.openssl.unimplemented" value="${test.openssl.unimplemented}" />
2136+
<sysproperty key="tomcat.test.relaxTiming" value="${test.relaxTiming}" />
2137+
<sysproperty key="tomcat.test.sslImplementation" value="${test.sslImplementation}" />
2138+
<sysproperty key="tomcat.test.http2.loopCount" value="${test.http2.loopCount}" />
2139+
<formatter type="${junit.formatter.type}"
2140+
usefile="${junit.formatter.usefile}"
2141+
extension=".NIO${junit.formatter.extension}" />
2142+
<test todir="${test.reports}" name="org.apache.tomcat.categories.SmokeSuite" />
2143+
</junit>
2144+
<antcall target="test-status"/>
2145+
</target>
2146+
20932147
<target name="test" description="Runs the JUnit test cases"
20942148
depends="-test-name-default,test-nio,coverage-report,test-status" />
20952149

‎test-profiles.properties.default‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ org/apache/catalina/servlets/TestDefaultServlet.java,\
4343
org/apache/catalina/servlets/TestDefaultServletOptions.java,\
4444
org/apache/catalina/servlets/TestWebdavServletOptionsFile.java,\
4545
org/apache/catalina/startup/TestContextConfig.java,\
46-
org/apache/catalina/startup/TestHostConfigAutomaticDeploymentA.java,\
47-
org/apache/catalina/startup/TestHostConfigAutomaticDeploymentB.java,\
48-
org/apache/catalina/startup/TestHostConfigAutomaticDeploymentC.java,\
46+
org/apache/catalina/startup/TestHostConfigAutomaticDeploymentDir.java,\
47+
org/apache/catalina/startup/TestHostConfigAutomaticDeploymentWar.java,\
48+
org/apache/catalina/startup/TestHostConfigAutomaticDeploymentXml.java,\
4949
org/apache/catalina/valves/rewrite/TestRewriteValve.java,\
5050
org/apache/catalina/valves/TestStuckThreadDetectionValve.java,\
5151
org/apache/coyote/ajp/TestAbstractAjpProcessor.java,\

‎test/org/apache/catalina/authenticator/TestFormAuthenticatorA.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232

3333
import org.junit.Assert;
3434
import org.junit.Test;
35+
import org.junit.experimental.categories.Category;
3536

37+
import org.apache.tomcat.categories.SmokeTest;
3638
import org.apache.catalina.Context;
3739
import org.apache.catalina.Valve;
3840
import org.apache.catalina.startup.SimpleHttpClient;
@@ -78,6 +80,7 @@
7880
* but it makes no claims to generality).
7981
*
8082
*/
83+
@Category(SmokeTest.class)
8184
public class TestFormAuthenticatorA extends TomcatBaseTest {
8285

8386
// these should really be singletons to be type-safe,

‎test/org/apache/catalina/authenticator/TestSSOnonLoginAndBasicAuthenticator.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727

2828
import org.junit.Assert;
2929
import org.junit.Test;
30+
import org.junit.experimental.categories.Category;
3031

32+
import org.apache.tomcat.categories.SmokeTest;
3133
import org.apache.catalina.Context;
3234
import org.apache.catalina.Session;
3335
import org.apache.catalina.session.ManagerBase;
@@ -58,6 +60,7 @@
5860
* ignore them. The Tomcat documentation clearly states that SSO <i>requires</i> the client to support cookies, so
5961
* access to resources in other webapp containers receives no SSO assistance.
6062
*/
63+
@Category(SmokeTest.class)
6164
public class TestSSOnonLoginAndBasicAuthenticator extends TomcatBaseTest {
6265

6366
protected static final boolean USE_COOKIES = true;

‎test/org/apache/catalina/core/TestAsyncContextStateChanges.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040
import org.junit.runner.RunWith;
4141
import org.junit.runners.Parameterized;
4242
import org.junit.runners.Parameterized.Parameter;
43+
import org.junit.experimental.categories.Category;
4344

45+
import org.apache.tomcat.categories.SmokeTest;
4446
import static org.apache.catalina.startup.SimpleHttpClient.CRLF;
4547
import org.apache.catalina.Context;
4648
import org.apache.catalina.Wrapper;
@@ -54,6 +56,7 @@
5456
* Expanded to cover https://bz.apache.org/bugzilla/show_bug.cgi?id=63817 and
5557
* additional scenarios.
5658
*/
59+
@Category(SmokeTest.class)
5760
@RunWith(Parameterized.class)
5861
public class TestAsyncContextStateChanges extends TomcatBaseTest {
5962

‎test/org/apache/catalina/core/TestStandardContextResources.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232

3333
import org.junit.Assert;
3434
import org.junit.Test;
35+
import org.junit.experimental.categories.Category;
3536

37+
import org.apache.tomcat.categories.SmokeTest;
3638
import org.apache.catalina.Context;
3739
import org.apache.catalina.startup.Constants;
3840
import org.apache.catalina.startup.ContextConfig;
@@ -42,6 +44,7 @@
4244
import org.apache.tomcat.util.buf.ByteChunk;
4345
import org.apache.tomcat.util.descriptor.web.WebXml;
4446

47+
@Category(SmokeTest.class)
4548
public class TestStandardContextResources extends TomcatBaseTest {
4649

4750
@Override

‎test/org/apache/catalina/core/TestStandardWrapper.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040

4141
import org.junit.Assert;
4242
import org.junit.Test;
43+
import org.junit.experimental.categories.Category;
4344

45+
import org.apache.tomcat.categories.SmokeTest;
4446
import org.apache.catalina.Context;
4547
import org.apache.catalina.Wrapper;
4648
import org.apache.catalina.authenticator.BasicAuthenticator;
@@ -52,6 +54,7 @@
5254
import org.apache.tomcat.util.descriptor.web.LoginConfig;
5355
import org.apache.tomcat.util.http.Method;
5456

57+
@Category(SmokeTest.class)
5558
public class TestStandardWrapper extends TomcatBaseTest {
5659

5760
@Test

‎test/org/apache/catalina/loader/TestVirtualContext.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525

2626
import org.junit.Assert;
2727
import org.junit.Test;
28+
import org.junit.experimental.categories.Category;
2829

30+
import org.apache.tomcat.categories.SmokeTest;
2931
import org.apache.catalina.WebResourceRoot;
3032
import org.apache.catalina.core.JreMemoryLeakPreventionListener;
3133
import org.apache.catalina.core.StandardContext;
@@ -37,6 +39,7 @@
3739
import org.apache.tomcat.util.buf.ByteChunk;
3840
import org.apache.tomcat.util.scan.StandardJarScanner;
3941

42+
@Category(SmokeTest.class)
4043
public class TestVirtualContext extends TomcatBaseTest {
4144

4245
@Override

‎test/org/apache/catalina/mapper/TestMapperWebapps.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828

2929
import org.junit.Assert;
3030
import org.junit.Test;
31+
import org.junit.experimental.categories.Category;
3132

33+
import org.apache.tomcat.categories.SmokeTest;
3234
import org.apache.catalina.core.StandardContext;
3335
import org.apache.catalina.startup.Tomcat;
3436
import org.apache.catalina.startup.TomcatBaseTest;
@@ -41,6 +43,7 @@
4143
/**
4244
* Mapper tests that use web applications on a running Tomcat instance.
4345
*/
46+
@Category(SmokeTest.class)
4447
public class TestMapperWebapps extends TomcatBaseTest {
4548

4649
@Test

0 commit comments

Comments
 (0)