This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch feature/WW-5256-freemarker-compress in repository https://gitbox.apache.org/repos/asf/struts.git
commit e6b0d603a9863edfbffa2035c9c5d86f89f37525 Author: Lukasz Lenart <[email protected]> AuthorDate: Fri Nov 21 10:10:52 2025 +0100 test(compress): WW-5256 add tests and documentation - Add tests for global compression disabled setting - Add test for force attribute overriding global setting - Update compress tag documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --- .../site/resources/tags/compress-description.html | 10 ++++- .../apache/struts2/components/CompressTest.java | 47 ++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/core/src/site/resources/tags/compress-description.html b/core/src/site/resources/tags/compress-description.html index 6865f0b72..1d8125d55 100644 --- a/core/src/site/resources/tags/compress-description.html +++ b/core/src/site/resources/tags/compress-description.html @@ -1 +1,9 @@ -Compress wrapped content +Compress wrapped content by removing whitespace between HTML tags. +<p> +This tag removes unnecessary whitespace from HTML output to reduce page size. +Compression is automatically disabled in devMode for easier debugging. +Use the <code>force</code> attribute to override this behavior. +</p> +<p> +Compression can also be disabled globally via <code>struts.compress.enabled=false</code>. +</p> diff --git a/core/src/test/java/org/apache/struts2/components/CompressTest.java b/core/src/test/java/org/apache/struts2/components/CompressTest.java index 6631850ab..480031dd7 100644 --- a/core/src/test/java/org/apache/struts2/components/CompressTest.java +++ b/core/src/test/java/org/apache/struts2/components/CompressTest.java @@ -123,6 +123,53 @@ public class CompressTest extends StrutsInternalTestCase { assertEquals("<html><head><title>File upload: result</title></head><body><h1>File upload: result</h1></body></html>", writer.toString()); } + public void testCompressionDisabledGlobally() { + Compress compress = new Compress(stack); + + String body = """ + <html> + <head> + <title>File upload: result</title> + </head> + <body> + <h1>File upload: result</h1> + </body> + </html> + """; + + StringWriter writer = new StringWriter(); + + compress.setDevMode("false"); + compress.setCompressionEnabled("false"); + compress.end(writer, body); + + assertEquals(body, writer.toString()); + } + + public void testCompressionDisabledGloballyButForced() { + Compress compress = new Compress(stack); + + String body = """ + <html> + <head> + <title>File upload: result</title> + </head> + <body> + <h1>File upload: result</h1> + </body> + </html> + """; + + StringWriter writer = new StringWriter(); + + compress.setDevMode("false"); + compress.setCompressionEnabled("false"); + compress.setForce("true"); + compress.end(writer, body); + + assertEquals("<html><head><title>File upload: result</title></head><body><h1>File upload: result</h1></body></html>", writer.toString()); + } + @Override public void setUp() throws Exception { super.setUp();
