Solve problem when xwork and core tests are running on a machine where default local is different from "en"

This commit is contained in:
Johannes Geppert
2015-06-07 11:54:46 +02:00
parent 72e6f70733
commit 9c67e4e836
6 changed files with 31 additions and 44 deletions
@@ -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();
}
@@ -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 {
-27
View File
@@ -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
+13
View File
@@ -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>
+1
View File
@@ -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>
+1
View File
@@ -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>