javaquery/api/src/test/java/org/apidesign/bck2brwsr/htmlpage/PageTest.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Wed, 20 Feb 2013 18:14:59 +0100
branchmodel
changeset 769 0c0fe97fe0c7
child 961 3cdaee10e72b
permissions -rw-r--r--
Processor allows only primitive types and String as its values
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@769
    22
import static org.testng.Assert.*;
jaroslav@769
    23
import org.testng.annotations.Test;
jaroslav@769
    24
jaroslav@769
    25
/** Verify errors emitted by the processor.
jaroslav@769
    26
 *
jaroslav@769
    27
 * @author Jaroslav Tulach <jtulach@netbeans.org>
jaroslav@769
    28
 */
jaroslav@769
    29
public class PageTest {
jaroslav@769
    30
    @Test public void verifyWrongType() throws IOException {
jaroslav@769
    31
        String html = "<html><body>"
jaroslav@769
    32
            + "</body></html>";
jaroslav@769
    33
        String code = "package x.y.z;\n"
jaroslav@769
    34
            + "import org.apidesign.bck2brwsr.htmlpage.api.*;\n"
jaroslav@769
    35
            + "@Page(xhtml=\"index.xhtml\", className=\"Model\", properties={\n"
jaroslav@769
    36
            + "  @Property(name=\"prop\", type=Runnable.class)\n"
jaroslav@769
    37
            + "})\n"
jaroslav@769
    38
            + "class X {\n"
jaroslav@769
    39
            + "}\n";
jaroslav@769
    40
        
jaroslav@769
    41
        Compile c = Compile.create(html, code);
jaroslav@769
    42
        assertEquals(c.getErrors().size(), 1, "One error: " + c.getErrors());
jaroslav@769
    43
        
jaroslav@769
    44
        String msg = c.getErrors().get(0).getMessage(Locale.ENGLISH);
jaroslav@769
    45
        if (!msg.contains("Runnable")) {
jaroslav@769
    46
            fail("Should contain warning about Runnable: " + msg);
jaroslav@769
    47
        }
jaroslav@769
    48
    }
jaroslav@769
    49
    
jaroslav@769
    50
}