KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > test > ssladvanced > unit > SSLUnitTestCase


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.ssladvanced.unit;
23
24 import javax.naming.InitialContext JavaDoc;
25 import javax.naming.NamingException JavaDoc;
26 import org.jboss.ejb3.test.ssladvanced.BusinessInterface;
27 import org.jboss.test.JBossTestCase;
28 import junit.framework.Test;
29
30 /**
31  * Sample client for the jboss container.
32  *
33  * @author <a HREF="mailto:bill@burkecentral.com">Bill Burke</a>
34  * @version $Id$
35  */

36
37 public class SSLUnitTestCase
38         extends JBossTestCase
39 {
40    org.jboss.logging.Logger log = getLog();
41
42
43    public SSLUnitTestCase(String JavaDoc name)
44    {
45       super(name);
46    }
47
48    public void testNoDefaultBinding() throws Exception JavaDoc
49    {
50       System.out.println("*** TEST No default binding");
51       InitialContext JavaDoc ctx = new InitialContext JavaDoc();
52       try
53       {
54          BusinessInterface bi = (BusinessInterface)ctx.lookup(BusinessInterface.class.getName());
55          throw new Exception JavaDoc("Nothing should be bound to the default name");
56       }
57       catch(NamingException JavaDoc e)
58       {
59          
60       }
61       System.out.println("*** success");
62    }
63
64    public void testSSLBindings() throws Exception JavaDoc
65    {
66       System.out.println("*** TEST SSL Bindings");
67       InitialContext JavaDoc ctx = new InitialContext JavaDoc();
68       BusinessInterface sf = (BusinessInterface)ctx.lookup("StatefulSSL");
69       assertEquals(sf.echo("123"), "*** 123 ***");
70       
71       BusinessInterface sfc = (BusinessInterface)ctx.lookup("StatefulClusteredSSL");
72       assertEquals(sfc.echo("123"), "*** 123 ***");
73       
74       BusinessInterface sl = (BusinessInterface)ctx.lookup("StatelessSSL");
75       assertEquals(sl.echo("123"), "*** 123 ***");
76
77       BusinessInterface slc = (BusinessInterface)ctx.lookup("StatelessClusteredSSL");
78       assertEquals(slc.echo("123"), "*** 123 ***");
79       System.out.println("*** success");
80    }
81    
82    public void testOverrideSSLBindings() throws Exception JavaDoc
83    {
84       System.out.println("*** TEST SSL Bindings");
85       InitialContext JavaDoc ctx = new InitialContext JavaDoc();
86       BusinessInterface sf = (BusinessInterface)ctx.lookup("OverrideStatefulClusteredSSL");
87       assertEquals(sf.echo("123"), "123");
88    }
89    
90    public void testNormalBindings() throws Exception JavaDoc
91    {
92       System.out.println("*** TEST Normal Bindings");
93       InitialContext JavaDoc ctx = new InitialContext JavaDoc();
94       BusinessInterface sf = (BusinessInterface)ctx.lookup("StatefulNormal");
95       assertEquals(sf.echo("123"), "*** 123 ***");
96       
97       BusinessInterface sfc = (BusinessInterface)ctx.lookup("StatefulClusteredNormal");
98       assertEquals(sfc.echo("123"), "*** 123 ***");
99       
100       BusinessInterface sl = (BusinessInterface)ctx.lookup("StatelessNormal");
101       assertEquals(sl.echo("123"), "*** 123 ***");
102
103       BusinessInterface slc = (BusinessInterface)ctx.lookup("StatelessClusteredNormal");
104       assertEquals(slc.echo("123"), "*** 123 ***");
105
106       System.out.println("*** success");
107    }
108    
109    public void testOverrideNormalBindings() throws Exception JavaDoc
110    {
111       System.out.println("*** TEST Normal Bindings");
112       InitialContext JavaDoc ctx = new InitialContext JavaDoc();
113       BusinessInterface sf = (BusinessInterface)ctx.lookup("OverrideStatefulClusteredNormal");
114       assertEquals(sf.echo("123"), "123");
115    }
116    
117
118    public static Test suite() throws Exception JavaDoc
119    {
120       return getDeploySetup(SSLUnitTestCase.class, "ssladvanced-test.jar");
121    }
122
123
124 }
125
Popular Tags