def test_03_09_cw_get_method(self):
     sclass = J.class_for_name('java.lang.String')
     iclass = J.get_static_field('java/lang/Integer', 'TYPE', 
                                 'Ljava/lang/Class;')
     c = J.get_class_wrapper('java.lang.String')
     m = c.getMethod('charAt', [ iclass ])
     self.assertEqual(J.to_string(J.call(m, 'getReturnType', '()Ljava/lang/Class;')), 'char')
     m = c.getMethod('concat', [ sclass])
     self.assertEqual(J.to_string(J.call(m, 'getReturnType', '()Ljava/lang/Class;')), 
                      'class java.lang.String')
 def test_01_07_get_dictionary_wrapper(self):
     properties = J.static_call("java/lang/System", "getProperties",
                                "()Ljava/util/Properties;")
     d = J.get_dictionary_wrapper(properties)
     self.assertTrue(d.size() > 10)
     self.assertFalse(d.isEmpty())
     keys = J.get_enumeration_wrapper(d.keys())
     values = J.get_enumeration_wrapper(d.elements())
     n_elems = d.size()
     for i in range(n_elems):
         self.assertTrue(keys.hasMoreElements())
         key = J.to_string(keys.nextElement())
         self.assertTrue(values.hasMoreElements())
         value = J.to_string(values.nextElement())
         self.assertEqual(J.to_string(d.get(key)), value)
     self.assertFalse(keys.hasMoreElements())
     self.assertFalse(values.hasMoreElements())
 def test_01_09_jdictionary_to_string_dictionary(self):
     properties = J.static_call("java/lang/System", "getProperties",
                                "()Ljava/util/Properties;")
     d = J.get_dictionary_wrapper(properties)
     pyd = J.jdictionary_to_string_dictionary(properties)
     keys = J.jenumeration_to_string_list(d.keys())
     for key in keys:
         value = J.to_string(d.get(key))
         self.assertEqual(pyd[key], value)
 def test_01_08_jenumeration_to_string_list(self):
     properties = J.static_call("java/lang/System", "getProperties",
                                "()Ljava/util/Properties;")
     d = J.get_dictionary_wrapper(properties)
     keys = J.jenumeration_to_string_list(d.keys())
     enum = J.get_enumeration_wrapper(d.keys())
     for i in range(d.size()):
         key = J.to_string(enum.nextElement())
         self.assertEqual(key, keys[i])
 def test_01_06_get_enumeration_wrapper(self):
     properties = J.static_call("java/lang/System", "getProperties",
                                "()Ljava/util/Properties;")
     keys = J.call(properties, "keys", "()Ljava/util/Enumeration;")
     enum = J.get_enumeration_wrapper(keys)
     has_java_vm_name = False
     while(enum.hasMoreElements()):
         key = J.to_string(enum.nextElement())
         if key == "java.vm.name":
             has_java_vm_name = True
     self.assertTrue(has_java_vm_name)
 def test_01_02_make_instance(self):
     jobject = J.make_instance("java/lang/Object", "()V")
     self.assertTrue(J.to_string(jobject).startswith("java.lang.Object"))
 def test_01_01_to_string(self):
     jstring = self.env.new_string_utf("Hello, world")
     self.assertEqual(J.to_string(jstring), "Hello, world")
 def test_04_03_field_type(self):
     c = J.get_class_wrapper('java.lang.Byte')
     f = J.get_field_wrapper(c.getField('MAX_VALUE'))
     t = f.getType()
     self.assertEqual(J.to_string(t), 'byte')
 def test_04_01_field_get(self):
     c = J.get_class_wrapper('java.lang.Byte')
     f = J.get_field_wrapper(c.getField('MAX_VALUE'))
     v = f.get(None)
     self.assertEqual(J.to_string(v), '127')
Beispiel #10
0
 def test_03_05_cw_get_annotations(self):
     c = J.get_class_wrapper('java.security.Identity')
     annotations = c.getAnnotations()
     annotations = J.get_env().get_object_array_elements(annotations)
     self.assertEqual(len(annotations), 1)
     self.assertEqual(J.to_string(annotations[0]),'@java.lang.Deprecated()')