001: /*
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 Bull S.A.
004: * Contact: jonas-team@objectweb.org
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: B_BasicHomeInterfaceEC.java 4066 2004-01-21 14:51:28Z legrasi $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.jtests.clients.entity;
027:
028: import javax.naming.NamingException;
029: import javax.rmi.PortableRemoteObject;
030: import junit.framework.Test;
031: import junit.framework.TestSuite;
032: import org.objectweb.jonas.jtests.beans.fbasic.SimpleHome;
033: import org.objectweb.jonas.jtests.beans.fbasic.Simple;
034: import java.util.Enumeration;
035:
036: /**
037: * This set of test are basic tests on CMP entity home interface.
038: * Only specific tests to CMP are here, all tests common to CMP and BMP
039: * are in the inherited class A_BasicHomeInterface.
040: * @author Philippe Coq, Philippe Durieux, Helene Joanin. (jonas team)
041: */
042: public abstract class B_BasicHomeInterfaceEC extends
043: B_BasicHomeInterface {
044:
045: public B_BasicHomeInterfaceEC(String name) {
046: super (name);
047: }
048:
049: // --------------------------------------------------------------------
050: // tests on clause where for CMP finder methods
051: // These tests are specific to CMP
052: // ---------------------------------------------------------------------
053:
054: /**
055: * testFinderBetween verify a finder method that return a Enumeration
056: * whith a where clause :
057: * where ?1 <= c_info and c_info <= ?2 and ?1 <= c_numtest and c_numtest <= ?2
058: * the purpose of this test is to verify the correct interpretation of parameters
059: * ?1 ?2
060: */
061: public void testFinderBetween() throws Exception {
062: int value = 991959;
063: getHome().create("991959_1", value, value);
064: getHome().create("991959_2", value, value);
065: Simple entity = null;
066: Enumeration eList = null;
067: eList = getHome().findInfo_beetwen(value, value);
068: int nb = 0;
069: while (eList.hasMoreElements()) {
070: entity = (Simple) javax.rmi.PortableRemoteObject.narrow(
071: eList.nextElement(), Simple.class);
072: nb++;
073: assertEquals("Wrong Info value", entity.getInfo(), value);
074: assertEquals("Wrong NumTest value", entity.getNumTest(),
075: value);
076: }
077: assertEquals("Wrong number of entities found", 2, nb);
078: getHome().remove("991959_1");
079: getHome().remove("991959_2");
080: }
081:
082: public void testFinderBetweenSansVerif() throws Exception {
083: int value = 991959;
084: getHome().create("991959_1", value, value);
085: getHome().create("991959_2", value, value);
086: Simple entity = null;
087: Enumeration eList = null;
088: eList = getHome().findInfo_beetwen(value, value);
089:
090: getHome().remove("991959_1");
091: getHome().remove("991959_2");
092: }
093:
094: // juste pour voir
095:
096: public void testCreateRemoveFinderBetween() throws Exception {
097: int value = 991959;
098: getHome().create("991959_1", value, value);
099: getHome().create("991959_2", value, value);
100: Simple entity = null;
101: Enumeration eList = null;
102:
103: getHome().remove("991959_1");
104: getHome().remove("991959_2");
105: }
106:
107: /**
108: * testFinderEqualOne verify a finder method that return a Enumeration
109: * whith a where clause :
110: * where c_info = ?1 and c_numtest = ?1
111: * the object of this test is to verify the correct interpretation of parameters
112: * ?1 ?2
113: */
114: public void testFinderEqualOne() throws Exception {
115: Simple entity = null;
116: Enumeration eList = null;
117: eList = getHome().findEqualOne(80);
118: int nb = 0;
119: while (eList.hasMoreElements()) {
120: entity = (Simple) javax.rmi.PortableRemoteObject.narrow(
121: eList.nextElement(), Simple.class);
122: nb++;
123: assertEquals(80, entity.getInfo());
124: assertEquals(80, entity.getNumTest());
125: }
126: assertEquals(2, nb);
127: }
128:
129: /**
130: * testFinderEqualTwo verify a finder method that return a Enumeration
131: * whith a where clause :
132: * where c_info = ? and c_numtest = ?
133: * the object of this test is to verify the correct interpretation of parameters
134: * ?1 ?2
135: */
136: public void testFinderEqualTwo() throws Exception {
137: Simple entity = null;
138: Enumeration eList = null;
139: eList = getHome().findEqualTwo(100, 90);
140: int nb = 0;
141: while (eList.hasMoreElements()) {
142: entity = (Simple) javax.rmi.PortableRemoteObject.narrow(
143: eList.nextElement(), Simple.class);
144: nb++;
145: assertEquals(100, entity.getInfo());
146: assertEquals(90, entity.getNumTest());
147: }
148: assertEquals(1, nb);
149: }
150:
151: }
|