org.exolab.jmscts.core
Class AbstractMessageVerifier

java.lang.Object
  |
  +--org.exolab.jmscts.core.AbstractMessageVerifier
All Implemented Interfaces:
MessageVerifier, java.io.Serializable
Direct Known Subclasses:
EmptyMessageVerifier, MessagePopulatorVerifier

public abstract class AbstractMessageVerifier
extends java.lang.Object
implements MessageVerifier

A helper class for verifying the content of messages. This class provides no verification functionality - that is left to sublasses.

It does provide helper methods to:

Version:
$Revision: 1.4 $ $Date: 2004/02/03 21:52:06 $
Author:
Tim Anderson
See Also:
MessageVerifier, Serialized Form

Constructor Summary
AbstractMessageVerifier()
          Construct a new instance.
AbstractMessageVerifier(java.lang.Class exception)
          Construct an instance with the expected exception thrown when methods are invoked
 
Method Summary
protected  void equal(java.lang.Object value, java.lang.Object expected)
          Helper to compare two objects for equality
protected  void expect(javax.jms.Message message, java.lang.String method, java.lang.Object expected)
          Helper to invoke a method taking no arguments, and verify that the result matches that expected
protected  void expect(javax.jms.Message message, java.lang.String method, java.lang.Object[] values, java.lang.Object expected)
          Helper to invoke a method taking a list of arguments, and verify that the result matches that expected
protected  void expect(javax.jms.Message message, java.lang.String method, java.lang.Object value, java.lang.Object expected)
          Helper to invoke a method taking a single argument, and verify that the result matches that expected
 java.lang.Class getExpectedException()
          Return the exception type expected to be thrown by methods
protected  MethodCache getMethods()
          Returns a cache of methods for a message, to avoid expensive reflect operations.
protected  java.lang.Object invoke(javax.jms.Message message, java.lang.String method)
          Invoke a method taking no arguments
protected  java.lang.Object invoke(javax.jms.Message message, java.lang.String method, java.lang.Object value)
          Invoke a method taking a single argument
protected  java.lang.Object invoke(javax.jms.Message message, java.lang.String method, java.lang.Object[] values)
          Invoke a method taking multiple arguments
 void verify(javax.jms.Message message)
          Verify a message's content.
 void verifyBytesMessage(javax.jms.BytesMessage message)
          Verify a BytesMessage instance.
 void verifyMapMessage(javax.jms.MapMessage message)
          Verify a MapMessage instance.
 void verifyMessage(javax.jms.Message message)
          Verify a Message instance.
 void verifyObjectMessage(javax.jms.ObjectMessage message)
          Verify an ObjectMessage instance.
 void verifyStreamMessage(javax.jms.StreamMessage message)
          Verify a StreamMessage instance.
 void verifyTextMessage(javax.jms.TextMessage message)
          Verify a TextMessage instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractMessageVerifier

public AbstractMessageVerifier()
Construct a new instance. No exceptions are expected to be thrown when invoking methods

AbstractMessageVerifier

public AbstractMessageVerifier(java.lang.Class exception)
Construct an instance with the expected exception thrown when methods are invoked
Parameters:
exception - the expected exception type when methods are invoked
Method Detail

verify

public void verify(javax.jms.Message message)
            throws java.lang.Exception
Verify a message's content. This method delegates the message to the appropriate verifier method.
Specified by:
verify in interface MessageVerifier
Parameters:
message - the message to verify
Throws:
java.lang.Exception - for any error

verifyMessage

public void verifyMessage(javax.jms.Message message)
                   throws java.lang.Exception
Verify a Message instance. This method throws UnsupportedOperationException if invoked. Subclasses needing the functionality must implement it.
Parameters:
message - the message to verify
Throws:
java.lang.Exception - for any error

verifyBytesMessage

public void verifyBytesMessage(javax.jms.BytesMessage message)
                        throws java.lang.Exception
Verify a BytesMessage instance. This method throws UnsupportedOperationException if invoked. Subclasses needing the functionality must implement it.
Parameters:
message - the message to verify
Throws:
java.lang.Exception - for any error

verifyMapMessage

public void verifyMapMessage(javax.jms.MapMessage message)
                      throws java.lang.Exception
