You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by th...@apache.org on 2019/08/31 22:07:24 UTC

[tapestry-5] branch master updated: Attempt to handle the intermittent failures of XMLTokenStreamTests.testStreamEncoding

This is an automated email from the ASF dual-hosted git repository.

thiagohp pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tapestry-5.git


The following commit(s) were added to refs/heads/master by this push:
     new b29b6dc  Attempt to handle the intermittent failures of XMLTokenStreamTests.testStreamEncoding
b29b6dc is described below

commit b29b6dc7293ac50a3c77c71ced52c340b14e9553
Author: Thiago H. de Paula Figueiredo <th...@arsmachina.com.br>
AuthorDate: Sat Aug 31 19:07:13 2019 -0300

    Attempt to handle the intermittent failures of
    XMLTokenStreamTests.testStreamEncoding
---
 .../internal/services/XMLTokenStreamTests.java     | 24 +++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/XMLTokenStreamTests.java b/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/XMLTokenStreamTests.java
index e80ad06..83ba966 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/XMLTokenStreamTests.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/XMLTokenStreamTests.java
@@ -92,7 +92,29 @@ public class XMLTokenStreamTests
             
             String testDocument="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>"+unicodeString+"</root>\n";
             XMLTokenStream xts=new XMLTokenStream(new ResourceStub(testDocument.getBytes("utf-8")),parserUrlMap);
-            xts.parse();
+            
+            // Ugly way to handle exceptions like java.io.IOException: Server returned HTTP response code: 503 for URL: http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent
+            // when running tests
+            int attempts = 0;
+            int maxAttempts = 10;
+            boolean success = false;
+            while (!success && attempts < maxAttempts)
+            {
+                try 
+                {
+                    xts.parse();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                    Thread.sleep(5000);
+                    attempts++;
+                    continue;
+                }
+                success = true;
+            }
+            if (attempts == maxAttempts) 
+            {
+                throw new RuntimeException("Maximum number of attempts reached");
+            }
             Assert.assertEquals(xts.next(), XMLTokenType.START_ELEMENT);
             Assert.assertEquals(xts.getLocalName(), "root");
             Assert.assertEquals(xts.next(), XMLTokenType.CHARACTERS);