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.Specification;
28  
29  /**
30   * jUnit tests for {@code Specification} implementations.
31   *
32   * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
33   * @version $JDTAUS: SpecificationTest.java 8641 2012-09-27 06:45:17Z schulte $
34   */
35  public class SpecificationTest extends TestCase
36  {
37      //--SpecificationTest-------------------------------------------------------
38  
39      public void testObject() throws Exception
40      {
41          final Specification s1 = new Specification();
42          final Specification s2 = new Specification();
43  
44          Assert.assertEquals( s1, s2 );
45          Assert.assertEquals( s1.hashCode(), s2.hashCode() );
46  
47          System.out.println( s1.toString() );
48          System.out.println( s2.toString() );
49  
50          s1.setImplementations( new Implementations() );
51          s2.setImplementations( new Implementations() );
52  
53          Assert.assertEquals( s1, s2 );
54          Assert.assertEquals( s1.hashCode(), s2.hashCode() );
55  
56          System.out.println( s1.toString() );
57          System.out.println( s2.toString() );
58  
59          final Specification clone1 = (Specification) s1.clone();
60          final Specification clone2 = (Specification) s2.clone();
61  
62          Assert.assertEquals( clone1, clone2 );
63          Assert.assertEquals( clone1.hashCode(), clone2.hashCode() );
64  
65          System.out.println( clone1.toString() );
66          System.out.println( clone2.toString() );
67      }
68  
69      public void testBackwardCompatibility_1_0() throws Exception
70      {
71          final ObjectInputStream in = new ObjectInputStream( this.getClass().
72              getResourceAsStream( "Specification.ser" ) );
73  
74          final Specification current = new Specification();
75          final Specification serialized = (Specification) in.readObject();
76  
77          Assert.assertEquals( current, serialized );
78          Assert.assertEquals( current.hashCode(), serialized.hashCode() );
79      }
80  
81      //-------------------------------------------------------SpecificationTest--
82  }