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: G_BasicHomeInterfaceEC2.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 org.objectweb.jonas.jtests.util.JTestCase;
035: import java.util.Enumeration;
036:
037: /**
038: * This set of test are basic tests on CMP version 2 entity home interface.
039: * All tests common to CMP are in the inherited class A_BasicHomeInterfaceEC.
040: * @author Helene Joanin (JOnAS team)
041: */
042: public class G_BasicHomeInterfaceEC2 extends B_BasicHomeInterfaceEC {
043:
044: private static String BEAN_HOME = "fbasicSimpleEC2Home";
045:
046: public G_BasicHomeInterfaceEC2(String name) {
047: super (name);
048: }
049:
050: public void testEmpty() throws Exception {
051: getHome();
052: }
053:
054: public SimpleHome getHome() {
055: if (home == null) {
056: try {
057: home = (SimpleHome) PortableRemoteObject.narrow(ictx
058: .lookup(BEAN_HOME), SimpleHome.class);
059: } catch (NamingException e) {
060: fail("Cannot get bean home");
061: }
062: // init here tables if CMP2
063: try {
064: home.findByPrimaryKey("pk1");
065: } catch (Exception e) {
066: // pk1 not found: we can create
067: try {
068: home.create("pk1", 10, 4);
069: home.create("pk2", 10, 4);
070: home.create("pk3", 10, 4);
071: home.create("pk4", 40, 8);
072: home.create("pk5", 50, 8);
073: home.create("pk6", 60, 8);
074: home.create("pk7", 70, 8);
075: home.create("pk8", 45, 20);
076: home.create("pk9", 55, 30);
077: home.create("pk10", 80, 80);
078: home.create("pk11", 80, 80);
079: home.create("pk12", 90, 90);
080: home.create("pk13", 100, 90);
081: home.create("pk14", 110, 90);
082: // to get a big table
083: for (int i = 0; i < 1000; i++) {
084: home.create(Integer.toString(i), 0, 0);
085: }
086:
087: } catch (Exception i) {
088: fail("cannot create elements of table");
089: }
090: }
091: }
092: return home;
093: }
094:
095: /**
096: * This suite is all CMP test cases
097: */
098: public static Test suite() {
099: return new TestSuite(G_BasicHomeInterfaceEC2.class);
100: }
101:
102: public static void main(String args[]) throws Exception {
103:
104: String testtorun = null;
105: // Get args
106: for (int argn = 0; argn < args.length; argn++) {
107: String s_arg = args[argn];
108: Integer i_arg;
109: if (s_arg.equals("-n")) {
110: testtorun = args[++argn];
111: }
112: }
113: if (testtorun == null) {
114: junit.textui.TestRunner.run(suite());
115: } else {
116:
117: junit.textui.TestRunner.run(new G_BasicHomeInterfaceEC2(
118: testtorun));
119:
120: }
121: }
122: }
|