View Javadoc

1   /*
2    *  jDTAUS Banking SPI
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.dtaus.spi.test;
22  
23  import java.util.Locale;
24  import junit.framework.Assert;
25  import junit.framework.TestCase;
26  import org.jdtaus.banking.dtaus.Header;
27  import org.jdtaus.banking.dtaus.Transaction;
28  import org.jdtaus.banking.dtaus.spi.IllegalHeaderException;
29  import org.jdtaus.banking.dtaus.spi.IllegalTransactionException;
30  import org.jdtaus.core.text.Message;
31  
32  /**
33   * Testcase for testing instantiation of various exception classes.
34   *
35   * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
36   * @version $JDTAUS: ExceptionsTest.java 8723 2012-10-04 20:09:53Z schulte $
37   */
38  public class ExceptionsTest extends TestCase
39  {
40      //--Tests-------------------------------------------------------------------
41  
42      public void testExceptionInstantiation() throws Exception
43      {
44          final IllegalHeaderException h = new IllegalHeaderException();
45          final IllegalTransactionException t = new IllegalTransactionException();
46  
47          final Message msg = new Message()
48          {
49  
50              public Object[] getFormatArguments( final Locale locale )
51              {
52                  return new Object[ 0 ];
53              }
54  
55              public String getText( final Locale locale )
56              {
57                  return this.getClass().getName();
58              }
59  
60          };
61  
62          h.addMessage( msg );
63          h.addMessage( Header.PROP_ACCOUNT, msg );
64          h.addMessage( Header.PROP_BANK, msg );
65          h.addMessage( Header.PROP_BANKDATA, msg );
66          h.addMessage( Header.PROP_CREATEDATE, msg );
67          h.addMessage( Header.PROP_CURRENCY, msg );
68          h.addMessage( Header.PROP_CUSTOMER, msg );
69          h.addMessage( Header.PROP_EXECUTIONDATE, msg );
70          h.addMessage( Header.PROP_REFERENCE, msg );
71          h.addMessage( Header.PROP_TYPE, msg );
72  
73          t.addMessage( msg );
74          t.addMessage( Transaction.PROP_AMOUNT, msg );
75          t.addMessage( Transaction.PROP_CURRENCY, msg );
76          t.addMessage( Transaction.PROP_DESCRIPTIONS, msg );
77          t.addMessage( Transaction.PROP_EXECUTIVEACCOUNT, msg );
78          t.addMessage( Transaction.PROP_EXECUTIVEBANK, msg );
79          t.addMessage( Transaction.PROP_EXECUTIVEEXT, msg );
80          t.addMessage( Transaction.PROP_EXECUTIVENAME, msg );
81          t.addMessage( Transaction.PROP_PRIMARYBANK, msg );
82          t.addMessage( Transaction.PROP_REFERENCE, msg );
83          t.addMessage( Transaction.PROP_TARGETACCOUNT, msg );
84          t.addMessage( Transaction.PROP_TARGETBANK, msg );
85          t.addMessage( Transaction.PROP_TARGETEXT, msg );
86          t.addMessage( Transaction.PROP_TARGETNAME, msg );
87          t.addMessage( Transaction.PROP_TYPE, msg );
88  
89          System.out.println( new IllegalHeaderException() );
90          System.out.println( new IllegalTransactionException() );
91          System.out.println( h );
92          System.out.println( t );
93      }
94  
95      public void testIllegalHeaderException() throws Exception
96      {
97          final IllegalHeaderException e = new IllegalHeaderException();
98          Assert.assertTrue( e.getMessages( "TEST" ).length == 0 );
99      }
100 
101     public void testIllegalTransactionException() throws Exception
102     {
103         final IllegalTransactionException e = new IllegalTransactionException();
104         Assert.assertTrue( e.getMessages( "TEST" ).length == 0 );
105     }
106 
107     //-------------------------------------------------------------------Tests--
108 }