public void testGetEquivalentTimezoneSamples() throws Exception { ConfigAdapterImpl impl = new ConfigAdapterImpl(); String tz = impl.getAvailableTimezone("US/Pacific"); assertEquals( "US/Pacific should return America/Los_Angeles as available equivalent", "America/Los_Angeles", tz); tz = impl.getAvailableTimezone("Zulu"); assertEquals("Zulu should return Etc/UTC as available equivalent", "Etc/UTC", tz); tz = impl.getAvailableTimezone("US/Central"); assertEquals( "US/Central should return America/Chicago as available equivalent", "America/Chicago", tz); tz = impl.getAvailableTimezone("Canada/Newfoundland"); assertEquals( "Canada/Newfoundland should return America/St_Johns as available equivalent", "America/St_Johns", tz); tz = impl.getAvailableTimezone("Cuba"); assertEquals("Cuba should return America/Havana as available equivalent", "America/Havana", tz); tz = impl.getAvailableTimezone("America/Los_Angeles"); assertEquals("America/Los_Angeles should be the same", "America/Los_Angeles", tz); tz = impl.getAvailableTimezone("GMT"); assertEquals("GMT should be the same", "GMT", tz); tz = impl.getAvailableTimezone("Unknown"); assertEquals("Default GMT timezone should be return if no matches", "GMT", tz); tz = impl.getAvailableTimezone("America/Unknown"); assertEquals("Default GMT timezone should be return if no matches", "GMT", tz); }
private void validateTimezoneIds(String[] timezonesToCheck) throws Exception { ConfigAdapterImpl configAdapter = new ConfigAdapterImpl(); ResourceLoader loader = Aura.getConfigAdapter().getResourceLoader(); List<String> failures = Lists.newLinkedList(); for (String timezone : timezonesToCheck) { String equivalent = configAdapter.getAvailableTimezone(timezone); if (loader.getResource( String.format("/aura/resources/libs_%s.js", equivalent.replace("/", "-"))) == null) { failures.add(equivalent); } } if (!failures.isEmpty()) { Collections.sort(failures); fail( String.format( "The following timezone IDs failed to map to a valid resource (%s out of %s): %s", failures.size(), timezonesToCheck.length, failures)); } }