1   /*
2    * The SmartWeb Framework
3    * Copyright (C) 2004-2006
4    *
5    * This library is free software; you can redistribute it and/or
6    * modify it under the terms of the GNU Lesser General Public
7    * License as published by the Free Software Foundation; either
8    * version 2.1 of the License, or (at your option) any later version.
9    *
10   * This library is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   * Lesser General Public License for more details.
14   *
15   * You should have received a copy of the GNU Lesser General Public
16   * License along with this library; if not, write to the Free Software
17   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18   *
19   * For further informations on the SmartWeb Framework please visit
20   *
21   *                        http://smartweb.sourceforge.net
22   */
23  package net.smartlab.web;
24  
25  import java.io.ByteArrayInputStream;
26  import java.io.ByteArrayOutputStream;
27  import java.io.ObjectInputStream;
28  import java.io.ObjectOutputStream;
29  
30  import junit.framework.TestCase;
31  
32  
33  /**
34   * @TODO documentation
35   * @author rlogiacco@smartlab.net
36   *
37   */
38  public class BusinessObjectTest extends TestCase {
39  
40  	/**
41  	 * @see junit.framework.TestCase#setUp()
42  	 */
43  	protected void setUp() throws Exception {
44  		super.setUp();
45  	}
46  
47  	/**
48  	 * @see junit.framework.TestCase#tearDown()
49  	 */
50  	protected void tearDown() throws Exception {
51  		super.tearDown();
52  	}
53  	
54  	public void testSerialization() throws Exception {
55  		Mock mock = new Mock();
56  		mock.setVersion(25);
57  		
58  		super.assertNotNull(mock.logger);
59  		
60  		// serialize
61  		ByteArrayOutputStream buffer = new ByteArrayOutputStream();
62  		ObjectOutputStream out = new ObjectOutputStream(buffer);
63  		out.writeObject(mock);
64  		out.close();
65  
66  		// deserialize
67  	    byte[] pickled = buffer.toByteArray();
68  	    ByteArrayInputStream read = new ByteArrayInputStream(pickled);
69  	    ObjectInputStream in = new ObjectInputStream(read);
70  	    Mock mockClone = (Mock)in.readObject();
71  	    
72  	    super.assertNotNull(mockClone.logger);
73  	}
74  	
75  	private static class Mock extends BusinessObject {
76  
77  		private static final long serialVersionUID = 8275056178438855026L;
78  		
79  	}
80  }