Search in sources :

Example 6 with SideEffect

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

the class ExemptionMechanismTest method test_finalize.

@SideEffect("Causes OutOfMemoryError to test finalization")
public void test_finalize() {
    Mock_ExemptionMechanism mem = new Mock_ExemptionMechanism(null, null, "Name");
    assertNotNull(mem);
    mem = null;
    assertFalse(flag);
    Vector v = new Vector();
    int capacity;
    try {
        while (true) {
            v.add(this);
        }
    } catch (OutOfMemoryError e) {
        capacity = v.size();
        v = null;
    }
    v = new Vector();
    for (int i = 0; i < capacity / 2; i++) {
        v.add(this);
    }
    v = null;
    assertTrue(flag);
}
Also used : Vector(java.util.Vector) SideEffect(dalvik.annotation.SideEffect)

Example 7 with SideEffect

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

the class OldURLClassLoaderTest method test_findResource_String.

/**
     * Regression for Harmony-2237
     */
@SideEffect("Support_TestWebServer requires isolation.")
public void test_findResource_String() throws Exception {
    File tempFile1 = File.createTempFile("textFile", ".txt");
    tempFile1.createNewFile();
    tempFile1.deleteOnExit();
    File tempFile2 = File.createTempFile("jarFile", ".jar");
    tempFile2.delete();
    tempFile2.deleteOnExit();
    Support_TestWebServer server = new Support_TestWebServer();
    try {
        int port = server.initServer();
        String tempPath1 = tempFile1.getParentFile().getAbsolutePath() + "/";
        InputStream is = getClass().getResourceAsStream("/tests/resources/hyts_patch.jar");
        Support_Resources.copyLocalFileto(tempFile2, is);
        String tempPath2 = tempFile2.getAbsolutePath();
        String tempPath3 = "http://localhost:" + port + "/";
        URLClassLoader urlLoader = getURLClassLoader(tempPath1, tempPath2);
        assertNull("Found inexistant resource", urlLoader.findResource("XXX"));
        assertNotNull("Couldn't find resource from directory", urlLoader.findResource(tempFile1.getName()));
        assertNotNull("Couldn't find resource from jar", urlLoader.findResource("Blah.txt"));
        urlLoader = getURLClassLoader(tempPath1, tempPath2, tempPath3);
        assertNotNull("Couldn't find resource from web", urlLoader.findResource("test1"));
        assertNull("Found inexistant resource from web", urlLoader.findResource("test3"));
    } finally {
        server.close();
    }
}
Also used : InputStream(java.io.InputStream) URLClassLoader(java.net.URLClassLoader) Support_TestWebServer(tests.support.Support_TestWebServer) File(java.io.File) SideEffect(dalvik.annotation.SideEffect)

Aggregations

SideEffect (dalvik.annotation.SideEffect)7 URL (java.net.URL)3 File (java.io.File)2 IOException (java.io.IOException)2 URLClassLoader (java.net.URLClassLoader)2 Vector (java.util.Vector)2 Support_TestWebServer (tests.support.Support_TestWebServer)2 InputStream (java.io.InputStream)1 Reference (java.lang.ref.Reference)1 ReferenceQueue (java.lang.ref.ReferenceQueue)1 SoftReference (java.lang.ref.SoftReference)1 Authenticator (java.net.Authenticator)1 ContentHandler (java.net.ContentHandler)1 HttpURLConnection (java.net.HttpURLConnection)1 InetSocketAddress (java.net.InetSocketAddress)1 MalformedURLException (java.net.MalformedURLException)1 PasswordAuthentication (java.net.PasswordAuthentication)1 Proxy (java.net.Proxy)1 URLConnection (java.net.URLConnection)1 InvalidKeyException (java.security.InvalidKeyException)1