01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.openejb.config;
17:
18: import junit.framework.TestCase;
19: import org.apache.openejb.assembler.classic.Assembler;
20: import org.apache.openejb.assembler.classic.ProxyFactoryInfo;
21: import org.apache.openejb.assembler.classic.SecurityServiceInfo;
22: import org.apache.openejb.assembler.classic.StatelessSessionContainerInfo;
23: import org.apache.openejb.assembler.classic.TransactionServiceInfo;
24: import org.apache.openejb.core.ivm.naming.InitContextFactory;
25: import org.apache.openejb.jee.EjbJar;
26: import org.apache.openejb.jee.StatelessBean;
27: import org.apache.openejb.jee.oejb3.EjbDeployment;
28: import org.apache.openejb.jee.oejb3.Jndi;
29: import org.apache.openejb.jee.oejb3.OpenejbJar;
30:
31: import javax.ejb.Local;
32: import javax.naming.InitialContext;
33:
34: /**
35: * @version $Rev: 602704 $ $Date: 2007-12-09 09:58:22 -0800 $
36: */
37: public class JndiNameTest extends TestCase {
38:
39: public void test() throws Exception {
40: System.setProperty(
41: javax.naming.Context.INITIAL_CONTEXT_FACTORY,
42: InitContextFactory.class.getName());
43:
44: ConfigurationFactory config = new ConfigurationFactory();
45: Assembler assembler = new Assembler();
46:
47: assembler.createProxyFactory(config
48: .configureService(ProxyFactoryInfo.class));
49: assembler.createTransactionManager(config
50: .configureService(TransactionServiceInfo.class));
51: assembler.createSecurityService(config
52: .configureService(SecurityServiceInfo.class));
53:
54: // containers
55: StatelessSessionContainerInfo statelessContainerInfo = config
56: .configureService(StatelessSessionContainerInfo.class);
57: assembler.createContainer(statelessContainerInfo);
58:
59: // Setup the descriptor information
60:
61: EjbModule ejbModule = new EjbModule(new EjbJar(),
62: new OpenejbJar());
63: ejbModule.getEjbJar().addEnterpriseBean(
64: new StatelessBean(FooBean.class));
65:
66: EjbDeployment ejbDeployment = new EjbDeployment(null,
67: "FooBean", "FooBean");
68: ejbDeployment.getJndi().add(new Jndi("thename", "Local"));
69: ejbModule.getOpenejbJar().addEjbDeployment(ejbDeployment);
70:
71: assembler.createApplication(config
72: .configureApplication(ejbModule));
73:
74: InitialContext initialContext = new InitialContext();
75: Object o = initialContext.lookup("thename");
76: assertNotNull(o);
77: }
78:
79: @Local
80: public static interface Foo {
81:
82: }
83:
84: public static class FooBean implements Foo {
85:
86: }
87: }
|