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.DataInterfaceReportnamen;
25  import org.fhw.cabaweb.ojb.dataobjects.Projekte;
26  import org.fhw.cabaweb.ojb.dataobjects.Reportnamen;
27  
28  import junit.framework.TestCase;
29  
30  /***
31   * Klasse f&uuml;r den Test der Datenzugriffe auf Reportnamen
32   *
33   * @author  <a href="mailto:thomas.vogt@tvc-software.com">Thomas Vogt</a>
34   * @version Version 1.0 06.06.2004
35   */
36  public class DataInterfaceReportnamenTest extends TestCase
37  {
38      private DataInterfaceReportnamen test;
39  
40  	public static void main(String[] args)
41  	{
42  		junit.textui.TestRunner.run(DataInterfaceReportnamenTest.class);
43  	}
44  
45  	/*
46  	 * @see TestCase#setUp()
47  	 */
48  	protected void setUp() throws Exception
49  	{
50  		super.setUp();
51  
52          test = new DataInterfaceReportnamen();
53  	}
54  
55  	/*
56  	 * @see TestCase#tearDown()
57  	 */
58  	protected void tearDown() throws Exception
59  	{
60  		super.tearDown();
61  	}
62  
63      final public void testErzeugen()
64      {
65          Reportnamen testreportname = new Reportnamen(new Projekte(new Integer(1), null, null, null), new Integer(99), "Testreportname", "Test");
66          Reportnamen retval = null;
67          
68          test.erzeugen(testreportname);
69          
70          Collection objekte = test.sucheBezeichnung("Testreportname");
71          
72          java.util.Iterator iter = objekte.iterator();
73          while (iter.hasNext())
74          {
75  //          System.out.println(iter.next());
76              retval = (Reportnamen) iter.next();
77          }         
78  
79          assertEquals(true, objekte.size() == 1);
80          test.loeschen(retval);
81      }
82  
83      final public void testEditieren()
84      {
85          Reportnamen testreportname = new Reportnamen(new Projekte(new Integer(1), null, null, null), new Integer(99), "Testreportname", "Test");
86          Reportnamen retval = null;
87          
88          test.erzeugen(testreportname);
89          
90          Collection objekte = test.sucheBezeichnung("Testreportname");
91          
92          java.util.Iterator iter = objekte.iterator();
93          while (iter.hasNext())
94          {
95  //          System.out.println(iter.next());
96              retval = (Reportnamen) iter.next();
97          }         
98  
99          testreportname = new Reportnamen(new Projekte(retval.getProjekte().getProjektnummer(), null, null, null), new Integer(99), "Testreportname ABC", "Test");
100         
101         test.editieren(testreportname);
102 
103         retval = (Reportnamen) test.sucheReportnummer(retval.getReportnummer());
104         
105         assertEquals(retval.toString(), testreportname.toString());
106         test.loeschen(retval);
107     }
108 
109     final public void testLoeschen()
110     {
111         Reportnamen testreportname = new Reportnamen(new Projekte(new Integer(1), null, null, null), new Integer(99), "Testreportname", "Test");
112         Reportnamen retval = null;
113         
114         test.erzeugen(testreportname);
115         
116         Collection objekte = test.sucheBezeichnung("Testreportname");
117         
118         java.util.Iterator iter = objekte.iterator();
119         while (iter.hasNext())
120         {
121 //          System.out.println(iter.next());
122             retval = (Reportnamen) iter.next();
123         }         
124 
125         test.loeschen(retval);
126         
127         objekte = test.sucheBezeichnung("Testreportname");
128         
129         iter = objekte.iterator();
130         while (iter.hasNext())
131         {
132 //          System.out.println(iter.next());
133             retval = (Reportnamen) iter.next();
134         }         
135 
136         assertEquals(true, objekte.size() == 0);
137     }
138 
139     final public void testSucheAlle()
140     {
141         Collection objekte = test.sucheAlle();
142 
143         assertNotSame(new Integer(0), new Integer(objekte.size()));
144     }
145 
146     final public void testSucheReportnummer()
147     {
148         Reportnamen testreportname = new Reportnamen(new Projekte(new Integer(1), null, null, null), new Integer(99), "Testreportname", "Test");
149         Reportnamen retval = null;
150         
151         test.erzeugen(testreportname);
152 
153         retval = (Reportnamen) test.sucheReportnummer(new Integer(99));
154         
155         assertNotNull(retval);
156         test.loeschen(retval);
157     }
158 
159     final public void testSucheProjektnummer()
160     {
161         Reportnamen testreportname = new Reportnamen(new Projekte(new Integer(1), null, null, null), new Integer(99), "Testreportname", "Test");
162         Reportnamen retval = null;
163         
164         test.erzeugen(testreportname);
165         
166         Collection objekte = test.sucheProjektnummer(new Integer(1));
167                 
168         java.util.Iterator iter = objekte.iterator();
169         while (iter.hasNext())
170         {
171 //          System.out.println(iter.next());
172             retval = (Reportnamen) iter.next();
173         }         
174 
175         assertEquals(new Integer(1), new Integer(objekte.size()));
176         test.loeschen(retval);
177     }
178 
179     final public void testSucheBezeichnung()
180     {
181         Reportnamen testreportname = new Reportnamen(new Projekte(new Integer(1), null, null, null), new Integer(99), "Testreportname", "Test");
182         Reportnamen retval = null;
183         
184         test.erzeugen(testreportname);
185         
186         Collection objekte = test.sucheBezeichnung("Testreportname");
187                 
188         java.util.Iterator iter = objekte.iterator();
189         while (iter.hasNext())
190         {
191 //          System.out.println(iter.next());
192             retval = (Reportnamen) iter.next();
193         }         
194 
195         assertEquals(retval.getBezeichnung(), "Testreportname");
196         test.loeschen(retval);
197     }
198 }