Revision: 19631
http://sourceforge.net/p/gate/code/19631
Author: markagreenwood
Date: 2016-10-05 06:50:49 +0000 (Wed, 05 Oct 2016)
Log Message:
-----------
more tests of the java compiler, but these are now in ANNIE where the impl
lives rather than in the core
Modified Paths:
--------------
gate/branches/sawdust2/plugins/ANNIE/pom.xml
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/util/compilers/Eclipse.java
Added Paths:
-----------
gate/branches/sawdust2/plugins/ANNIE/src/test/java/gate/util/
gate/branches/sawdust2/plugins/ANNIE/src/test/java/gate/util/TestJavac.java
Removed Paths:
-------------
gate/branches/sawdust2/gate-core/.settings/
gate/branches/sawdust2/gate-core/src/test/disabled/gate/util/TestJavac.java
Deleted:
gate/branches/sawdust2/gate-core/src/test/disabled/gate/util/TestJavac.java
===================================================================
--- gate/branches/sawdust2/gate-core/src/test/disabled/gate/util/TestJavac.java
2016-10-05 06:48:43 UTC (rev 19630)
+++ gate/branches/sawdust2/gate-core/src/test/disabled/gate/util/TestJavac.java
2016-10-05 06:50:49 UTC (rev 19631)
@@ -1,128 +0,0 @@
-/*
- *
- * Copyright (c) 1995-2012, The University of Sheffield. See the file
- * COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
- *
- * This file is part of GATE (see http://gate.ac.uk/), and is free
- * software, licenced under the GNU Library General Public License,
- * Version 2, June 1991 (in the distribution as file licence.html,
- * and also available at http://gate.ac.uk/gate/licence.html).
- *
- * Valentin Tablan, 26/Feb/2002
- *
- * $Id$
- */
-
-package gate.util;
-
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.*;
-
-import gate.Gate;
-
-public class TestJavac extends TestCase{
- /** Construction */
- public TestJavac(String name) { super(name); }
-
- /** Fixture set up */
- @Override
- public void setUp() {
- } // setUp
-
- /** Test suite routine for the test runner */
- public static Test suite() {
- return new TestSuite(TestJavac.class);
- } // suite
-
- /** Jdk compiler */
- public void testCompiler() throws Exception {
-
- String nl = Strings.getNl();
- String javaSource =
- "package foo.bar;" + nl +
- "public class Outer {" + nl +
- "//let's make an inner class " + nl +
- " class Adder{" + nl +
- " public int inc(int i){" + nl +
- " return i + 1;" + nl +
- " }//inc(int)" + nl +
- " }//class Adder" + nl +
- " //let's make another inner class" + nl +
- " class Deccer{" + nl +
- " public int dec(int i){" + nl +
- " return i - 1;" + nl +
- " }//dec(int)" + nl +
- " }//clas Deccer" + nl +
- " //some public methods" + nl +
- " public int inc(int i){" + nl +
- " return new Adder().inc(i);" + nl +
- " }" + nl +
- " public int dec(int i){" + nl +
- " return new Deccer().dec(i);" + nl +
- " }" + nl +
- " }//class Outer" + nl;
-
- //load the class
- Map<String,String> sources = new HashMap<String,String>();
- sources.put("foo.bar.Outer", javaSource);
- Javac.loadClasses(sources, Gate.getClassLoader());
- //try to access the class
- Class<?> testClass = Gate.getClassLoader().loadClass("foo.bar.Outer");
- assertNotNull("Could not find decalred class", testClass);
- Object testInstance = testClass.newInstance();
- assertNotNull("Could not instantiate declared class", testInstance);
- Method testMethod = testClass.getDeclaredMethod(
- "inc",
- new Class[]{int.class});
- assertNotNull("Could not find declared method", testMethod);
- Object result = testMethod.invoke(testInstance,
- new Object[]{new Integer(1)});
- assertEquals("Invalid result", result, new Integer(2));
-
- testMethod = testClass.getDeclaredMethod(
- "dec",
- new Class[]{int.class});
- assertNotNull("Could not find declared method", testMethod);
- result = testMethod.invoke(testInstance, new Object[]{new Integer(2)});
- assertEquals("Invalid result", result, new Integer(1));
- }
-
- public void testCompileError() throws Exception {
- System.err.println("Testing for a compile error:");
- String nl = Strings.getNl();
- String javaSource =
- "package foo.bar;" + nl +
- "public class X {" + nl +
- " //some public methods" + nl +
- " public void foo(){" + nl +
- " String nullStr = null;" + nl +
- "// This should cause a compile error:" + nl +
- " nullStr = 123;" + nl +
- "} " + nl +
- " " + nl +
- " " + nl +
- " }//class Outer" + nl;
-
- //load the class
- Map<String,String> sources = new HashMap<String,String>();
- sources.put("foo.bar.X", javaSource);
- boolean gotException = false;
- try {
- Javac.loadClasses(sources,Gate.getClassLoader());
- }
- catch (GateException ge) {
- gotException = true;
- }
- finally {
-// newSyserr.flush();
-// // re-enable System.out
-// System.setErr(syserr);
-// newSyserr.close();
- }
- assertTrue("Garbage java code did not raise an exception!",
- gotException);
- }
-}
\ No newline at end of file
Modified: gate/branches/sawdust2/plugins/ANNIE/pom.xml
===================================================================
--- gate/branches/sawdust2/plugins/ANNIE/pom.xml 2016-10-05 06:48:43 UTC
(rev 19630)
+++ gate/branches/sawdust2/plugins/ANNIE/pom.xml 2016-10-05 06:50:49 UTC
(rev 19631)
@@ -4,6 +4,8 @@
<modelVersion>4.0.0</modelVersion>
+ <name>ANNIE</name>
+
<parent>
<groupId>uk.ac.gate.plugins</groupId>
<artifactId>base-plugin</artifactId>
Modified:
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/util/compilers/Eclipse.java
===================================================================
---
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/util/compilers/Eclipse.java
2016-10-05 06:48:43 UTC (rev 19630)
+++
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/util/compilers/Eclipse.java
2016-10-05 06:50:49 UTC (rev 19631)
@@ -337,11 +337,11 @@
settings.put(CompilerOptions.OPTION_ReportUnusedLabel,
CompilerOptions.IGNORE);
- // source and target - force 1.6 target as GATE only requires 1.6 or later.
+ // source and target - force 1.8 target as GATE only requires 1.8 or later.
settings.put(CompilerOptions.OPTION_Source,
CompilerOptions.VERSION_1_8);
settings.put(CompilerOptions.OPTION_TargetPlatform,
- CompilerOptions.VERSION_1_6);
+ CompilerOptions.VERSION_1_8);
final IProblemFactory problemFactory =
new DefaultProblemFactory(Locale.getDefault());
Copied:
gate/branches/sawdust2/plugins/ANNIE/src/test/java/gate/util/TestJavac.java
(from rev 19630,
gate/branches/sawdust2/gate-core/src/test/disabled/gate/util/TestJavac.java)
===================================================================
--- gate/branches/sawdust2/plugins/ANNIE/src/test/java/gate/util/TestJavac.java
(rev 0)
+++ gate/branches/sawdust2/plugins/ANNIE/src/test/java/gate/util/TestJavac.java
2016-10-05 06:50:49 UTC (rev 19631)
@@ -0,0 +1,128 @@
+/*
+ *
+ * Copyright (c) 1995-2012, The University of Sheffield. See the file
+ * COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
+ *
+ * This file is part of GATE (see http://gate.ac.uk/), and is free
+ * software, licenced under the GNU Library General Public License,
+ * Version 2, June 1991 (in the distribution as file licence.html,
+ * and also available at http://gate.ac.uk/gate/licence.html).
+ *
+ * Valentin Tablan, 26/Feb/2002
+ *
+ * $Id$
+ */
+
+package gate.util;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.*;
+
+import gate.Gate;
+
+public class TestJavac extends TestCase{
+ /** Construction */
+ public TestJavac(String name) { super(name); }
+
+ /** Fixture set up */
+ @Override
+ public void setUp() {
+ } // setUp
+
+ /** Test suite routine for the test runner */
+ public static Test suite() {
+ return new TestSuite(TestJavac.class);
+ } // suite
+
+ /** Jdk compiler */
+ public void testCompiler() throws Exception {
+
+ String nl = Strings.getNl();
+ String javaSource =
+ "package foo.bar;" + nl +
+ "public class Outer {" + nl +
+ "//let's make an inner class " + nl +
+ " class Adder{" + nl +
+ " public int inc(int i){" + nl +
+ " return i + 1;" + nl +
+ " }//inc(int)" + nl +
+ " }//class Adder" + nl +
+ " //let's make another inner class" + nl +
+ " class Deccer{" + nl +
+ " public int dec(int i){" + nl +
+ " return i - 1;" + nl +
+ " }//dec(int)" + nl +
+ " }//clas Deccer" + nl +
+ " //some public methods" + nl +
+ " public int inc(int i){" + nl +
+ " return new Adder().inc(i);" + nl +
+ " }" + nl +
+ " public int dec(int i){" + nl +
+ " return new Deccer().dec(i);" + nl +
+ " }" + nl +
+ " }//class Outer" + nl;
+
+ //load the class
+ Map<String,String> sources = new HashMap<String,String>();
+ sources.put("foo.bar.Outer", javaSource);
+ Javac.loadClasses(sources, Gate.getClassLoader());
+ //try to access the class
+ Class<?> testClass = Gate.getClassLoader().loadClass("foo.bar.Outer");
+ assertNotNull("Could not find decalred class", testClass);
+ Object testInstance = testClass.newInstance();
+ assertNotNull("Could not instantiate declared class", testInstance);
+ Method testMethod = testClass.getDeclaredMethod(
+ "inc",
+ new Class[]{int.class});
+ assertNotNull("Could not find declared method", testMethod);
+ Object result = testMethod.invoke(testInstance,
+ new Object[]{new Integer(1)});
+ assertEquals("Invalid result", result, new Integer(2));
+
+ testMethod = testClass.getDeclaredMethod(
+ "dec",
+ new Class[]{int.class});
+ assertNotNull("Could not find declared method", testMethod);
+ result = testMethod.invoke(testInstance, new Object[]{new Integer(2)});
+ assertEquals("Invalid result", result, new Integer(1));
+ }
+
+ public void testCompileError() throws Exception {
+ System.err.println("Testing for a compile error:");
+ String nl = Strings.getNl();
+ String javaSource =
+ "package foo.bar;" + nl +
+ "public class X {" + nl +
+ " //some public methods" + nl +
+ " public void foo(){" + nl +
+ " String nullStr = null;" + nl +
+ "// This should cause a compile error:" + nl +
+ " nullStr = 123;" + nl +
+ "} " + nl +
+ " " + nl +
+ " " + nl +
+ " }//class Outer" + nl;
+
+ //load the class
+ Map<String,String> sources = new HashMap<String,String>();
+ sources.put("foo.bar.X", javaSource);
+ boolean gotException = false;
+ try {
+ Javac.loadClasses(sources,Gate.getClassLoader());
+ }
+ catch (GateException ge) {
+ gotException = true;
+ }
+ finally {
+// newSyserr.flush();
+// // re-enable System.out
+// System.setErr(syserr);
+// newSyserr.close();
+ }
+ assertTrue("Garbage java code did not raise an exception!",
+ gotException);
+ }
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs