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_AdvancedHomeEC2.java 9725 2006-10-12 07:01:48Z durieuxp $
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.annuaire.PersonneHome;
035:
036: /**
037: * This is an advanced test suite for home interface on entity bean CMP v2.
038: * * All tests common to CMP v1 and CMP v2 are in the inherited class A_AdvancedHomeEC.
039: * Beans used: annuaire
040: * @author Philippe Coq, Philippe Durieux, Helene Joanin (jonas team)
041: */
042: public class F_AdvancedHomeEC2 extends A_AdvancedHomeEC {
043:
044: private static String BEAN_HOME = "annuairePersonneEC2Home";
045: private static PersonneHome ehome = null;
046:
047: public F_AdvancedHomeEC2(String name) {
048: super (name);
049: }
050:
051: protected boolean isInit = false;
052:
053: protected void setUp() {
054: super .setUp();
055: if (!isInit) {
056: useBeans("annuaire", false);
057: getHome();
058: isInit = true;
059: }
060: }
061:
062: public PersonneHome getHome() {
063: if (ehome == null) {
064: try {
065: ehome = (PersonneHome) PortableRemoteObject.narrow(ictx
066: .lookup(BEAN_HOME), PersonneHome.class);
067: } catch (NamingException e) {
068: fail("Cannot get bean home");
069: }
070: // check if tables have been initialized
071: try {
072: ehome.findByPrimaryKey("Charly Mingus");
073: } catch (Exception e) {
074: // init here tables if CMP2
075: try {
076: utx.begin();
077: ehome.create("Philippe Durieux", "638");
078: ehome.create("Philippe Coq", "1235456");
079: ehome.create("Adriana Danes", "1233456");
080: ehome.create("Helene Joanin", "1230456");
081: ehome.create("Gerard Vandome", "1232456");
082: ehome.create("Francois Exertier", "1323456");
083: ehome.create("Emmanuel Facarde", "1234356");
084: ehome.create("Charly Mingus", "1238456");
085: ehome.create("Thelonious Monk", "1239456");
086: ehome.create("Jean-Luc Richard", "1203456");
087: } catch (Exception i) {
088: debug("Cannote create bean" + i);
089: } finally {
090: try {
091: utx.commit();
092: } catch (Exception e3) {
093: }
094: }
095: }
096: }
097: return ehome;
098: }
099:
100: public static Test suite() {
101: return new TestSuite(F_AdvancedHomeEC2.class);
102: }
103:
104: public static void main(String args[]) {
105: String testtorun = null;
106: // Get args
107: for (int argn = 0; argn < args.length; argn++) {
108: String s_arg = args[argn];
109: Integer i_arg;
110: if (s_arg.equals("-n")) {
111: testtorun = args[++argn];
112: }
113: }
114: if (testtorun == null) {
115: junit.textui.TestRunner.run(suite());
116: } else {
117: junit.textui.TestRunner
118: .run(new F_AdvancedHomeEC2(testtorun));
119: }
120: }
121: }
|