KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > test > localcall > unit > TestLocalCallsTestCase


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22
23 package org.jboss.ejb3.test.localcall.unit;
24
25 import javax.naming.InitialContext JavaDoc;
26 import org.jboss.ejb3.test.localcall.ServiceRemote;
27 import org.jboss.ejb3.test.localcall.StatefulClustered;
28 import org.jboss.ejb3.test.localcall.StatefulRemote;
29 import org.jboss.ejb3.test.localcall.StatelessClustered;
30 import org.jboss.ejb3.test.localcall.StatelessRemote;
31 import org.jboss.test.JBossTestCase;
32 import junit.framework.Test;
33
34 /**
35  *
36  * @author <a HREF="mailto:kabir.khan@jboss.org">Kabir Khan</a>
37  * @version $Revision: 39547 $
38  */

39 public class TestLocalCallsTestCase extends JBossTestCase
40 {
41    public TestLocalCallsTestCase(String JavaDoc name)
42    {
43       super(name);
44       
45    }
46    
47    public void testRemoteIfLocalCalls() throws Exception JavaDoc
48    {
49       System.out.println("Testing local");
50       InitialContext JavaDoc ctx = getInitialContext();
51       StatefulRemote stateful1 = (StatefulRemote)ctx.lookup("StatefulBean/remote");
52       StatefulRemote stateful2 = (StatefulRemote)ctx.lookup("StatefulBean/remote");
53       
54       StatefulClustered statefulClustered1 = (StatefulClustered)ctx.lookup("StatefulClusteredBean/remote");
55       StatefulClustered statefulClustered2 = (StatefulClustered)ctx.lookup("StatefulClusteredBean/remote");
56       
57       StatelessRemote stateless1 = (StatelessRemote)ctx.lookup("StatelessBean/remote");
58       StatelessRemote stateless2 = (StatelessRemote)ctx.lookup("StatelessBean/remote");
59       
60       StatelessClustered statelessClustered1 = (StatelessClustered)ctx.lookup("StatelessClusteredBean/remote");
61       StatelessClustered statelessClustered2 = (StatelessClustered)ctx.lookup("StatelessClusteredBean/remote");
62       
63       ServiceRemote service1 = (ServiceRemote)ctx.lookup("ServiceBean/remote");
64       ServiceRemote service2 = (ServiceRemote)ctx.lookup("ServiceBean/remote");
65       
66       stateful1.test();
67       stateful2.test();
68       statefulClustered1.test();
69       statefulClustered2.test();
70       stateless1.test();
71       stateless2.test();
72       statelessClustered1.test();
73       statelessClustered2.test();
74       service1.test();
75       service2.test();
76             
77       assertFalse(stateful1.hashCode() == stateful2.hashCode());
78       assertFalse(statefulClustered1.hashCode() == statefulClustered2.hashCode());
79       assertTrue(stateless1.hashCode() == stateless2.hashCode());
80       assertTrue(statelessClustered1.hashCode() == statelessClustered2.hashCode());
81       assertTrue(service1.hashCode() == service2.hashCode());
82       
83       assertFalse(stateful1.equals(stateful2));
84       assertFalse(statefulClustered1.equals(statefulClustered2));
85       assertTrue(stateless1.equals(stateless2));
86       assertTrue(statelessClustered1.equals(statelessClustered2));
87       assertTrue(service1.equals(service2));
88       
89    }
90    
91    public void testLocalIfLocalCalls() throws Exception JavaDoc
92    {
93       System.out.println("TESTING LOCAL CALLS");
94       InitialContext JavaDoc ctx = getInitialContext();
95       ServiceRemote service = (ServiceRemote)ctx.lookup("ServiceBean/remote");
96       service.testLocal();
97    }
98    
99    public static Test suite() throws Exception JavaDoc
100    {
101       return getDeploySetup(TestLocalCallsTestCase.class, "localcall-test.jar");
102    }
103 }
104
Popular Tags