KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jtests > clients > entity > F_TierEC2


1 /*
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 2004 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  * --------------------------------------------------------------------------
21  * $Id: F_TierEC2.java,v 1.1 2004/12/08 13:25:40 joaninh Exp $
22  * --------------------------------------------------------------------------
23  */

24
25 package org.objectweb.jonas.jtests.clients.entity;
26
27 import java.util.Collection JavaDoc;
28
29 import javax.naming.NamingException JavaDoc;
30 import javax.rmi.PortableRemoteObject JavaDoc;
31
32 import junit.framework.Test;
33 import junit.framework.TestSuite;
34
35 import org.objectweb.jonas.jtests.beans.relation.tier.TestFacade;
36 import org.objectweb.jonas.jtests.beans.relation.tier.TestFacadeHome;
37 import org.objectweb.jonas.jtests.util.JTestCase;
38
39
40
41 /**
42  * This is a test suite on CMP 2 and EJBQL.
43  * @author Helene Joanin
44  */

45 public class F_TierEC2 extends JTestCase {
46
47     private static TestFacadeHome facadeHome = null;
48
49     public F_TierEC2(String JavaDoc name) {
50         super(name);
51     }
52
53     protected static boolean isInit = false;
54
55     protected void setUp() {
56         super.setUp();
57         if (!isInit) {
58             useBeans("tier", true);
59             try {
60                 facadeHome = (TestFacadeHome)
61                     PortableRemoteObject.narrow(ictx.lookup("Rel_Tier_TestFacadeHomeRemote"),
62                                                 TestFacadeHome.class);
63             } catch (NamingException JavaDoc e) {
64                 fail("Cannot get bean home: " + e.getMessage());
65             }
66             isInit = true;
67         }
68     }
69
70     /**
71      * Test the findByTiemorOrTiephy method.
72      * @throws Exception
73      */

74     public void testFindByTiemorOrTiephy() throws Exception JavaDoc {
75         Collection JavaDoc c;
76         TestFacade facade = facadeHome.create();
77         c = facade.tierfindByTiemorOrTiephy("none");
78         assertEquals("Number of 'none' Tier: ", 0, c.size());
79         c = facade.tierfindByTiemorOrTiephy("helene joanin");
80         assertEquals("Number of 'helene joanin' Tier: ", 1, c.size());
81     }
82     
83     protected boolean initStateOK() throws Exception JavaDoc {
84         return true;
85     }
86
87     public static Test suite() {
88         return new TestSuite(F_TierEC2.class);
89     }
90
91     public static void main (String JavaDoc args[]) {
92         String JavaDoc testtorun = null;
93         // Get args
94
for (int argn = 0; argn < args.length; argn++) {
95             String JavaDoc sarg = args[argn];
96             if (sarg.equals("-n")) {
97                 testtorun = args[++argn];
98             }
99         }
100         if (testtorun == null) {
101             junit.textui.TestRunner.run(suite());
102         } else {
103             junit.textui.TestRunner.run(new F_TierEC2(testtorun));
104         }
105     }
106 }
107
Popular Tags