Exemplo n.º 1
0
    def test_deserializing_java_output_2(self):
        try:
            byte_stream = _get_java_output_stream(self.wd)

            # read integers
            self.assertEqual(42, srl.deserialize_vint(byte_stream))
            self.assertEqual(4242, srl.deserialize_vint(byte_stream))
            self.assertEqual(424242, srl.deserialize_vint(byte_stream))
            self.assertEqual(42424242, srl.deserialize_vint(byte_stream))
            self.assertEqual(-42, srl.deserialize_vint(byte_stream))

            # longs
            self.assertEqual(42, srl.deserialize_vint(byte_stream))
            self.assertEqual(424242, srl.deserialize_vint(byte_stream))
            self.assertEqual(4242424242, srl.deserialize_vint(byte_stream))

            # strings
            # first one is plain ASCII
            self.assertEqual(u"hello world", wu.readString(byte_stream))
            # second has accented characters
            self.assertEqual(u"oggi è giovedì", wu.readString(byte_stream))

            # final piece is an encoded Text object
            self.assertEqual(
                u"à Text object", srl.deserialize_text(byte_stream)
            )
        finally:
            pass
Exemplo n.º 2
0
    def test_deserializing_java_output(self):
        wd = tempfile.mkdtemp(prefix="pydoop_")
        try:
            byte_stream = _get_java_output_stream(wd)

            # read integers
            self.assertEqual(42, wu.readVInt(byte_stream))
            self.assertEqual(4242, wu.readVInt(byte_stream))
            self.assertEqual(424242, wu.readVInt(byte_stream))
            self.assertEqual(42424242, wu.readVInt(byte_stream))
            self.assertEqual(-42, wu.readVInt(byte_stream))

            # longs
            self.assertEqual(42, wu.readVLong(byte_stream))
            self.assertEqual(424242, wu.readVLong(byte_stream))
            self.assertEqual(4242424242, wu.readVLong(byte_stream))

            # strings
            # first one is plain ASCII
            self.assertEqual(u"hello world", wu.readString(byte_stream))
            # second has accented characters
            self.assertEqual(u"oggi è giovedì", wu.readString(byte_stream))

            # final piece is an encoded Text object
            self.assertEqual(u"à Text object",
                             srl.deserialize_text(byte_stream))
        finally:
            shutil.rmtree(wd)
Exemplo n.º 3
0
    def test_deserializing_java_output(self):
        wd = tempfile.mkdtemp(prefix="pydoop_")
        try:
            byte_stream = _get_java_output_stream(wd)

            # read integers
            self.assertEqual(42, wu.readVInt(byte_stream))
            self.assertEqual(4242, wu.readVInt(byte_stream))
            self.assertEqual(424242, wu.readVInt(byte_stream))
            self.assertEqual(42424242, wu.readVInt(byte_stream))
            self.assertEqual(-42, wu.readVInt(byte_stream))

            # longs
            self.assertEqual(42, wu.readVLong(byte_stream))
            self.assertEqual(424242, wu.readVLong(byte_stream))
            self.assertEqual(4242424242, wu.readVLong(byte_stream))

            # strings
            # first one is plain ASCII
            self.assertEqual(u"hello world", wu.readString(byte_stream))
            # second has accented characters
            self.assertEqual(u"oggi è giovedì", wu.readString(byte_stream))

            # final piece is an encoded Text object
            self.assertEqual(u"à Text object", srl.deserialize_text(byte_stream))
        finally:
            shutil.rmtree(wd)
Exemplo n.º 4
0
    def test_deserializing_java_output_2(self):
        try:
            byte_stream = _get_java_output_stream(self.wd)

            # read integers
            self.assertEqual(42, srl.deserialize_vint(byte_stream))
            self.assertEqual(4242, srl.deserialize_vint(byte_stream))
            self.assertEqual(424242, srl.deserialize_vint(byte_stream))
            self.assertEqual(42424242, srl.deserialize_vint(byte_stream))
            self.assertEqual(-42, srl.deserialize_vint(byte_stream))

            # longs
            self.assertEqual(42, srl.deserialize_vint(byte_stream))
            self.assertEqual(424242, srl.deserialize_vint(byte_stream))
            self.assertEqual(4242424242, srl.deserialize_vint(byte_stream))

            # strings
            # first one is plain ASCII
            self.assertEqual(u"hello world", wu.readString(byte_stream))
            # second has accented characters
            self.assertEqual(u"oggi è giovedì", wu.readString(byte_stream))

            # final piece is an encoded Text object
            self.assertEqual(
                u"à Text object", srl.deserialize_text(byte_stream)
            )
        finally:
            pass
Exemplo n.º 5
0
 def test_wu_nonascii_string(self):
     # test for self-consistency
     wu.writeString(self.stream, u"àéìòù")
     self.stream.seek(0)
     self.assertEqual(u"àéìòù", wu.readString(self.stream))
Exemplo n.º 6
0
 def test_wu_ascii_string(self):
     # test for self-consistency
     wu.writeString(self.stream, "simple")
     self.stream.seek(0)
     self.assertEqual(u"simple", wu.readString(self.stream))
Exemplo n.º 7
0
 def test_wu_nonascii_string(self):
     # test for self-consistency
     wu.writeString(self.stream, u"àéìòù")
     self.stream.seek(0)
     self.assertEqual(u"àéìòù", wu.readString(self.stream))
Exemplo n.º 8
0
 def test_wu_ascii_string(self):
     # test for self-consistency
     wu.writeString(self.stream, "simple")
     self.stream.seek(0)
     self.assertEqual(u"simple", wu.readString(self.stream))