You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2020/04/05 05:46:07 UTC
[struts] 02/06: Fix for test running on JDK 9+. If using Spring 4.x
mock objects the MockServletContext has a dependency on javax.activation
that causes a java.lang.NoClassDefFoundError. - Test updated to allow the
single call that triggers this in JDK9+ to continue as long as the class
not found is FileTypeMap (expected).
This is an automated email from the ASF dual-hosted git repository.
lukaszlenart pushed a commit to branch action-context-boost
in repository https://gitbox.apache.org/repos/asf/struts.git
commit b0197f370e15286675481517f7eb284b43a818b9
Author: JCgH4164838Gh792C124B5 <43...@users.noreply.github.com>
AuthorDate: Sun Mar 22 15:37:20 2020 -0400
Fix for test running on JDK 9+. If using Spring 4.x mock objects the
MockServletContext has a dependency on javax.activation that causes a
java.lang.NoClassDefFoundError.
- Test updated to allow the single call that triggers this in JDK9+
to continue as long as the class not found is FileTypeMap (expected).
---
.../org/apache/struts2/StrutsSpringPortletMockObjectsTest.java | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/plugins/junit-portlet/src/test/java/org/apache/struts2/StrutsSpringPortletMockObjectsTest.java b/plugins/junit-portlet/src/test/java/org/apache/struts2/StrutsSpringPortletMockObjectsTest.java
index 6ba60f3..e802dc6 100644
--- a/plugins/junit-portlet/src/test/java/org/apache/struts2/StrutsSpringPortletMockObjectsTest.java
+++ b/plugins/junit-portlet/src/test/java/org/apache/struts2/StrutsSpringPortletMockObjectsTest.java
@@ -1465,7 +1465,15 @@ public class StrutsSpringPortletMockObjectsTest extends StrutsSpringTestCase {
assertNull("ServletWrappingPortletContext resource stream for /ThisDoesNotExist not null ?", servletWrappingPortletContext.getResourceAsStream("/ThisDoesNotExist"));
assertTrue("ServletWrappingPortletContext major version not >= 2 ?", servletWrappingPortletContext.getMajorVersion() >= 2);
assertTrue("ServletWrappingPortletContext minor version not >= 0 ?", servletWrappingPortletContext.getMajorVersion() >= 0);
- assertNull("ServletWrappingPortletContext MIME type for / not null ?", servletWrappingPortletContext.getMimeType("/"));
+ try {
+ assertNull("ServletWrappingPortletContext MIME type for / not null ?", servletWrappingPortletContext.getMimeType("/"));
+ } catch (NoClassDefFoundError ncdfe) {
+ // If compiled with Spring 4.x the MockServletContext has a dependency on javax.activation. This will cause a runtime failure running under JDK 9+ due to removal
+ // of the javax.activation module. For that reason we will ignore the NoClassDefFoundError failure provided it is for the known FileTypeMap dependency.
+ if (!ncdfe.getMessage().contains("javax/activation/FileTypeMap")) {
+ fail("Unexpected exception: " + ncdfe);
+ }
+ }
assertNotNull("ServletWrappingPortletContext real path for / null ?", servletWrappingPortletContext.getRealPath("/"));
assertNull("ServletWrappingPortletContext real path for /ThisDoesNotExist not null ? ?", servletWrappingPortletContext.getRealPath("/ThisDoesNotExist"));
assertNull("ServletWrappingPortletContext resource paths for / not null ?", servletWrappingPortletContext.getResourcePaths("/"));