cache: fix compression with encryption

This commit is contained in:
Adam
2017-12-16 18:24:00 -05:00
parent cba9866304
commit 21f2543059
2 changed files with 38 additions and 15 deletions

View File

@@ -131,7 +131,7 @@ public class DataFileTest
}
@Test
public void testKeys() throws IOException
public void testEnc() throws IOException
{
File file = folder.newFile();
int[] keys = new int[]
@@ -153,4 +153,28 @@ public class DataFileTest
Assert.assertEquals(res.crc, res2.crc);
Assert.assertEquals(42, res2.revision);
}
@Test
public void testEncGz() throws IOException
{
File file = folder.newFile();
int[] keys = new int[]
{
4, 8, 15, 16
};
DataFile df = new DataFile(file);
byte[] compressedData = DataFile.compress("testtesttesttest1".getBytes(), CompressionType.GZ, 42, keys);
DataFileWriteResult res = df.write(42, 3, compressedData, 0);
compressedData = df.read(42, 3, res.sector, res.compressedLength);
DataFileReadResult res2 = DataFile.decompress(compressedData, keys);
byte[] buf = res2.data;
String str = new String(buf);
Assert.assertEquals("testtesttesttest1", str);
Assert.assertEquals(res.crc, res2.crc);
Assert.assertEquals(42, res2.revision);
}
}