Index: classlib/make/properties.xml
===================================================================
--- classlib/make/properties.xml (revision 1023650)
+++ classlib/make/properties.xml (working copy)
@@ -849,6 +849,7 @@
+
Index: jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tests/tools/javac/binary/JavacBinTest.java
===================================================================
--- jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tests/tools/javac/binary/JavacBinTest.java (revision 0)
+++ jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tests/tools/javac/binary/JavacBinTest.java (revision 0)
@@ -0,0 +1,208 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.tests.tools.javac.binary;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+import tests.support.Support_Exec;
+
+public class JavacBinTest extends TestCase {
+
+ private static final String RESOURCES = "resources/";
+
+ private static final String javacExe = getJavacPath();
+
+ /**
+ * Method that takes in a non-existent file and checks the output for the
+ * appropriate Error message
+ *
+ */
+ public void test_nonExists() throws IOException, InterruptedException {
+
+ final String testStr = "no_this_test.java";
+ final List args = new ArrayList();
+ args.add(testStr);
+ final Object[] output = Support_Exec.run(javacExe, args, null, false);
+
+ final Integer exitValue = (Integer) output[0];
+ final String stdOut = (String) output[1];
+ final String stdErr = (String) output[2];
+
+ // Clear the ArrayList, to free up the resources
+ args.clear();
+
+ if (exitValue == 0) {
+ System.err.println("Error: " + stdErr);
+ System.err.println("Output: " + stdOut);
+ fail(" The javac process should have terminated abnormally due to a bad parameter");
+ }
+
+ assertTrue("The output should contain \"" + testStr + "\" Error - \""
+ + stdErr + "\"", stdErr.contains(testStr));
+
+ assertTrue("The output should contain \"is missing\" Error - \""
+ + stdErr + "\"", stdErr.contains("is missing"));
+ }
+
+ /**
+ * Method that takes a valid (A program without any errors) file and tests
+ * for the proper return code
+ */
+ public void test_exists() throws IOException, InterruptedException {
+
+ final String testStr = RESOURCES + "Simple.java";
+ final List args = new ArrayList();
+ args.add(testStr);
+ final Object[] output = Support_Exec.run(javacExe, args, null, false);
+
+ final Integer exitValue = (Integer) output[0];
+ final String stdOut = (String) output[1];
+ final String stdErr = (String) output[2];
+
+ // Clear the ArrayList, to free up the resources
+ args.clear();
+
+ if (exitValue != 0) {
+ System.err.println("Error: " + stdErr);
+ System.err.println("Output: " + stdOut);
+ fail(" The javac process terminated abnormally with Exit status "
+ + exitValue);
+ }
+
+ final String classFile = RESOURCES + "Simple.class";
+ final File clsFile = new File(classFile);
+
+ assertTrue("The program " + testStr
+ + " should cleanly compile. Error - \"" + stdErr + "\"",
+ stdErr.trim().equals(""));
+
+ assertTrue("The program output should generate " + classFile, clsFile
+ .exists());
+ }
+
+ /**
+ * 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() throws IOException,
+ InterruptedException {
+
+ final String testStr = RESOURCES + "Sample.java";
+
+ final List args = new ArrayList();
+ args.add(testStr);
+ final Object[] output = Support_Exec.run(javacExe, args, null, false);
+
+ final Integer exitValue = (Integer) output[0];
+ final String stdOut = (String) output[1];
+ final String stdErr = (String) output[2];
+
+ // Clear the ArrayList, to free up the resources
+ args.clear();
+
+ if (exitValue == 0) {
+ System.err.println("Error: " + stdErr);
+ System.err.println("Output: " + stdOut);
+ fail(" The javac process should not terminate normally due to unresolved dependencies ");
+ }
+
+ assertTrue(
+ "The program "
+ + testStr
+ + " shouldn't compile due to unresolved dependencies. Error - \""
+ + stdErr + "\"", stdErr.contains("error"));
+ }
+
+ /**
+ * 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() throws IOException,
+ InterruptedException {
+
+ final String testStr = RESOURCES + "Sample.java";
+ final String option1 = "-classpath";
+ final String jarFile = RESOURCES + "Dependency.jar";
+
+ final List args = new ArrayList();
+ args.add(testStr);
+ args.add(option1);
+ args.add(jarFile);
+
+ final Object[] output = Support_Exec.run(javacExe, args, null, false);
+
+ // Clear the ArrayList, to free up the resources
+ args.clear();
+
+ final Integer exitValue = (Integer) output[0];
+ final String stdOut = (String) output[1];
+ final String stdErr = (String) output[2];
+
+ if (exitValue != 0) {
+ System.err.println("Error: " + stdErr);
+ System.err.println("Output: " + stdOut);
+ fail(" The javac process terminated abnormally with Exit status "
+ + exitValue);
+ }
+
+ final String classFile = RESOURCES + "Sample.class";
+ final File clsFile = new File(classFile);
+
+ assertTrue("The program " + testStr
+ + " should compile as the dependency " + jarFile
+ + " is resolved. Error - " + stdErr, stdErr.trim().equals("")
+ && clsFile.exists());
+ }
+
+ /**
+ * Method to construct an absolute path to the javac executable
+ * test.jre.home needs to be set to a proper value for this to work
+ *
+ * @return Absolute path to the javac executable
+ */
+ private static String getJavacPath() {
+ String jreHome = System.getProperty("test.jre.home");
+ String osName = System.getProperty("os.name");
+ String extn = null;
+ String executable = null;
+ if (jreHome != null) {
+ if (!jreHome.endsWith(File.separator)) {
+ jreHome += File.separator;
+ }
+ executable = jreHome + ".." + File.separator + "bin"
+ + File.separator + "javac";
+ if (osName.contains("Windows"))
+ extn = ".exe";
+ else
+ extn = "";
+ File exeFile = new File(executable + extn);
+ if (!exeFile.exists()) {
+ System.err.println("test.jre.home " + jreHome);
+ fail("Please set test.jre.home to point to the jre directory of the appropriate JDK");
+ }
+ } else {
+ System.err.println("test.jre.home " + jreHome);
+ fail("Please set test.jre.home to point to the jre directory of the appropriate JDK");
+ }
+ return executable;
+ }
+}
Index: jdktools/modules/jdktools/src/test/java/windows/org/apache/harmony/tests/tools/javaw/binary/JavawBinTest.java
===================================================================
--- jdktools/modules/jdktools/src/test/java/windows/org/apache/harmony/tests/tools/javaw/binary/JavawBinTest.java (revision 0)
+++ jdktools/modules/jdktools/src/test/java/windows/org/apache/harmony/tests/tools/javaw/binary/JavawBinTest.java (revision 0)
@@ -0,0 +1,271 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.tests.tools.javaw.binary;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+import tests.support.Support_Exec;
+
+public class JavawBinTest extends TestCase {
+
+ private static final String RESOURCES = "resources/";
+
+ private static final String javawExe = getJavawPath();
+
+ /**
+ * Method that attempts a execution of a class file using javaw
+ *
+ * @throws IOException
+ * IOException thrown during a stream read
+ * @throws InterruptedException
+ * InterruptedException during a Thread interrupt
+ */
+ public void testExecution() throws IOException, InterruptedException {
+
+ String javacExe = getJavacPath();
+ // Compile a file
+ final String testStr = RESOURCES + "Simple.java";
+
+ final List args = new ArrayList();
+ args.add(testStr);
+ final Object[] compilationOutput = Support_Exec.run(javacExe, args,
+ null, false);
+
+ Integer exitValue = (Integer) compilationOutput[0];
+ String stdOut = (String) compilationOutput[1];
+ String stdErr = (String) compilationOutput[2];
+
+ if (exitValue != 0) {
+ System.err.println("Error: " + stdErr);
+ System.err.println("Output: " + stdOut);
+ fail(" The javac process terminated abnormally with Exit status "
+ + exitValue);
+ }
+
+ final String classFile = RESOURCES + "Simple";
+ final File clsFile = new File(classFile + ".class");
+
+ assertTrue("The program " + testStr
+ + " should cleanly compile. Error \"" + stdErr + "\"", stdErr
+ .trim().equals(""));
+
+ assertTrue(" Class file " + classFile + " does not exist ", clsFile
+ .exists());
+
+ args.clear();
+ args.add(classFile);
+ final Object[] execOutput = Support_Exec.run(javawExe, args, null,
+ false);
+
+ exitValue = (Integer) execOutput[0];
+ stdOut = (String) execOutput[1];
+ stdErr = (String) execOutput[2];
+
+ // Clear the ArrayList, to free up the resources
+ args.clear();
+
+ if (exitValue != 0) {
+ System.err.println("Error: " + stdErr);
+ System.err.println("Output: " + stdOut);
+ fail(" The javaw process terminated abnormally with Exit status "
+ + exitValue);
+ }
+
+ assertTrue("Class file " + classFile
+ + " executed with errors. Error - \"" + stdErr + "\"", stdErr
+ .trim().equals(""));
+
+ assertTrue("Program output doesn't contain \"Hello World\"", stdOut
+ .contains("Hello World"));
+
+ }
+
+ /**
+ * Method to execute a Jar file
+ *
+ * @throws IOException
+ * IOException thrown during a stream read
+ * @throws InterruptedException
+ * InterruptedException during a Thread interrupt
+ */
+ public void testJarExecution() throws IOException, InterruptedException {
+ final String jarFile = RESOURCES + "Simple.jar";
+
+ final List args = new ArrayList();
+ args.add("-jar");
+ args.add(jarFile);
+ final Object[] output = Support_Exec.run(javawExe, args, null, false);
+
+ Integer exitValue = (Integer) output[0];
+ String stdOut = (String) output[1];
+ String stdErr = (String) output[2];
+
+ // Clear the ArrayList, to free up the resources
+ args.clear();
+
+ if (exitValue != 0) {
+ System.err.println("Error: " + stdErr);
+ System.err.println("Output: " + stdOut);
+ fail(" The javaw process terminated abnormally with Exit status "
+ + exitValue);
+ }
+
+ assertTrue("Jar file " + jarFile
+ + " was executed with errors. Error - \"" + stdErr + "\"",
+ stdErr.trim().equals(""));
+
+ assertTrue("Program output doesn't contain \"Hello World\"", stdOut
+ .contains("Hello World"));
+ }
+
+ /**
+ * Method to execute a jar which depends on another class and the class is
+ * not resolved in the classpath
+ *
+ * @throws IOException
+ * IOException thrown during a stream read
+ * @throws InterruptedException
+ * InterruptedException during a Thread interrupt
+ */
+ public void testJarExecWithUnresolvedCP() throws IOException,
+ InterruptedException {
+ final String jarFile = RESOURCES + "Sample_unresolved.jar";
+
+ final List args = new ArrayList();
+ args.add("-jar");
+ args.add(jarFile);
+ final Object[] output = Support_Exec.run(javawExe, args, null, false);
+
+ Integer exitValue = (Integer) output[0];
+ String stdOut = (String) output[1];
+ String stdErr = (String) output[2];
+
+ // Clear the ArrayList, to free up the resources
+ args.clear();
+
+ if (exitValue == 0) {
+ System.err.println("Error: " + stdErr);
+ System.err.println("Output: " + stdOut);
+ fail(" The javaw process should not terminate normally due to unresolved dependencies");
+ }
+ assertTrue("Jar file " + jarFile + " wasn't executed. Error - \""
+ + stdErr + "\"", stdErr.contains("ClassNotFoundException")
+ || stdErr.contains("NoClassDefFoundError"));
+ }
+
+ /**
+ * Method to execute a jar which depends on another class and the class is
+ * resolved in the classpath
+ *
+ * @throws IOException
+ * @throws InterruptedException
+ */
+ public void testJarExecWithResolvedCP() throws IOException,
+ InterruptedException {
+ final String jarFile = RESOURCES + "Sample_resolved.jar";
+
+ final List args = new ArrayList();
+ args.add("-jar");
+ args.add(jarFile);
+ final Object[] output = Support_Exec.run(javawExe, args, null, false);
+
+ Integer exitValue = (Integer) output[0];
+ String stdOut = (String) output[1];
+ String stdErr = (String) output[2];
+
+ // Clear the ArrayList, to free up the resources
+ args.clear();
+
+ if (exitValue != 0) {
+ System.err.println("Error: " + stdErr);
+ System.err.println("Output: " + stdOut);
+ fail(" The javaw process terminated abnormally with Exit status "
+ + exitValue);
+ }
+
+ assertTrue("Jar file " + jarFile + " wasn't executed. Error - \""
+ + stdErr + "\"", stdErr.trim().equals(""));
+
+ assertTrue("Failure output doesn't contain \"Dependency\" StdOut - "
+ + stdOut, stdOut.contains("Dependency"));
+ }
+
+ /**
+ * Method to construct an absolute path to the javac executable
+ * test.jre.home needs to be set to a proper value for this to work
+ *
+ * @return Absolute path to the javac executable
+ */
+ private static String getJavacPath() {
+ String jreHome = System.getProperty("test.jre.home");
+ String osName = System.getProperty("os.name");
+ String extn = null;
+ String executable = null;
+ if (jreHome != null) {
+ if (!jreHome.endsWith(File.separator)) {
+ jreHome += File.separator;
+ }
+ executable = jreHome + ".." + File.separator + "bin"
+ + File.separator + "javac";
+ if (osName.contains("Windows"))
+ extn = ".exe";
+ else
+ extn = "";
+ File exeFile = new File(executable + extn);
+ if (!exeFile.exists()) {
+ System.err.println("test.jre.home " + jreHome);
+ fail("Please set test.jre.home to point to the jre directory of the appropriate JDK");
+ }
+ } else {
+ System.err.println("test.jre.home " + jreHome);
+ fail("Please set test.jre.home to point to the jre directory of the appropriate JDK");
+ }
+ return executable;
+ }
+
+ /**
+ * Method to construct an absolute path to the javaw executable
+ * test.jre.home needs to be set to a proper value for this to work
+ *
+ * @return Absolute path to the javaw executable
+ */
+ private static String getJavawPath() {
+ String jreHome = System.getProperty("test.jre.home");
+ String executable = null;
+ if (jreHome != null) {
+ if (!jreHome.endsWith(File.separator)) {
+ jreHome += File.separator;
+ }
+ // This is a Windows only test
+ executable = jreHome + "bin" + File.separator + "javaw.exe";
+ File exeFile = new File(executable);
+ if (!exeFile.exists()) {
+ System.err.println("test.jre.home " + jreHome);
+ fail("Please set test.jre.home to point to the jre directory of the appropriate JDK");
+ }
+ } else {
+ System.err.println("test.jre.home " + jreHome);
+ fail("Please set test.jre.home to point to the jre directory of the appropriate JDK");
+ }
+ return executable;
+ }
+}
\ No newline at end of file
Index: jdktools/modules/jdktools/src/test/resources/Dependency.jar
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: jdktools/modules/jdktools/src/test/resources/Sample.java
===================================================================
--- jdktools/modules/jdktools/src/test/resources/Sample.java (revision 1023650)
+++ jdktools/modules/jdktools/src/test/resources/Sample.java (working copy)
@@ -20,12 +20,13 @@
public class Sample {
- /**
+ /**Command line arguments
* @param args
*/
public static void main(String[] args) {
- // TODO Auto-generated method stub
+
Dependency d = new Dependency(10,20);
+ System.out.println(d.toString());
}
}
Index: jdktools/modules/jdktools/src/test/resources/Sample_resolved.jar
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: jdktools\modules\jdktools\src\test\resources\Sample_resolved.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Index: jdktools/modules/jdktools/src/test/resources/Sample_unresolved.jar
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: jdktools\modules\jdktools\src\test\resources\Sample_unresolved.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Index: jdktools/modules/jdktools/src/test/resources/Simple.jar
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: jdktools\modules\jdktools\src\test\resources\Simple.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream