01: /*
02: * JBoss, Home of Professional Open Source.
03: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
04: * as indicated by the @author tags. See the copyright.txt file in the
05: * distribution for a full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * 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.jaxr.scout.basic;
23:
24: import junit.framework.TestCase;
25:
26: import javax.naming.Context;
27: import javax.naming.InitialContext;
28: import javax.naming.NamingException;
29: import javax.xml.registry.ConnectionFactory;
30: import java.util.Properties;
31:
32: /**
33: * Tests the JAXR connection factory bound
34: * to JNDI
35: *
36: * @author <mailto:Anil.Saldhana@jboss.org>Anil Saldhana
37: * @since Apr 12, 2005
38: */
39: public class JaxrJNDIConnectionTestCase extends TestCase {
40: public JaxrJNDIConnectionTestCase(String name) {
41: super (name);
42: }
43:
44: public void testJaxrJNDIConnection() throws Exception {
45: String bindname = System.getProperty("jndi.bind.name");
46: InitialContext ctx = getClientContext();
47: ConnectionFactory factory = (ConnectionFactory) ctx
48: .lookup(bindname);
49: assertNotNull("Connection Factory from JNDI:", factory);
50: }
51:
52: protected InitialContext getClientContext() throws NamingException {
53: String hostname = System.getProperty("host.name");
54: Properties env = new Properties();
55: env.setProperty(Context.INITIAL_CONTEXT_FACTORY,
56: "org.jnp.interfaces.NamingContextFactory");
57: env.setProperty(Context.URL_PKG_PREFIXES,
58: "org.jboss.naming:org.jnp.interfaces");
59: env.setProperty(Context.PROVIDER_URL, "jnp://" + hostname
60: + ":1099");
61: return new InitialContext(env);
62: }
63: }
|