Debian Codegraph @

test/jpypetest/test_serial.py

raw symbols SCIP
1 # *****************************************************************************
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 #
15 # See NOTICE file for details.
16 #
17 # *****************************************************************************
18 from jpype import JException, java, JProxy, JClass
19 import os
20 import sys
21 import tempfile
22 import traceback
23 import common
24
25
26 class SerializationTestCase(common.JPypeTestCase):
27
28 def setUp(self):
29 super(SerializationTestCase, self).setUp()
30 self.tempname = tempfile.mktemp()
31
32 def tearDown(self):
33 os.remove(self.tempname)
34
35 def testSerialize(self):
36 o = JClass("jpype.serial.SerializationTest")()
37 tmp = self.tempname
38 fos = java.io.FileOutputStream(tmp)
39 oos = java.io.ObjectOutputStream(fos)
40 oos.writeObject(o)
41 oos.flush()
42 oos.close()
43 fos.close()
44
45
46 # The following cannto work because JPype has no way to simulate the "caller's ClassLoader"
47 # def testDeSerialize(self):
48 # fis = java.io.FileInputStream(self.tempname)
49 # ois = java.io.ObjectInputStream(fis)
50 #
51 # o = ois.readObject()
52 # ois.close()
53 # fis.close()