1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.jdtaus.core.container.test;
22
23 import java.io.ObjectInputStream;
24 import junit.framework.Assert;
25 import junit.framework.TestCase;
26 import org.jdtaus.core.container.Dependency;
27 import org.jdtaus.core.container.Implementation;
28 import org.jdtaus.core.container.Specification;
29
30
31
32
33
34
35
36 public class DependencyTest extends TestCase
37 {
38
39
40 public void testObject() throws Exception
41 {
42 final Dependency d1 = new Dependency();
43 final Dependency d2 = new Dependency();
44
45 Assert.assertEquals( d1, d2 );
46 Assert.assertEquals( d1.hashCode(), d2.hashCode() );
47
48 System.out.println( d1.toString() );
49 System.out.println( d2.toString() );
50
51 d1.setImplementation( new Implementation() );
52 d1.setSpecification( new Specification() );
53 d2.setImplementation( new Implementation() );
54 d2.setSpecification( new Specification() );
55
56 Assert.assertEquals( d1, d2 );
57 Assert.assertEquals( d1.hashCode(), d2.hashCode() );
58
59 System.out.println( d1.toString() );
60 System.out.println( d2.toString() );
61
62 final Dependency clone1 = (Dependency) d1.clone();
63 final Dependency clone2 = (Dependency) d2.clone();
64
65 Assert.assertEquals( clone1, clone2 );
66 Assert.assertEquals( clone1.hashCode(), clone2.hashCode() );
67
68 System.out.println( clone1.toString() );
69 System.out.println( clone2.toString() );
70 }
71
72 public void testBackwardCompatibility_1_0() throws Exception
73 {
74 final ObjectInputStream in = new ObjectInputStream( this.getClass().
75 getResourceAsStream( "Dependency.ser" ) );
76
77 final Dependency current = new Dependency();
78 final Dependency serialized = (Dependency) in.readObject();
79
80 Assert.assertEquals( current, serialized );
81 Assert.assertEquals( current.hashCode(), serialized.hashCode() );
82 }
83
84
85 }