From 50f02c9a0ff14c86b15c6956f7296efcad35a59c Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Sat, 11 Jun 2016 08:45:41 +0000 Subject: [PATCH] Improve output on invalid HTTP Status Code and ignore another failure to contact the TSP server git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1747863 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/poifs/crypt/dsig/services/TSPTimeStampService.java | 6 ++++-- .../org/apache/poi/poifs/crypt/TestSignatureInfo.java | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/TSPTimeStampService.java b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/TSPTimeStampService.java index 0478048f7c..cc1c4c4a96 100644 --- a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/TSPTimeStampService.java +++ b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/TSPTimeStampService.java @@ -150,8 +150,10 @@ public class TSPTimeStampService implements TimeStampService { int statusCode = huc.getResponseCode(); if (statusCode != 200) { - LOG.log(POILogger.ERROR, "Error contacting TSP server ", signatureConfig.getTspUrl()); - throw new IOException("Error contacting TSP server " + signatureConfig.getTspUrl()); + LOG.log(POILogger.ERROR, "Error contacting TSP server ", signatureConfig.getTspUrl() + + ", had status code " + statusCode + "/" + huc.getResponseMessage()); + throw new IOException("Error contacting TSP server " + signatureConfig.getTspUrl() + + ", had status code " + statusCode + "/" + huc.getResponseMessage()); } // HTTP input validation diff --git a/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java b/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java index 889b0dd1ab..eb09fa0ad2 100644 --- a/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java +++ b/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java @@ -389,10 +389,13 @@ public class TestSignatureInfo { throw e; } if((e.getCause() instanceof ConnectException) || (e.getCause() instanceof SocketTimeoutException)) { - assertTrue("Only allowing ConnectException with 'timed out' as message here, but had: " + e, + Assume.assumeTrue("Only allowing ConnectException with 'timed out' as message here, but had: " + e, e.getCause().getMessage().contains("timed out")); + } else if (e.getCause() instanceof IOException) { + Assume.assumeTrue("Only allowing IOException with 'Error contacting TSP server' as message here, but had: " + e, + e.getCause().getMessage().contains("Error contacting TSP server")); } else if (e.getCause() instanceof RuntimeException) { - assertTrue("Only allowing RuntimeException with 'This site is cur' as message here, but had: " + e, + Assume.assumeTrue("Only allowing RuntimeException with 'This site is cur' as message here, but had: " + e, e.getCause().getMessage().contains("This site is cur")); } else { throw e; -- 2.39.5