rt/vm/src/test/java/org/apidesign/vm4brwsr/DelayedLoadingTest.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Fri, 11 Oct 2013 09:58:03 +0200
changeset 1367 6193e735f4d1
parent 789 rt/vm/src/test/java/org/apidesign/vm4brwsr/SystemTest.java@bb7506513353
child 1787 ea12a3bb4b33
permissions -rw-r--r--
If a class is not available during Ahead-Of-Time compilation it needs to be ready for dynamic loading
jaroslav@704
     1
/**
jaroslav@704
     2
 * Back 2 Browser Bytecode Translator
jaroslav@704
     3
 * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
jaroslav@704
     4
 *
jaroslav@704
     5
 * This program is free software: you can redistribute it and/or modify
jaroslav@704
     6
 * it under the terms of the GNU General Public License as published by
jaroslav@704
     7
 * the Free Software Foundation, version 2 of the License.
jaroslav@704
     8
 *
jaroslav@704
     9
 * This program is distributed in the hope that it will be useful,
jaroslav@704
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
jaroslav@704
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
jaroslav@704
    12
 * GNU General Public License for more details.
jaroslav@704
    13
 *
jaroslav@704
    14
 * You should have received a copy of the GNU General Public License
jaroslav@704
    15
 * along with this program. Look for COPYING file in the top folder.
jaroslav@704
    16
 * If not, see http://opensource.org/licenses/GPL-2.0.
jaroslav@704
    17
 */
jaroslav@704
    18
package org.apidesign.vm4brwsr;
jaroslav@704
    19
jaroslav@1367
    20
import java.net.URL;
jaroslav@704
    21
import org.testng.annotations.BeforeClass;
jaroslav@789
    22
import org.testng.annotations.AfterClass;
jaroslav@704
    23
import org.testng.annotations.Test;
jaroslav@704
    24
jaroslav@704
    25
/**
jaroslav@704
    26
 *
jaroslav@704
    27
 * @author Jaroslav Tulach <jtulach@netbeans.org>
jaroslav@704
    28
 */
jaroslav@1367
    29
public class DelayedLoadingTest {
jaroslav@747
    30
    private static TestVM code;
jaroslav@747
    31
    
jaroslav@1367
    32
    @Test public void verifyUsageOf() throws Exception {
jaroslav@1367
    33
        code.register(new BytesLoader());
jaroslav@704
    34
        
jaroslav@1367
    35
        URL u = new URL("http://apidesign.org");
jaroslav@1367
    36
        
jaroslav@1367
    37
        Object str = code.execCode("Access URI", 
jaroslav@1367
    38
            DelayedLoading.class, "toStrViaURI__Ljava_lang_String_2Ljava_lang_String_2",
jaroslav@1367
    39
            u.toExternalForm(), u.toExternalForm()
jaroslav@704
    40
        );
jaroslav@704
    41
    }
jaroslav@704
    42
    
jaroslav@704
    43
    
jaroslav@704
    44
    @BeforeClass 
jaroslav@747
    45
    public static void compileTheCode() throws Exception {
jaroslav@747
    46
        code = TestVM.compileClass(
jaroslav@1367
    47
            "org/apidesign/vm4brwsr/DelayedLoading");
jaroslav@704
    48
    }
jaroslav@789
    49
    @AfterClass
jaroslav@789
    50
    public static void releaseTheCode() {
jaroslav@789
    51
        code = null;
jaroslav@789
    52
    }
jaroslav@704
    53
    
jaroslav@704
    54
}
jaroslav@704
    55