Debian Codegraph @

test/jpypetest/test_shutdown.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 import unittest
19 import jpype
20 import subrun
21
22
23 @subrun.TestCase
24 class ShutdownTest(unittest.TestCase):
25
26 @classmethod
27 def setUpClass(cls):
28 jpype.startJVM(convertStrings=False)
29
30 # Create some resources
31 cls.jstr = jpype.java.lang.String("good morning")
32 cls.jobj = jpype.java.lang.Object()
33 cls.jcls = jpype.JClass("java.lang.String")
34 cls.jarray = jpype.JArray(jpype.JInt)([1, 2, 3, 4])
35
36 # Then blow everything up
37 jpype.shutdownJVM()
38
39 def testArrayGet(self):
40 with self.assertRaises(jpype.JVMNotRunning):
41 type(self).jarray[0]
42
43 def testArraySet(self):
44 with self.assertRaises(jpype.JVMNotRunning):
45 type(self).jarray[0] = 1
46
47 def testArrayGetSlice(self):
48 with self.assertRaises(jpype.JVMNotRunning):
49 type(self).jarray[0:2]
50
51 def testArraySetSlice(self):
52 with self.assertRaises(jpype.JVMNotRunning):
53 type(self).jarray[0:2] = [1, 2]
54
55 def testArrayStr(self):
56 with self.assertRaises(jpype.JVMNotRunning):
57 str(type(self).jarray)
58
59 def testClassCtor(self):
60 with self.assertRaises(jpype.JVMNotRunning):
61 obj = type(self).jcls()
62
63 def testObjectInvoke(self):
64 with self.assertRaises(jpype.JVMNotRunning):
65 type(self).jobj.wait()
66
67 def testObjectStr(self):
68 with self.assertRaises(jpype.JVMNotRunning):
69 str(type(self).jobj)
70
71 def testStringInvoke(self):
72 with self.assertRaises(jpype.JVMNotRunning):
73 type(self).jstr.substring(1)
74
75 def testStringStr(self):
76 with self.assertRaises(jpype.JVMNotRunning):
77 str(type(self).jstr)