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