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.Implementations;
027import org.jdtaus.core.container.Specification;
028
029/**
030 * jUnit tests for {@code Specification} implementations.
031 *
032 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
033 * @version $JDTAUS: SpecificationTest.java 8641 2012-09-27 06:45:17Z schulte $
034 */
035public class SpecificationTest extends TestCase
036{
037    //--SpecificationTest-------------------------------------------------------
038
039    public void testObject() throws Exception
040    {
041        final Specification s1 = new Specification();
042        final Specification s2 = new Specification();
043
044        Assert.assertEquals( s1, s2 );
045        Assert.assertEquals( s1.hashCode(), s2.hashCode() );
046
047        System.out.println( s1.toString() );
048        System.out.println( s2.toString() );
049
050        s1.setImplementations( new Implementations() );
051        s2.setImplementations( new Implementations() );
052
053        Assert.assertEquals( s1, s2 );
054        Assert.assertEquals( s1.hashCode(), s2.hashCode() );
055
056        System.out.println( s1.toString() );
057        System.out.println( s2.toString() );
058
059        final Specification clone1 = (Specification) s1.clone();
060        final Specification clone2 = (Specification) s2.clone();
061
062        Assert.assertEquals( clone1, clone2 );
063        Assert.assertEquals( clone1.hashCode(), clone2.hashCode() );
064
065        System.out.println( clone1.toString() );
066        System.out.println( clone2.toString() );
067    }
068
069    public void testBackwardCompatibility_1_0() throws Exception
070    {
071        final ObjectInputStream in = new ObjectInputStream( this.getClass().
072            getResourceAsStream( "Specification.ser" ) );
073
074        final Specification current = new Specification();
075        final Specification serialized = (Specification) in.readObject();
076
077        Assert.assertEquals( current, serialized );
078        Assert.assertEquals( current.hashCode(), serialized.hashCode() );
079    }
080
081    //-------------------------------------------------------SpecificationTest--
082}