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