diff --git a/.gitignore b/.gitignore
index 4750576e2..e0875669a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -62,3 +62,4 @@ bundles/target
plugins/target
target
plugins/testng/test-output
+test-output
diff --git a/.travis.yml b/.travis.yml
index 8d985742d..e12ba2fb9 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,12 +5,17 @@ jdk:
- openjdk7
- oraclejdk8
- oraclejdk9
+ - oraclejdk11
install: true
script: mvn test -DskipAssembly
after_success:
- - mvn clean cobertura:cobertura org.eluder.coveralls:coveralls-maven-plugin:report com.updateimpact:updateimpact-maven-plugin:submit -Ptravis-coveralls,update-impact -DskipAssembly
+ # TODO delete following if statement after fix of https://github.com/cobertura/cobertura/issues/271
+ - if [ "$TRAVIS_JDK_VERSION" == "openjdk8" ] || [ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ];
+ then mvn clean cobertura:cobertura org.eluder.coveralls:coveralls-maven-plugin:report com.updateimpact:updateimpact-maven-plugin:submit -Ptravis-coveralls,update-impact -DskipAssembly;
+ else echo "Not reporting coverage for $TRAVIS_JDK_VERSION due to incomatibility or to save performance";
+ fi;
env:
global:
diff --git a/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilTest.java b/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilTest.java
index d6372fdcb..28d0d59e5 100644
--- a/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilTest.java
@@ -27,9 +27,9 @@ import com.opensymphony.xwork2.test.User;
import com.opensymphony.xwork2.util.*;
import com.opensymphony.xwork2.util.reflection.ReflectionContextState;
import ognl.*;
-import org.apache.struts2.TestUtils;
import java.lang.reflect.Method;
+import java.text.DateFormat;
import java.util.*;
public class OgnlUtilTest extends XWorkTestCase {
@@ -373,24 +373,8 @@ public class OgnlUtilTest extends XWorkTestCase {
cal.set(Calendar.YEAR, 1982);
assertEquals(cal.getTime(), foo.getBirthday());
-
- //UK style test
- if (TestUtils.isJdk9OrLater()) {
- /* In JDK 9 and later, the default locale data uses data derived from the
- Unicode Consortium's Common Locale Data Repository (CLDR). The short date-time format is ‹{1}, {0}› in the
- CLDR locale, as opposed to {1} {0} in the JRE locale data.
- Please refer : http://www.oracle.com/technetwork/java/javase/9-relnote-issues-3704069.html#JDK-8008577 */
- props.put("event", "18/10/2006, 14:23:45");
- props.put("meeting", "09/09/2006, 14:30");
- }
- else {
- props.put("event", "18/10/2006 14:23:45");
- props.put("meeting", "09/09/2006 14:30");
- }
- context.put(ActionContext.LOCALE, Locale.UK);
- ognlUtil.setProperties(props, foo, context);
-
+ //UK style test
cal = Calendar.getInstance();
cal.clear();
cal.set(Calendar.MONTH, Calendar.OCTOBER);
@@ -399,9 +383,12 @@ public class OgnlUtilTest extends XWorkTestCase {
cal.set(Calendar.HOUR_OF_DAY, 14);
cal.set(Calendar.MINUTE, 23);
cal.set(Calendar.SECOND, 45);
-
- assertEquals(cal.getTime(), foo.getEvent());
-
+
+ Date eventTime = cal.getTime();
+ String formatted = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, Locale.UK)
+ .format(eventTime);
+ props.put("event", formatted);
+
cal = Calendar.getInstance();
cal.clear();
cal.set(Calendar.MONTH, Calendar.SEPTEMBER);
@@ -409,8 +396,19 @@ public class OgnlUtilTest extends XWorkTestCase {
cal.set(Calendar.YEAR, 2006);
cal.set(Calendar.HOUR_OF_DAY, 14);
cal.set(Calendar.MINUTE, 30);
-
- assertEquals(cal.getTime(), foo.getMeeting());
+
+ Date meetingTime = cal.getTime();
+ formatted = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, Locale.UK)
+ .format(meetingTime);
+ props.put("meeting", formatted);
+
+ context.put(ActionContext.LOCALE, Locale.UK);
+
+ ognlUtil.setProperties(props, foo, context);
+
+ assertEquals(eventTime, foo.getEvent());
+
+ assertEquals(meetingTime, foo.getMeeting());
//test RFC 3339 date format for JSON
props.put("event", "1996-12-19T16:39:57Z");
diff --git a/core/src/test/java/com/opensymphony/xwork2/util/ClassPathFinderTest.java b/core/src/test/java/com/opensymphony/xwork2/util/ClassPathFinderTest.java
index 34c0bbe81..dd395ee07 100644
--- a/core/src/test/java/com/opensymphony/xwork2/util/ClassPathFinderTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/util/ClassPathFinderTest.java
@@ -62,12 +62,14 @@ public class ClassPathFinderTest extends XWorkTestCase {
NotURLClassLoader loader = new NotURLClassLoader(Thread.currentThread().getContextClassLoader());
Thread.currentThread().setContextClassLoader(loader);
- Class> clazz = loader.loadClass(ClassPathFinderTest.class.getName());
- Object test = clazz.getConstructor().newInstance();
+ try {
+ Class> clazz = loader.loadClass(ClassPathFinderTest.class.getName());
+ Object test = clazz.getConstructor().newInstance();
- clazz.getMethod("testFinder").invoke(test);
-
- Thread.currentThread().setContextClassLoader(loader.parentClassLoader);
+ clazz.getMethod("testFinder").invoke(test);
+ } finally {
+ Thread.currentThread().setContextClassLoader(loader.parentClassLoader);
+ }
}
@@ -89,6 +91,8 @@ public class ClassPathFinderTest extends XWorkTestCase {
loadedClasses.put(name, defineClass(name, classBits, 0, classBits.length));
} catch (IOException e) {
throw new ClassNotFoundException("class " + name + " is not findable", e);
+ } catch (Exception e) {
+ loadedClasses.put(name, parentClassLoader.loadClass(name));
}
}
diff --git a/core/src/test/java/com/opensymphony/xwork2/util/fs/JarEntryRevisionTest.java b/core/src/test/java/com/opensymphony/xwork2/util/fs/JarEntryRevisionTest.java
index 6969ccd3f..20a21ce7c 100644
--- a/core/src/test/java/com/opensymphony/xwork2/util/fs/JarEntryRevisionTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/util/fs/JarEntryRevisionTest.java
@@ -34,6 +34,7 @@ import java.net.URLConnection;
import java.net.URLStreamHandler;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.jar.Attributes;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
@@ -49,10 +50,13 @@ public class JarEntryRevisionTest extends XWorkTestCase {
fileManager = container.getInstance(FileManagerFactory.class).getFileManager();
}
- private void createJarFile(long time) throws Exception {
+ private String createJarFile(long time) throws Exception {
Manifest manifest = new Manifest();
manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
- FileOutputStream fos = new FileOutputStream("target/JarEntryRevisionTest_testNeedsReloading.jar", false);
+ Path jarPath = Paths.get(Thread.currentThread().getContextClassLoader()
+ .getResource("xwork-jar.jar").toURI()).getParent();
+ File jarFile = jarPath.resolve("JarEntryRevisionTest_testNeedsReloading.jar").toFile();
+ FileOutputStream fos = new FileOutputStream(jarFile, false);
JarOutputStream target = new JarOutputStream(fos, manifest);
target.putNextEntry(new ZipEntry("com/opensymphony/xwork2/util/fs/"));
ZipEntry entry = new ZipEntry("com/opensymphony/xwork2/util/fs/JarEntryRevisionTest.class");
@@ -64,13 +68,14 @@ public class JarEntryRevisionTest extends XWorkTestCase {
target.closeEntry();
target.close();
fos.close();
+
+ return jarFile.toURI().toURL().toExternalForm();
}
public void testNeedsReloading() throws Exception {
long now = System.currentTimeMillis();
- createJarFile(now);
- URL url = new URL("jar:file:target/JarEntryRevisionTest_testNeedsReloading.jar!/com/opensymphony/xwork2/util/fs/JarEntryRevisionTest.class");
+ URL url = new URL("jar:" + createJarFile(now) + "!/com/opensymphony/xwork2/util/fs/JarEntryRevisionTest.class");
Revision entry = JarEntryRevision.build(url, fileManager);
assert entry != null;
assertFalse(entry.needsReloading());
@@ -82,9 +87,8 @@ public class JarEntryRevisionTest extends XWorkTestCase {
public void testNeedsReloadingWithContainerProvidedURLConnection() throws Exception {
long now = System.currentTimeMillis();
- createJarFile(now);
URL url = new URL(null,
- "jar:file:target/JarEntryRevisionTest_testNeedsReloading.jar!/com/opensymphony/xwork2/util/fs/JarEntryRevisionTest.class",
+ "jar:" + createJarFile(now) + "!/com/opensymphony/xwork2/util/fs/JarEntryRevisionTest.class",
new ContainerProvidedURLStreamHandler());
Revision entry = JarEntryRevision.build(url, fileManager);
assert entry != null;
@@ -97,9 +101,7 @@ public class JarEntryRevisionTest extends XWorkTestCase {
public void testNeedsReloadingWithContainerProvidedURLConnectionEmptyProtocol() throws Exception {
long now = System.currentTimeMillis();
- createJarFile(now);
- File targetDir = new File("target");
- String targetUrlStr = targetDir.toURI().toURL().toString();
+ String targetUrlStr = createJarFile(now);
if (targetUrlStr.startsWith("file:")) {
targetUrlStr = targetUrlStr.substring(5);//emptying protocol; we expect framework will fix it
}
@@ -107,7 +109,7 @@ public class JarEntryRevisionTest extends XWorkTestCase {
targetUrlStr = targetUrlStr.substring(1);//we expect framework will fix it also
}
URL url = new URL(null,
- "zip:" + targetUrlStr + "JarEntryRevisionTest_testNeedsReloading.jar!/com/opensymphony/xwork2/util/fs/JarEntryRevisionTest.class",
+ "zip:" + targetUrlStr + "!/com/opensymphony/xwork2/util/fs/JarEntryRevisionTest.class",
new ContainerProvidedURLStreamHandler());
Revision entry = JarEntryRevision.build(url, fileManager);
assert entry != null;
diff --git a/core/src/test/java/org/apache/struts2/TestUtils.java b/core/src/test/java/org/apache/struts2/TestUtils.java
index 111cd898a..32f5630da 100644
--- a/core/src/test/java/org/apache/struts2/TestUtils.java
+++ b/core/src/test/java/org/apache/struts2/TestUtils.java
@@ -91,20 +91,4 @@ public class TestUtils {
return buffer.toString();
}
-
- public static boolean isJdk9OrLater() {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
-
- if(loader instanceof URLClassLoader) {
- return false;
- }
-
- loader = TestUtils.class.getClassLoader();
-
- if(loader instanceof URLClassLoader) {
- return false;
- }
-
- return true;
- }
}
diff --git a/plugins/bean-validation/pom.xml b/plugins/bean-validation/pom.xml
index 71aaffcec..bb6d82658 100644
--- a/plugins/bean-validation/pom.xml
+++ b/plugins/bean-validation/pom.xml
@@ -61,6 +61,37 @@
test
+
+
+ javax.xml.bind
+ jaxb-api
+ 2.3.1
+ test
+
+
+ com.sun.xml.bind
+ jaxb-core
+ 2.3.0.1
+ test
+
+
+ com.sun.xml.bind
+ jaxb-impl
+ 2.3.1
+ test
+
+
+ javax.activation
+ activation
+ 1.1.1
+ test
+
+
\ No newline at end of file
diff --git a/plugins/embeddedjsp/src/test/java/org/apache/struts2/EmbeddedJSPResultTest.java b/plugins/embeddedjsp/src/test/java/org/apache/struts2/EmbeddedJSPResultTest.java
index 952cd8491..dbc807011 100644
--- a/plugins/embeddedjsp/src/test/java/org/apache/struts2/EmbeddedJSPResultTest.java
+++ b/plugins/embeddedjsp/src/test/java/org/apache/struts2/EmbeddedJSPResultTest.java
@@ -231,12 +231,14 @@ public class EmbeddedJSPResultTest extends TestCase {
NotURLClassLoader loader = new NotURLClassLoader(parentClassLoader);
Thread.currentThread().setContextClassLoader(loader);
- result.setLocation("org/apache/struts2/tag0.jsp");
- result.execute(null);
+ try {
+ result.setLocation("org/apache/struts2/tag0.jsp");
+ result.execute(null);
- assertEquals("Thissessionisnotsecure.OtherText", StringUtils.deleteWhitespace(response.getContentAsString()));
-
- Thread.currentThread().setContextClassLoader(parentClassLoader);
+ assertEquals("Thissessionisnotsecure.OtherText", StringUtils.deleteWhitespace(response.getContentAsString()));
+ } finally {
+ Thread.currentThread().setContextClassLoader(parentClassLoader);
+ }
}
@Override
diff --git a/pom.xml b/pom.xml
index f7b12bd98..0b1ef52fb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -110,6 +110,7 @@
https://builds.apache.org/analysis/
+ 2.22.1
@@ -169,6 +170,7 @@
+
true
@@ -178,7 +180,8 @@
org.apache.maven.plugins
maven-surefire-plugin
- --add-modules java.activation --add-modules java.xml.bind
+
+ 0
@@ -233,12 +236,12 @@
org.apache.maven.plugins
maven-surefire-plugin
- 2.20.1
+ ${maven-surefire-plugin.version}
org.apache.maven.surefire
surefire-junit47
- 2.20.1
+ ${maven-surefire-plugin.version}