This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-vfs.git
The following commit(s) were added to refs/heads/master by this push:
new fca7cfd Add change Locale for ParseXmlInZipTestCase (#107)
fca7cfd is described below
commit fca7cfd8b86b9cca5a7489fc13971b1367e6ffd2
Author: Lee <[email protected]>
AuthorDate: Thu Aug 20 06:29:23 2020 +0800
Add change Locale for ParseXmlInZipTestCase (#107)
---
.../vfs2/provider/zip/test/ParseXmlInZipTestCase.java | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git
a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/zip/test/ParseXmlInZipTestCase.java
b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/zip/test/ParseXmlInZipTestCase.java
index 756dccc..e4c1ea0 100644
---
a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/zip/test/ParseXmlInZipTestCase.java
+++
b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/zip/test/ParseXmlInZipTestCase.java
@@ -21,6 +21,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+import java.util.Locale;
import java.util.regex.Pattern;
import javax.xml.parsers.DocumentBuilder;
@@ -32,7 +33,9 @@ import org.apache.commons.vfs2.FileObject;
import org.apache.commons.vfs2.FileSystemException;
import org.apache.commons.vfs2.FileSystemManager;
import org.apache.commons.vfs2.VFS;
+import org.junit.After;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
@@ -42,6 +45,8 @@ import org.xml.sax.SAXException;
*/
public class ParseXmlInZipTestCase {
+ private Locale defaultLocale;
+
private File createTempFile() throws IOException {
final File zipFile = new
File("src/test/resources/test-data/read-xml-tests.zip");
final File newZipFile =
File.createTempFile(getClass().getSimpleName(), ".zip");
@@ -80,6 +85,20 @@ public class ParseXmlInZipTestCase {
return documentBuilder;
}
+ @Before
+ public void changeDefaultLocale() {
+ // save origin default Locale
+ defaultLocale = Locale.getDefault();
+
+ // change default Locale to US. Prevent Regular Matching fail.
+ Locale.setDefault(new Locale("en", "US"));
+ }
+
+ @After
+ public void resetDefaultLocale() {
+ Locale.setDefault(defaultLocale);
+ }
+
@Test
public void testParseXmlInZip() throws IOException, SAXException {
final File newZipFile = createTempFile();