@Test public void testCreateArchive() { try { setUp(); } catch (Exception e) { fail(e.getMessage()); } try { GenericSignedFlashArchive archive = new GenericSignedFlashArchive(settings); // cannot test the size since a version.txt is created and put into archive when the // unsigned archive becames signed // File file = new File(UNSIGNED_FLASH_ARCHIVE_FILENAME); // assertEquals(file.length(), archive.getLength()); assertEquals(0, archive.getDestinationAddress()); GenericCertificate cert = new GenericSignedHeader(); archive.setCertificate(cert); assertEquals(cert, archive.getCertificate()); byte[] b = new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; archive.setSignature(b); assertTrue(Arrays.equals(b, archive.getSignature())); } catch (SignerException e) { fail(e.getMessage()); } }
@Test public void testNonExistingFile() { try { setUp(); } catch (Exception e) { fail(e.getMessage()); } try { settings.setSignerSetting(ISignerSettings.KEY_INPUT_FILE, NON_EXISITNG_FILE_FILENAME); GenericSignedFlashArchive archive = new GenericSignedFlashArchive(settings); archive.getClass(); fail("should not get here"); } catch (SignerException e) { e.getMessage(); } }
@Test public void testDirAsInputFile() { try { setUp(); } catch (Exception e) { fail(e.getMessage()); } try { settings.setSignerSetting( ISignerSettings.KEY_INPUT_FILE, Activator.getResourcesPath() + DIRECTORY_FILE_FILENAME); GenericSignedFlashArchive archive = new GenericSignedFlashArchive(settings); archive.getClass(); fail("should not get here"); } catch (SignerException e) { e.getMessage(); } }