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