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.Dependencies;
27 import org.jdtaus.core.container.Implementation;
28 import org.jdtaus.core.container.Properties;
29 import org.jdtaus.core.container.Specifications;
30
31
32
33
34
35
36
37 public class ImplementationTest extends TestCase
38 {
39
40
41 public void testObject() throws Exception
42 {
43 final Implementation i1 = new Implementation();
44 final Implementation i2 = new Implementation();
45
46 Assert.assertEquals( i1, i2 );
47 Assert.assertEquals( i1.hashCode(), i2.hashCode() );
48
49 System.out.println( i1.toString() );
50 System.out.println( i2.toString() );
51
52 i1.setDependencies( new Dependencies() );
53 i1.setImplementedSpecifications( new Specifications() );
54 i1.setParent( new Implementation() );
55 i1.setProperties( new Properties() );
56
57 i2.setDependencies( new Dependencies() );
58 i2.setImplementedSpecifications( new Specifications() );
59 i2.setParent( new Implementation() );
60 i2.setProperties( new Properties() );
61
62 Assert.assertEquals( i1, i2 );
63 Assert.assertEquals( i1.hashCode(), i2.hashCode() );
64
65 System.out.println( i1.toString() );
66 System.out.println( i2.toString() );
67
68 final Implementation clone1 = (Implementation) i1.clone();
69 final Implementation clone2 = (Implementation) i2.clone();
70
71 Assert.assertEquals( clone1, clone2 );
72 Assert.assertEquals( clone1.hashCode(), clone2.hashCode() );
73
74 System.out.println( clone1.toString() );
75 System.out.println( clone2.toString() );
76 }
77
78 public void testBackwardCompatibility_1_0() throws Exception
79 {
80 final ObjectInputStream in = new ObjectInputStream( this.getClass().
81 getResourceAsStream( "Implementation.ser" ) );
82
83 final Implementation current = new Implementation();
84 final Implementation serialized = (Implementation) in.readObject();
85
86 Assert.assertEquals( current, serialized );
87 Assert.assertEquals( current.hashCode(), serialized.hashCode() );
88 }
89
90
91 }