001: /*
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 2004 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: * $Id: F_TierEC2.java 7533 2005-10-19 15:55:05Z durieuxp $
022: * --------------------------------------------------------------------------
023: */
024:
025: package org.objectweb.jonas.jtests.clients.entity;
026:
027: import java.util.Collection;
028:
029: import javax.naming.NamingException;
030: import javax.rmi.PortableRemoteObject;
031:
032: import junit.framework.Test;
033: import junit.framework.TestSuite;
034:
035: import org.objectweb.jonas.jtests.beans.relation.tier.TestFacade;
036: import org.objectweb.jonas.jtests.beans.relation.tier.TestFacadeHome;
037: import org.objectweb.jonas.jtests.util.JTestCase;
038:
039: /**
040: * This is a test suite on CMP 2 and EJBQL.
041: * @author Helene Joanin
042: */
043: public class F_TierEC2 extends JTestCase {
044:
045: private static TestFacadeHome facadeHome = null;
046:
047: public F_TierEC2(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("tier", true);
057: try {
058: facadeHome = (TestFacadeHome) PortableRemoteObject
059: .narrow(
060: ictx
061: .lookup("Rel_Tier_TestFacadeHomeRemote"),
062: TestFacadeHome.class);
063: } catch (NamingException e) {
064: fail("Cannot get bean home: " + e.getMessage());
065: }
066: isInit = true;
067: }
068: }
069:
070: /**
071: * Test the findByTiemorOrTiephy method.
072: * @throws Exception
073: */
074: public void testFindByTiemorOrTiephy() throws Exception {
075: Collection c;
076: TestFacade facade = facadeHome.create();
077: c = facade.tierfindByTiemorOrTiephy("none");
078: assertEquals("Number of 'none' Tier: ", 0, c.size());
079: c = facade.tierfindByTiemorOrTiephy("helene joanin");
080: assertEquals("Number of 'helene joanin' Tier: ", 1, c.size());
081: }
082:
083: protected boolean initStateOK() throws Exception {
084: return true;
085: }
086:
087: public static Test suite() {
088: return new TestSuite(F_TierEC2.class);
089: }
090:
091: public static void main(String args[]) {
092: String testtorun = null;
093: // Get args
094: for (int argn = 0; argn < args.length; argn++) {
095: String sarg = args[argn];
096: if (sarg.equals("-n")) {
097: testtorun = args[++argn];
098: }
099: }
100: if (testtorun == null) {
101: junit.textui.TestRunner.run(suite());
102: } else {
103: junit.textui.TestRunner.run(new F_TierEC2(testtorun));
104: }
105: }
106: }
|