Search in sources :

Example 36 with KnownFailure

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

the class SecureClassLoaderTest method testSecureClassLoaderClassLoader.

@KnownFailure("Android doesn't allow null parent.")
public void testSecureClassLoaderClassLoader() throws Exception {
    URL[] urls = new URL[] { new URL("http://localhost") };
    URLClassLoader ucl = URLClassLoader.newInstance(urls);
    new MyClassLoader(ucl);
    try {
        new MyClassLoader(null);
    } catch (Exception e) {
        fail("unexpected exception: " + e);
    }
}
Also used : URLClassLoader(java.net.URLClassLoader) URL(java.net.URL) KnownFailure(dalvik.annotation.KnownFailure)

Example 37 with KnownFailure

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

the class SignatureTest method testUpdatebyteArrayintint2.

/*
     * Class under test for void update(byte[], int, int)
     */
@KnownFailure("Android throws IllegalArgumentException, RI throws NullpointerException")
public void testUpdatebyteArrayintint2() throws Exception {
    MySignature1 s = new MySignature1("ABC");
    byte[] b = { 1, 2, 3, 4 };
    s.initVerify(new MyPublicKey());
    s.update(b, 0, 3);
    s.initSign(new MyPrivateKey());
    s.update(b, 0, 3);
    assertEquals("state", MySignature1.SIGN, s.getState());
    assertTrue("update() failed", s.runEngineUpdate2);
    try {
        s.update(null, 0, 3);
        fail("NullPointerException wasn't thrown");
    } catch (NullPointerException npe) {
    // ok
    }
}
Also used : MySignature1(org.apache.harmony.security.tests.support.MySignature1) KnownFailure(dalvik.annotation.KnownFailure)

Example 38 with KnownFailure

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

the class ResourceBundleTest method test_getBundleLjava_lang_StringLjava_util_LocaleLjava_lang_ClassLoader.

/**
     * java.util.ResourceBundle#getBundle(java.lang.String,
     *        java.util.Locale, java.lang.ClassLoader)
     */
@KnownFailure("It's not allowed to pass null as parent class loader to" + " a new ClassLoader anymore. Maybe we need to change" + " URLClassLoader to allow this? It's not specified.")
public void test_getBundleLjava_lang_StringLjava_util_LocaleLjava_lang_ClassLoader() {
    String classPath = System.getProperty("java.class.path");
    StringTokenizer tok = new StringTokenizer(classPath, File.pathSeparator);
    Vector<URL> urlVec = new Vector<URL>();
    String resPackage = Support_Resources.RESOURCE_PACKAGE;
    try {
        while (tok.hasMoreTokens()) {
            String path = tok.nextToken();
            String url;
            if (new File(path).isDirectory())
                url = "file:" + path + resPackage + "subfolder/";
            else
                url = "jar:file:" + path + "!" + resPackage + "subfolder/";
            urlVec.addElement(new URL(url));
        }
    } catch (MalformedURLException e) {
    }
    URL[] urls = new URL[urlVec.size()];
    for (int i = 0; i < urlVec.size(); i++) urls[i] = urlVec.elementAt(i);
    URLClassLoader loader = new URLClassLoader(urls, null);
    String name = Support_Resources.RESOURCE_PACKAGE_NAME + ".hyts_resource";
    ResourceBundle bundle = ResourceBundle.getBundle(name, Locale.getDefault());
    assertEquals("Wrong value read", "parent", bundle.getString("property"));
    bundle = ResourceBundle.getBundle(name, Locale.getDefault(), loader);
    assertEquals("Wrong cached value", "resource", bundle.getString("property"));
    try {
        ResourceBundle.getBundle(null, Locale.getDefault(), loader);
        fail("NullPointerException expected");
    } catch (NullPointerException ee) {
    //expected
    }
    try {
        ResourceBundle.getBundle(name, null, loader);
        fail("NullPointerException expected");
    } catch (NullPointerException ee) {
    //expected
    }
    try {
        ResourceBundle.getBundle(name, Locale.getDefault(), (ClassLoader) null);
        fail("NullPointerException expected");
    } catch (NullPointerException ee) {
    //expected
    }
    try {
        ResourceBundle.getBundle("", Locale.getDefault(), loader);
        fail("MissingResourceException expected");
    } catch (MissingResourceException ee) {
    //expected
    }
    // Regression test for Harmony-3823
    B bb = new B();
    String s = bb.find("nonexistent");
    s = bb.find("name");
    assertEquals("Wrong property got", "Name", s);
}
Also used : MalformedURLException(java.net.MalformedURLException) B(tests.api.java.util.support.B) MissingResourceException(java.util.MissingResourceException) URL(java.net.URL) StringTokenizer(java.util.StringTokenizer) URLClassLoader(java.net.URLClassLoader) ResourceBundle(java.util.ResourceBundle) Vector(java.util.Vector) File(java.io.File) KnownFailure(dalvik.annotation.KnownFailure)

Example 39 with KnownFailure

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

the class SAXParserFactoryTest method test_newInstance.

@KnownFailure("Dalvik doesn't honor system properties when choosing a SAX implementation")
public void test_newInstance() {
    try {
        SAXParserFactory dtf = SAXParserFactory.newInstance();
        assertNotNull("New Instance of DatatypeFactory is null", dtf);
        System.setProperty("javax.xml.parsers.SAXParserFactory", "org.apache.harmony.xml.parsers.SAXParserFactoryImpl");
        SAXParserFactory spf1 = SAXParserFactory.newInstance();
        assertTrue(spf1 instanceof org.apache.harmony.xml.parsers.SAXParserFactoryImpl);
        String key = "javax.xml.parsers.SAXParserFactory = org.apache.harmony.xml.parsers.SAXParserFactoryImpl";
        ByteArrayInputStream bis = new ByteArrayInputStream(key.getBytes());
        Properties prop = System.getProperties();
        prop.load(bis);
        SAXParserFactory spf2 = SAXParserFactory.newInstance();
        assertTrue(spf2 instanceof org.apache.harmony.xml.parsers.SAXParserFactoryImpl);
        System.setProperty("javax.xml.parsers.SAXParserFactory", "");
        try {
            SAXParserFactory.newInstance();
            fail("Expected FactoryConfigurationError was not thrown");
        } catch (FactoryConfigurationError e) {
        // expected
        }
    } catch (IOException ioe) {
        fail("Unexpected exception " + ioe.toString());
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) IOException(java.io.IOException) Properties(java.util.Properties) FactoryConfigurationError(javax.xml.parsers.FactoryConfigurationError) SAXParserFactory(javax.xml.parsers.SAXParserFactory) KnownFailure(dalvik.annotation.KnownFailure)

Aggregations

KnownFailure (dalvik.annotation.KnownFailure)39 ResultSet (java.sql.ResultSet)21 IOException (java.io.IOException)12 SQLException (java.sql.SQLException)12 ByteBuffer (java.nio.ByteBuffer)11 SSLEngine (javax.net.ssl.SSLEngine)11 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)10 ReadOnlyBufferException (java.nio.ReadOnlyBufferException)9 KeyManagementException (java.security.KeyManagementException)9 ResultSetMetaData (java.sql.ResultSetMetaData)9 SSLException (javax.net.ssl.SSLException)9 URL (java.net.URL)2 URLClassLoader (java.net.URLClassLoader)2 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)2 HashSet (java.util.HashSet)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 InputStream (java.io.InputStream)1