dew/src/test/java/org/apidesign/bck2brwsr/dew/CompileTest.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Mon, 23 Sep 2013 00:59:14 +0200
branchjavac
changeset 1295 5b3ae17babdf
parent 544 08ffdc3938e7
child 1345 0546c3f2a96a
permissions -rw-r--r--
Can we run Javac in the bck2brwsr VM?
jaroslav@468
     1
/**
jaroslav@468
     2
 * Back 2 Browser Bytecode Translator
jaroslav@468
     3
 * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
jaroslav@468
     4
 *
jaroslav@468
     5
 * This program is free software: you can redistribute it and/or modify
jaroslav@468
     6
 * it under the terms of the GNU General Public License as published by
jaroslav@468
     7
 * the Free Software Foundation, version 2 of the License.
jaroslav@468
     8
 *
jaroslav@468
     9
 * This program is distributed in the hope that it will be useful,
jaroslav@468
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
jaroslav@468
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
jaroslav@468
    12
 * GNU General Public License for more details.
jaroslav@468
    13
 *
jaroslav@468
    14
 * You should have received a copy of the GNU General Public License
jaroslav@468
    15
 * along with this program. Look for COPYING file in the top folder.
jaroslav@468
    16
 * If not, see http://opensource.org/licenses/GPL-2.0.
jaroslav@468
    17
 */
jaroslav@462
    18
package org.apidesign.bck2brwsr.dew;
jaroslav@462
    19
jaroslav@462
    20
import java.io.IOException;
jaroslav@1295
    21
import org.apidesign.bck2brwsr.vmtest.Compare;
jaroslav@1295
    22
import org.apidesign.bck2brwsr.vmtest.VMTest;
jaroslav@462
    23
import static org.testng.Assert.*;
jaroslav@1295
    24
import org.testng.annotations.Factory;
jaroslav@462
    25
jaroslav@462
    26
/**
jaroslav@462
    27
 *
jaroslav@462
    28
 * @author Jaroslav Tulach <jtulach@netbeans.org>
jaroslav@462
    29
 */
jaroslav@462
    30
public class CompileTest  {
jaroslav@1295
    31
    @Compare public void testCompile() throws IOException {
jaroslav@462
    32
        String html = "<html><body>"
jaroslav@462
    33
                + " <button id='btn'>Hello!</button>"
jaroslav@462
    34
                + "</body></html>";
jaroslav@462
    35
        String java = "package x.y.z;"
jaroslav@463
    36
                + "import org.apidesign.bck2brwsr.htmlpage.api.*;"
jaroslav@469
    37
                + "import static org.apidesign.bck2brwsr.htmlpage.api.OnEvent.*;"
jaroslav@463
    38
            + "@Page(xhtml=\"index.html\", className=\"Index\")"
jaroslav@463
    39
            + "class X { "
jaroslav@469
    40
            + "   @On(event=CLICK, id=\"btn\") static void clcs() {}"
jaroslav@463
    41
            + "}";
jaroslav@464
    42
        Compile result = Compile.create(html, java);
jaroslav@462
    43
jaroslav@462
    44
        assertNotNull(result.get("x/y/z/X.class"), "Class X is compiled: " + result);
jaroslav@463
    45
        assertNotNull(result.get("x/y/z/Index.class"), "Class Index is compiled: " + result);
jaroslav@462
    46
    }
jaroslav@1295
    47
    
jaroslav@1295
    48
    @Factory public static Object[] create() {
jaroslav@1295
    49
        return VMTest.create(CompileTest.class);
jaroslav@1295
    50
    }
jaroslav@462
    51
}