KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > test > dd > override > unit > OverrideTestCase


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.ejb3.test.dd.override.unit;
23
24 import javax.naming.InitialContext JavaDoc;
25 import javax.naming.NamingEnumeration JavaDoc;
26 import org.jboss.logging.Logger;
27 import org.jboss.test.JBossTestCase;
28 import junit.framework.Test;
29
30 /**
31  * Test for EJB3 deployment of EJB2.0 Bank EJBs
32  *
33  * @version <tt>$Revision: 39361 $</tt>
34  * @author <a HREF="mailto:bdecoste@jboss.com">William DeCoste</a>
35  */

36 public class OverrideTestCase
37     extends JBossTestCase {
38
39    private static final Logger log = Logger
40          .getLogger(OverrideTestCase.class);
41
42    public OverrideTestCase(String JavaDoc name)
43    {
44       super(name);
45    }
46 /*
47    public void testTxOverride() throws Exception
48    {
49       InitialContext jndiContext = new InitialContext();
50       
51       Foo foo = (Foo) jndiContext.lookup("Foo");
52       assertNotNull(foo);
53       
54       SecurityAssociation.setPrincipal(new SimplePrincipal("rolefail"));
55       SecurityAssociation.setCredential("password".toCharArray());
56       
57       assertFalse(foo.transactionExisted());
58       
59       try {
60          foo.bar();
61          assertTrue(false);
62       } catch (Exception e){
63          assertTrue(e instanceof SecurityException);
64       }
65       
66       SecurityAssociation.setPrincipal(new SimplePrincipal("somebody"));
67       SecurityAssociation.setCredential("password".toCharArray());
68       
69       foo.bar();
70       assertFalse(foo.transactionExisted());
71    }
72  
73    public void testRemoteOverride() throws Exception
74    {
75       try {
76       InitialContext jndiContext = new InitialContext();
77       
78       LocalFoo foo = (LocalFoo) jndiContext.lookup("LocalFoo");
79       assertNotNull(foo);
80       
81       foo.bar();
82       } catch (Exception e){
83          e.printStackTrace();
84          throw e;
85       }
86    } */

87    
88    public void testNaming()
89    {
90       lookup("");
91    }
92    
93    private void lookup(String JavaDoc name)
94    {
95       log.info("lookup " + name);
96       try {
97          InitialContext JavaDoc jndiContext = new InitialContext JavaDoc();
98          NamingEnumeration JavaDoc names = jndiContext.list(name);
99          if (names != null){
100             while (names.hasMore()){
101                log.info(" " + names.next());
102             }
103          }
104       } catch (Exception JavaDoc e){
105       }
106    }
107    
108    public static Test suite() throws Exception JavaDoc
109    {
110       return getDeploySetup(OverrideTestCase.class, "dd-override1B.jar");
111    }
112
113 }
114
Popular Tags