1   /*
2    * Created on 2004-12-19
3    *
4    * TODO To change the template for this generated file go to
5    * Window - Preferences - Java - Code Style - Code Templates
6    */
7   package org.sourceforge.jvb3d.Model;
8   
9   import java.io.ByteArrayInputStream;
10  import java.io.ByteArrayOutputStream;
11  import java.io.ObjectInputStream;
12  import java.io.ObjectOutputStream;
13  
14  import junit.framework.TestCase;
15  
16  /***
17   * @author spootnick
18   *
19   * TODO To change the template for this generated type comment go to
20   * Window - Preferences - Java - Code Style - Code Templates
21   */
22  public class MovableObjectTest extends TestCase {
23  
24  	private TestMovableObject obj1,obj2;
25  	/*
26  	 * @see TestCase#setUp()
27  	 */
28  	protected void setUp() throws Exception {
29  		super.setUp();
30  		obj1=new TestMovableObject();
31  		obj2=new TestMovableObject();
32  		obj1.isServer=false;
33  		obj2.isServer=false;
34  	}
35  
36  	/*
37  	 * @see TestCase#tearDown()
38  	 */
39  	protected void tearDown() throws Exception {
40  		super.tearDown();
41  	}
42  
43  	/***
44  	 * Constructor for MovableObjectTest.
45  	 * @param arg0
46  	 */
47  	public MovableObjectTest(String arg0) {
48  		super(arg0);
49  	}
50  	/*
51  	 * Testuje metode equals 
52  	 */
53  	public void testMovableObjectEquals(){
54  		assertTrue(!obj1.equals(null));
55  		assertEquals(obj1,new MovableObject());
56  		assertEquals(obj1,obj1);
57  		assertEquals(obj1,obj2);
58  		obj2.setSpeed(10f);
59  		
60  	}
61  	
62  	public void testMovableObjectExternalizable() throws Exception{
63  		ByteArrayOutputStream bao = new ByteArrayOutputStream();
64  		ObjectOutputStream out= new ObjectOutputStream(bao);
65  		obj1.setStrafeSpeed(10f);
66  		obj1.writeExternal(out);
67  		out.close();
68  		byte[] buf=bao.toByteArray(); 
69  		ByteArrayInputStream bai = new ByteArrayInputStream(buf);
70  		ObjectInputStream in = new ObjectInputStream(bai);
71  		obj2.readExternal(in);
72  		//obj2.setStrafeSpeed(1f);
73  		assertTrue("prêdkoœæ po deserializacji inna niz przed",obj2.getStrafeSpeed()==10f);
74  		assertEquals(obj1,obj2);
75  	}
76  
77  }