1 /** 2 * 3 * Copyright 2003-2004 The Apache Software Foundation 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * 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 */ 17 package org.apache.notgeronimo.itests.naming.common; 18 19 import java.sql.Connection; 20 import javax.naming.InitialContext; 21 import javax.sql.DataSource; 22 import javax.jms.Topic; 23 import javax.jms.Queue; 24 import javax.jms.ConnectionFactory; 25 import javax.management.j2ee.Management; 26 import javax.management.j2ee.ManagementHome; 27 28 import org.apache.notgeronimo.itests.naming.common.webservice.interop.InteropLab; 29 import org.apache.notgeronimo.itests.naming.common.webservice.interop.InteropTestPortType; 30 31 /** 32 * @version $Rev: $ $Date: $ 33 */ 34 public class Test { 35 36 public void testWebServiceLookup() throws Exception { 37 InteropLab interopLab = (InteropLab) new InitialContext().lookup("java:comp/env/service/InteropLab"); 38 InteropTestPortType interopTestPortType = interopLab.getinteropTestPort(); 39 int result = interopTestPortType.echoInteger(1); 40 if (result != 1) { 41 throw new Exception("Result was not 1 but " + result); 42 } 43 } 44 45 public void testResourceRefLookup() throws Exception { 46 InitialContext initialContext = new InitialContext(); 47 Object o = initialContext.lookup("java:comp/env/jdbc/DefaultDatasource"); 48 DataSource ds = (DataSource) o; 49 Connection jdbcConnection = ds.getConnection(); 50 jdbcConnection.close(); 51 52 o = initialContext.lookup("java:comp/env/jms/JMSConnectionFactory"); 53 ConnectionFactory connectionFactory = (ConnectionFactory) o; 54 javax.jms.Connection jmsConnection = connectionFactory.createConnection(); 55 jmsConnection.close(); 56 57 o = initialContext.lookup("java:comp/env/jms/Queue"); 58 Queue jmsQueue = (Queue) o; 59 60 o = initialContext.lookup("java:comp/env/jms/Topic"); 61 Topic jmsTopic = (Topic) o; 62 } 63 64 public void testMEJBLookup() throws Exception { 65 InitialContext initialContext = new InitialContext(); 66 Object o = initialContext.lookup("java:comp/env/ejb/mgmt/MEJB"); 67 ManagementHome home = (ManagementHome)o; 68 Management mejb = home.create(); 69 mejb.getMBeanCount(); 70 } 71 72 } 73