1 // serial.java -- Checks that object can bee serialized and deserialized. |
|
2 // |
|
3 // Copyright (c) 2003 Mark J. Wielaard (mark@klomp.org) |
|
4 // |
|
5 // This program is free software; you can redistribute it and/or modify |
|
6 // it under the terms of the GNU General Public License as published |
|
7 // by the Free Software Foundation, either version 2 of the License, or |
|
8 // (at your option) any later version. |
|
9 // |
|
10 // This program is distributed in the hope that it will be useful, but |
|
11 // WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 // GNU General Public License for more details. |
|
14 // |
|
15 // You should have received a copy of the GNU General Public License |
|
16 // along with this program; if not, write to the Free Software Foundation |
|
17 // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA |
|
18 |
|
19 // Tags: JDK1.2 |
|
20 |
|
21 package gnu.testlet.java.text.DecimalFormatSymbols; |
|
22 |
|
23 import gnu.testlet.Testlet; |
|
24 import gnu.testlet.TestHarness; |
|
25 |
|
26 import java.io.*; |
|
27 import java.text.DecimalFormatSymbols; |
|
28 import java.util.Locale; |
|
29 |
|
30 public class serial implements Testlet |
|
31 { |
|
32 private static String infinity = "supermuch"; |
|
33 private static String nan = "Ehe?"; |
|
34 |
|
35 public void test(TestHarness harness) |
|
36 { |
|
37 DecimalFormatSymbols dfs1 = new DecimalFormatSymbols(Locale.US); |
|
38 dfs1.setInfinity(infinity); |
|
39 dfs1.setNaN(nan); |
|
40 |
|
41 // Serialize and Deserialize.e |
|
42 Object o = null; |
|
43 try |
|
44 { |
|
45 ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
|
46 ObjectOutputStream oos = new ObjectOutputStream(baos); |
|
47 |
|
48 oos.writeObject(dfs1); |
|
49 oos.close(); |
|
50 |
|
51 byte[] bs = baos.toByteArray(); |
|
52 ByteArrayInputStream bois = new ByteArrayInputStream(bs); |
|
53 ObjectInputStream ois = new ObjectInputStream(bois); |
|
54 o = ois.readObject(); |
|
55 ois.close(); |
|
56 } |
|
57 catch (IOException ioe) |
|
58 { |
|
59 harness.debug(ioe); |
|
60 } |
|
61 catch (ClassNotFoundException cnfe) |
|
62 { |
|
63 harness.debug(cnfe); |
|
64 } |
|
65 |
|
66 DecimalFormatSymbols dfs2 = (DecimalFormatSymbols) o; |
|
67 harness.check(dfs1, dfs2); |
|
68 |
|
69 harness.check(dfs2.getInfinity(), infinity); |
|
70 harness.check(dfs2.getNaN(), nan); |
|
71 } |
|
72 |
|
73 } |
|
74 |
|