try to fix windows integration tests

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1885888 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2021-01-24 22:25:08 +00:00
parent ed836507e5
commit 6038381e3a
2 changed files with 12 additions and 9 deletions

View File

@ -155,13 +155,10 @@ public abstract class SlideShowHandler extends POIFSFileHandler {
// We saw exceptions with JDK 8 on Windows in the Jenkins CI which // We saw exceptions with JDK 8 on Windows in the Jenkins CI which
// seem to only be triggered by some font (maybe Calibri?!) // seem to only be triggered by some font (maybe Calibri?!)
// We cannot avoid this, so let's try to not make the tests fail in this case // We cannot avoid this, so let's try to not make the tests fail in this case
Assumptions.assumeFalse( if (!"-1".equals(e.getMessage()) ||
e.getMessage().equals("-1") && !ExceptionUtils.readStackTrace(e).contains("ExtendedTextSourceLabel.getJustificationInfos")) {
ExceptionUtils.readStackTrace(e).contains("ExtendedTextSourceLabel.getJustificationInfos"), throw e;
"JDK sometimes fails at this point on some fonts on Windows machines, but we " + }
"should not fail the build because of this: " + ExceptionUtils.readStackTrace(e));
throw e;
} }
graphics.dispose(); graphics.dispose();

View File

@ -165,13 +165,14 @@ public class TestAllFiles {
exec.execute(); exec.execute();
fail(errPrefix + "Expected failed assertion"); fail(errPrefix + "Expected failed assertion");
} catch (AssertionFailedError e) { } catch (AssertionFailedError e) {
assertEquals(exMessage, e.getMessage(), errPrefix); String actMsg = pathReplace(e.getMessage());
assertEquals(exMessage, actMsg, errPrefix);
} catch (Throwable e) { } catch (Throwable e) {
fail(errPrefix + "Unexpected exception", e); fail(errPrefix + "Unexpected exception", e);
} }
} else if (exClass != null) { } else if (exClass != null) {
Exception e = assertThrows((Class<? extends Exception>)exClass, exec); Exception e = assertThrows((Class<? extends Exception>)exClass, exec);
String actMsg = e.getMessage(); String actMsg = pathReplace(e.getMessage());
if (NullPointerException.class.isAssignableFrom(exClass)) { if (NullPointerException.class.isAssignableFrom(exClass)) {
// with Java 16+ NullPointerExceptions may contain a message ... but apparently not always ?! // with Java 16+ NullPointerExceptions may contain a message ... but apparently not always ?!
assertTrue(jreVersion >= 16 || actMsg == null, errPrefix); assertTrue(jreVersion >= 16 || actMsg == null, errPrefix);
@ -186,4 +187,9 @@ public class TestAllFiles {
assertDoesNotThrow(exec, errPrefix); assertDoesNotThrow(exec, errPrefix);
} }
} }
private static String pathReplace(String msg) {
// Windows path replacement
return msg == null ? null : msg.replace('\\', '/');
}
} }