# HG changeset patch # User Jaroslav Tulach # Date 1398759835 -7200 # Node ID 9583bcc50db35afb08f120eef99b4eccd0e4ed23 # Parent daa5f903b529f4ffc42daadd7b9c61225fb117fc Making sure resources can be loaded in brwsr testing mode with extensions diff -r daa5f903b529 -r 9583bcc50db3 launcher/http/src/main/java/org/apidesign/bck2brwsr/launcher/CompileCP.java --- a/launcher/http/src/main/java/org/apidesign/bck2brwsr/launcher/CompileCP.java Mon Apr 28 20:23:44 2014 +0200 +++ b/launcher/http/src/main/java/org/apidesign/bck2brwsr/launcher/CompileCP.java Tue Apr 29 10:23:55 2014 +0200 @@ -54,6 +54,7 @@ Bck2Brwsr.newCompiler() .addClasses(classes.toArray(new String[0])) + .addResources(arr.toArray(new String[0])) .library(true) .resources(new JarRes()) .generate(w); @@ -80,6 +81,7 @@ try { Bck2Brwsr.newCompiler() .addRootClasses(classes.toArray(new String[0])) + .addResources(arr.toArray(new String[0])) .library(true) .resources(new EmulationResources()) .generate(w); diff -r daa5f903b529 -r 9583bcc50db3 rt/emul/brwsrtest/src/test/java/org/apidesign/bck2brwsr/brwsrtest/ResourcesInBrwsrTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rt/emul/brwsrtest/src/test/java/org/apidesign/bck2brwsr/brwsrtest/ResourcesInBrwsrTest.java Tue Apr 29 10:23:55 2014 +0200 @@ -0,0 +1,46 @@ +/** + * Back 2 Browser Bytecode Translator + * Copyright (C) 2012 Jaroslav Tulach + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. Look for COPYING file in the top folder. + * If not, see http://opensource.org/licenses/GPL-2.0. + */ +package org.apidesign.bck2brwsr.brwsrtest; + +import java.io.InputStream; +import org.apidesign.bck2brwsr.vmtest.Compare; +import org.apidesign.bck2brwsr.vmtest.VMTest; +import org.testng.annotations.Factory; + +/** + * + * @author Jaroslav Tulach + */ +public class ResourcesInBrwsrTest { + + @Compare public String readResourceAsStream() throws Exception { + InputStream is = getClass().getResourceAsStream("Resources.txt"); + assert is != null : "The stream for Resources.txt should be found"; + byte[] b = new byte[30]; + int len = is.read(b); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < len; i++) { + sb.append((char)b[i]); + } + return sb.toString(); + } + + @Factory public static Object[] create() { + return VMTest.create(ResourcesInBrwsrTest.class); + } +} diff -r daa5f903b529 -r 9583bcc50db3 rt/emul/brwsrtest/src/test/resources/org/apidesign/bck2brwsr/brwsrtest/Resources.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rt/emul/brwsrtest/src/test/resources/org/apidesign/bck2brwsr/brwsrtest/Resources.txt Tue Apr 29 10:23:55 2014 +0200 @@ -0,0 +1,1 @@ +Ahoj