diff options
author | Simon Harrer <simon.harrer@gmail.com> | 2013-10-23 11:25:37 +0200 |
---|---|---|
committer | Simon Harrer <simon.harrer@gmail.com> | 2013-10-23 11:25:37 +0200 |
commit | ea01a539b3bc4139230b9025124060211a408edd (patch) | |
tree | dac19a55418f8d36742f3b4dae358a6ef7bc2114 /src/test/java/com | |
parent | 0365f6248d6aaa7c765ac63273c282d16161a623 (diff) | |
download | gitblit-ea01a539b3bc4139230b9025124060211a408edd.tar.gz gitblit-ea01a539b3bc4139230b9025124060211a408edd.zip |
Change locale to english for ByteFormatTest to run successful on systems with german locale
Diffstat (limited to 'src/test/java/com')
-rw-r--r-- | src/test/java/com/gitblit/tests/ByteFormatTest.java | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/test/java/com/gitblit/tests/ByteFormatTest.java b/src/test/java/com/gitblit/tests/ByteFormatTest.java index d59055e7..ec3b395e 100644 --- a/src/test/java/com/gitblit/tests/ByteFormatTest.java +++ b/src/test/java/com/gitblit/tests/ByteFormatTest.java @@ -17,6 +17,8 @@ package com.gitblit.tests; import static org.junit.Assert.assertEquals;
+import java.util.Locale;
+
import org.junit.Test;
import com.gitblit.utils.ByteFormat;
@@ -25,12 +27,20 @@ public class ByteFormatTest { @Test
public void testByteFormat() throws Exception {
- ByteFormat format = new ByteFormat();
- assertEquals("10 b", format.format(10));
- assertEquals("10 KB", format.format(1024 * 10));
- assertEquals("1,000 KB", format.format(1024 * 1000));
- assertEquals("2.0 MB", format.format(2 * 1024 * 1000));
- assertEquals("1,000.0 MB", format.format(1024 * 1024 * 1000));
- assertEquals("2.0 GB", format.format(2 * 1024 * 1024 * 1000));
+ // sets locale for this test
+ Locale defaultLocale = Locale.getDefault();
+
+ try {
+ Locale.setDefault(Locale.ENGLISH);
+ ByteFormat format = new ByteFormat();
+ assertEquals("10 b", format.format(10));
+ assertEquals("10 KB", format.format(1024 * 10));
+ assertEquals("1,000 KB", format.format(1024 * 1000));
+ assertEquals("2.0 MB", format.format(2 * 1024 * 1000));
+ assertEquals("1,000.0 MB", format.format(1024 * 1024 * 1000));
+ assertEquals("2.0 GB", format.format(2 * 1024 * 1024 * 1000));
+ } finally {
+ Locale.setDefault(defaultLocale);
+ }
}
}
|