I have my test case class below.  When I run this test case, i don't see the
destroy() method being called on a ManagedConnection...

package com.virginaustralia.sabre.jca;

import java.util.Properties;

import javax.annotation.Resource;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.resource.ResourceException;

import junit.framework.Assert;

import org.apache.openejb.api.LocalClient;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;

@LocalClient
public class SabreResourceAdapterTest {
                
        private static InitialContext initialContext = null;
        
        @BeforeClass
        public static void beforeClass() throws Exception {
                if (initialContext == null) {
                        Properties p = new Properties();
                        p.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.core.LocalInitialContextFactory");
                        p.setProperty("openejb.embedded.initialcontext.close", 
"destroy");
                        
                        p.setProperty("sabre-test-pool.pooling", "true");
                        p.setProperty("sabre-test-pool.poolMinSize", "7");
                        p.setProperty("sabre-test-pool.poolMaxSize", "10");
                        
            initialContext = new InitialContext(p);
                }
        }

        @AfterClass
        public static void afterClass() throws Exception {
                if (initialContext != null) {
                        initialContext.close();
                        initialContext = null;
                }
        }

        @Resource(name="sabre-test-pool")
        private SabreConnectionFactory scf;
        
        @Before
        public void setUp() throws NamingException {
                initialContext.bind("inject", this);
        }
        
        @Test
        public void testSabreResourceAdapter() throws NamingException,
ResourceException {
                //System.out.println("Performing lookup of sabre resource 
adapter...");
                //SabreConnectionFactory scf =
(SabreConnectionFactory)initialContext.lookup("java:openejb/Resource/sabre-jca");
                SabreConnection sc = scf.getConnection();
                sc.close();
                sc = scf.getConnection();
                sc.close();
        }
        
        @Test
        @Ignore
        public void testGettingLotsOfConnections() throws NamingException,
ResourceException {
                SabreConnectionFactory scf =
(SabreConnectionFactory)initialContext.lookup("java:openejb/Resource/sabre-test-pool");
                Assert.assertNotNull(scf);
                
                for (int i = 1; i <= 10; i++) {
                        SabreConnection[] connections = new SabreConnection[i];
                        for (int j = 0; j < i; j++) {
                                System.out.println("Getting connection number " 
+ j + "...");
                                connections[j] = scf.getConnection();
                        }
                        
                        for (int j = 0; j < i; j++) {
                                System.out.println("Closing connection number " 
+ j + "...");
                                connections[j].close();
                        }
                }
        }
}




--
View this message in context: 
http://openejb.979440.n4.nabble.com/openejb-not-destroying-ManagedConnections-on-shutdown-tp4658799p4658979.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Reply via email to