Search in sources :

Example 1 with Factory

use of android.icu.text.TimeZoneNames.Factory in project j2objc by google.

the class TimeZoneFormatTest method TestDefaultTimeZoneNames.

// Coverage for default implementation and abstract methods in base class.
@Test
public void TestDefaultTimeZoneNames() {
    long date = System.currentTimeMillis();
    TimeZoneNames.Factory factory;
    try {
        Class cls = Class.forName("android.icu.text.TimeZoneNames$DefaultTimeZoneNames$FactoryImpl");
        factory = (Factory) cls.newInstance();
    } catch (Exception e) {
        errln("Could not create class DefaultTimeZoneNames.FactoryImpl: " + e.getClass() + ": " + e.getMessage());
        return;
    }
    TimeZoneNames tzn = factory.getTimeZoneNames(ULocale.ENGLISH);
    assertEquals("Abstract: getAvailableMetaZoneIDs()", tzn.getAvailableMetaZoneIDs(), Collections.emptySet());
    assertEquals("Abstract: getAvailableMetaZoneIDs(String tzID)", tzn.getAvailableMetaZoneIDs("America/Chicago"), Collections.emptySet());
    assertEquals("Abstract: getMetaZoneID(String tzID, long date)", tzn.getMetaZoneID("America/Chicago", date), null);
    assertEquals("Abstract: getReferenceZoneID(String mzID, String region)", tzn.getReferenceZoneID("America_Central", "IT"), null);
    assertEquals("Abstract: getMetaZoneDisplayName(String mzID, NameType type)", tzn.getMetaZoneDisplayName("America_Central", NameType.LONG_DAYLIGHT), null);
    assertEquals("Abstract: getTimeZoneDisplayName(String mzID, NameType type)", tzn.getTimeZoneDisplayName("America/Chicago", NameType.LONG_DAYLIGHT), null);
    assertEquals("Abstract: find(CharSequence text, int start, EnumSet<NameType> nameTypes)", tzn.find("foo", 0, EnumSet.noneOf(NameType.class)), Collections.emptyList());
    // Other abstract-class methods that aren't covered
    tzn = new TimeZoneNamesInheriter();
    try {
        tzn.find(null, 0, null);
    } catch (UnsupportedOperationException e) {
        assertEquals("find() exception", "The method is not implemented in TimeZoneNames base class.", e.getMessage());
    }
}
Also used : TZDBTimeZoneNames(android.icu.impl.TZDBTimeZoneNames) TimeZoneNames(android.icu.text.TimeZoneNames) Factory(android.icu.text.TimeZoneNames.Factory) ParseException(java.text.ParseException) Test(org.junit.Test)

Aggregations

TZDBTimeZoneNames (android.icu.impl.TZDBTimeZoneNames)1 TimeZoneNames (android.icu.text.TimeZoneNames)1 Factory (android.icu.text.TimeZoneNames.Factory)1 ParseException (java.text.ParseException)1 Test (org.junit.Test)1