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