    public void testCreateAndCheckKey() throws Exception {
        String osPath = mTmpFile.getAbsolutePath();
        KeygenOutput keygenOutput = new KeygenOutput();
        long now = System.currentTimeMillis();
        DebugKeyProvider provider;
        try {
            provider = new DebugKeyProvider(osPath,  null , keygenOutput);
        } catch (Throwable t) {
            String msg = String.format("%1$s in %2$s\n%3$s",
                    t.getClass().getSimpleName(), osPath, t.toString());
            throw new Exception(msg, t);
        }
        assertNotNull(provider);
        assertEquals("", keygenOutput.getOut());
        assertEquals("", keygenOutput.getErr());
        PrivateKey key = provider.getDebugKey();
        assertNotNull(key);
        X509Certificate certificate = (X509Certificate) provider.getCertificate();
        assertNotNull(certificate);
        Calendar c = Calendar.getInstance();
        c.setTimeInMillis(now);
        assertTrue(certificate.getNotAfter().compareTo(c.getTime()) > 0);
        c.add(Calendar.DAY_OF_YEAR, 365);
        c.add(Calendar.SECOND, -1);
        assertTrue("1 year expiration failed",
                certificate.getNotAfter().compareTo(c.getTime()) > 0);
        c.add(Calendar.DAY_OF_YEAR, 29 * 365);
        c.add(Calendar.HOUR_OF_DAY, -1);
        assertTrue("30 year expiration failed",
                certificate.getNotAfter().compareTo(c.getTime()) > 0);
        c.add(Calendar.HOUR, 1);
        assertFalse("30 year and 1 hour expiration failed",
                certificate.getNotAfter().compareTo(c.getTime()) > 0);
    }

    public void testCreateAndCheckKey() throws Exception {
        String osPath = mTmpFile.getAbsolutePath();
        KeygenOutput keygenOutput = new KeygenOutput();
        long now = System.currentTimeMillis();
        DebugKeyProvider provider;
        try {
            provider = new DebugKeyProvider(osPath,  null , keygenOutput);
        } catch (Throwable t) {
            String msg = String.format("%1$s in %2$s\n%3$s",
                    t.getClass().getSimpleName(), osPath, t.toString());
            throw new Exception(msg, t);
        }
        assertNotNull(provider);
        assertEquals("", keygenOutput.getOut());
        assertEquals("", keygenOutput.getErr());
        PrivateKey key = provider.getDebugKey();
        assertNotNull(key);
        X509Certificate certificate = (X509Certificate) provider.getCertificate();
        assertNotNull(certificate);
        Calendar c = Calendar.getInstance();
        c.setTimeInMillis(now);
        assertTrue(certificate.getNotAfter().compareTo(c.getTime()) > 0);
        c.add(Calendar.DAY_OF_YEAR, 365);
        c.add(Calendar.SECOND, -1);
        assertTrue("1 year expiration failed",
                certificate.getNotAfter().compareTo(c.getTime()) > 0);
        c.add(Calendar.DAY_OF_YEAR, 29 * 365);
        c.add(Calendar.HOUR_OF_DAY, -1);
        assertTrue("30 year expiration failed",
                certificate.getNotAfter().compareTo(c.getTime()) > 0);
        c.add(Calendar.HOUR, 5);
        assertFalse("30 year and a few hours expiration failed",
                certificate.getNotAfter().compareTo(c.getTime()) > 0);
    }
