jaroslav@769: /** jaroslav@769: * Back 2 Browser Bytecode Translator jaroslav@769: * Copyright (C) 2012 Jaroslav Tulach jaroslav@769: * jaroslav@769: * This program is free software: you can redistribute it and/or modify jaroslav@769: * it under the terms of the GNU General Public License as published by jaroslav@769: * the Free Software Foundation, version 2 of the License. jaroslav@769: * jaroslav@769: * This program is distributed in the hope that it will be useful, jaroslav@769: * but WITHOUT ANY WARRANTY; without even the implied warranty of jaroslav@769: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jaroslav@769: * GNU General Public License for more details. jaroslav@769: * jaroslav@769: * You should have received a copy of the GNU General Public License jaroslav@769: * along with this program. Look for COPYING file in the top folder. jaroslav@769: * If not, see http://opensource.org/licenses/GPL-2.0. jaroslav@769: */ jaroslav@769: package org.apidesign.bck2brwsr.htmlpage; jaroslav@769: jaroslav@769: import java.io.IOException; jaroslav@769: import java.util.Locale; jaroslav@769: import static org.testng.Assert.*; jaroslav@769: import org.testng.annotations.Test; jaroslav@769: jaroslav@769: /** Verify errors emitted by the processor. jaroslav@769: * jaroslav@769: * @author Jaroslav Tulach jaroslav@769: */ jaroslav@769: public class PageTest { jaroslav@769: @Test public void verifyWrongType() throws IOException { jaroslav@769: String html = "" jaroslav@769: + ""; jaroslav@769: String code = "package x.y.z;\n" jaroslav@769: + "import org.apidesign.bck2brwsr.htmlpage.api.*;\n" jaroslav@769: + "@Page(xhtml=\"index.xhtml\", className=\"Model\", properties={\n" jaroslav@769: + " @Property(name=\"prop\", type=Runnable.class)\n" jaroslav@769: + "})\n" jaroslav@769: + "class X {\n" jaroslav@769: + "}\n"; jaroslav@769: jaroslav@769: Compile c = Compile.create(html, code); jaroslav@769: assertEquals(c.getErrors().size(), 1, "One error: " + c.getErrors()); jaroslav@769: jaroslav@769: String msg = c.getErrors().get(0).getMessage(Locale.ENGLISH); jaroslav@769: if (!msg.contains("Runnable")) { jaroslav@769: fail("Should contain warning about Runnable: " + msg); jaroslav@769: } jaroslav@769: } jaroslav@769: jaroslav@769: }