def test_enumeration_to_list(self): """ Tests method enumeration_to_list. """ lin = ["A", "B", "C", "D"] v = javabridge.make_instance("java/util/Vector", "()V") for element in lin: javabridge.call(v, "add", "(Ljava/lang/Object;)Z", element) enm = javabridge.call(v, "elements", "()Ljava/util/Enumeration;") lout = types.enumeration_to_list(enm) self.assertEqual(lin, lout, msg="Elements differ")
def values(self): """ Returns the labels, strings or relation-values. :return: all the values, None if not NOMINAL, STRING, or RELATION :rtype: list """ enm = javabridge.call(self.jobject, "enumerateValues", "()Ljava/util/Enumeration;") if enm is None: return None else: return types.enumeration_to_list(enm)
def test_read_write(self): """ Tests methods read and write. """ fname = self.tempfile("readwrite.ser") self.delfile(fname) lin = ["A", "B", "C", "D"] vin = javabridge.make_instance("java/util/Vector", "()V") for element in lin: javabridge.call(vin, "add", "(Ljava/lang/Object;)Z", element) serialization.write(fname, vin) self.assertTrue(os.path.exists(fname), msg="Failed to write to " + fname + "?") vout = serialization.read(fname) self.assertIsNotNone(vout, msg="Failed to read from " + fname + "?") enm = javabridge.call(vin, "elements", "()Ljava/util/Enumeration;") lout = types.enumeration_to_list(enm) self.delfile(fname) self.assertEqual(lin, lout, msg="Input/output differ")