001 package com.mockrunner.mock.jms; 002 003 import javax.jms.Connection; 004 import javax.jms.JMSException; 005 006 import com.mockrunner.jms.ConfigurationManager; 007 import com.mockrunner.jms.DestinationManager; 008 009 /** 010 * Mock implementation of JMS <code>TopicConnectionFactory</code>. 011 */ 012 public class MockTopicConnectionFactory extends MockConnectionFactory 013 { 014 public MockTopicConnectionFactory(DestinationManager destinationManager, ConfigurationManager configurationManager) 015 { 016 super(destinationManager, configurationManager); 017 } 018 019 public Connection createConnection() throws JMSException 020 { 021 return createTopicConnection(); 022 } 023 024 public Connection createConnection(String name, String password) throws JMSException 025 { 026 return createTopicConnection(name, password); 027 } 028 029 /** 030 * Returns the connection with the specified index 031 * or <code>null</code> if no such connection 032 * exists. 033 * @param index the index 034 * @return the connection 035 */ 036 public MockTopicConnection getTopicConnection(int index) 037 { 038 if(connections().size() <= index) return null; 039 return (MockTopicConnection)connections().get(index); 040 } 041 042 /** 043 * Returns the latest created connection 044 * or <code>null</code> if no such connection 045 * exists. 046 * @return the connection 047 */ 048 public MockTopicConnection getLatestTopicConnection() 049 { 050 if(connections().size() == 0) return null; 051 return (MockTopicConnection)connections().get(connections().size() - 1); 052 } 053 }