1 4 package com.tc.util.diff; 5 6 import com.tc.exception.ImplementMe; 7 import com.tc.test.TCTestCase; 8 9 12 public class DifferenceTest extends TCTestCase { 13 14 private static class TestDifference extends Difference { 16 public TestDifference(DifferenceContext where) { 17 super(where); 18 } 19 20 public Object a() { 21 throw new ImplementMe(); 22 } 23 24 public Object b() { 25 throw new ImplementMe(); 26 } 27 28 public String toString() { 29 throw new ImplementMe(); 30 } 31 } 32 33 public void testConstruction() throws Exception { 34 try { 35 new TestDifference(null); 36 fail("Didn't get NPE on no context"); 37 } catch (NullPointerException npe) { 38 } 40 } 41 42 public void testWhere() throws Exception { 43 DifferenceContext context = DifferenceContext.createInitial().sub("a").sub("b"); 44 Difference test = new TestDifference(context); 45 46 assertSame(context, test.where()); 47 } 48 49 public void testEquals() throws Exception { 50 DifferenceContext contextA = DifferenceContext.createInitial().sub("a"); 51 DifferenceContext contextB = DifferenceContext.createInitial().sub("b"); 52 53 Difference a = new TestDifference(contextA); 54 Difference b = new TestDifference(contextB); 55 Difference c = new TestDifference(contextA); 56 57 assertEquals(a, c); 58 assertEquals(c, a); 59 60 assertFalse(a.equals(b)); 61 assertFalse(b.equals(a)); 62 assertFalse(c.equals(b)); 63 assertFalse(b.equals(c)); 64 } 65 66 } | Popular Tags |