001/* 002 * jDTAUS Banking SPI 003 * Copyright (C) 2005 Christian Schulte 004 * <cs@schulte.it> 005 * 006 * This library is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU Lesser General Public 008 * License as published by the Free Software Foundation; either 009 * version 2.1 of the License, or any later version. 010 * 011 * This library is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 * Lesser General Public License for more details. 015 * 016 * You should have received a copy of the GNU Lesser General Public 017 * License along with this library; if not, write to the Free Software 018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 019 * 020 */ 021package org.jdtaus.banking.dtaus.spi.test; 022 023import java.util.Locale; 024import junit.framework.Assert; 025import junit.framework.TestCase; 026import org.jdtaus.banking.dtaus.Header; 027import org.jdtaus.banking.dtaus.Transaction; 028import org.jdtaus.banking.dtaus.spi.IllegalHeaderException; 029import org.jdtaus.banking.dtaus.spi.IllegalTransactionException; 030import org.jdtaus.core.text.Message; 031 032/** 033 * Testcase for testing instantiation of various exception classes. 034 * 035 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> 036 * @version $JDTAUS: ExceptionsTest.java 8723 2012-10-04 20:09:53Z schulte $ 037 */ 038public class ExceptionsTest extends TestCase 039{ 040 //--Tests------------------------------------------------------------------- 041 042 public void testExceptionInstantiation() throws Exception 043 { 044 final IllegalHeaderException h = new IllegalHeaderException(); 045 final IllegalTransactionException t = new IllegalTransactionException(); 046 047 final Message msg = new Message() 048 { 049 050 public Object[] getFormatArguments( final Locale locale ) 051 { 052 return new Object[ 0 ]; 053 } 054 055 public String getText( final Locale locale ) 056 { 057 return this.getClass().getName(); 058 } 059 060 }; 061 062 h.addMessage( msg ); 063 h.addMessage( Header.PROP_ACCOUNT, msg ); 064 h.addMessage( Header.PROP_BANK, msg ); 065 h.addMessage( Header.PROP_BANKDATA, msg ); 066 h.addMessage( Header.PROP_CREATEDATE, msg ); 067 h.addMessage( Header.PROP_CURRENCY, msg ); 068 h.addMessage( Header.PROP_CUSTOMER, msg ); 069 h.addMessage( Header.PROP_EXECUTIONDATE, msg ); 070 h.addMessage( Header.PROP_REFERENCE, msg ); 071 h.addMessage( Header.PROP_TYPE, msg ); 072 073 t.addMessage( msg ); 074 t.addMessage( Transaction.PROP_AMOUNT, msg ); 075 t.addMessage( Transaction.PROP_CURRENCY, msg ); 076 t.addMessage( Transaction.PROP_DESCRIPTIONS, msg ); 077 t.addMessage( Transaction.PROP_EXECUTIVEACCOUNT, msg ); 078 t.addMessage( Transaction.PROP_EXECUTIVEBANK, msg ); 079 t.addMessage( Transaction.PROP_EXECUTIVEEXT, msg ); 080 t.addMessage( Transaction.PROP_EXECUTIVENAME, msg ); 081 t.addMessage( Transaction.PROP_PRIMARYBANK, msg ); 082 t.addMessage( Transaction.PROP_REFERENCE, msg ); 083 t.addMessage( Transaction.PROP_TARGETACCOUNT, msg ); 084 t.addMessage( Transaction.PROP_TARGETBANK, msg ); 085 t.addMessage( Transaction.PROP_TARGETEXT, msg ); 086 t.addMessage( Transaction.PROP_TARGETNAME, msg ); 087 t.addMessage( Transaction.PROP_TYPE, msg ); 088 089 System.out.println( new IllegalHeaderException() ); 090 System.out.println( new IllegalTransactionException() ); 091 System.out.println( h ); 092 System.out.println( t ); 093 } 094 095 public void testIllegalHeaderException() throws Exception 096 { 097 final IllegalHeaderException e = new IllegalHeaderException(); 098 Assert.assertTrue( e.getMessages( "TEST" ).length == 0 ); 099 } 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}