001 /*
002 * Copyright 2001-2005 Stephen Colebourne
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.joda.time.tz;
017
018 import java.lang.reflect.Constructor;
019 import java.lang.reflect.Modifier;
020 import java.util.Set;
021
022 import junit.framework.TestCase;
023 import junit.framework.TestSuite;
024
025 import org.joda.time.DateTimeZone;
026
027 /**
028 * This class is a JUnit test for UTCProvider.
029 *
030 * @author Stephen Colebourne
031 */
032 public class TestUTCProvider extends TestCase {
033
034 private DateTimeZone zone = null;
035
036 public static void main(String[] args) {
037 junit.textui.TestRunner.run(suite());
038 }
039
040 public static TestSuite suite() {
041 return new TestSuite(TestUTCProvider.class);
042 }
043
044 public TestUTCProvider(String name) {
045 super(name);
046 }
047
048 //-----------------------------------------------------------------------
049 public void testClass() throws Exception {
050 Class cls = UTCProvider.class;
051 assertEquals(true, Modifier.isPublic(cls.getModifiers()));
052
053 Constructor con = cls.getDeclaredConstructor((Class[]) null);
054 assertEquals(1, cls.getDeclaredConstructors().length);
055 assertEquals(true, Modifier.isPublic(con.getModifiers()));
056 }
057
058 //-----------------------------------------------------------------------
059 public void testGetAvailableIDs() throws Exception {
060 Provider p = new UTCProvider();
061 Set set = p.getAvailableIDs();
062 assertEquals(1, set.size());
063 assertEquals("UTC", set.iterator().next());
064 }
065
066 //-----------------------------------------------------------------------
067 public void testGetZone_String() throws Exception {
068 Provider p = new UTCProvider();
069 assertSame(DateTimeZone.UTC, p.getZone("UTC"));
070 assertEquals(null, p.getZone(null));
071 assertEquals(null, p.getZone("Europe/London"));
072 assertEquals(null, p.getZone("Blah"));
073 }
074
075 }