コード例 #1
0
 @Test
 public void testDataFileGetCommand() throws IOException, DatabaseCorruptedException {
   filePath.getParent().toFile().mkdir();
   try (DataOutputStream file = new DataOutputStream(new FileOutputStream(filePath.toString()))) {
     file.write(correctKey1.getBytes(encoding));
     file.write('\0');
     file.writeInt(correctKey1.length() + correctKey2.length() + 2 + offsetLength * 2);
     file.write(correctKey2.getBytes(encoding));
     file.write('\0');
     file.writeInt(
         correctKey2.length()
             + correctKey2.length()
             + 2
             + offsetLength * 2
             + testStringValue.length());
     file.write(testStringValue.getBytes(encoding));
     file.write(testStringValue.getBytes(encoding));
   }
   DataFile test = new DataFile(testDir, new Coordinates(folderIndex, fileIndex), table, provider);
   assertEquals(testStoreableValue, test.get(correctKey1));
   assertEquals(testStoreableValue, test.get(correctKey2));
 }
コード例 #2
0
 @Test
 public void testGetCalledForNonAssociatedCorrectKey()
     throws IOException, DatabaseCorruptedException {
   DataFile test = new DataFile(testDir, new Coordinates(folderIndex, fileIndex), table, provider);
   assertEquals(null, test.get(correctKey1));
 }
コード例 #3
0
 @Test
 public void testGetCalledForExistentKey() throws IOException, DatabaseCorruptedException {
   DataFile test = new DataFile(testDir, new Coordinates(folderIndex, fileIndex), table, provider);
   test.put(correctKey1, testStoreableValue);
   assertEquals(testStoreableValue, test.get(correctKey1));
 }
コード例 #4
0
 @Test(expected = IllegalArgumentException.class)
 public void testGetThrowsExceptionForKeyNotFromThisDataFile()
     throws IOException, DatabaseCorruptedException {
   DataFile test = new DataFile(testDir, new Coordinates(folderIndex, fileIndex), table, provider);
   test.get(wrongKey);
 }