@Test public void testExportImport() throws Exception { File exportFile = new File(testDir, "ExportImportTest-" + System.currentTimeMillis() + ".txt"); addressBook.export(exportFile, null); File tmpAddressBookFile = new File(testDir, "ExportImportAB-" + System.currentTimeMillis()); AddressBook tmpAddressBook = new AddressBook(tmpAddressBookFile, passwordHolder); FileInputStream fis = new FileInputStream(exportFile); try { tmpAddressBook.importFromFileDescriptor(fis.getFD(), null, false, false); SortedSet<Contact> start = addressBook.getAll(); SortedSet<Contact> end = tmpAddressBook.getAll(); for (Contact contact : start) { assertThat(contact, isIn(end)); } for (Contact contact : end) { assertThat(contact, isIn(start)); } } finally { try { fis.close(); } catch (IOException e) { } assertTrue("Can't delete file: " + exportFile.getAbsolutePath(), exportFile.delete()); assertTrue("Can't delete file: " + tmpAddressBookFile.getAbsolutePath(), tmpAddressBookFile.delete()); } }
public SortedSet<Contact> getAll() throws PasswordException { initializeIfNeeded(); return contacts; }
AddressBook extends ExportableData { public SortedSet<Contact> getAll() throws PasswordException { initializeIfNeeded(); return contacts; } }
AddressBook extends ExportableData { public SortedSet<Contact> getAll() throws PasswordException { initializeIfNeeded(); return contacts; } AddressBook(File addressFile, PasswordHolder passwordHolder); }
AddressBook extends ExportableData { public SortedSet<Contact> getAll() throws PasswordException { initializeIfNeeded(); return contacts; } AddressBook(File addressFile, PasswordHolder passwordHolder); void save(); void add(Contact contact); void remove(String destination); void changePassword(byte[] oldPassword, DerivedKey newKey); void clearPasswordProtectedData(); Contact get(String destination); boolean contains(String base64dest); SortedSet<Contact> getAll(); int size(); }
AddressBook extends ExportableData { public SortedSet<Contact> getAll() throws PasswordException { initializeIfNeeded(); return contacts; } AddressBook(File addressFile, PasswordHolder passwordHolder); void save(); void add(Contact contact); void remove(String destination); void changePassword(byte[] oldPassword, DerivedKey newKey); void clearPasswordProtectedData(); Contact get(String destination); boolean contains(String base64dest); SortedSet<Contact> getAll(); int size();  }