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



##########
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:
       @lukaszlenart @sepe81 Thank you both! I found the method 
```allOf(java.lang.Iterable<Matcher<? super T>> matchers)``` which can put all 
matchers together and be used as the second argument to ```assertThat```.
   
   The dynamic messages are a little different (if my understanding of "dynamic 
message" is correct). With the new assertion methods, there are extra text like 
```a string starting with...```.
   Original:
   ```
   expected:<<input[]type="text" name="te...> but was:<<input[ ]type="text" 
name="te...>
   ```
   New:
   ```
   Expected: (a string starting with "<inputtype=\"text\" name=\"test\" 
value=\"\" id=\"test\"" and a string containing "foo=\"bar\"" and a string 
containing "placeholder=\"input\"" and a string ending with "<input 
type=\"text\" name=\"test\" value=\"\" id=\"test\" break=\"true\"/><input 
type=\"text\" name=\"required\" value=\"\" id=\"required\" required=\"true\"/>")
        but: a string starting with "<inputtype=\"text\" name=\"test\" 
value=\"\" id=\"test\"" was "<input type="text" name="test" value="" id="test" 
placeholder="input" foo="bar"/><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"/>"
   ```
   
   In the error messages above, I intentionally deleted the space between 
```input```  and ```type``` to create an error.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to