/* JFox, the OpenSource J2EE Application Server
 *
 * Distributable under GNU LGPL license by gun.org
 * more details please visit http://www.huihoo.org/jfox
 */

package org.jfox.jms;

import javax.jms.Connection;
import javax.naming.InitialContext;

import junit.framework.TestCase;

/**
 * @author <a href="mailto:young_yy@hotmail.com">Young Yang</a>
 */

public class JMSConnectionFactoryTest extends TestCase {
    JMSConnectionFactory jmsConnectionFactory;

    public void setUp() throws Exception {
        super.setUp();
        InitialContext ctx = new InitialContext();
        Object cf = ctx.lookup("jms/defaultcf");
        jmsConnectionFactory = (JMSConnectionFactory) javax.rmi.PortableRemoteObject.narrow(cf, JMSConnectionFactory.class);
    }

    public void tearDown() throws Exception {
        super.tearDown();
    }

    public void testInstance() throws Exception {
        System.out.println("toString: " + jmsConnectionFactory.toString());
    }

    public void testCreateConnection() throws Exception {
        Connection conn = jmsConnectionFactory.createConnection();
        System.out.println("create connection: " + conn);
    }

    public void testStartConnection() throws Exception {
        Connection conn = jmsConnectionFactory.createConnection();
        System.out.println("create connection: " + conn);
        conn.start();
        System.out.println("ClientID: " + conn.getClientID());
    }

}
