From 246ecda5e2b3a532925211002c549a3f057c27f1 Mon Sep 17 00:00:00 2001 From: Sebastian Bazley Date: Mon, 24 Sep 2012 17:01:47 +0000 Subject: [PATCH] Split test into 4 so each failure can be detected git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1389484 13f79535-47bb-0310-9956-ffa450edef68 --- .../lang3/time/FastDateParserTest.java | 84 +++++++++++++++---- 1 file changed, 69 insertions(+), 15 deletions(-) diff --git a/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java b/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java index 77cb9e2a5..417f5434b 100644 --- a/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java +++ b/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java @@ -179,7 +179,7 @@ public void testAmPm() throws ParseException { } @Test - public void testLocales() { + public void testLocales_Long_AD() throws Exception { for(Locale locale : Locale.getAvailableLocales()) { Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US); @@ -190,23 +190,77 @@ public void testLocales() { String longFormat= "GGGG/yyyy/MMMM/dddd/aaaa/EEEE/ZZZZ"; SimpleDateFormat sdf = new SimpleDateFormat(longFormat, locale); DateParser fdf = getInstance(longFormat, locale); - - checkParse(cal, sdf, fdf); - - cal.set(Calendar.ERA, GregorianCalendar.BC); - checkParse(cal, sdf, fdf); - - String shortFormat= "G/y/M/d/a/E/Z"; - sdf = new SimpleDateFormat(shortFormat, locale); - fdf = getInstance(shortFormat, locale); - checkParse(cal, sdf, fdf); - - cal.set(Calendar.ERA, GregorianCalendar.AD); - checkParse(cal, sdf, fdf); + checkParse(cal, sdf, fdf); } catch(ParseException ex) { // TODO: why do ja_JP_JP, hi_IN, th_TH, and th_TH_TH fail? - System.out.println("Locale "+locale+ " failed"); + System.out.println("Long AD Locale "+locale+ " failed\n" + ex.toString()); + } + } + } + + @Test + public void testLocales_Long_BC() throws Exception { + + for(Locale locale : Locale.getAvailableLocales()) { + Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US); + cal.clear(); + cal.set(2003, 1, 10); + cal.set(Calendar.ERA, GregorianCalendar.BC); + + try { + String longFormat= "GGGG/yyyy/MMMM/dddd/aaaa/EEEE/ZZZZ"; + SimpleDateFormat sdf = new SimpleDateFormat(longFormat, locale); + DateParser fdf = getInstance(longFormat, locale); + checkParse(cal, sdf, fdf); + } + catch(ParseException ex) { + // TODO: why do ja_JP_JP, hi_IN, th_TH, and th_TH_TH fail? + System.out.println("Long BC Locale "+locale+ " failed\n" + ex.toString()); + } + } + } + + @Test + public void testLocales_Short_BC() throws Exception { + + for(Locale locale : Locale.getAvailableLocales()) { + Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US); + cal.clear(); + cal.set(2003, 1, 10); + cal.set(Calendar.ERA, GregorianCalendar.BC); + + try { + String shortFormat= "G/y/M/d/a/E/Z"; + SimpleDateFormat sdf = new SimpleDateFormat(shortFormat, locale); + DateParser fdf = getInstance(shortFormat, locale); + checkParse(cal, sdf, fdf); + } + catch(ParseException ex) { + // TODO: why do ja_JP_JP, hi_IN, th_TH, and th_TH_TH fail? + System.out.println("Short BC Locale "+locale+ " failed\n" + ex.toString()); + } + } + } + + @Test + public void testLocales_Short_AD() throws Exception { + + for(Locale locale : Locale.getAvailableLocales()) { + Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US); + cal.clear(); + cal.set(2003, 1, 10); + cal.set(Calendar.ERA, GregorianCalendar.AD); + + try { + String shortFormat= "G/y/M/d/a/E/Z"; + SimpleDateFormat sdf = new SimpleDateFormat(shortFormat, locale); + DateParser fdf = getInstance(shortFormat, locale); + checkParse(cal, sdf, fdf); + } + catch(ParseException ex) { + // TODO: why do ja_JP_JP, hi_IN, th_TH, and th_TH_TH fail? + System.out.println("Short_AD Locale "+locale+ " failed\n" + ex.toString()); } } }