Refactored test into separate class, to avoid needless repeated execution by subclasses of the original test.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1673049 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Duncan Jones 2015-04-12 19:59:04 +00:00
parent 5aa87b52f1
commit 2ed96f00f7
2 changed files with 44 additions and 18 deletions

View File

@ -21,7 +21,6 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.Serializable;
import java.text.DateFormatSymbols;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
@ -31,7 +30,6 @@ import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import java.util.regex.Pattern;
import org.apache.commons.lang3.SerializationUtils;
import org.junit.Assert;
@ -641,20 +639,4 @@ public class FastDateParserTest {
assertEquals(message+trial.three, cal.getTime(), parser.parse(dateStub+trial.three));
}
}
@Test
public void testTimeZoneStrategyPattern() {
Pattern tz = Pattern.compile(FastDateParser.TimeZoneStrategy.TZ_DATABASE);
Assert.assertFalse(tz.matcher("GMT-1234").matches());
for (Locale locale : Locale.getAvailableLocales()) {
final String[][] zones = DateFormatSymbols.getInstance(locale).getZoneStrings();
for (final String[] zone : zones) {
for (String zoneExpr : zone) {
Assert.assertTrue(locale.getDisplayName() + ":" + zoneExpr, tz.matcher(zoneExpr).matches());
}
}
}
}
}

View File

@ -0,0 +1,44 @@
/*
* 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.
*/
package org.apache.commons.lang3.time;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.text.DateFormatSymbols;
import java.util.Locale;
import java.util.regex.Pattern;
import org.junit.Test;
public class FastDateParser_TimeZoneStrategyTest {
@Test
public void testTimeZoneStrategyPattern() {
Pattern tz = Pattern.compile(FastDateParser.TimeZoneStrategy.TZ_DATABASE);
assertFalse(tz.matcher("GMT-1234").matches());
for (Locale locale : Locale.getAvailableLocales()) {
final String[][] zones = DateFormatSymbols.getInstance(locale).getZoneStrings();
for (final String[] zone : zones) {
for (String zoneExpr : zone) {
assertTrue(locale.getDisplayName() + ":" + zoneExpr, tz.matcher(zoneExpr).matches());
}
}
}
}
}