From 3eaeed1699ccf2d9a437c49d7e10e714c33ee9fe Mon Sep 17 00:00:00 2001 From: JCgH4164838Gh792C124B5 <43964333+JCgH4164838Gh792C124B5@users.noreply.github.com> Date: Mon, 31 Dec 2018 17:24:08 -0500 Subject: [PATCH] Update length check in testComplex() to compensate for miscalculation of expected length. - Test jsp is processed into a 218 line String, meaning 218 more characters (crlf vs lf) on Windows vs. Linux/Unix. --- .../apache/struts2/EmbeddedJSPResultTest.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/plugins/embeddedjsp/src/test/java/org/apache/struts2/EmbeddedJSPResultTest.java b/plugins/embeddedjsp/src/test/java/org/apache/struts2/EmbeddedJSPResultTest.java index 7d96f9ba2..ca72f8fe0 100644 --- a/plugins/embeddedjsp/src/test/java/org/apache/struts2/EmbeddedJSPResultTest.java +++ b/plugins/embeddedjsp/src/test/java/org/apache/struts2/EmbeddedJSPResultTest.java @@ -259,12 +259,18 @@ public class EmbeddedJSPResultTest extends TestCase { int testValue5Index = responseString.indexOf("testvalue5 set/if worked."); int lastGroupIndex = responseString.indexOf("End include tests
"); int lastHtmlIndex = responseString.indexOf(""); - assertTrue("Did not find title ?", titleIndex > 0); - assertTrue("Test value 1 not present or index not > title index ?", testValue1Index > titleIndex); - assertTrue("Test value 5 not present or index not > test value 1 index ?", testValue5Index > testValue1Index); - assertTrue("Last group index not present or index not > test value 5 index ?", lastGroupIndex > testValue5Index); - assertTrue("Last html index not present or index not > last group index ?", lastHtmlIndex > lastGroupIndex); - assertTrue("Response not at least length: 3400 ?", responseLength > 3400); + assertTrue("Did not find title index (" + titleIndex + ") ?", titleIndex > 0); + assertTrue("Test value 1 not present or index (" + testValue1Index + ") not > title index (" + titleIndex + ") ?", + testValue1Index > titleIndex); + assertTrue("Test value 5 not present or index (" + testValue5Index + ") not > test value 1 index (" + testValue1Index + ") ?", + testValue5Index > testValue1Index); + assertTrue("Last group index not present or index (" + lastGroupIndex + ") not > test value 5 index (" + testValue5Index + ") ?", + lastGroupIndex > testValue5Index); + assertTrue("Last html index not present or index (" + lastHtmlIndex + ") not > last group index (" + lastGroupIndex + ") ?", + lastHtmlIndex > lastGroupIndex); + // complex0.jsp length 3439 in Windows and estimated 3221 in Linux/Unix (with 218 lines, Windows has around 218 additional + // characters (crlf vs. lf). Test length larger than the min(Windows,Linux)), rounded down to the nearest 100. + assertTrue("Response length (" + responseLength + ") not at least length: 3200 ?", responseLength > 3200); } public void testInstanceHelper() throws Exception {