Executing JUnit test inside of a Java plugin-less browser.
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/.hgsub Sun Mar 20 19:44:18 2016 +0100
1.3 @@ -0,0 +1,1 @@
1.4 +rt/aot-junit = [git]https://github.com/jtulach/junit.git
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/.hgsubstate Sun Mar 20 19:44:18 2016 +0100
2.3 @@ -0,0 +1,1 @@
2.4 +5621ac14942b5e1a4297ecd68ed7a2e1f9ce7bee rt/aot-junit
3.1 --- a/rt/aot-nb-test/pom.xml Sun Mar 20 19:37:07 2016 +0100
3.2 +++ b/rt/aot-nb-test/pom.xml Sun Mar 20 19:44:18 2016 +0100
3.3 @@ -48,10 +48,10 @@
3.4 <artifactId>org-openide-util-lookup</artifactId>
3.5 </dependency>
3.6 <dependency>
3.7 - <groupId>${project.groupId}</groupId>
3.8 - <artifactId>emul.mini</artifactId>
3.9 - <version>${project.version}</version>
3.10 - <scope>test</scope>
3.11 + <groupId>org.apidesign.junit</groupId>
3.12 + <artifactId>junit-osgi</artifactId>
3.13 + <version>4.12</version>
3.14 + <type>jar</type>
3.15 </dependency>
3.16 </dependencies>
3.17 <build>
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/rt/aot-nb-test/src/main/java/org/apidesign/bck2brwsr/aot/junit/RunTest.java Sun Mar 20 19:44:18 2016 +0100
4.3 @@ -0,0 +1,71 @@
4.4 +/**
4.5 + * Back 2 Browser Bytecode Translator
4.6 + * Copyright (C) 2012-2015 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
4.7 + *
4.8 + * This program is free software: you can redistribute it and/or modify
4.9 + * it under the terms of the GNU General Public License as published by
4.10 + * the Free Software Foundation, version 2 of the License.
4.11 + *
4.12 + * This program is distributed in the hope that it will be useful,
4.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4.15 + * GNU General Public License for more details.
4.16 + *
4.17 + * You should have received a copy of the GNU General Public License
4.18 + * along with this program. Look for COPYING file in the top folder.
4.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
4.20 + */
4.21 +package org.apidesign.bck2brwsr.aot.junit;
4.22 +
4.23 +import java.io.PrintStream;
4.24 +import java.io.UnsupportedEncodingException;
4.25 +import junit.framework.AssertionFailedError;
4.26 +import junit.framework.JUnit4TestAdapter;
4.27 +import junit.framework.Test;
4.28 +import junit.framework.TestListener;
4.29 +import junit.framework.TestResult;
4.30 +import junit.textui.ResultPrinter;
4.31 +
4.32 +public class RunTest extends ResultPrinter {
4.33 + public static void main(String... args) throws UnsupportedEncodingException {
4.34 + System.err.println(run());
4.35 + }
4.36 +
4.37 + public static String run() throws UnsupportedEncodingException {
4.38 + TestResult tr = new TestResult();
4.39 + class L implements TestListener {
4.40 + StringBuilder sb = new StringBuilder();
4.41 +
4.42 + @Override
4.43 + public void addError(Test test, Throwable e) {
4.44 + sb.append(test.toString()).append("\n");
4.45 + }
4.46 +
4.47 + @Override
4.48 + public void addFailure(Test test, AssertionFailedError e) {
4.49 + sb.append(test.toString()).append("\n");;
4.50 + }
4.51 +
4.52 + @Override
4.53 + public void endTest(Test test) {
4.54 + sb.append(test.toString()).append("\n");;
4.55 + }
4.56 +
4.57 + @Override
4.58 + public void startTest(Test test) {
4.59 + sb.append(test.toString()).append("\n");;
4.60 + }
4.61 + }
4.62 + L listener = new L();
4.63 + tr.addListener(listener);
4.64 + listener.sb.append("Starting the test run\n");
4.65 + JUnit4TestAdapter suite = new JUnit4TestAdapter(TestedTest.class);
4.66 + suite.run(tr);
4.67 + listener.sb.append("End of test run\n");
4.68 + return listener.sb.toString();
4.69 + }
4.70 +
4.71 + RunTest(PrintStream writer) {
4.72 + super(writer);
4.73 + }
4.74 +}
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/rt/aot-nb-test/src/main/java/org/apidesign/bck2brwsr/aot/junit/TestedTest.java Sun Mar 20 19:44:18 2016 +0100
5.3 @@ -0,0 +1,32 @@
5.4 +/**
5.5 + * Back 2 Browser Bytecode Translator
5.6 + * Copyright (C) 2012-2015 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
5.7 + *
5.8 + * This program is free software: you can redistribute it and/or modify
5.9 + * it under the terms of the GNU General Public License as published by
5.10 + * the Free Software Foundation, version 2 of the License.
5.11 + *
5.12 + * This program is distributed in the hope that it will be useful,
5.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
5.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5.15 + * GNU General Public License for more details.
5.16 + *
5.17 + * You should have received a copy of the GNU General Public License
5.18 + * along with this program. Look for COPYING file in the top folder.
5.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
5.20 + */
5.21 +package org.apidesign.bck2brwsr.aot.junit;
5.22 +
5.23 +import org.junit.Test;
5.24 +import static org.junit.Assert.fail;
5.25 +
5.26 +public class TestedTest {
5.27 + @Test
5.28 + public void ok() {
5.29 + }
5.30 +
5.31 + @Test
5.32 + public void error() {
5.33 + fail("Failing");
5.34 + }
5.35 +}
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/rt/aot-nb-test/src/test/java/org/apidesign/bck2brwsr/aot/junit/test/JUnitRunTest.java Sun Mar 20 19:44:18 2016 +0100
6.3 @@ -0,0 +1,37 @@
6.4 +/**
6.5 + * Back 2 Browser Bytecode Translator
6.6 + * Copyright (C) 2012-2015 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
6.7 + *
6.8 + * This program is free software: you can redistribute it and/or modify
6.9 + * it under the terms of the GNU General Public License as published by
6.10 + * the Free Software Foundation, version 2 of the License.
6.11 + *
6.12 + * This program is distributed in the hope that it will be useful,
6.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
6.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6.15 + * GNU General Public License for more details.
6.16 + *
6.17 + * You should have received a copy of the GNU General Public License
6.18 + * along with this program. Look for COPYING file in the top folder.
6.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
6.20 + */
6.21 +package org.apidesign.bck2brwsr.aot.junit.test;
6.22 +
6.23 +import org.apidesign.bck2brwsr.aot.junit.RunTest;
6.24 +import org.apidesign.bck2brwsr.vmtest.Compare;
6.25 +import org.apidesign.bck2brwsr.vmtest.VMTest;
6.26 +import org.testng.annotations.Factory;
6.27 +
6.28 +/**
6.29 + *
6.30 + * @author Jaroslav Tulach
6.31 + */
6.32 +public class JUnitRunTest {
6.33 + @Compare public String runTests() throws Exception {
6.34 + return RunTest.run();
6.35 + }
6.36 +
6.37 + @Factory public static Object[] create() {
6.38 + return VMTest.create(JUnitRunTest.class);
6.39 + }
6.40 +}
7.1 --- a/rt/pom.xml Sun Mar 20 19:37:07 2016 +0100
7.2 +++ b/rt/pom.xml Sun Mar 20 19:44:18 2016 +0100
7.3 @@ -18,6 +18,7 @@
7.4 <module>vm</module>
7.5 <module>vmtest</module>
7.6 <module>aot</module>
7.7 + <module>aot-junit</module>
7.8 <module>aot-nb-test</module>
7.9 </modules>
7.10 <profiles>