|
32 | 32 | from __future__ import print_function |
33 | 33 |
|
34 | 34 | # Standard library |
35 | | -from javaobj.utils import bytes_char |
36 | | -import javaobj.v2 as javaobj |
37 | 35 | import logging |
38 | 36 | import os |
39 | 37 | import subprocess |
|
47 | 45 | sys.path.insert(0, os.path.abspath(os.path.dirname(os.getcwd()))) |
48 | 46 |
|
49 | 47 | # Local |
| 48 | +from javaobj.utils import bytes_char, java_data_fd |
| 49 | +import javaobj.v2 as javaobj |
50 | 50 |
|
51 | 51 | # ------------------------------------------------------------------------------ |
52 | 52 |
|
@@ -247,6 +247,36 @@ def test_chars_rw(self): |
247 | 247 | pobj = javaobj.loads(jobj) |
248 | 248 | _logger.debug("Read char objects: %s", pobj) |
249 | 249 | self.assertEqual(pobj, expected) |
| 250 | + self.assertEqual(pobj, expected.decode("latin1")) |
| 251 | + |
| 252 | + def test_gzip_open(self): |
| 253 | + """ |
| 254 | + Tests if the GZip auto-uncompress works |
| 255 | + """ |
| 256 | + with java_data_fd(self.read_file("testChars.ser", stream=True)) as fd: |
| 257 | + base = fd.read() |
| 258 | + |
| 259 | + with java_data_fd( |
| 260 | + self.read_file("testChars.ser.gz", stream=True) |
| 261 | + ) as fd: |
| 262 | + gzipped = fd.read() |
| 263 | + |
| 264 | + self.assertEqual( |
| 265 | + base, gzipped, "Uncompressed content doesn't match the original" |
| 266 | + ) |
| 267 | + |
| 268 | + def test_chars_gzip(self): |
| 269 | + """ |
| 270 | + Reads testChars.ser.gz |
| 271 | + """ |
| 272 | + # Expected string as a UTF-16 string |
| 273 | + expected = "python-javaobj".encode("utf-16-be") |
| 274 | + |
| 275 | + jobj = self.read_file("testChars.ser.gz") |
| 276 | + pobj = javaobj.loads(jobj) |
| 277 | + _logger.debug("Read char objects: %s", pobj) |
| 278 | + self.assertEqual(pobj, expected) |
| 279 | + self.assertEqual(pobj, expected.decode("latin1")) |
250 | 280 |
|
251 | 281 | def test_double_rw(self): |
252 | 282 | """ |
|
0 commit comments