Ejemplo n.º 1
0
    def test_deserializing_java_output_1(self):
        try:
            byte_stream = _get_java_output_stream(self.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:
            pass
Ejemplo 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)
Ejemplo 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)
Ejemplo n.º 4
0
    def test_deserializing_java_output_1(self):
        try:
            byte_stream = _get_java_output_stream(self.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:
            pass
Ejemplo n.º 5
0
 def test_wu_ints(self):
     # test for self-consistency
     wu.writeVInt(self.stream, 42)
     wu.writeVLong(self.stream, 4000000000)
     self.stream.seek(0)
     self.assertEqual(42, wu.readVInt(self.stream))
     self.assertEqual(4000000000, wu.readVLong(self.stream))
Ejemplo n.º 6
0
 def test_wu_ints(self):
     # test for self-consistency
     wu.writeVInt(self.stream, 42)
     wu.writeVLong(self.stream, 4000000000)
     self.stream.seek(0)
     self.assertEqual(42, wu.readVInt(self.stream))
     self.assertEqual(4000000000, wu.readVLong(self.stream))