![JAR search and dependency download from the Maven repository](/logo.png)
com.mockrunner.jms.DestinationManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mockrunner-jdk1.6-j2ee1.3 Show documentation
Show all versions of mockrunner-jdk1.6-j2ee1.3 Show documentation
Mockrunner is a lightweight framework for unit testing applications
in the J2EE environment. It supports servlets, filters, tag classes
and Struts actions. It includes a JDBC a JMS and a JCA test
framework and can be used to test EJB based applications.
The newest version!
package com.mockrunner.jms;
import java.util.HashMap;
import java.util.Map;
import com.mockrunner.mock.jms.MockQueue;
import com.mockrunner.mock.jms.MockTopic;
/**
* The DestinationManager
can be used
* to create queues and topics, which is normally an
* administrative act. Since queues and topics are ususally
* acquired using JNDI in a J2EE environment, you can bind
* the created objects to the mock context with the help
* of {@link com.mockrunner.ejb.EJBTestModule#bindToContext}.
*/
public class DestinationManager
{
private Map queues;
private Map topics;
public DestinationManager()
{
queues = new HashMap();
topics = new HashMap();
}
/**
* Creates a new Queue
that is available
* for {@link com.mockrunner.mock.jms.MockQueueSession#createQueue}
* calls. Creating queues is an administrative act.
* Before {@link com.mockrunner.mock.jms.MockQueueSession#createQueue}
* can be sucessfully called, you have to create a Queue
* with this method. You can also bind the created queue to the
* mock JNDI context using {@link com.mockrunner.ejb.EJBTestModule#bindToContext}.
* @param name the name of the Queue
* @return the created Queue
*/
public MockQueue createQueue(String name)
{
MockQueue queue = new MockQueue(name);
queues.put(name, queue);
return queue;
}
/**
* Removes a formerly created Queue
.
* @param name the name of the Queue
*/
public void removeQueue(String name)
{
queues.remove(name);
}
/**
* Returns a Queue
that was created with
* {@link #createQueue} or null
if no such
* Queue
is present.
* @param name the name of the Queue
* @return the Queue
*/
public MockQueue getQueue(String name)
{
return (MockQueue)queues.get(name);
}
/**
* Creates a new Topic
that is available
* for {@link com.mockrunner.mock.jms.MockTopicSession#createTopic}
* calls. Creating topics is an administrative act.
* Before {@link com.mockrunner.mock.jms.MockTopicSession#createTopic}
* can be sucessfully called, you have to create a Topic
* with this method. You can also bind the created topic to the
* mock JNDI context using {@link com.mockrunner.ejb.EJBTestModule#bindToContext}.
* @param name the name of the Topic
* @return the created Topic
*/
public MockTopic createTopic(String name)
{
MockTopic topic = new MockTopic(name);
topics.put(name, topic);
return topic;
}
/**
* Removes a formerly created Topic
.
* @param name the name of the Topic
*/
public void removeTopic(String name)
{
topics.remove(name);
}
/**
* Returns a Topic
that was created with
* {@link #createTopic} or null
if no such
* Topic
is present.
* @param name the name of the Topic
* @return the Topic
*/
public MockTopic getTopic(String name)
{
return (MockTopic)topics.get(name);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy