001    package com.mockrunner.mock.connector.spi;
002    
003    import java.io.PrintWriter;
004    import java.util.Vector;
005    
006    import javax.resource.ResourceException;
007    import javax.resource.spi.ConnectionEventListener;
008    import javax.resource.spi.ConnectionRequestInfo;
009    import javax.resource.spi.LocalTransaction;
010    import javax.resource.spi.ManagedConnection;
011    import javax.resource.spi.ManagedConnectionMetaData;
012    import javax.security.auth.Subject;
013    import javax.transaction.xa.XAResource;
014    
015    /**
016     * Mock implementation of <code>ManagedConnection</code>.
017     */
018    public class MockManagedConnection implements ManagedConnection 
019    {
020        private PrintWriter logWriter;
021        private ManagedConnectionMetaData metaData;
022        private Vector listeners;
023    
024        public MockManagedConnection()
025        {
026            metaData = new MockManagedConnectionMetaData();
027            listeners = new Vector();
028        }
029    
030        public Object getConnection(Subject subject, ConnectionRequestInfo connectionRequestInfo) throws ResourceException
031        {
032            return null;
033        }
034    
035        public void destroy() throws ResourceException
036        {
037    
038        }
039    
040        public void cleanup() throws ResourceException
041        {
042    
043        }
044    
045        public void associateConnection(Object connection) throws ResourceException
046        {
047    
048        }
049    
050        public void addConnectionEventListener(ConnectionEventListener listener)
051        {
052            listeners.add(listener);
053        }
054    
055        public void removeConnectionEventListener(ConnectionEventListener listener)
056        {
057            listeners.remove(listener);
058        }
059    
060        public XAResource getXAResource() throws ResourceException
061        {
062            return null;
063        }
064    
065        public LocalTransaction getLocalTransaction() throws ResourceException
066        {
067            return null;
068        }
069    
070        public ManagedConnectionMetaData getMetaData() throws ResourceException
071        {
072            return metaData;
073        }
074    
075        public PrintWriter getLogWriter() throws ResourceException
076        {
077            return logWriter;
078        }
079    
080        public void setLogWriter(PrintWriter logWriter) throws ResourceException
081        {
082            this.logWriter = logWriter;
083        }
084    
085        public void setMetaData(ManagedConnectionMetaData metaData)
086        {
087            this.metaData = metaData;
088        }
089    }