001/*
002 *  jDTAUS Banking RI CurrencyDirectory
003 *  Copyright (c) 2011 Christian Schulte
004 *
005 *  This library is free software; you can redistribute it and/or
006 *  modify it under the terms of the GNU Lesser General Public
007 *  License as published by the Free Software Foundation; either
008 *  version 2.1 of the License, or any later version.
009 *
010 *  This library is distributed in the hope that it will be useful,
011 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
012 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013 *  Lesser General Public License for more details.
014 *
015 *  You should have received a copy of the GNU Lesser General Public
016 *  License along with this library; if not, write to the Free Software
017 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
018 *
019 */
020package org.jdtaus.banking.ri.currencydir.test;
021
022import java.util.Currency;
023import java.util.Date;
024import junit.framework.Assert;
025import org.jdtaus.banking.ri.currencydir.JaxpCurrencyDirectory;
026import org.jdtaus.banking.spi.UnsupportedCurrencyException;
027
028/**
029 * Tests the {@link JaxpCurrencyDirectory} implementation to operate without finding resources.
030 *
031 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
032 * @version $JDTAUS: JaxpCurrencyDirectory_NoCurrencies_Test.java 8661 2012-09-27 11:29:58Z schulte $
033 */
034public class JaxpCurrencyDirectory_NoCurrencies_Test extends AbstractJaxpCurrencyDirectoryTest
035{
036
037    protected ClassLoader getClassLoader()
038    {
039        return this.getClass().getClassLoader();
040    }
041
042    public void testCurrencyConstraints() throws Exception
043    {
044        System.out.println( "Skipped due to empty directory." );
045    }
046
047    public void testGetDtausCode() throws Exception
048    {
049        assert this.getCurrencyMapper() != null;
050
051        try
052        {
053            this.getCurrencyMapper().getDtausCode( null, new Date() );
054            throw new AssertionError();
055        }
056        catch ( NullPointerException e )
057        {
058            Assert.assertNotNull( e.getMessage() );
059            System.out.println( e.toString() );
060        }
061
062        try
063        {
064            this.getCurrencyMapper().getDtausCode( Currency.getInstance( "EUR" ), null );
065            throw new AssertionError();
066        }
067        catch ( NullPointerException e )
068        {
069            Assert.assertNotNull( e.getMessage() );
070            System.out.println( e.toString() );
071        }
072
073        try
074        {
075            this.getCurrencyMapper().getDtausCode( Currency.getInstance( "DEM" ), new Date() );
076            throw new AssertionError();
077        }
078        catch ( UnsupportedCurrencyException e )
079        {
080            Assert.assertNotNull( e.getMessage() );
081            System.out.println( e.toString() );
082        }
083    }
084
085    public void testGetDtausCurrency() throws Exception
086    {
087        assert this.getCurrencyMapper() != null;
088
089        try
090        {
091            this.getCurrencyMapper().getDtausCurrency( '1', null );
092            throw new AssertionError();
093        }
094        catch ( NullPointerException e )
095        {
096            Assert.assertNotNull( e.getMessage() );
097            System.out.println( e.toString() );
098        }
099    }
100
101}