You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2019/06/12 14:27:32 UTC

[sling-whiteboard] 09/11: AgentIT: better handling of missing exception lines

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

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git

commit 65231667f5ed57c428385a34f20dda982f9e1e38
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Wed Jun 12 16:14:16 2019 +0200

    AgentIT: better handling of missing exception lines
---
 .../src/test/java/org/apache/sling/uca/impl/AgentIT.java     | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/url-connection-agent/src/test/java/org/apache/sling/uca/impl/AgentIT.java b/url-connection-agent/src/test/java/org/apache/sling/uca/impl/AgentIT.java
index 59240cd..dd2bbfe 100644
--- a/url-connection-agent/src/test/java/org/apache/sling/uca/impl/AgentIT.java
+++ b/url-connection-agent/src/test/java/org/apache/sling/uca/impl/AgentIT.java
@@ -55,6 +55,7 @@ import org.slf4j.LoggerFactory;
 @ExtendWith(MisbehavingServerExtension.class)
 public class AgentIT {
     
+    private static final String EXCEPTION_MARKER = "Exception in thread \"main\" ";
     private static final Path STDERR = Paths.get("target", "stderr.txt");
     private static final Path STDOUT = Paths.get("target", "stdout.txt");
     private static final Logger LOG = LoggerFactory.getLogger(AgentIT.class);
@@ -195,12 +196,15 @@ public class AgentIT {
         return String.join(File.pathSeparator, elements);
     }
 
-    private RecordedThrowable newRecordedThrowable(String string) {
+    private RecordedThrowable newRecordedThrowable(String line) {
+        
+        if ( !line.startsWith(EXCEPTION_MARKER) )
+            return null;
      
-        string = string.replace("Exception in thread \"main\" ", "");
+        line = line.replace(EXCEPTION_MARKER, "");
 
-        String className = string.substring(0, string.indexOf(':'));
-        String message = string.substring(string.indexOf(':') + 2); // ignore ':' and leading ' '
+        String className = line.substring(0, line.indexOf(':'));
+        String message = line.substring(line.indexOf(':') + 2); // ignore ':' and leading ' '
 
         return new RecordedThrowable(className, message);
     }