|
12 | 12 | import org.junit.Before; |
13 | 13 | import org.junit.Test; |
14 | 14 |
|
15 | | -class ArrayClass implements Serializable { |
| 15 | +enum Color |
| 16 | +{ |
| 17 | + RED("RED"), GREEN("GREEN"), BLUE("BLUE"), UNKNOWN("UNKNOWN"); |
| 18 | + private final String value; |
| 19 | + |
| 20 | + Color(String value) |
| 21 | + { |
| 22 | + this.value = value; |
| 23 | + } |
16 | 24 |
|
17 | | - public String[] stringArr = {"1", "2", "3"}; |
18 | | - public int[] integerArr = {1,2,3}; |
19 | | - public boolean[] boolArr = {true, false, true}; |
20 | | - public TestConcrete[] concreteArr = {new TestConcrete(), new TestConcrete()}; |
21 | | - |
| 25 | + public String getValue() |
| 26 | + { |
| 27 | + return value; |
| 28 | + } |
| 29 | +} |
| 30 | + |
| 31 | +class ClassWithEnum implements Serializable { |
| 32 | + public Color color = Color.GREEN; |
| 33 | + public Color[] colors = {Color.GREEN, Color.BLUE, Color.RED}; |
22 | 34 | } |
23 | 35 |
|
24 | 36 | class SuperAaaa implements Serializable { |
@@ -177,13 +189,13 @@ public void testSuper() throws Exception { |
177 | 189 | } |
178 | 190 |
|
179 | 191 | @Test |
180 | | - public void testArrays() throws Exception { |
181 | | - oos = new ObjectOutputStream(fos = new FileOutputStream("objArrays.ser")); |
182 | | - oos.writeObject(new ArrayClass()); |
| 192 | + public void testEnums() throws Exception { |
| 193 | + oos = new ObjectOutputStream(fos = new FileOutputStream("objEnums.ser")); |
| 194 | + ClassWithEnum ts = new ClassWithEnum(); |
| 195 | + |
| 196 | + oos.writeObject(ts); |
183 | 197 | oos.flush(); |
184 | 198 | } |
185 | | - |
186 | | - |
187 | 199 |
|
188 | 200 | // public void test_readObject() throws Exception { |
189 | 201 | // String s = "HelloWorld"; |
|
0 commit comments