Beispiel #1
0
 def testSyncronizedFail(self):
     with self.assertRaisesRegex(TypeError, "Java object is required"):
         with jpype.synchronized(object()):
             pass
     with self.assertRaisesRegex(TypeError,
                                 "Java primitives cannot be used"):
         with jpype.synchronized(jpype.JInt(1)):
             pass
Beispiel #2
0
    def run(self):
        global glob, success, obj
        with synchronized(obj):
            # Increment the global resource
            glob += 1

            # Wait for a while
            time.sleep(0.1)

            # If anything else accessed then it was a fail
            if glob != 1:
                success = False

            # Decrement the global resoure
            glob -= 1
Beispiel #3
0
 def testSynchronizeFail(self):
     with self.assertRaises(TypeError):
         jpype.synchronized("hello")
Beispiel #4
0
 def testMonitor(self):
     JI = JClass("java.lang.Integer")
     with jpype.synchronized(JI) as monitor:
         self.assertIsInstance(str(monitor), str)
         self.assertIsInstance(repr(monitor), str)