| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 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 |
|
| 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 |
|
| 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) |