View Javadoc

1   /*
2    *  jDTAUS Banking RI CurrencyDirectory
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.banking.ri.currencydir.test;
22  
23  import java.util.Date;
24  import junit.framework.Assert;
25  import junit.framework.TestCase;
26  import org.jdtaus.banking.ri.currencydir.JaxpCurrency;
27  
28  /**
29   * Tests the {@link JaxpCurrency} implementation.
30   *
31   * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
32   * @version $JDTAUS: JaxpCurrencyTest.java 8723 2012-10-04 20:09:53Z schulte $
33   */
34  public class JaxpCurrencyTest extends TestCase
35  {
36  
37      public void testObject() throws Exception
38      {
39          JaxpCurrency c1 = new JaxpCurrency();
40          JaxpCurrency c2 = new JaxpCurrency();
41  
42          Assert.assertEquals( c1, c2 );
43          Assert.assertEquals( c1.hashCode(), c2.hashCode() );
44  
45          c2.setDtausCode( new Character( 'X' ) );
46  
47          Assert.assertFalse( c1.equals( c2 ) );
48          Assert.assertFalse( c1.hashCode() == c2.hashCode() );
49  
50          c2.setDtausCode( null );
51          c2.setEndDate( new Date() );
52  
53          Assert.assertFalse( c1.equals( c2 ) );
54          Assert.assertFalse( c1.hashCode() == c2.hashCode() );
55  
56          c2.setEndDate( null );
57          c2.setIsoCode( "DEM" );
58  
59          Assert.assertFalse( c1.equals( c2 ) );
60          Assert.assertFalse( c1.hashCode() == c2.hashCode() );
61  
62          c2.setIsoCode( null );
63          c2.setStartDate( new Date() );
64  
65          Assert.assertFalse( c1.equals( c2 ) );
66          Assert.assertFalse( c1.hashCode() == c2.hashCode() );
67  
68          c2.setStartDate( null );
69  
70          Assert.assertEquals( c1, c2 );
71          Assert.assertEquals( c1.hashCode(), c2.hashCode() );
72      }
73  
74  }