KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jtests > clients > entity > B_BasicHomeInterfaceEC


1 /*
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: B_BasicHomeInterfaceEC.java,v 1.2 2004/01/21 14:51:28 legrasi Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.jtests.clients.entity;
27
28 import javax.naming.NamingException JavaDoc;
29 import javax.rmi.PortableRemoteObject JavaDoc;
30 import junit.framework.Test;
31 import junit.framework.TestSuite;
32 import org.objectweb.jonas.jtests.beans.fbasic.SimpleHome;
33 import org.objectweb.jonas.jtests.beans.fbasic.Simple;
34 import java.util.Enumeration JavaDoc;
35
36 /**
37  * This set of test are basic tests on CMP entity home interface.
38  * Only specific tests to CMP are here, all tests common to CMP and BMP
39  * are in the inherited class A_BasicHomeInterface.
40  * @author Philippe Coq, Philippe Durieux, Helene Joanin. (jonas team)
41  */

42 public abstract class B_BasicHomeInterfaceEC extends B_BasicHomeInterface {
43
44     public B_BasicHomeInterfaceEC(String JavaDoc name) {
45         super(name);
46     }
47    
48   
49     // --------------------------------------------------------------------
50
// tests on clause where for CMP finder methods
51
// These tests are specific to CMP
52
// ---------------------------------------------------------------------
53

54     /**
55      * testFinderBetween verify a finder method that return a Enumeration
56      * whith a where clause :
57      * where ?1 <= c_info and c_info <= ?2 and ?1 <= c_numtest and c_numtest <= ?2
58      * the purpose of this test is to verify the correct interpretation of parameters
59      * ?1 ?2
60      */

61     public void testFinderBetween() throws Exception JavaDoc {
62         int value = 991959;
63         getHome().create("991959_1", value, value);
64         getHome().create("991959_2", value, value);
65         Simple entity = null;
66         Enumeration JavaDoc eList = null;
67         eList = getHome().findInfo_beetwen(value, value);
68         int nb = 0;
69         while (eList.hasMoreElements()) {
70             entity = (Simple) javax.rmi.PortableRemoteObject.narrow(eList.nextElement(), Simple.class);
71             nb++;
72             assertEquals("Wrong Info value", entity.getInfo(), value);
73             assertEquals("Wrong NumTest value", entity.getNumTest(), value);
74         }
75         assertEquals("Wrong number of entities found", 2, nb);
76         getHome().remove("991959_1");
77         getHome().remove("991959_2");
78     }
79
80   public void testFinderBetweenSansVerif() throws Exception JavaDoc {
81         int value = 991959;
82         getHome().create("991959_1", value, value);
83         getHome().create("991959_2", value, value);
84         Simple entity = null;
85         Enumeration JavaDoc eList = null;
86         eList = getHome().findInfo_beetwen(value, value);
87         
88         getHome().remove("991959_1");
89         getHome().remove("991959_2");
90     }
91
92
93    // juste pour voir
94

95     public void testCreateRemoveFinderBetween() throws Exception JavaDoc {
96         int value = 991959;
97         getHome().create("991959_1", value, value);
98         getHome().create("991959_2", value, value);
99         Simple entity = null;
100         Enumeration JavaDoc eList = null;
101         
102         getHome().remove("991959_1");
103         getHome().remove("991959_2");
104     }
105     /**
106      * testFinderEqualOne verify a finder method that return a Enumeration
107      * whith a where clause :
108      * where c_info = ?1 and c_numtest = ?1
109      * the object of this test is to verify the correct interpretation of parameters
110      * ?1 ?2
111      */

112     public void testFinderEqualOne() throws Exception JavaDoc {
113         Simple entity = null;
114         Enumeration JavaDoc eList = null;
115         eList = getHome().findEqualOne(80);
116         int nb = 0;
117         while (eList.hasMoreElements()) {
118             entity = (Simple) javax.rmi.PortableRemoteObject.narrow(eList.nextElement(), Simple.class);
119             nb++;
120             assertEquals(80, entity.getInfo());
121             assertEquals(80, entity.getNumTest());
122         }
123         assertEquals(2, nb);
124     }
125
126     /**
127      * testFinderEqualTwo verify a finder method that return a Enumeration
128      * whith a where clause :
129      * where c_info = ? and c_numtest = ?
130      * the object of this test is to verify the correct interpretation of parameters
131      * ?1 ?2
132      */

133     public void testFinderEqualTwo() throws Exception JavaDoc {
134         Simple entity = null;
135         Enumeration JavaDoc eList = null;
136         eList = getHome().findEqualTwo(100, 90);
137         int nb = 0;
138         while (eList.hasMoreElements()) {
139             entity = (Simple) javax.rmi.PortableRemoteObject.narrow(eList.nextElement(), Simple.class);
140             nb++;
141             assertEquals(100, entity.getInfo());
142             assertEquals(90, entity.getNumTest());
143         }
144         assertEquals(1, nb);
145     }
146
147 }
148
149
Popular Tags