001/*
002 *  jDTAUS Core API
003 *  Copyright (C) 2005 Christian Schulte
004 *  <cs@schulte.it>
005 *
006 *  This library is free software; you can redistribute it and/or
007 *  modify it under the terms of the GNU Lesser General Public
008 *  License as published by the Free Software Foundation; either
009 *  version 2.1 of the License, or any later version.
010 *
011 *  This library is distributed in the hope that it will be useful,
012 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
013 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014 *  Lesser General Public License for more details.
015 *
016 *  You should have received a copy of the GNU Lesser General Public
017 *  License along with this library; if not, write to the Free Software
018 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
019 *
020 */
021package org.jdtaus.core.container.test;
022
023import java.io.ObjectInputStream;
024import junit.framework.Assert;
025import junit.framework.TestCase;
026import org.jdtaus.core.container.Message;
027
028/**
029 * jUnit tests for {@code Message} implementations.
030 *
031 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
032 * @version $JDTAUS: MessageTest.java 8641 2012-09-27 06:45:17Z schulte $
033 */
034public class MessageTest extends TestCase
035{
036    //--MessageTest-------------------------------------------------------------
037
038    public void testObject() throws Exception
039    {
040        final Message m1 = new Message();
041        final Message m2 = new Message();
042
043        Assert.assertEquals( m1, m2 );
044        Assert.assertEquals( m1.hashCode(), m2.hashCode() );
045
046        System.out.println( m1.toString() );
047        System.out.println( m2.toString() );
048
049        m1.setName( "TEST" );
050        m2.setName( "TEST" );
051
052        Assert.assertEquals( m1, m2 );
053        Assert.assertEquals( m1.hashCode(), m2.hashCode() );
054
055        System.out.println( m1.toString() );
056        System.out.println( m2.toString() );
057
058        final Message clone1 = (Message) m1.clone();
059        final Message clone2 = (Message) m2.clone();
060
061        Assert.assertEquals( clone1, clone2 );
062        Assert.assertEquals( clone1.hashCode(), clone2.hashCode() );
063
064        System.out.println( clone1.toString() );
065        System.out.println( clone2.toString() );
066    }
067
068    public void testBackwardCompatibility_1_5() throws Exception
069    {
070        final ObjectInputStream in = new ObjectInputStream( this.getClass().
071            getResourceAsStream( "Message.ser" ) );
072
073        final Message current = new Message();
074        final Message serialized = (Message) in.readObject();
075
076        Assert.assertEquals( current, serialized );
077        Assert.assertEquals( current.hashCode(), serialized.hashCode() );
078    }
079
080    //-------------------------------------------------------------MessageTest--
081}