001    package com.mockrunner.mock.jms;
002    
003    import javax.jms.JMSException;
004    import javax.jms.QueueSession;
005    import javax.jms.ServerSession;
006    import javax.jms.Session;
007    
008    /**
009     * Mock implementation of JMS <code>ServerSession</code>.
010     * The <code>ServerSession</code> is not meant for application
011     * use.
012     */
013    public class MockServerSession implements ServerSession
014    {
015        private MockConnection connection;
016        private Session session;
017        private boolean started;
018        
019        public MockServerSession(MockConnection connection)
020        {
021            this.connection = connection;
022            session = new MockSession(connection, false, QueueSession.AUTO_ACKNOWLEDGE);
023            started = false;
024        }
025        
026        /**
027         * Returns if this server session was started.
028         * @return <code>true</code> if this server session is started
029         */
030        public boolean isStarted()
031        {
032            return started;
033        }
034        
035        public void setSession(Session session)
036        {
037            this.session = session;
038        }
039        
040        public Session getSession() throws JMSException
041        {
042            connection.throwJMSException();
043            return session;
044        }
045    
046        public void start() throws JMSException
047        {
048            connection.throwJMSException();
049            started = true;
050        }
051    }