/*
 * Created on Mar 4, 2004
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
package org.codehaus.activemq.message;

import junit.framework.TestCase;

import javax.jms.JMSException;

/**
 * @version $Revision: 1.1 $
 */
public class ActiveMQObjectMessageTest extends TestCase {

    public static void main(String[] args) {
        junit.textui.TestRunner.run(ActiveMQObjectMessageTest.class);
    }

    /*
     * @see TestCase#setUp()
     */
    protected void setUp() throws Exception {
        super.setUp();
    }

    /*
     * @see TestCase#tearDown()
     */
    protected void tearDown() throws Exception {
        super.tearDown();
    }

    /**
     * Constructor for ActiveMQObjectMessageTest.
     *
     * @param arg0
     */
    public ActiveMQObjectMessageTest(String arg0) {
        super(arg0);
    }

    public void testGetPacketType() {
        ActiveMQObjectMessage msg = new ActiveMQObjectMessage();
        assertTrue(msg.getPacketType() == Packet.ACTIVEMQ_OBJECT_MESSAGE);
    }

    public void testSetObject() {
        ActiveMQObjectMessage msg = new ActiveMQObjectMessage();
        String str = "testText";
        try {
            msg.setObject(str);
            assertTrue(msg.getObject() == str);
        }
        catch (JMSException e) {
            e.printStackTrace();
        }
        boolean readOnlyTest = false;
        msg.setReadOnly(true);
        try {
            msg.setObject(str);
        }
        catch (JMSException e) {
            readOnlyTest = true;
        }
        assertTrue(readOnlyTest);
    }


}
