View Javadoc

1   /*
2    *  jDTAUS Core API
3    *  Copyright (C) 2005 Christian Schulte
4    *  <cs@schulte.it>
5    *
6    *  This library is free software; you can redistribute it and/or
7    *  modify it under the terms of the GNU Lesser General Public
8    *  License as published by the Free Software Foundation; either
9    *  version 2.1 of the License, or any later version.
10   *
11   *  This library is distributed in the hope that it will be useful,
12   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14   *  Lesser General Public License for more details.
15   *
16   *  You should have received a copy of the GNU Lesser General Public
17   *  License along with this library; if not, write to the Free Software
18   *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
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   * jUnit tests for {@code Module} implementations.
33   *
34   * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
35   * @version $JDTAUS: ModuleTest.java 8641 2012-09-27 06:45:17Z schulte $
36   */
37  public class ModuleTest extends TestCase
38  {
39      //--ModuleTest--------------------------------------------------------------
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      //--------------------------------------------------------------ModuleTest--
89  }