Search in sources :

Example 6 with BrokenTest

use of dalvik.annotation.BrokenTest in project robovm by robovm.

the class OldPKIXParametersTest method testPKIXParametersKeyStore04.

/**
     * Test #4 for <code>PKIXParameters(KeyStore)</code> constructor<br>
     *
     * @throws InvalidAlgorithmParameterException
     * @throws KeyStoreException
     */
@BrokenTest("Fails in CTS environment, but passes in CoreTestRunner")
public final void testPKIXParametersKeyStore04() throws Exception {
    KeyStore store = KeyStore.getInstance("PKCS12");
    KeyStoreTestPKCS12 k = new KeyStoreTestPKCS12();
    ByteArrayInputStream stream = new ByteArrayInputStream(k.keyStoreData);
    try {
        PKIXParameters p = new PKIXParameters(store);
    } catch (KeyStoreException e) {
    // ok
    }
    store = KeyStore.getInstance("PKCS12");
    store.load(stream, new String(KeyStoreTestPKCS12.keyStorePassword).toCharArray());
    stream.close();
    try {
        PKIXParameters p = new PKIXParameters(store);
    } catch (InvalidAlgorithmParameterException e) {
    // ok
    }
    KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
    keystore.load(null, null);
    keystore.setCertificateEntry("test", TestUtils.rootCertificateSS);
    PKIXParameters p = new PKIXParameters(keystore);
}
Also used : KeyStoreTestPKCS12(tests.targets.security.KeyStoreTestPKCS12) InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) ByteArrayInputStream(java.io.ByteArrayInputStream) PKIXParameters(java.security.cert.PKIXParameters) KeyStoreException(java.security.KeyStoreException) KeyStore(java.security.KeyStore) BrokenTest(dalvik.annotation.BrokenTest)

Example 7 with BrokenTest

use of dalvik.annotation.BrokenTest in project robovm by robovm.

the class URLConnectionTest method test_getContentEncoding.

/**
     * @throws IOException
     * {@link java.net.URLConnection#getContentEncoding()}
     */
@BrokenTest("Fails in CTS, passes in CoreTestRunner")
public void test_getContentEncoding() throws IOException {
    // faulty setup
    try {
        fileURLCon.getContentEncoding();
        fail("Exception expected");
    } catch (Throwable e) {
    //ok
    }
    // positive case
    URL url = new URL("http://www.amazon.com/");
    URLConnection con = url.openConnection();
    con.setRequestProperty("Accept-Encoding", "gzip");
    con.connect();
    assertEquals(con.getContentEncoding(), "gzip");
    uc2.setRequestProperty("Accept-Encoding", "bla");
    uc2.connect();
    assertNull(uc2.getContentEncoding());
}
Also used : URL(java.net.URL) HttpURLConnection(java.net.HttpURLConnection) URLConnection(java.net.URLConnection) JarURLConnection(java.net.JarURLConnection) BrokenTest(dalvik.annotation.BrokenTest)

Aggregations

BrokenTest (dalvik.annotation.BrokenTest)7 KeyPair (java.security.KeyPair)3 KeyPairGenerator (java.security.KeyPairGenerator)3 ByteArrayInputStream (java.io.ByteArrayInputStream)1 HttpURLConnection (java.net.HttpURLConnection)1 JarURLConnection (java.net.JarURLConnection)1 ServerSocket (java.net.ServerSocket)1 Socket (java.net.Socket)1 URL (java.net.URL)1 URLConnection (java.net.URLConnection)1 ByteBuffer (java.nio.ByteBuffer)1 AlgorithmParameterGenerator (java.security.AlgorithmParameterGenerator)1 AlgorithmParameters (java.security.AlgorithmParameters)1 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)1 KeyStore (java.security.KeyStore)1 KeyStoreException (java.security.KeyStoreException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 SecureRandom (java.security.SecureRandom)1 PKIXParameters (java.security.cert.PKIXParameters)1 NumberFormat (java.text.NumberFormat)1