[jboss-cvs] jboss-serialization/tests/org/jboss/serial/immutable ...

Clebert Suconic csuconic at jboss.com
Mon Apr 9 19:05:21 EDT 2007


  User: csuconic
  Date: 07/04/09 19:05:21

  Added:       tests/org/jboss/serial/immutable 
                        ImmutableClassesTestCase.java
  Log:
  http://jira.jboss.org/jira/browse/JBSER-84 - Basic implementation
  
  Revision  Changes    Path
  1.1      date: 2007/04/09 23:05:21;  author: csuconic;  state: Exp;jboss-serialization/tests/org/jboss/serial/immutable/ImmutableClassesTestCase.java
  
  Index: ImmutableClassesTestCase.java
  ===================================================================
  package org.jboss.serial.immutable;
  
  import junit.framework.TestCase;
  
  import java.io.*;
  
  import org.jboss.serial.io.JBossObjectInputStream;
  import org.jboss.serial.io.JBossObjectOutputStream;
  
  public class ImmutableClassesTestCase extends TestCase
  {
  	
  	public void testImmutableGraph() throws Exception
  	{
  		Graph graph = new Graph();
  		graph.str1 = new String("str1");
  		graph.str2 = new String("str1");
  		
  		assertEquals(graph.str1, graph.str2);
  		assertNotSame(graph.str1, graph.str2);
  		
  		ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
  		JBossObjectOutputStream jbout = new JBossObjectOutputStream(byteOut);
  		jbout.writeObject(graph);
  		jbout.close();
  		
  		
  		JBossObjectInputStream jbinput = new JBossObjectInputStream(new ByteArrayInputStream(byteOut.toByteArray()));
  		Graph graph2 = (Graph)jbinput.readObject();
  		
  		assertNotSame (graph, graph2);
  		assertEquals(graph2.str1, graph2.str2);
  		assertSame(graph2.str1, graph2.str2);
  		
  	}
  	
  	
  	
  	static class Graph
  	{
  		public Graph()
  		{
  		}
  		
  		String str1;
  		String str2;
  	}
  
  }
  
  
  



More information about the jboss-cvs-commits mailing list