View Javadoc

1   /*
2    *  jDTAUS Banking RI CurrencyDirectory
3    *  Copyright (c) 2011 Christian Schulte
4    *
5    *  This library is free software; you can redistribute it and/or
6    *  modify it under the terms of the GNU Lesser General Public
7    *  License as published by the Free Software Foundation; either
8    *  version 2.1 of the License, or any later version.
9    *
10   *  This library is distributed in the hope that it will be useful,
11   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   *  Lesser General Public License for more details.
14   *
15   *  You should have received a copy of the GNU Lesser General Public
16   *  License along with this library; if not, write to the Free Software
17   *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18   *
19   */
20  package org.jdtaus.banking.ri.currencydir.test;
21  
22  import java.util.Currency;
23  import java.util.Date;
24  import junit.framework.Assert;
25  import org.jdtaus.banking.ri.currencydir.JaxpCurrencyDirectory;
26  import org.jdtaus.banking.spi.UnsupportedCurrencyException;
27  
28  /**
29   * Tests the {@link JaxpCurrencyDirectory} implementation to operate without finding resources.
30   *
31   * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
32   * @version $JDTAUS: JaxpCurrencyDirectory_NoCurrencies_Test.java 8661 2012-09-27 11:29:58Z schulte $
33   */
34  public class JaxpCurrencyDirectory_NoCurrencies_Test extends AbstractJaxpCurrencyDirectoryTest
35  {
36  
37      protected ClassLoader getClassLoader()
38      {
39          return this.getClass().getClassLoader();
40      }
41  
42      public void testCurrencyConstraints() throws Exception
43      {
44          System.out.println( "Skipped due to empty directory." );
45      }
46  
47      public void testGetDtausCode() throws Exception
48      {
49          assert this.getCurrencyMapper() != null;
50  
51          try
52          {
53              this.getCurrencyMapper().getDtausCode( null, new Date() );
54              throw new AssertionError();
55          }
56          catch ( NullPointerException e )
57          {
58              Assert.assertNotNull( e.getMessage() );
59              System.out.println( e.toString() );
60          }
61  
62          try
63          {
64              this.getCurrencyMapper().getDtausCode( Currency.getInstance( "EUR" ), null );
65              throw new AssertionError();
66          }
67          catch ( NullPointerException e )
68          {
69              Assert.assertNotNull( e.getMessage() );
70              System.out.println( e.toString() );
71          }
72  
73          try
74          {
75              this.getCurrencyMapper().getDtausCode( Currency.getInstance( "DEM" ), new Date() );
76              throw new AssertionError();
77          }
78          catch ( UnsupportedCurrencyException e )
79          {
80              Assert.assertNotNull( e.getMessage() );
81              System.out.println( e.toString() );
82          }
83      }
84  
85      public void testGetDtausCurrency() throws Exception
86      {
87          assert this.getCurrencyMapper() != null;
88  
89          try
90          {
91              this.getCurrencyMapper().getDtausCurrency( '1', null );
92              throw new AssertionError();
93          }
94          catch ( NullPointerException e )
95          {
96              Assert.assertNotNull( e.getMessage() );
97              System.out.println( e.toString() );
98          }
99      }
100 
101 }