javaquery/api/src/test/java/org/apidesign/bck2brwsr/htmlpage/PageTest.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Wed, 10 Apr 2013 09:55:26 +0200
branchmodel
changeset 961 3cdaee10e72b
parent 769 0c0fe97fe0c7
child 1505 706b66d8c481
permissions -rw-r--r--
Allow usage of generated classes in @Model and @Page annotations
jaroslav@769
     1
/**
jaroslav@769
     2
 * Back 2 Browser Bytecode Translator
jaroslav@769
     3
 * Copyright (C) 2012 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@769
    24
import static org.testng.Assert.*;
jaroslav@769
    25
import org.testng.annotations.Test;
jaroslav@769
    26
jaroslav@769
    27
/** Verify errors emitted by the processor.
jaroslav@769
    28
 *
jaroslav@769
    29
 * @author Jaroslav Tulach <jtulach@netbeans.org>
jaroslav@769
    30
 */
jaroslav@769
    31
public class PageTest {
jaroslav@769
    32
    @Test public void verifyWrongType() throws IOException {
jaroslav@769
    33
        String html = "<html><body>"
jaroslav@769
    34
            + "</body></html>";
jaroslav@769
    35
        String code = "package x.y.z;\n"
jaroslav@769
    36
            + "import org.apidesign.bck2brwsr.htmlpage.api.*;\n"
jaroslav@769
    37
            + "@Page(xhtml=\"index.xhtml\", className=\"Model\", properties={\n"
jaroslav@769
    38
            + "  @Property(name=\"prop\", type=Runnable.class)\n"
jaroslav@769
    39
            + "})\n"
jaroslav@769
    40
            + "class X {\n"
jaroslav@769
    41
            + "}\n";
jaroslav@769
    42
        
jaroslav@769
    43
        Compile c = Compile.create(html, code);
jaroslav@961
    44
        assertFalse(c.getErrors().isEmpty(), "One error: " + c.getErrors());
jaroslav@961
    45
        for (Diagnostic<? extends JavaFileObject> e : c.getErrors()) {
jaroslav@961
    46
            String msg = e.getMessage(Locale.ENGLISH);
jaroslav@961
    47
            if (!msg.contains("Runnable")) {
jaroslav@961
    48
                fail("Should contain warning about Runnable: " + msg);
jaroslav@961
    49
            }
jaroslav@769
    50
        }
jaroslav@769
    51
    }
jaroslav@769
    52
    
jaroslav@769
    53
}