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: F_BasicHomeInterfaceEC2.java 4406 2004-03-19 11:57:20Z benoitf $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.jtests.clients.entity;
027:
028: import javax.naming.NamingException;
029: import javax.rmi.PortableRemoteObject;
030:
031: import junit.framework.Test;
032: import junit.framework.TestSuite;
033:
034: import org.objectweb.jonas.jtests.beans.ebasic.SimpleHome;
035:
036: /**
037: * This set of test are basic tests on CMP version 2 entity home interface.
038: * All tests common to CMP are in the inherited class A_BasicHomeInterfaceEC.
039: * @author Helene Joanin (JOnAS team)
040: */
041: public class F_BasicHomeInterfaceEC2 extends A_BasicHomeInterfaceEC {
042:
043: private static String BEAN_HOME = "ebasicSimpleEC2Home";
044:
045: public F_BasicHomeInterfaceEC2(String name) {
046: super (name);
047: }
048:
049: public SimpleHome getHome() {
050: if (home == null) {
051: try {
052: home = (SimpleHome) PortableRemoteObject.narrow(ictx
053: .lookup(BEAN_HOME), SimpleHome.class);
054: } catch (NamingException e) {
055: fail("Cannot get bean home");
056: }
057: // init here tables if CMP2
058: try {
059: home.findByPrimaryKey("pk1");
060: } catch (Exception e) {
061: try {
062: home.create("pk1", 10, 4);
063: home.create("pk2", 10, 4);
064: home.create("pk3", 10, 4);
065: home.create("pk4", 40, 8);
066: home.create("pk5", 50, 8);
067: home.create("pk6", 60, 8);
068: home.create("pk7", 70, 8);
069: home.create("pk8", 45, 20);
070: home.create("pk9", 55, 30);
071: home.create("pk10", 80, 80);
072: home.create("pk11", 80, 80);
073: home.create("pk12", 90, 90);
074: home.create("pk13", 100, 90);
075: home.create("pk14", 110, 90);
076: } catch (Exception i) {
077: fail("Cannot init database table Simple");
078: }
079: }
080: }
081: return home;
082: }
083:
084: /**
085: * This suite is all CMP test cases
086: */
087: public static Test suite() {
088: return new TestSuite(F_BasicHomeInterfaceEC2.class);
089: }
090:
091: public static void main(String args[]) throws Exception {
092:
093: String testtorun = null;
094: // Get args
095: for (int argn = 0; argn < args.length; argn++) {
096: String s_arg = args[argn];
097: Integer i_arg;
098: if (s_arg.equals("-n")) {
099: testtorun = args[++argn];
100: }
101: }
102: if (testtorun == null) {
103: junit.textui.TestRunner.run(suite());
104: } else {
105:
106: junit.textui.TestRunner.run(new F_BasicHomeInterfaceEC2(
107: testtorun));
108:
109: }
110: }
111: }
|