Skip to content

Commit 61b771d

Browse files
author
vbuell
committed
arrays
1 parent 59b2df2 commit 61b771d

File tree

6 files changed

+123
-1
lines changed

6 files changed

+123
-1
lines changed

eip_tests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ def test_0(self):
1616
print peiping.endpoint(self.simple_generator()).to("")
1717
peiping.run()
1818

19+
def test_parsing(self):
20+
print peiping.from_ascii("[http:/serv]->(mymethod)->[file:~/serv]")
21+
peiping.run()
22+
1923

2024
if __name__ == '__main__':
2125
unittest.main()

java/src/OneTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@
1212
import org.junit.Before;
1313
import org.junit.Test;
1414

15+
class ArrayClass implements Serializable {
16+
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+
22+
}
23+
1524
class SuperAaaa implements Serializable {
1625

1726
public String superString = "Super!!";
@@ -166,6 +175,15 @@ public void testSuper() throws Exception {
166175
oos.writeObject(ts);
167176
oos.flush();
168177
}
178+
179+
@Test
180+
public void testArrays() throws Exception {
181+
oos = new ObjectOutputStream(fos = new FileOutputStream("objArrays.ser"));
182+
oos.writeObject(new ArrayClass());
183+
oos.flush();
184+
}
185+
186+
169187

170188
// public void test_readObject() throws Exception {
171189
// String s = "HelloWorld";

javaobj.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def __init__(self):
8282
self.TC_CLASSDESC: self.do_classdesc,
8383
self.TC_OBJECT: self.do_object,
8484
self.TC_STRING: self.do_string,
85+
self.TC_ARRAY: self.do_array,
8586
self.TC_CLASS: self.do_class,
8687
self.TC_BLOCKDATA: self.do_blockdata,
8788
self.TC_REFERENCE: self.do_reference
@@ -288,6 +289,18 @@ def do_string(self, parent=None, ident=0):
288289
ba = self._readString()
289290
return str(ba)
290291

292+
def do_array(self, parent=None, ident=0):
293+
# TC_ARRAY classDesc newHandle (int)<size> values[size]
294+
self.print_ident("[array]", ident)
295+
classdesc = self.read_and_exec_opcode(ident=ident+1, expect=[self.TC_CLASSDESC, self.TC_PROXYCLASSDESC, self.TC_NULL])
296+
(size, ) = self._readStruct(">i")
297+
self.print_ident("size: " + str(size), ident)
298+
for i in range(size):
299+
res = self.read_and_exec_opcode(ident=ident+1)
300+
print res
301+
302+
return None
303+
291304
def do_reference(self, parent=None, ident=0):
292305
# TODO: Reference isn't supported yed
293306
(handle, reference) = self._readStruct(">HH")

peiping.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
import re
2+
import peiping_http as http
3+
4+
uri_map = {
5+
"http": http.HttpEndpoint,
6+
"cui": http.ConsoleEndpoint,
7+
"file": http.FileEndpoint
8+
}
9+
10+
routes = []
11+
12+
113
class Endpoint():
214
def to(self, object):
315
print type(object)
@@ -10,4 +22,20 @@ def endpoint(object):
1022

1123
def run():
1224
for route in routes:
13-
route.run()
25+
route.run()
26+
27+
def from_ascii(str):
28+
pat_endpoint = re.compile(r"\[(.+?)\]")
29+
# something like "[http:/serv]->(mymethod)->[file:~/serv]"
30+
res = pat_endpoint.findall(str)
31+
if res:
32+
print res#.group(1)
33+
pass
34+
35+
def route(destination):
36+
def wrap(function):
37+
def wrap_function(self, message):
38+
function(self, message)
39+
Stomping.add_route(destination, wrap_function)
40+
return wrap_function
41+
return wrap

peiping_http.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
2+
3+
class Endpoint():
4+
def create_producer():
5+
pass
6+
7+
def create_consumer():
8+
pass
9+
10+
11+
class ConsoleEndpoint(Endpoint):
12+
def create_producer():
13+
pass
14+
15+
def create_consumer():
16+
pass
17+
18+
class FileEndpoint(Endpoint):
19+
def create_producer():
20+
pass
21+
22+
def create_consumer():
23+
pass
24+
25+
class HttpEndpoint(Endpoint):
26+
def create_producer():
27+
pass
28+
29+
def create_consumer():
30+
pass
31+
32+
33+
34+
class Producer():
35+
pass
36+
37+
class HttProducer():
38+
# http://93z.org/notes/writing-werkzeug-routing-converter/
39+
pass
40+
41+
class FileProducer():
42+
pass
43+
44+
class ConsoleProducer():
45+
pass

tests.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,19 @@ def test_super(self):
106106
print pobj.bool
107107
print pobj.integer
108108

109+
def test_arrays(self):
110+
jobj = self.read_file("objArrays.ser")
111+
pobj = javaobj.loads(jobj)
112+
print pobj
113+
114+
classdesc = pobj.get_class()
115+
print classdesc
116+
print classdesc.fields_names
117+
print classdesc.fields_types
118+
119+
print pobj.childString
120+
print pobj.bool
121+
print pobj.integer
122+
109123
if __name__ == '__main__':
110124
unittest.main()

0 commit comments

Comments
 (0)