1   ////////////////////////////////////////////////////////////////////////////////
2   //CabaWeb
3   //Copyright (C) 2004  Thomas Vogt <Thomas.Vogt@TVC-Software.com>
4   //
5   //This library is free software; you can redistribute it and/or
6   //modify it under the terms of the GNU Lesser General Public
7   //License as published by the Free Software Foundation; either
8   //version 2.1 of the License, or (at your option) any later version.
9   //
10  //This library is distributed in the hope that it will be useful,
11  //but WITHOUT ANY WARRANTY; without even the implied warranty of
12  //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  //Lesser General Public License for more details.
14  //
15  //You should have received a copy of the GNU Lesser General Public
16  //License along with this library; if not, write to the Free Software
17  //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  ////////////////////////////////////////////////////////////////////////////////
19  
20  package org.fhw.cabaweb.junittests;
21  
22  import java.util.Collection;
23  
24  import org.fhw.cabaweb.data.DataInterfaceSprachen;
25  import org.fhw.cabaweb.ojb.dataobjects.Sprachen;
26  
27  import junit.framework.TestCase;
28  
29  /***
30   * Klasse f&uuml;r den Test der Datenzugriffe auf Sprachen
31   *
32   * @author  <a href="mailto:thomas.vogt@tvc-software.com">Thomas Vogt</a>
33   * @version Version 1.0 06.06.2004
34   */
35  public class DataInterfaceSprachenTest extends TestCase
36  {
37      private DataInterfaceSprachen test;
38  
39  	public static void main(String[] args)
40  	{
41  		junit.textui.TestRunner.run(DataInterfaceSprachenTest.class);
42  	}
43  
44  	/*
45  	 * @see TestCase#setUp()
46  	 */
47  	protected void setUp() throws Exception
48  	{
49  		super.setUp();
50      
51          test = new DataInterfaceSprachen();
52      }
53  
54  	/*
55  	 * @see TestCase#tearDown()
56  	 */
57  	protected void tearDown() throws Exception
58  	{
59  		super.tearDown();
60  	}
61  
62      final public void testErzeugen()
63      {
64          Sprachen testsprache = new Sprachen(new Integer(999), "Testsprache", new Boolean(true));
65          Sprachen retval = null;
66          
67          test.erzeugen(testsprache);
68          
69          Collection objekte = test.sucheSprachname("Testsprache");
70          
71          java.util.Iterator iter = objekte.iterator();
72          while (iter.hasNext())
73          {
74  //          System.out.println(iter.next());
75              retval = (Sprachen) iter.next();
76          }         
77  
78          assertEquals(true, objekte.size() == 1);
79          test.loeschen(retval);
80      }
81  
82      final public void testEditieren()
83      {
84          Sprachen testsprache = new Sprachen(new Integer(999), "Testsprache", new Boolean(true));
85          Sprachen retval = null;
86          
87          test.erzeugen(testsprache);
88          
89          Collection objekte = test.sucheSprachname("Testsprache");
90          
91          java.util.Iterator iter = objekte.iterator();
92          while (iter.hasNext())
93          {
94  //          System.out.println(iter.next());
95              retval = (Sprachen) iter.next();
96          }         
97  
98          testsprache = new Sprachen(retval.getSprachnummer(), "Testsprache ABC", new Boolean(false));
99          
100         test.editieren(testsprache);
101 
102         retval = (Sprachen) test.sucheSprachnummer(retval.getSprachnummer());
103         
104         assertEquals(retval.toString(), testsprache.toString());
105         test.loeschen(retval);
106     }
107 
108     final public void testLoeschen()
109     {
110         Sprachen testsprache = new Sprachen(new Integer(999), "Testsprache", new Boolean(true));
111         Sprachen retval = null;
112         
113         test.erzeugen(testsprache);
114         
115         Collection objekte = test.sucheSprachname("Testsprache");
116         
117         java.util.Iterator iter = objekte.iterator();
118         while (iter.hasNext())
119         {
120 //          System.out.println(iter.next());
121             retval = (Sprachen) iter.next();
122         }         
123 
124         test.loeschen(retval);
125         
126         objekte = test.sucheSprachname("Testsprache");
127         
128         iter = objekte.iterator();
129         while (iter.hasNext())
130         {
131 //          System.out.println(iter.next());
132             retval = (Sprachen) iter.next();
133         }         
134 
135         assertEquals(true, objekte.size() == 0);
136     }
137 
138     final public void testSucheAlle()
139     {
140         Collection objekte = test.sucheAlle();
141 
142         assertNotSame(new Integer(0), new Integer(objekte.size()));
143     }
144 
145     final public void testSucheSprachnummer()
146     {
147         Sprachen retval = (Sprachen) test.sucheSprachnummer(new Integer(1));
148         
149         assertNotNull(retval);
150     }
151 
152     final public void testSucheSprachname()
153     {
154         Sprachen testsprache = new Sprachen(new Integer(999), "Testsprache", new Boolean(true));
155         Sprachen retval = null;
156         
157         test.erzeugen(testsprache);
158         
159         Collection objekte = test.sucheSprachname("Testsprache");
160         
161         java.util.Iterator iter = objekte.iterator();
162         while (iter.hasNext())
163         {
164 //          System.out.println(iter.next());
165             retval = (Sprachen) iter.next();
166         }         
167 
168         assertEquals(retval.getSprachname(), "Testsprache");
169         test.loeschen(retval);
170     }
171 }