KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > joda > time > tz > TestUTCProvider


1 /*
2  * Copyright 2001-2005 Stephen Colebourne
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.joda.time.tz;
17
18 import java.lang.reflect.Constructor JavaDoc;
19 import java.lang.reflect.Modifier JavaDoc;
20 import java.util.Set JavaDoc;
21
22 import junit.framework.TestCase;
23 import junit.framework.TestSuite;
24
25 import org.joda.time.DateTimeZone;
26
27 /**
28  * This class is a JUnit test for UTCProvider.
29  *
30  * @author Stephen Colebourne
31  */

32 public class TestUTCProvider extends TestCase {
33
34     private DateTimeZone zone = null;
35
36     public static void main(String JavaDoc[] args) {
37         junit.textui.TestRunner.run(suite());
38     }
39
40     public static TestSuite suite() {
41         return new TestSuite(TestUTCProvider.class);
42     }
43
44     public TestUTCProvider(String JavaDoc name) {
45         super(name);
46     }
47
48     //-----------------------------------------------------------------------
49
public void testClass() throws Exception JavaDoc {
50         Class JavaDoc cls = UTCProvider.class;
51         assertEquals(true, Modifier.isPublic(cls.getModifiers()));
52         
53         Constructor JavaDoc con = cls.getDeclaredConstructor((Class JavaDoc[]) null);
54         assertEquals(1, cls.getDeclaredConstructors().length);
55         assertEquals(true, Modifier.isPublic(con.getModifiers()));
56     }
57
58     //-----------------------------------------------------------------------
59
public void testGetAvailableIDs() throws Exception JavaDoc {
60         Provider p = new UTCProvider();
61         Set JavaDoc set = p.getAvailableIDs();
62         assertEquals(1, set.size());
63         assertEquals("UTC", set.iterator().next());
64     }
65
66     //-----------------------------------------------------------------------
67
public void testGetZone_String() throws Exception JavaDoc {
68         Provider p = new UTCProvider();
69         assertSame(DateTimeZone.UTC, p.getZone("UTC"));
70         assertEquals(null, p.getZone(null));
71         assertEquals(null, p.getZone("Europe/London"));
72         assertEquals(null, p.getZone("Blah"));
73     }
74
75 }
76
Popular Tags