Verify a MapMessage instance. This method throws UnsupportedOperationException if invoked. Subclasses needing the functionality must implement it.
Parameters:
message - the message to verify
Throws:
java.lang.Exception - for any error

verifyObjectMessage

public void verifyObjectMessage(javax.jms.ObjectMessage message)
                         throws java.lang.Exception
Verify an ObjectMessage instance. This method throws UnsupportedOperationException if invoked. Subclasses needing the functionality must implement it.
Parameters:
message - the message to verify
Throws:
java.lang.Exception - for any error

verifyStreamMessage

public void verifyStreamMessage(javax.jms.StreamMessage message)
                         throws java.lang.Exception
Verify a StreamMessage instance. This method throws UnsupportedOperationException if invoked. Subclasses needing the functionality must implement it.
Parameters:
message - the message to verify
Throws:
java.lang.Exception - for any error

verifyTextMessage

public void verifyTextMessage(javax.jms.TextMessage message)
                       throws java.lang.Exception
Verify a TextMessage instance. This method throws UnsupportedOperationException if invoked. Subclasses needing the functionality must implement it.
Parameters:
message - the message to verify
Throws:
java.lang.Exception - for any error

getExpectedException

public java.lang.Class getExpectedException()
Return the exception type expected to be thrown by methods
Returns:
the expected exception type, or null, if no exceptions are expected

invoke

protected java.lang.Object invoke(javax.jms.Message message,
                                  java.lang.String method)
                           throws java.lang.Exception
Invoke a method taking no arguments
Parameters:
message - the message to invoke the method on
method - the method to invoke
Returns:
the result of the method invocation, or null if it returns void, or didn't complete
Throws:
java.lang.Exception - for any error

invoke

protected java.lang.Object invoke(javax.jms.Message message,
                                  java.lang.String method,
                                  java.lang.Object value)
                           throws java.lang.Exception
Invoke a method taking a single argument
Parameters:
message - the message to invoke the method on
method - the method to invoke
value - the argument to pass to the method
Returns:
the result of the method invocation, or null if it returns void, or didn't complete
Throws:
java.lang.Exception - for any error

invoke

protected java.lang.Object invoke(javax.jms.Message message,
                                  java.lang.String method,
                                  java.lang.Object[] values)
                           throws java.lang.Exception
Invoke a method taking multiple arguments
Parameters:
message - the message to invoke the method on
method - the method to invoke
values - the arguments to pass to the method
Returns:
the result of the method invocation, or null if it returns void, or didn't complete
Throws:
java.lang.Exception - for any error

expect

protected void expect(javax.jms.Message message,
                      java.lang.String method,
                      java.lang.Object expected)
               throws java.lang.Exception
Helper to invoke a method taking no arguments, and verify that the result matches that expected
Parameters:
message - the message to invoke the method on
method - the method to invoke
expected - the expected return value
Throws:
java.lang.Exception - for any error

expect

protected void expect(javax.jms.Message message,
                      java.lang.String method,
                      java.lang.Object value,
                      java.lang.Object expected)
               throws java.lang.Exception
Helper to invoke a method taking a single argument, and verify that the result matches that expected
Parameters:
message - the message to invoke the method on
method - the method to invoke
value - the argument to pass to the method
expected - the expected return value
Throws:
java.lang.Exception - for any error

expect

protected void expect(javax.jms.Message message,
                      java.lang.String method,
                      java.lang.Object[] values,
                      java.lang.Object expected)
               throws java.lang.Exception
Helper to invoke a method taking a list of arguments, and verify that the result matches that expected
Parameters:
message - the message to invoke the method on
method - the method to invoke
values - the arguments to pass to the method
expected - the expected return value
Throws:
java.lang.Exception - for any error

equal

protected void equal(java.lang.Object value,
                     java.lang.Object expected)
              throws java.lang.Exception
Helper to compare two objects for equality
Parameters:
value - the value to compare against
expected - the expected value
Throws:
java.lang.Exception - if the objects aren't equal

getMethods

protected MethodCache getMethods()
Returns a cache of methods for a message, to avoid expensive reflect operations. This implementation returns null - subclasses needing improved performance should provide their own implementation
Returns:
null


Copyright © 2001-2004 JMS CTS Team. All Rights Reserved.