org.apache.qpid.test.utils
Class QpidClientConnection

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.apache.qpid.test.utils.QpidTestCase
              extended by org.apache.qpid.test.utils.QpidBrokerTestCase
                  extended by org.apache.qpid.test.utils.QpidClientConnection
All Implemented Interfaces:
ExceptionListener, junit.framework.Test

public class QpidClientConnection
extends QpidBrokerTestCase
implements ExceptionListener


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.qpid.test.utils.QpidBrokerTestCase
QpidBrokerTestCase.MessageType
 
Field Summary
protected  boolean connected
           
protected  Session session
           
 
Fields inherited from class org.apache.qpid.test.utils.QpidBrokerTestCase
_broker, _brokerLanguage, _brokerLogPrefix, _brokerOutputStream, _brokerPersistent, _brokers, _configFile, _connectionFactory, _connections, _initialContext, _interleaveBrokerLog, _output, _outputFile, _testName, BROKER_READY, CONTENT, CPP, DEFAULT_MANAGEMENT_PORT, DEFAULT_MESSAGE_SIZE, DEFAULT_PORT, DEFAULT_SSL_PORT, DEFAULT_VM_PORT, EXTERNAL, INDEX, JAVA, LOGMONITOR_TIMEOUT, QPID_HOME, QpidHome, QUEUE, RECEIVE_TIMEOUT, TOPIC, VM
 
Fields inherited from class org.apache.qpid.test.utils.QpidTestCase
MEMORY_STORE_CLASS_NAME, MS_CLASS_NAME_KEY
 
Constructor Summary
QpidClientConnection(String broker)
           
 
Method Summary
 void connect()
           
 void consume(String queueName, int readTimeout)
          Completely clears a queue.
 void disconnect()
           
 void disconnectWithoutCommit()
           
 String getBrokerList()
           
 Connection getConnection()
           
 Message getNextMessage(String queueName)
          GET the top message on a queue.
 Message getNextMessage(String queueName, long readTimeout)
          GET the top message on a queue.
 Session getSession()
           
 String getVirtualHost()
           
 boolean isConnected()
           
 void onException(JMSException exception)
          override as necessary
 void put(String queueName, String payload, int copies)
          Put a String as a text messages, repeat n times.
 void setBrokerList(String brokerlist)
           
 void setPrefetch(int prefetch)
           
 void setVirtualHost(String virtualHost)
           
 
Methods inherited from class org.apache.qpid.test.utils.QpidBrokerTestCase
cleanBroker, createMessage, createNextMessage, drainQueue, getBroker, getBrokerCommand, getClientConnection, getConfigurationStringProperty, getConnection, getConnection, getConnectionFactory, getConnectionFactory, getConnectionURL, getInitialContext, getLogger, getManagementPort, getMessageSize, getPort, getPort, getTestConfigFile, getTestQueue, getTestQueueName, getTestVirtualhostsFile, isBroker010, isBroker08, isBrokerStorePersistent, isCppBroker, isExternalBroker, isJavaBroker, makeVirtualHostPersistent, reloadBrokerSecurityConfig, restartBroker, restartBroker, revertLoggingLevels, revertSystemProperties, runBare, saveTestConfiguration, saveTestVirtualhosts, sendMessage, sendMessage, sendMessage, setBrokerEnvironment, setBrokerOnlySystemProperty, setConfigurationProperty, setLoggerLevel, setMessageSize, setSystemProperty, setSystemProperty, setTestClientSystemProperty, setUp, startBroker, startBroker, stopBroker, stopBroker, tearDown
 
Methods inherited from class org.apache.qpid.test.utils.QpidTestCase
, getTestProfileMessageStoreClassName, run
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

session

protected Session session

connected

protected boolean connected
Constructor Detail

QpidClientConnection

public QpidClientConnection(String broker)
Method Detail

getConnection

public Connection getConnection()
Overrides:
getConnection in class QpidBrokerTestCase

connect

public void connect()
             throws JMSException
Throws:
JMSException

disconnect

public void disconnect()
                throws Exception
Throws:
Exception

disconnectWithoutCommit

public void disconnectWithoutCommit()
                             throws JMSException
Throws:
JMSException

getBrokerList

public String getBrokerList()

setBrokerList

public void setBrokerList(String brokerlist)

getVirtualHost

public String getVirtualHost()

setVirtualHost

public void setVirtualHost(String virtualHost)

setPrefetch

public void setPrefetch(int prefetch)

onException

public void onException(JMSException exception)
override as necessary

Specified by:
onException in interface ExceptionListener

isConnected

public boolean isConnected()

getSession

public Session getSession()

put

public void put(String queueName,
                String payload,
                int copies)
         throws JMSException
Put a String as a text messages, repeat n times. A null payload will result in a null message.

Parameters:
queueName - The queue name to put to
payload - the content of the payload
copies - the number of messages to put
Throws:
JMSException - any exception that occurs

getNextMessage

public Message getNextMessage(String queueName,
                              long readTimeout)
                       throws JMSException
GET the top message on a queue. Consumes the message. Accepts timeout value.

Parameters:
queueName - The quename to get from
readTimeout - The timeout to use
Returns:
the content of the text message if any
Throws:
JMSException - any exception that occured

getNextMessage

public Message getNextMessage(String queueName)
                       throws JMSException
GET the top message on a queue. Consumes the message.

Parameters:
queueName - The Queuename to get from
Returns:
The string content of the text message, if any received
Throws:
JMSException - any exception that occurs

consume

public void consume(String queueName,
                    int readTimeout)
             throws JMSException,
                    InterruptedException
Completely clears a queue. For readTimeout behaviour see Javadocs for javax.jms.MessageConsumer.

Parameters:
queueName - The Queue name to consume from
readTimeout - The timeout for each consume
Throws:
JMSException - Any exception that occurs during the consume
InterruptedException - If the consume thread was interrupted during a consume.


Licensed to the Apache Software Foundation