@Test public void testGetItem2() throws Exception { String link = "link"; final Item item = new Item(link, "login", "pass"); // Compare items without password databaseControl.addItem(item, password); assertEquals(databaseControl.getItem(link, password), item); try { databaseControl.getItem("wronglink", password); fail("Didn't trigger NoSuchItemException."); } catch (NoSuchItemException nsie) { } // Crypted tests Password newPassword = new Password("NewPassword".getBytes()); databaseControl.addItem(item, password); databaseControl.setPassword(password, newPassword); try { databaseControl.getItem(link, password); fail("Didn't trigger InvalidPasswordException!"); } catch (InvalidPasswordException e) { } assertEquals(databaseControl.getItem(link, newPassword), item); }
@Test public void testGetItem() throws Exception { String link = "link"; Item item = new Item(link, "username", "password"); databaseControl.addItem(item, password); assertEquals(databaseControl.getItem(link, password), item); }