Skip to content

Commit 146b6c2

Browse files
committed
test: handle StatTest.testToString time format differences in different locale
Signed-off-by: Lianjie Ruan <[email protected]>
1 parent 23aaab5 commit 146b6c2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

core/src/test/java/org/dcache/nfs/vfs/StatTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.io.ByteArrayOutputStream;
77
import java.io.ObjectInputStream;
88
import java.io.ObjectOutputStream;
9+
import java.text.SimpleDateFormat;
910
import java.util.Calendar;
1011

1112
import org.junit.Test;
@@ -30,17 +31,18 @@ public void testToString() {
3031
localCal.set(Calendar.MILLISECOND, 0);
3132
stat.setMTime(localCal.getTimeInMillis());
3233
stat.setMode(0755 | Stat.S_IFDIR);
33-
assertEquals("drwxr-xr-x 7 1 2 3 Feb 01 14:15", stat.toString());
34+
SimpleDateFormat formatter = new SimpleDateFormat("MMM dd HH:mm");
35+
assertEquals("drwxr-xr-x 7 1 2 3 "+formatter.format(localCal.getTime()), stat.toString());
3436
stat.setMode(0401 | Stat.S_IFREG);
3537
stat.setNlink(6666);
3638
stat.setSize(1024*16);
3739
localCal.set(Calendar.DAY_OF_MONTH, 29);
3840
localCal.set(Calendar.HOUR_OF_DAY, 1);
3941
stat.setMTime(localCal.getTimeInMillis());
40-
assertEquals("-r-------x 6666 1 2 16K Mar 01 01:15", stat.toString());
42+
assertEquals("-r-------x 6666 1 2 16K "+formatter.format(localCal.getTime()), stat.toString());
4143
stat.setMode(0070 | Stat.S_IFLNK);
4244
stat.setSize(1024*1024*1024*1024L - 1); //one byte short of 1TB
43-
assertEquals("l---rwx--- 6666 1 2 1024G Mar 01 01:15", stat.toString());
45+
assertEquals("l---rwx--- 6666 1 2 1024G "+formatter.format(localCal.getTime()), stat.toString());
4446
}
4547

4648
@Test

0 commit comments

Comments
 (0)