@Test
public void testBackup() throws IOException {
//Graph downloadedTestGraphX = null;
//Graph downloadedTestGraphY = null;
Graph downloadedBackupContentsGraph = null;
byte[] download = backup.createBackup();
ByteArrayInputStream bais = new ByteArrayInputStream(download);
ZipInputStream compressedTcs = new ZipInputStream(bais);
Map<String, TripleCollection> extractedTc = new HashMap<String, TripleCollection>();
String folder = "";
ZipEntry entry;
while ((entry = compressedTcs.getNextEntry()) != null) {
String entryName = entry.getName();
if (entry.isDirectory()) {
folder = entryName;
} else {
Assert.assertTrue(entryName.startsWith(folder+testGraphFileName)
|| entryName.equals(backupContentFileName));
ByteArrayOutputStream baos = new ByteArrayOutputStream(download.length);
int count;
byte buffer[] = new byte[2048];
while ((count = compressedTcs.read(buffer, 0, 2048)) != -1) {
baos.write(buffer, 0, count);
}
ByteArrayInputStream serializedGraph = new ByteArrayInputStream(
baos.toByteArray());
/*if (entryName.equals(folder+testGraphFileName + ".nt")) {
downloadedTestGraphX = parser.parse(serializedGraph,
SupportedFormat.N_TRIPLE, null);
} else if (entryName.startsWith(folder+testGraphFileName)) {
downloadedTestGraphY = parser.parse(serializedGraph,
SupportedFormat.N_TRIPLE, null);
}*/
if (entryName.equals(backupContentFileName)) {
downloadedBackupContentsGraph = parser.parse(serializedGraph,
SupportedFormat.N_TRIPLE, null);
} else {
Graph deserializedGraph = parser.parse(serializedGraph,
SupportedFormat.N_TRIPLE, null);
extractedTc.put(entryName, deserializedGraph);
}
baos.flush();
baos.close();