View Javadoc
1   /*
2    *  jDTAUS Banking Test Suite
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.it;
22  
23  import java.util.Date;
24  import junit.framework.Assert;
25  import junit.framework.TestCase;
26  import org.jdtaus.banking.TextschluesselVerzeichnis;
27  
28  /**
29   * Testcase for {@code TextschluesselVerzeichnis} implementations.
30   *
31   * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
32   * @version $JDTAUS: TextschluesselVerzeichnisTest.java 8723 2012-10-04 20:09:53Z schulte $
33   */
34  public class TextschluesselVerzeichnisTest extends TestCase
35  {
36  
37      /** Implementation to test. */
38      private TextschluesselVerzeichnis directory;
39  
40      /**
41       * Gets the {@code TextschluesselVerzeichnis} implementation tests are performed with.
42       *
43       * @return the {@code TextschluesselVerzeichnis} implementation tests are performed with.
44       */
45      public TextschluesselVerzeichnis getTextschluesselVerzeichnis()
46      {
47          return this.directory;
48      }
49  
50      /**
51       * Sets the {@code TextschluesselVerzeichnis} implementation tests are performed with.
52       *
53       * @param value the {@code TextschluesselVerzeichnis} implementation to perform tests with.
54       */
55      public final void setTextschluesselVerzeichnis( final TextschluesselVerzeichnis value )
56      {
57          this.directory = value;
58      }
59  
60      /**
61       * Tests the {@link TextschluesselVerzeichnis#getTextschluessel(int,int)} method to handle illegal arguments
62       * correctly.
63       */
64      public void testGetTextschluessel() throws Exception
65      {
66          assert this.getTextschluesselVerzeichnis() != null;
67  
68          try
69          {
70              this.getTextschluesselVerzeichnis().getTextschluessel( Integer.MIN_VALUE, 0 );
71              throw new AssertionError();
72          }
73          catch ( IllegalArgumentException e )
74          {
75              Assert.assertNotNull( e.getMessage() );
76              System.out.println( e.toString() );
77          }
78  
79          try
80          {
81              this.getTextschluesselVerzeichnis().getTextschluessel( 0, Integer.MIN_VALUE );
82              throw new AssertionError();
83          }
84          catch ( IllegalArgumentException e )
85          {
86              Assert.assertNotNull( e.getMessage() );
87              System.out.println( e.toString() );
88          }
89  
90          try
91          {
92              this.getTextschluesselVerzeichnis().getTextschluessel( Integer.MAX_VALUE, 0 );
93              throw new AssertionError();
94          }
95          catch ( IllegalArgumentException e )
96          {
97              Assert.assertNotNull( e.getMessage() );
98              System.out.println( e.toString() );
99          }
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 }