javaquery/api/src/test/java/org/apidesign/bck2brwsr/htmlpage/PageTest.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Tue, 24 Feb 2015 11:12:53 +0100
changeset 1787 ea12a3bb4b33
parent 1505 706b66d8c481
permissions -rw-r--r--
Using year range 2012-2015 in copyright header
jaroslav@769
     1
/**
jaroslav@769
     2
 * Back 2 Browser Bytecode Translator
jaroslav@1787
     3
 * Copyright (C) 2012-2015 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
jaroslav@769
     4
 *
jaroslav@769
     5
 * This program is free software: you can redistribute it and/or modify
jaroslav@769
     6
 * it under the terms of the GNU General Public License as published by
jaroslav@769
     7
 * the Free Software Foundation, version 2 of the License.
jaroslav@769
     8
 *
jaroslav@769
     9
 * This program is distributed in the hope that it will be useful,
jaroslav@769
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
jaroslav@769
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
jaroslav@769
    12
 * GNU General Public License for more details.
jaroslav@769
    13
 *
jaroslav@769
    14
 * You should have received a copy of the GNU General Public License
jaroslav@769
    15
 * along with this program. Look for COPYING file in the top folder.
jaroslav@769
    16
 * If not, see http://opensource.org/licenses/GPL-2.0.
jaroslav@769
    17
 */
jaroslav@769
    18
package org.apidesign.bck2brwsr.htmlpage;
jaroslav@769
    19
jaroslav@769
    20
import java.io.IOException;
jaroslav@769
    21
import java.util.Locale;
jaroslav@961
    22
import javax.tools.Diagnostic;
jaroslav@961
    23
import javax.tools.JavaFileObject;
jaroslav@1505
    24
import org.apidesign.bck2brwsr.core.ExtraJavaScript;
jaroslav@769
    25
import static org.testng.Assert.*;
jaroslav@769
    26
import org.testng.annotations.Test;
jaroslav@769
    27
jaroslav@769
    28
/** Verify errors emitted by the processor.
jaroslav@769
    29
 *
jaroslav@769
    30
 * @author Jaroslav Tulach <jtulach@netbeans.org>
jaroslav@769
    31
 */
jaroslav@1505
    32
@ExtraJavaScript(processByteCode = false, resource = "")
jaroslav@769
    33
public class PageTest {
jaroslav@769
    34
    @Test public void verifyWrongType() throws IOException {
jaroslav@769
    35
        String html = "<html><body>"
jaroslav@769
    36
            + "</body></html>";
jaroslav@769
    37
        String code = "package x.y.z;\n"
jaroslav@769
    38
            + "import org.apidesign.bck2brwsr.htmlpage.api.*;\n"
jaroslav@769
    39
            + "@Page(xhtml=\"index.xhtml\", className=\"Model\", properties={\n"
jaroslav@769
    40
            + "  @Property(name=\"prop\", type=Runnable.class)\n"
jaroslav@769
    41
            + "})\n"
jaroslav@769
    42
            + "class X {\n"
jaroslav@769
    43
            + "}\n";
jaroslav@769
    44
        
jaroslav@769
    45
        Compile c = Compile.create(html, code);
jaroslav@961
    46
        assertFalse(c.getErrors().isEmpty(), "One error: " + c.getErrors());
jaroslav@961
    47
        for (Diagnostic<? extends JavaFileObject> e : c.getErrors()) {
jaroslav@961
    48
            String msg = e.getMessage(Locale.ENGLISH);
jaroslav@961
    49
            if (!msg.contains("Runnable")) {
jaroslav@961
    50
                fail("Should contain warning about Runnable: " + msg);
jaroslav@961
    51
            }
jaroslav@769
    52
        }
jaroslav@769
    53
    }
jaroslav@769
    54
    
jaroslav@769
    55
}