You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by jo...@apache.org on 2015/06/07 21:04:21 UTC
[2/6] struts git commit: Solve problem when xwork and core tests are
running on a machine where default local is different from "en"
Solve problem when xwork and core tests are running on a machine where default local is different from "en"
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/9c67e4e8
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/9c67e4e8
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/9c67e4e8
Branch: refs/heads/master
Commit: 9c67e4e8366b5c30a02d4b2ee496493e8abda837
Parents: 72e6f70
Author: Johannes Geppert <jo...@gmail.com>
Authored: Sun Jun 7 11:54:46 2015 +0200
Committer: Johannes Geppert <jo...@gmail.com>
Committed: Sun Jun 7 11:54:46 2015 +0200
----------------------------------------------------------------------
.../struts2/dispatcher/StreamResultTest.java | 25 +++++++++---------
.../interceptor/FileUploadInterceptorTest.java | 8 +++---
core/src/test/resources/log4j.properties | 27 --------------------
core/src/test/resources/log4j2.xml | 13 ++++++++++
pom.xml | 1 +
xwork-core/pom.xml | 1 +
6 files changed, 31 insertions(+), 44 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/9c67e4e8/core/src/test/java/org/apache/struts2/dispatcher/StreamResultTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/dispatcher/StreamResultTest.java b/core/src/test/java/org/apache/struts2/dispatcher/StreamResultTest.java
index 054dbe3..147823d 100644
--- a/core/src/test/java/org/apache/struts2/dispatcher/StreamResultTest.java
+++ b/core/src/test/java/org/apache/struts2/dispatcher/StreamResultTest.java
@@ -21,22 +21,21 @@
package org.apache.struts2.dispatcher;
+import com.opensymphony.xwork2.Action;
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.mock.MockActionInvocation;
+import com.opensymphony.xwork2.util.ClassLoaderUtil;
+import com.opensymphony.xwork2.util.ValueStack;
+import org.apache.struts2.ServletActionContext;
+import org.apache.struts2.StrutsInternalTestCase;
+import org.springframework.mock.web.MockHttpServletResponse;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
-import org.apache.struts2.ServletActionContext;
-import org.apache.struts2.StrutsInternalTestCase;
-import org.springframework.mock.web.MockHttpServletResponse;
-
-import com.opensymphony.xwork2.util.ClassLoaderUtil;
-import com.opensymphony.xwork2.Action;
-import com.opensymphony.xwork2.ActionContext;
-import com.opensymphony.xwork2.mock.MockActionInvocation;
-import com.opensymphony.xwork2.util.ValueStack;
-
/**
* Unit test for {@link StreamResult}.
*
@@ -249,8 +248,8 @@ public class StreamResultTest extends StrutsInternalTestCase {
public class MyImageAction implements Action {
public InputStream getStreamForImage() throws Exception {
- // just use src/test/log4j.properties as test file
- URL url = ClassLoaderUtil.getResource("log4j.properties", StreamResultTest.class);
+ // just use src/test/log4j2.xml as test file
+ URL url = ClassLoaderUtil.getResource("log4j2.xml", StreamResultTest.class);
File file = new File(new URI(url.toString()));
FileInputStream fis = new FileInputStream(file);
return fis;
@@ -261,7 +260,7 @@ public class StreamResultTest extends StrutsInternalTestCase {
}
public long getContentLength() throws Exception {
- URL url = ClassLoaderUtil.getResource("log4j.properties", StreamResultTest.class);
+ URL url = ClassLoaderUtil.getResource("log4j2.xml", StreamResultTest.class);
File file = new File(new URI(url.toString()));
return file.length();
}
http://git-wip-us.apache.org/repos/asf/struts/blob/9c67e4e8/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java b/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java
index acf045e..9dbb114 100644
--- a/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java
+++ b/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java
@@ -158,9 +158,9 @@ public class FileUploadInterceptorTest extends StrutsInternalTestCase {
// when file is not of allowed types
ValidationAwareSupport validation = new ValidationAwareSupport();
- URL url = ClassLoaderUtil.getResource("log4j.properties", FileUploadInterceptorTest.class);
+ URL url = ClassLoaderUtil.getResource("log4j2.xml", FileUploadInterceptorTest.class);
File file = new File(new URI(url.toString()));
- assertTrue("log4j.properties should be in src/test folder", file.exists());
+ assertTrue("log4j2.xml should be in src/test folder", file.exists());
boolean notOk = interceptor.acceptFile(action, file, "filename", "text/html", "inputName", validation);
assertFalse(notOk);
@@ -169,10 +169,10 @@ public class FileUploadInterceptorTest extends StrutsInternalTestCase {
List errors = (List) validation.getFieldErrors().get("inputName");
assertEquals(1, errors.size());
String msg = (String) errors.get(0);
- // the error message shoul contain at least this test
+ // the error message should contain at least this test
assertTrue(msg.startsWith("The file is to large to be uploaded"));
assertTrue(msg.indexOf("inputName") > 0);
- assertTrue(msg.indexOf("log4j.properties") > 0);
+ assertTrue(msg.indexOf("log4j2.xml") > 0);
}
public void testNoMultipartRequest() throws Exception {
http://git-wip-us.apache.org/repos/asf/struts/blob/9c67e4e8/core/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/core/src/test/resources/log4j.properties b/core/src/test/resources/log4j.properties
deleted file mode 100644
index 28ca560..0000000
--- a/core/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# $Id$
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-log4j.rootLogger = WARN, stdout
-
-log4j.appender.stdout = org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.Threshold = WARN
-log4j.appender.stdout.Target = System.out
-log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern = %d{ISO8601} %-5p [%F:%L] : %m%n
http://git-wip-us.apache.org/repos/asf/struts/blob/9c67e4e8/core/src/test/resources/log4j2.xml
----------------------------------------------------------------------
diff --git a/core/src/test/resources/log4j2.xml b/core/src/test/resources/log4j2.xml
new file mode 100644
index 0000000..4b13539
--- /dev/null
+++ b/core/src/test/resources/log4j2.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration>
+ <Appenders>
+ <Console name="STDOUT" target="SYSTEM_OUT">
+ <PatternLayout pattern="%d{ISO8601} %-5p [%F:%L] : %m%n"/>
+ </Console>
+ </Appenders>
+ <Loggers>
+ <Root level="warn">
+ <AppenderRef ref="STDOUT"/>
+ </Root>
+ </Loggers>
+</Configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/struts/blob/9c67e4e8/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 9fdec9d..f0c4be6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -156,6 +156,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>2.3.1</version>
<configuration>
+ <argLine>-Duser.language=en -Duser.region=US</argLine>
<includes>
<include>**/*Test.java</include>
</includes>
http://git-wip-us.apache.org/repos/asf/struts/blob/9c67e4e8/xwork-core/pom.xml
----------------------------------------------------------------------
diff --git a/xwork-core/pom.xml b/xwork-core/pom.xml
index fca1912..3ba6461 100644
--- a/xwork-core/pom.xml
+++ b/xwork-core/pom.xml
@@ -37,6 +37,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>2.6</version>
<configuration>
+ <argLine>-Duser.language=en -Duser.region=US</argLine>
<properties>
<property>
<name>maven.testng.output.dir</name>