You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by GitBox <gi...@apache.org> on 2021/11/15 17:53:07 UTC

[GitHub] [struts] yyfMichaelYan commented on a change in pull request #506: Fix flaky test testDynamicAttributesSupport.

yyfMichaelYan commented on a change in pull request #506:
URL: https://github.com/apache/struts/pull/506#discussion_r749556453



##########
File path: core/src/test/java/org/apache/struts2/views/freemarker/FreemarkerResultMockedTest.java
##########
@@ -113,15 +113,16 @@ public void testDynamicAttributesSupport() throws Exception {
         ActionMapping mapping = container.getInstance(ActionMapper.class).getMapping(request, configurationManager);
         dispatcher.serviceAction(request, response, mapping);
 
-        String expected =
-            "<input type=\"text\" name=\"test\" value=\"\" id=\"test\" foo=\"bar\" placeholder=\"input\"/>"
-                + "<input type=\"text\" name=\"test\" value=\"\" id=\"test\" foo=\"bar\" placeholder=\"input\"/>"
-                + "<input type=\"text\" name=\"test\" value=\"\" id=\"test\" break=\"true\"/>"
-                + "<input type=\"text\" name=\"required\" value=\"\" id=\"required\" required=\"true\"/>";
+        String input1 = "<input type=\"text\" name=\"test\" value=\"\" id=\"test\" foo=\"bar\" placeholder=\"input\"/>";
+        String input2 = "<input type=\"text\" name=\"test\" value=\"\" id=\"test\" placeholder=\"input\" foo=\"bar\"/>";
+        String input34 = "<input type=\"text\" name=\"test\" value=\"\" id=\"test\" break=\"true\"/>"
+                       + "<input type=\"text\" name=\"required\" value=\"\" id=\"required\" required=\"true\"/>";
 
         String result = stringWriter.toString();
-
-        assertEquals(expected, result);
+        assertTrue(result.equals(input1 + input1 + input34)
+                || result.equals(input1 + input2 + input34)
+                || result.equals(input2 + input1 + input34)
+                || result.equals(input2 + input2 + input34));

Review comment:
       Hi Lukasz! Thanks for your suggestion! Now, the two possible orders of ```foo``` and ```placeholder``` are covered by the two ```.contains()``` method, and the last two ```input``` elements (i.e. the constant part) is covered by the ```.endsWith()``` method.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@struts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org