1 42 43 package org.jfree.ui.junit; 44 45 import java.io.ByteArrayInputStream ; 46 import java.io.ByteArrayOutputStream ; 47 import java.io.ObjectInput ; 48 import java.io.ObjectInputStream ; 49 import java.io.ObjectOutput ; 50 import java.io.ObjectOutputStream ; 51 52 import junit.framework.Test; 53 import junit.framework.TestCase; 54 import junit.framework.TestSuite; 55 56 import org.jfree.ui.Layer; 57 58 61 public class LayerTests extends TestCase { 62 63 68 public static Test suite() { 69 return new TestSuite(LayerTests.class); 70 } 71 72 77 public LayerTests(final String name) { 78 super(name); 79 } 80 81 84 public void testEquals() { 85 assertTrue(Layer.FOREGROUND.equals(Layer.FOREGROUND)); 86 assertTrue(Layer.BACKGROUND.equals(Layer.BACKGROUND)); 87 assertFalse(Layer.FOREGROUND.equals(Layer.BACKGROUND)); 88 } 89 90 93 public void testSerialization() { 94 95 final Layer l1 = Layer.FOREGROUND; 96 Layer l2 = null; 97 98 try { 99 final ByteArrayOutputStream buffer = new ByteArrayOutputStream (); 100 final ObjectOutput out = new ObjectOutputStream (buffer); 101 out.writeObject(l1); 102 out.close(); 103 104 final ObjectInput in = new ObjectInputStream (new ByteArrayInputStream (buffer.toByteArray())); 105 l2 = (Layer) in.readObject(); 106 in.close(); 107 } 108 catch (Exception e) { 109 System.out.println(e.toString()); 110 } 111 assertTrue(l1 == l2); 112 113 } 114 115 } 116 | Popular Tags |