Skip to content

Commit 2124aef

Browse files
author
vbuell
committed
enum test added
1 parent 6b34f7f commit 2124aef

File tree

3 files changed

+33
-11
lines changed

3 files changed

+33
-11
lines changed

java/src/OneTest.java

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,25 @@
1212
import org.junit.Before;
1313
import org.junit.Test;
1414

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+
}
1624

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};
2234
}
2335

2436
class SuperAaaa implements Serializable {
@@ -177,13 +189,13 @@ public void testSuper() throws Exception {
177189
}
178190

179191
@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);
183197
oos.flush();
184198
}
185-
186-
187199

188200
// public void test_readObject() throws Exception {
189201
// String s = "HelloWorld";

objEnums.ser

190 Bytes
Binary file not shown.

tests.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,16 @@ def test_arrays(self):
126126
print pobj.boolArr
127127
print pobj.concreteArr
128128

129+
def test_enums(self):
130+
jobj = self.read_file("objEnums.ser")
131+
pobj = javaobj.loads(jobj)
132+
print pobj
133+
134+
classdesc = pobj.get_class()
135+
print classdesc
136+
print classdesc.fields_names
137+
print classdesc.fields_types
138+
129139
def test_sun_example(self):
130140
marshaller = javaobj.JavaObjectUnmarshaller(open("sunExample.ser"))
131141
pobj = marshaller.readObject()

0 commit comments

Comments
 (0)