You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by hi...@apache.org on 2010/08/11 23:47:03 UTC
svn commit: r984597 - in
/harmony/enhanced/java/trunk/jdktools/modules/jdktools: ./
src/test/java/org/apache/harmony/tests/tools/javac/ src/test/resources/
Author: hindessm
Date: Wed Aug 11 21:47:02 2010
New Revision: 984597
URL: http://svn.apache.org/viewvc?rev=984597&view=rev
Log:
Apply patch and zip from "[#HARMONY-6618] [jdktools] Additional Unit
tests to increase the functional verification for javac".
Added:
harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/resources/
harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/resources/Dependency.jar (with props)
harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/resources/Sample.java (with props)
harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/resources/Simple.java (with props)
Modified:
harmony/enhanced/java/trunk/jdktools/modules/jdktools/build.xml
harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/java/org/apache/harmony/tests/tools/javac/MainTest.java
Modified: harmony/enhanced/java/trunk/jdktools/modules/jdktools/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/jdktools/modules/jdktools/build.xml?rev=984597&r1=984596&r2=984597&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/jdktools/modules/jdktools/build.xml (original)
+++ harmony/enhanced/java/trunk/jdktools/modules/jdktools/build.xml Wed Aug 11 21:47:02 2010
@@ -169,6 +169,11 @@
<mkdir dir="${tests.hdk.dir}" />
<copy file="make/run-test.xml" tofile="${tests.hdk.dir}/build.xml" />
+
+ <copy todir= "${tests.hdk.dir}/resources">
+ <fileset dir = "src/test/resources" />
+ </copy>
+
<hy.jar.bin destfile="${tests.hdk.dir}/${hy.module}_tests.jar">
<fileset dir="bin/test" />
Modified: harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/java/org/apache/harmony/tests/tools/javac/MainTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/java/org/apache/harmony/tests/tools/javac/MainTest.java?rev=984597&r1=984596&r2=984597&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/java/org/apache/harmony/tests/tools/javac/MainTest.java (original)
+++ harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/java/org/apache/harmony/tests/tools/javac/MainTest.java Wed Aug 11 21:47:02 2010
@@ -17,22 +17,82 @@
package org.apache.harmony.tests.tools.javac;
-import junit.framework.TestCase;
+import java.io.File;
import java.io.PrintWriter;
import java.io.StringWriter;
-import com.sun.tools.javac.Main;
+import junit.framework.TestCase;
-public class MainTest extends TestCase {
+import com.sun.tools.javac.Main;
- public void test_main() throws Exception {
- StringWriter out = new StringWriter();
- String testStr = "no_this_test.java";
- Main.compile(new String[]{testStr}, new PrintWriter(out));
- assertTrue("The output should have " + testStr, out.toString().contains(testStr));
+public class MainTest extends TestCase {
+
+ private static final String RESOURCES = "resources/";
+
+ /**
+ * Method that takes in a non-existent file and checks the output for the appropriate Error message
+ *
+ */
+ public void test_nonExists() {
+ final StringWriter out = new StringWriter();
+ final String testStr = "no_this_test.java";
+ final int rc = Main.compile(new String[]{testStr}, new PrintWriter(out));
+ assertTrue("The output should have " + testStr, out.toString().contains("missing") && rc == 1);
}
-
- public void test_nothing() {
- // bogus test
- }
+
+ /**
+ * Method that takes a valid (A pgm without any errors) file and tests for the proper return code
+ */
+ public void test_exists()
+ {
+ final StringWriter out = new StringWriter();
+ final StringWriter err = new StringWriter();
+
+ final String srcFile = RESOURCES + "Simple.java";
+ final File f = new File(srcFile);
+ final String testStr = f.getAbsolutePath();
+
+ final int rc = Main.compile(new String[]{testStr}, new PrintWriter(out), new PrintWriter(err));
+ assertTrue("The program " + testStr + " should cleanly compile", err.toString().trim().equals("") && rc == 0 );
+ }
+
+ /**
+ * Method that takes a valid (A program without any errors) file but with unresolved dependencies and tests for the proper return code
+ */
+ public void test_existsWithUnresolvedDep()
+ {
+ final StringWriter out = new StringWriter();
+ final StringWriter err = new StringWriter();
+
+ final String srcFile = RESOURCES + "Sample.java";
+ final File f = new File(srcFile);
+ final String testStr = f.getAbsolutePath();
+
+ final int rc = Main.compile(new String[]{testStr}, new PrintWriter(out), new PrintWriter(err));
+ assertTrue("The program " + testStr + " shouldn't compile due to unresolved dependencies", err.toString().contains("ERROR") && (rc == 1) );
+ }
+
+ /**
+ * Method that takes a valid (A program without any errors) file with Resolved dependencies and tests for the proper return code
+ */
+ public void test_existsWithResolvedDep()
+ {
+ final StringWriter out = new StringWriter();
+ final StringWriter err = new StringWriter();
+
+ final String srcFile = RESOURCES + "Sample.java";
+ final File f = new File(srcFile);
+ final String testStr = f.getAbsolutePath();
+
+ final String option1 = "-classpath" ;
+
+ final String jarFile = RESOURCES + "Dependency.jar";
+ final File f1 = new File(jarFile);
+ final String option2 = f1.getAbsolutePath();
+
+ final int rc = Main.compile(new String[]{testStr, option1, option2}, new PrintWriter(out), new PrintWriter(err));
+ assertTrue("The program " + testStr + " should compile as dependency " + option2 + " is resolved", ! err.toString().contains("ERROR") && (rc == 0) );
+ }
+
+
}
Added: harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/resources/Dependency.jar
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/resources/Dependency.jar?rev=984597&view=auto
==============================================================================
Binary file - no diff available.
Propchange: harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/resources/Dependency.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/resources/Sample.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/resources/Sample.java?rev=984597&view=auto
==============================================================================
--- harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/resources/Sample.java (added)
+++ harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/resources/Sample.java Wed Aug 11 21:47:02 2010
@@ -0,0 +1,15 @@
+package tests.resources;
+
+import tests.resources.jdktools.Dependency;
+
+public class Sample {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+ Dependency d = new Dependency(10,20);
+ }
+
+}
Propchange: harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/resources/Sample.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/resources/Simple.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/resources/Simple.java?rev=984597&view=auto
==============================================================================
--- harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/resources/Simple.java (added)
+++ harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/resources/Simple.java Wed Aug 11 21:47:02 2010
@@ -0,0 +1,10 @@
+package tests.resources.jdktools;
+
+public class Simple
+{
+ static public void main(String[] args)
+ {
+ // Do Nothing
+ }
+
+}
\ No newline at end of file
Propchange: harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/resources/Simple.java
------------------------------------------------------------------------------
svn:eol-style = native