@Test
public void testSignZip() throws IOException, LocalRepoKeyStore.InitException, IndexUpdater.SigningException {

    Context context = ApplicationProvider.getApplicationContext();
    File xmlIndexJarUnsigned = File.createTempFile(getClass().getName(), "unsigned.jar");
    BufferedOutputStream bo = new BufferedOutputStream(new FileOutputStream(xmlIndexJarUnsigned));
    JarOutputStream jo = new JarOutputStream(bo);
    JarEntry je = new JarEntry(IndexUpdater.DATA_FILE_NAME);
    jo.putNextEntry(je);
    InputStream inputStream = getClass().getClassLoader().getResourceAsStream("smallRepo.xml");
    IOUtils.copy(inputStream, jo);
    jo.close();
    bo.close();
    LocalRepoKeyStore localRepoKeyStore = LocalRepoKeyStore.get(context);
    Certificate localCert = localRepoKeyStore.getCertificate();
    assertFalse(TextUtils.isEmpty(Utils.calcFingerprint(localCert)));
    File xmlIndexJar = File.createTempFile(getClass().getName(), IndexUpdater.SIGNED_FILE_NAME);
    localRepoKeyStore.signZip(xmlIndexJarUnsigned, xmlIndexJar);
    JarFile jarFile = new JarFile(xmlIndexJar, true);
    JarEntry indexEntry = (JarEntry) jarFile.getEntry(IndexUpdater.DATA_FILE_NAME);
    byte[] data = IOUtils.toByteArray(jarFile.getInputStream(indexEntry));
    assertEquals(17187, data.length);
    assertNotNull(IndexUpdater.getSigningCertFromJar(indexEntry));
}