KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > naming > test > ENCUnitTestCase


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 package org.jboss.test.naming.test;
23
24 import java.io.IOException JavaDoc;
25 import java.rmi.RemoteException JavaDoc;
26 import javax.ejb.CreateException JavaDoc;
27 import javax.ejb.EJBObject JavaDoc;
28 import javax.naming.InitialContext JavaDoc;
29 import javax.naming.NamingException JavaDoc;
30 import javax.rmi.PortableRemoteObject JavaDoc;
31
32 import junit.framework.Test;
33 import junit.framework.TestCase;
34 import junit.framework.TestSuite;
35
36 import org.jboss.test.JBossTestCase;
37 import org.jboss.test.naming.interfaces.TestENCHome;
38 import org.jboss.test.naming.interfaces.TestENCHome2;
39 import org.jboss.test.naming.interfaces.TestENC;
40
41 /**
42  * Tests of the secure access to EJBs.
43  *
44  * @author Scott.Stark@jboss.org
45  * @author <a HREF="mailto:d_jencks@users.sourceforge.net">David Jencks</a>
46  * @version $Revision: 37406 $
47  */

48 public class ENCUnitTestCase extends JBossTestCase
49 {
50    /**
51     * Constructor for the ENCUnitTestCase object
52     *
53     * @param name Testcase name
54     */

55    public ENCUnitTestCase(String JavaDoc name)
56    {
57       super(name);
58    }
59
60    /** Tests of accessing the various types of java:comp entries
61     *
62     * @exception Exception Description of Exception
63     */

64    public void testENC() throws Exception JavaDoc
65    {
66       Object JavaDoc obj = getInitialContext().lookup("ENCBean");
67       obj = PortableRemoteObject.narrow(obj, TestENCHome.class);
68       TestENCHome home = (TestENCHome)obj;
69       getLog().debug("Found TestENCHome");
70
71       TestENC bean = home.create();
72       getLog().debug("Created ENCBean");
73       bean.accessENC();
74       bean.remove();
75    }
76
77    /**
78     * A unit test for JUnit
79     *
80     * @exception Exception Description of Exception
81     */

82    public void testENC2() throws Exception JavaDoc
83    {
84       Object JavaDoc obj = getInitialContext().lookup("ENCBean0");
85       obj = PortableRemoteObject.narrow(obj, TestENCHome2.class);
86       TestENCHome2 home = (TestENCHome2)obj;
87       getLog().debug("Found TestENCHome2");
88
89       TestENC bean = home.create();
90       getLog().debug("Created ENCBean0");
91       bean.accessENC();
92       bean.remove();
93    }
94
95    public static Test suite() throws Exception JavaDoc
96    {
97       return getDeploySetup(ENCUnitTestCase.class, "naming.jar");
98    }
99
100 }
101
Popular Tags