001/*
002 *  jDTAUS Banking Test Suite
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.it;
022
023import java.util.Date;
024import junit.framework.Assert;
025import junit.framework.TestCase;
026import org.jdtaus.banking.TextschluesselVerzeichnis;
027
028/**
029 * Testcase for {@code TextschluesselVerzeichnis} implementations.
030 *
031 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
032 * @version $JDTAUS: TextschluesselVerzeichnisTest.java 8723 2012-10-04 20:09:53Z schulte $
033 */
034public class TextschluesselVerzeichnisTest extends TestCase
035{
036
037    /** Implementation to test. */
038    private TextschluesselVerzeichnis directory;
039
040    /**
041     * Gets the {@code TextschluesselVerzeichnis} implementation tests are performed with.
042     *
043     * @return the {@code TextschluesselVerzeichnis} implementation tests are performed with.
044     */
045    public TextschluesselVerzeichnis getTextschluesselVerzeichnis()
046    {
047        return this.directory;
048    }
049
050    /**
051     * Sets the {@code TextschluesselVerzeichnis} implementation tests are performed with.
052     *
053     * @param value the {@code TextschluesselVerzeichnis} implementation to perform tests with.
054     */
055    public final void setTextschluesselVerzeichnis( final TextschluesselVerzeichnis value )
056    {
057        this.directory = value;
058    }
059
060    /**
061     * Tests the {@link TextschluesselVerzeichnis#getTextschluessel(int,int)} method to handle illegal arguments
062     * correctly.
063     */
064    public void testGetTextschluessel() throws Exception
065    {
066        assert this.getTextschluesselVerzeichnis() != null;
067
068        try
069        {
070            this.getTextschluesselVerzeichnis().getTextschluessel( Integer.MIN_VALUE, 0 );
071            throw new AssertionError();
072        }
073        catch ( IllegalArgumentException e )
074        {
075            Assert.assertNotNull( e.getMessage() );
076            System.out.println( e.toString() );
077        }
078
079        try
080        {
081            this.getTextschluesselVerzeichnis().getTextschluessel( 0, Integer.MIN_VALUE );
082            throw new AssertionError();
083        }
084        catch ( IllegalArgumentException e )
085        {
086            Assert.assertNotNull( e.getMessage() );
087            System.out.println( e.toString() );
088        }
089
090        try
091        {
092            this.getTextschluesselVerzeichnis().getTextschluessel( Integer.MAX_VALUE, 0 );
093            throw new AssertionError();
094        }
095        catch ( IllegalArgumentException e )
096        {
097            Assert.assertNotNull( e.getMessage() );
098            System.out.println( e.toString() );
099        }
100
101
102        try
103        {
104            this.getTextschluesselVerzeichnis().getTextschluessel( 0, Integer.MAX_VALUE );
105            throw new AssertionError();
106        }
107        catch ( IllegalArgumentException e )
108        {
109            Assert.assertNotNull( e.getMessage() );
110            System.out.println( e.toString() );
111        }
112
113        try
114        {
115            this.getTextschluesselVerzeichnis().getTextschluessel( Integer.MIN_VALUE, 0, new Date() );
116            throw new AssertionError();
117        }
118        catch ( IllegalArgumentException e )
119        {
120            Assert.assertNotNull( e.getMessage() );
121            System.out.println( e.toString() );
122        }
123
124        try
125        {
126            this.getTextschluesselVerzeichnis().getTextschluessel( 0, Integer.MIN_VALUE, new Date() );
127            throw new AssertionError();
128        }
129        catch ( IllegalArgumentException e )
130        {
131            Assert.assertNotNull( e.getMessage() );
132            System.out.println( e.toString() );
133        }
134
135        try
136        {
137            this.getTextschluesselVerzeichnis().getTextschluessel( Integer.MAX_VALUE, 0, new Date() );
138            throw new AssertionError();
139        }
140        catch ( IllegalArgumentException e )
141        {
142            Assert.assertNotNull( e.getMessage() );
143            System.out.println( e.toString() );
144        }
145
146        try
147        {
148            this.getTextschluesselVerzeichnis().getTextschluessel( 0, Integer.MAX_VALUE, new Date() );
149            throw new AssertionError();
150        }
151        catch ( IllegalArgumentException e )
152        {
153            Assert.assertNotNull( e.getMessage() );
154            System.out.println( e.toString() );
155        }
156
157        try
158        {
159            this.getTextschluesselVerzeichnis().getTextschluessel( 0, 0, null );
160            throw new AssertionError();
161        }
162        catch ( NullPointerException e )
163        {
164            Assert.assertNotNull( e.getMessage() );
165            System.out.println( e.toString() );
166        }
167    }
168
169    /**
170     * Test the {@link TextschluesselVerzeichnis#getTextschluessel()} method to not throw any exceptions.
171     */
172    public void testGetAllTextschluessel() throws Exception
173    {
174        assert this.getTextschluesselVerzeichnis() != null;
175        Assert.assertNotNull( this.getTextschluesselVerzeichnis().getTextschluessel() );
176    }
177
178    /**
179     * Tests the {@link TextschluesselVerzeichnis#search(boolean,boolean)} method to not return {@code null} references.
180     */
181    public void testSearch() throws Exception
182    {
183        assert this.getTextschluesselVerzeichnis() != null;
184        Assert.assertTrue( this.getTextschluesselVerzeichnis().search( false, false ).length >= 0 );
185
186        try
187        {
188            this.getTextschluesselVerzeichnis().search( false, false, null );
189            throw new AssertionError();
190        }
191        catch ( NullPointerException e )
192        {
193            Assert.assertNotNull( e.getMessage() );
194            System.out.println( e.toString() );
195        }
196    }
197
198    /**
199     * Tests the {@link TextschluesselVerzeichnis#searchTextschluessel(Boolean,Boolean,Date)} method to not return
200     * {@code null} references.
201     */
202    public void testSearchTextschluessel() throws Exception
203    {
204        assert this.getTextschluesselVerzeichnis() != null;
205        Assert.assertTrue( this.getTextschluesselVerzeichnis().searchTextschluessel( null, null, null ).length >= 0 );
206    }
207
208}