Index: modules/jdktools/build.xml
===================================================================
--- modules/jdktools/build.xml (revision 984320)
+++ modules/jdktools/build.xml (working copy)
@@ -169,6 +169,11 @@
+
+
+
+
+
Index: modules/jdktools/src/test/java/org/apache/harmony/tests/tools/javac/MainTest.java
===================================================================
--- modules/jdktools/src/test/java/org/apache/harmony/tests/tools/javac/MainTest.java (revision 984320)
+++ modules/jdktools/src/test/java/org/apache/harmony/tests/tools/javac/MainTest.java (working copy)
@@ -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 junit.framework.TestCase;
+
import com.sun.tools.javac.Main;
-public class MainTest extends TestCase {
-
- 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) );
+ }
+
+
}
Index: modules/jdktools/src/test/resources/Dependency.jar
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: modules\jdktools\src\test\resources\Dependency.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Index: modules/jdktools/src/test/resources/Sample.java
===================================================================
--- modules/jdktools/src/test/resources/Sample.java (revision 0)
+++ modules/jdktools/src/test/resources/Sample.java (revision 0)
@@ -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);
+ }
+
+}
Index: modules/jdktools/src/test/resources/Simple.java
===================================================================
--- modules/jdktools/src/test/resources/Simple.java (revision 0)
+++ modules/jdktools/src/test/resources/Simple.java (revision 0)
@@ -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