1 16 package org.joda.time.tz; 17 18 import junit.framework.TestCase; 19 import junit.framework.TestSuite; 20 21 import org.joda.time.DateTimeZone; 22 23 28 public class TestFixedDateTimeZone extends TestCase { 29 30 public static void main(String [] args) { 31 junit.textui.TestRunner.run(suite()); 32 } 33 34 public static TestSuite suite() { 35 return new TestSuite(TestFixedDateTimeZone.class); 36 } 37 38 private DateTimeZone originalDateTimeZone = null; 39 40 public TestFixedDateTimeZone(String name) { 41 super(name); 42 } 43 44 protected void setUp() throws Exception { 45 originalDateTimeZone = DateTimeZone.getDefault(); 46 DateTimeZone.setDefault(DateTimeZone.UTC); 47 } 48 49 protected void tearDown() throws Exception { 50 DateTimeZone.setDefault(originalDateTimeZone); 51 } 52 53 public void testEquals() throws Exception { 54 FixedDateTimeZone zone1 = new FixedDateTimeZone("A", "B", 1, 5); 55 FixedDateTimeZone zone1b = new FixedDateTimeZone("A", "B", 1, 5); 56 FixedDateTimeZone zone2 = new FixedDateTimeZone("A", "C", 1, 5); 57 FixedDateTimeZone zone3 = new FixedDateTimeZone("A", "B", 2, 5); 58 FixedDateTimeZone zone4 = new FixedDateTimeZone("A", "B", 1, 6); 59 60 assertEquals(true, zone1.equals(zone1)); 61 assertEquals(true, zone1.equals(zone1b)); 62 assertEquals(true, zone1.equals(zone2)); assertEquals(false, zone1.equals(zone3)); 64 assertEquals(false, zone1.equals(zone4)); 65 } 66 67 public void testHashCode() throws Exception { 68 FixedDateTimeZone zone1 = new FixedDateTimeZone("A", "B", 1, 5); 69 FixedDateTimeZone zone1b = new FixedDateTimeZone("A", "B", 1, 5); 70 FixedDateTimeZone zone2 = new FixedDateTimeZone("A", "C", 1, 5); 71 FixedDateTimeZone zone3 = new FixedDateTimeZone("A", "B", 2, 5); 72 FixedDateTimeZone zone4 = new FixedDateTimeZone("A", "B", 1, 6); 73 74 assertEquals(true, zone1.hashCode() == zone1.hashCode()); 75 assertEquals(true, zone1.hashCode() == zone1b.hashCode()); 76 assertEquals(true, zone1.hashCode() == zone2.hashCode()); assertEquals(false, zone1.hashCode() == zone3.hashCode()); 78 assertEquals(false, zone1.hashCode() == zone4.hashCode()); 79 } 80 81 } 82 | Popular Tags |