changeset 30:b3c0a99a49f6

jtreg supports junit
author jrose
date Mon, 12 Oct 2009 16:27:58 -0700
parents 7c3f96e3b7f0
children 912e00503502
files jtreg/jtreg-no-junit.zip jtreg/junitsupport.patch jtreg/junitsupport.txt
diffstat 3 files changed, 1290 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
Binary file jtreg/jtreg-no-junit.zip has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jtreg/junitsupport.patch	Mon Oct 12 16:27:58 2009 -0700
@@ -0,0 +1,1261 @@
+diff --git a/.hgignore b/.hgignore
+--- a/.hgignore
++++ b/.hgignore
+@@ -1,2 +1,3 @@
+ ^(build|dist)/
+-nbproject/private/
+\ No newline at end of file
++nbproject/private/
++^make/faq.*html
+\ No newline at end of file
+diff --git a/make/Defs.gmk b/make/Defs.gmk
+--- a/make/Defs.gmk
++++ b/make/Defs.gmk
+@@ -82,6 +82,12 @@
+ 
+ JAVATEST_JAR = $(JAVATEST_HOME)/lib/javatest.jar
+ 
++#----- JUnit 4: see http://www.junit.org/
++
++# http://sourceforge.net/projects/junit/files/junit/4.5/junit-4.5.jar/download
++
++JUNIT_JAR = /w/jjg/work/os-jtreg/junit-4.5.jar
++
+ #----- Ant: see http://ant.apache.org/
+ 
+ ifndef ANTHOME
+diff --git a/make/Makefile b/make/Makefile
+--- a/make/Makefile
++++ b/make/Makefile
+@@ -43,6 +43,7 @@
+ include doc.gmk
+ include javatest.gmk
+ include javahelp.gmk
++include junit.gmk
+ 
+ #----------------------------------------------------------------------
+ #
+diff --git a/make/build.properties b/make/build.properties
+--- a/make/build.properties
++++ b/make/build.properties
+@@ -39,6 +39,9 @@
+ jhall.jar = ${javahelp.home}/lib/jhall.jar
+ jh.jar = ${javahelp.home}/lib/jh.jar
+ 
++# JUnit (should be 4.5 or better)
++junit.jar = /w/jjg/work/os-jtreg/junit-4.5.jar
++
+ # Ant ((should be version 1.6.5 or better)
+ #ant.home = 
+ ant.jar = /usr/share/java/ant.jar
+diff --git a/make/build.xml b/make/build.xml
+--- a/make/build.xml
++++ b/make/build.xml
+@@ -44,6 +44,7 @@
+     <property name="dist.dir" location="dist" />
+     <property name="dist.jtreg.dir" location="${dist.dir}/jtreg" />
+     <property name="dist.jtreg.zip" location="${dist.dir}/jtreg.zip" />
++    <property name="dist.jtreg-no-junit.zip" location="${dist.dir}/jtreg-no-junit.zip" />
+     
+     <patternset id="helpset">
+         <include name="*.hs"/>
+@@ -71,6 +72,7 @@
+         </tstamp>
+         <available property="javatest.ok" file="${javatest.home}/COPYRIGHT-javatest.html"/>
+         <available property="jtharness.ok" file="${javatest.home}/legal/copyright.txt"/>
++        <available property="junit.ok" file="${junit.jar}"/>
+     </target>
+     
+     <!-- ********** jtreg ************************************************** -->
+@@ -91,11 +93,15 @@
+     </patternset>
+     
+     <target name="dist-jtreg" 
+-        depends="import-javatest,import-jtharness,jar-jtreg,-dist-jtreg.bin,-dist-jtreg.doc,-dist-jtreg.legal"
++        depends="import-javatest,import-junit,import-jtharness,jar-jtreg,-dist-jtreg.bin,-dist-jtreg.doc,-dist-jtreg.legal"
+         description="build jtreg for distribution">
+         <zip destfile="${dist.jtreg.zip}" filesOnly="true" basedir="${dist.dir}">
+             <include name="jtreg/"/>
+         </zip>
++        <zip destfile="${dist.jtreg-no-junit.zip}" filesOnly="true" basedir="${dist.dir}">
++            <include name="jtreg/"/>
++            <exclude name="**/*junit*"/>
++        </zip>
+     </target>
+     
+     <target name="-dist-jtreg.bin" depends="jar-jtreg,-dist-jtreg.doc">
+@@ -134,7 +140,7 @@
+             <manifest>
+                 <attribute name="Built-By" value="${user.name}"/>
+                 <attribute name="Main-Class" value="com.sun.javatest.regtest.Main"/>
+-                <attribute name="Class-Path" value="javatest.jar jh.jar"/>
++                <attribute name="Class-Path" value="javatest.jar jh.jar junit.jar"/>
+                 <attribute name="jtreg-Name" value="jtreg"/>
+                 <attribute name="jtreg-Version" value="${build.version}"/>
+                 <attribute name="jtreg-Milestone" value="${build.milestone}"/>
+@@ -166,7 +172,7 @@
+             debug="true" debuglevel="source,lines" 
+             srcdir="${src.classes.dir}" 
+             destdir="${build.classes.dir}"
+-            classpath="${build.classes.dir}:${javatest.jar}">
++            classpath="${build.classes.dir}:${javatest.jar}:${junit.jar}">
+             <patternset refid="jtreg.jdk11.files"/>
+             <compilerarg line="-Xlint:deprecation -Werror"/>
+         </javac>
+@@ -174,7 +180,7 @@
+             debug="true" debuglevel="source,lines" 
+             srcdir="${src.classes.dir}" 
+             destdir="${build.classes.dir}"
+-            classpath="${build.classes.dir}:${javatest.jar}">
++            classpath="${build.classes.dir}:${javatest.jar}:${junit.jar}">
+             <compilerarg line="-Xlint:all -Werror"/>
+             <patternset refid="jtreg.packages"/>
+         </javac>
+@@ -247,7 +253,7 @@
+         <!-- have to set fork=true because otherwise output redirection gets screwed up -->
+         <mkdir dir="${build.dir}/jtreg"/>
+         <java fork="true" failonerror="true"
+-            classname="com.sun.javatest.regtest.Main" classpath="${build.classes.dir}:${javatest.jar}:${jh.jar}"
++            classname="com.sun.javatest.regtest.Main" classpath="${build.classes.dir}:${javatest.jar}:${junit.jar}:${jh.jar}"
+             output="${build.dir}/jtreg/usage.txt">
+             <jvmarg value="-Dprogram=jtreg"/>
+             <arg value="-help"/>
+@@ -274,6 +280,10 @@
+         <copy file="${javatest.jar}" tofile="${dist.jtreg.dir}/lib/javatest.jar"/>
+     </target>
+ 
++    <target name="import-junit" depends="-init" if="junit.ok">
++        <copy file="${junit.jar}" tofile="${dist.jtreg.dir}/lib/junit.jar"/>
++    </target>
++
+     <target name="import-jtharness" depends="-init,import-javahelp" if="jtharness.ok">
+         <copy todir="${dist.jtreg.dir}/legal/jtharness" file="${javatest.home}/legal/copyright.txt"/>
+         <copy todir="${dist.jtreg.dir}/legal/jtharness" file="${javatest.home}/legal/license.txt"/>
+@@ -329,7 +339,7 @@
+  
+     <target name="-test-jtreg.i18n" depends="compile-jtreg,-ant-jct.utils">
+         <!-- have to set fork=true because otherwise output redirection gets screwed up -->
+-        <java fork="true" classname="com.sun.javatest.regtest.Main" classpath="${build.classes.dir}:${javatest.jar}:${jh.jar}"
++        <java fork="true" classname="com.sun.javatest.regtest.Main" classpath="${build.classes.dir}:${javatest.jar}:${junit.jar}:${jh.jar}"
+             output="${build.dir}/jtreg.i18n" >
+             <sysproperty key="javatest.i18n.log" value="com.sun.javatest.regtest"/>
+             <arg value="-help"/>
+diff --git a/make/classes_com_sun_javatest_regtest.gmk b/make/classes_com_sun_javatest_regtest.gmk
+--- a/make/classes_com_sun_javatest_regtest.gmk
++++ b/make/classes_com_sun_javatest_regtest.gmk
+@@ -42,6 +42,7 @@
+ 	IgnoreAction.java \
+ 	IgnoreKind.java \
+ 	JDK.java \
++	JUnitAction.java \
+ 	Main.java \
+ 	MainAction.java \
+ 	Option.java \
+@@ -71,14 +72,14 @@
+ 		$(JAVAFILES.com.sun.javatest.regtest-jdk11:%=$(JAVADIR)/com/sun/javatest/regtest/%) \
+ 		$(JAVATEST_JAR) \
+ 		$(CLASSDIR)
+-	CLASSPATH=$(JAVADIR):$(CLASSDIR):$(JAVATEST_JAR) \
++	CLASSPATH=$(JAVADIR):$(CLASSDIR):$(JAVATEST_JAR):$(JUNIT_JAR) \
+ 		$(J2SEJAVAC) -source 1.2 -target 1.1 -d $(CLASSDIR) $(JAVAFILES.com.sun.javatest.regtest-jdk11:%=$(JAVADIR)/com/sun/javatest/regtest/%)
+ 	echo "classes built at `date`" > $@
+ 
+ $(BUILDDIR)/classes.com.sun.javatest.regtest.ok: \
+ 		$(JAVAFILES.com.sun.javatest.regtest-j2se:%=$(JAVADIR)/com/sun/javatest/regtest/%) \
+ 		$(BUILDDIR)/classes.com.sun.javatest.regtest-jdk11.ok 
+-	CLASSPATH=$(CLASSDIR):$(ANTHOME)/lib/ant.jar:$(JAVATEST_JAR):$(JAVAHELP_JAR) \
++	CLASSPATH=$(CLASSDIR):$(ANTHOME)/lib/ant.jar:$(JAVATEST_JAR):$(JUNIT_JAR):$(JAVAHELP_JAR) \
+ 		$(J2SEJAVAC) -target $(J2SEJAVAC_TARGET) -encoding ISO8859-1 -d $(CLASSDIR) $(JAVAFILES.com.sun.javatest.regtest-j2se:%=$(JAVADIR)/com/sun/javatest/regtest/%)
+ 	echo "classes built at `date`" > $@
+ 
+diff --git a/make/export.gmk b/make/export.gmk
+--- a/make/export.gmk
++++ b/make/export.gmk
+@@ -29,6 +29,7 @@
+ #
+ 
+ ZIPFILES = $(IMAGES_DIR)/jtreg.zip
++ZIPFILES += $(IMAGES_DIR)/jtreg-no-junit.zip
+ VERBOSEZIPFILES = $(ZIPFILES:%.zip=%-$(VERBOSE_ZIP_SUFFIX).zip)
+ 
+ BUILDFILES += $(ZIPFILES)
+diff --git a/make/jtreg.gmk b/make/jtreg.gmk
+--- a/make/jtreg.gmk
++++ b/make/jtreg.gmk
+@@ -25,6 +25,7 @@
+ 
+ 
+ JTREG_ZIP = $(IMAGES_DIR)/jtreg.zip
++JTREG_NO_JUNIT_ZIP = $(IMAGES_DIR)/jtreg-no-junit.zip
+ 	
+ TARGETS.ZIP.jtreg += $(JTREG_IMAGEJARDIR)/javatest.jar
+ TARGETS.ZIP.jtreg += $(JTREG_IMAGEJARDIR)/jh.jar
+@@ -34,5 +35,12 @@
+ 	$(RM) $@
+ 	dir=`pwd`; cd $(IMAGES_DIR); $(ZIP) -rq $$dir/$@ $(@F:%.zip=%)
+ 
++$(JTREG_NO_JUNIT_ZIP): $(JTREG_ZIP)
++	$(RM) $@ $@-tmp.zip
++	$(CP) $(JTREG_ZIP) $@-tmp.zip
++	$(ZIP) -d $@-tmp.zip `(cd $(IMAGES_DIR); find jtreg -type f | grep -i junit)`
++	$(CP) $@-tmp.zip $@
++	$(RM) $@-tmp.zip
++
+ TESTS += \
+ 	$(TESTS.jtreg) 
+diff --git a/make/javatest.gmk b/make/junit.gmk
+copy from make/javatest.gmk
+copy to make/junit.gmk
+--- a/make/javatest.gmk
++++ b/make/junit.gmk
+@@ -1,5 +1,5 @@
+ #
+-# Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
++# Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
+ # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ #
+ # This code is free software; you can redistribute it and/or modify it
+@@ -23,34 +23,9 @@
+ # have any questions.
+ #
+ 
+-ifdef JTHARNESS_HOME
+-    TARGETS.ZIP.jtreg += $(JTREG_IMAGEDIR)/legal/jtharness/copyright.txt
+-    TARGETS.ZIP.jtreg += $(JTREG_IMAGEDIR)/legal/jtharness/license.txt
+-else
+-    TARGETS.ZIP.jtreg += $(JTREG_IMAGEDIR)/legal/javatest/copyright.html
+-    TARGETS.ZIP.jtreg += $(JTREG_IMAGEDIR)/doc/javatest/javatestGUI.pdf
+-endif
++TARGETS.ZIP.jtreg += $(JTREG_IMAGEJARDIR)/junit.jar
+ 
+-$(JTREG_IMAGEDIR)/legal/jtharness/copyright.txt \
+-$(JTREG_IMAGEDIR)/legal/jtharness/license.txt: \
+-		$(JTREG_IMAGEDIR)/legal/jtharness/%: $(JTHARNESS_HOME)/legal/%
++$(JTREG_IMAGEDIR)/lib/junit.jar: $(JUNIT_JAR)
+ 	$(RM) -f $@
+ 	$(MKDIR) -p $(@D)
+-	$(CP) $< $@
+-
+-$(JTREG_IMAGEDIR)/legal/javatest/copyright.html: \
+-		$(JAVATEST_HOME)/COPYRIGHT-javatest.html
+-	$(RM) -f $@
+-	$(MKDIR) -p $(@D)
+-	$(CP) $< $@
+-
+-$(JTREG_IMAGEDIR)/doc/javatest/javatestGUI.pdf: \
+-		$(JTREG_IMAGEDIR)/%: $(JAVATEST_HOME)/%
+-	$(RM) -f $@
+-	$(MKDIR) -p $(@D)
+-	$(CP) $< $@
+-
+-$(JTREG_IMAGEDIR)/lib/javatest.jar: $(JAVATEST_JAR)
+-	$(RM) -f $@
+-	$(MKDIR) -p $(@D)
+-	$(CP) $(JAVATEST_JAR) $@
++	$(CP) $(JUNIT_JAR) $@
+diff --git a/make/netbeans/jtreg/nbproject/project.xml b/make/netbeans/jtreg/nbproject/project.xml
+--- a/make/netbeans/jtreg/nbproject/project.xml
++++ b/make/netbeans/jtreg/nbproject/project.xml
+@@ -56,16 +56,16 @@
+                     <location>${root}/make</location>
+                 </source-folder>
+                 <source-folder>
++                    <label>jtreg</label>
++                    <location>.</location>
++                    <encoding>UTF-8</encoding>
++                </source-folder>
++                <source-folder>
+                     <label>Source files</label>
+                     <type>java</type>
+                     <location>${root}/src/share/classes</location>
+                     <encoding>UTF-8</encoding>
+                 </source-folder>
+-                <source-folder>
+-                    <label>jtreg</label>
+-                    <location>.</location>
+-                    <encoding>UTF-8</encoding>
+-                </source-folder>
+             </folders>
+             <ide-actions>
+                 <action name="build">
+@@ -85,6 +85,10 @@
+                     <target>clean</target>
+                     <target>build</target>
+                 </action>
++                <action name="debug">
++                    <script>nbproject/ide-file-targets.xml</script>
++                    <target>debug-nb</target>
++                </action>
+             </ide-actions>
+             <view>
+                 <items>
+@@ -106,6 +110,7 @@
+                     <ide-action name="rebuild"/>
+                     <ide-action name="clean"/>
+                     <ide-action name="test"/>
++                    <ide-action name="debug"/>
+                 </context-menu>
+             </view>
+             <subprojects/>
+@@ -113,7 +118,7 @@
+         <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/1">
+             <compilation-unit>
+                 <package-root>${root}/src/share/classes</package-root>
+-                <classpath mode="compile">${javatest.jar}:${jh.jar}:${ant.jar}</classpath>
++                <classpath mode="compile">/Users/jrose/Downloads/jtharness-4_2_1-dev-bin-b10-24_sep_2009/lib/javatest.jar:/Users/jrose/Downloads/jtharness-4_2_1-dev-bin-b10-24_sep_2009/lib/jh.jar:/Users/jrose/Downloads/jtharness-4_2_1-dev-bin-b10-24_sep_2009/lib/jt-junit.jar:/Users/jrose/env/ANT_HOME/lib/ant.jar:/Users/jrose/Projects/jtharness/code/src:../../../../../env/jars/junit-4.5.jar</classpath>
+                 <source-level>1.5</source-level>
+             </compilation-unit>
+         </java-data>
+diff --git a/src/share/classes/com/sun/javatest/diff/i18n.properties b/src/share/classes/com/sun/javatest/diff/i18n.properties
+--- a/src/share/classes/com/sun/javatest/diff/i18n.properties
++++ b/src/share/classes/com/sun/javatest/diff/i18n.properties
+@@ -24,8 +24,8 @@
+ #
+ 
+ help.cantFindReleaseNotes=
+-help.cantFindSpec=
+-help.cantReadSpec=
++#help.cantFindSpec=
++#help.cantReadSpec=
+ help.onlineHelp.pleaseWait=
+ help.releaseNotes=
+ 
+diff --git a/src/share/classes/com/sun/javatest/regtest/Action.java b/src/share/classes/com/sun/javatest/regtest/Action.java
+--- a/src/share/classes/com/sun/javatest/regtest/Action.java
++++ b/src/share/classes/com/sun/javatest/regtest/Action.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright 1998-2007 Sun Microsystems, Inc.  All Rights Reserved.
++ * Copyright 1998-2009 Sun Microsystems, Inc.  All Rights Reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -486,6 +486,11 @@
+         IGNORE_TEST_SUPPRESSED   = "@ignore suppressed by command line option",
+         IGNORE_TEST_SUPPRESSED_C = "@ignore suppressed by command line option: ",
+ 
++        // junit
++        JUNIT_NO_DRIVER        = "No JUnit 4 driver (install junit.jar next to jtreg.jar)",
++        JUNIT_NO_CLASSNAME     = "No class provided for `junit'",
++        JUNIT_BAD_MAIN_ARG     = "Bad argument provided for class in `junit'",
++
+         // main
+         MAIN_NO_CLASSNAME     = "No class provided for `main'",
+         MAIN_MANUAL_NO_VAL    = "Arguments to `manual' option not supported: ",
+diff --git a/src/share/classes/com/sun/javatest/regtest/JUnitAction.java b/src/share/classes/com/sun/javatest/regtest/JUnitAction.java
+new file mode 100644
+--- /dev/null
++++ b/src/share/classes/com/sun/javatest/regtest/JUnitAction.java
+@@ -0,0 +1,138 @@
++/*
++ * Copyright 1998-2008 Sun Microsystems, Inc.  All Rights Reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.  Sun designates this
++ * particular file as subject to the "Classpath" exception as provided
++ * by Sun in the LICENSE file that accompanied this code.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
++ * CA 95054 USA or visit www.sun.com if you need additional information or
++ * have any questions.
++ */
++
++package com.sun.javatest.regtest;
++
++import java.io.File;
++import java.util.ArrayList;
++import java.util.Arrays;
++import java.util.List;
++
++import com.sun.javatest.Status;
++import com.sun.javatest.TestResult;
++import java.util.Iterator;
++
++/**
++ * This class implements the "junit" action, which is a variation of "main".
++ *
++ * @author Iris A Garcia
++ * @see Action
++ */
++public class JUnitAction extends Action
++{
++    /**
++     * This method does initial processing of the options and arguments for the
++     * action.  Processing is determined by the requirements of run().
++     *
++     * Verify arguments are not of length 0 and separate them into the options
++     * to java, the classname, and the parameters to the named class.
++     *
++     * Verify that the options are valid for the "junit" action.
++     *
++     * @param opts The options for the action.
++     * @param args The arguments for the actions.
++     * @param reason Indication of why this action was invoked.
++     * @param script The script.
++     * @exception  ParseException If the options or arguments are not expected
++     *             for the action or are improperly formated.
++     */
++    public void init(String[][] opts, String[] args, String reason,
++                     RegressionScript script)
++        throws ParseException
++    {
++        this.script = script;
++        this.reason = reason;
++
++        Class<?> junitRunner = junitRunnerClass();
++        if (junitRunner == null)
++            throw new ParseException(JUNIT_NO_DRIVER);
++
++        if (args.length == 0)
++            throw new ParseException(JUNIT_NO_CLASSNAME);
++
++        mainAction = new MainAction();
++        mainAction.init(opts, args, reason, script, junitRunner.getName());
++
++        if (mainAction.getMainArgs().length() != 0)
++            throw new ParseException(JUNIT_BAD_MAIN_ARG);
++
++    } // init()
++    
++    @Override
++    public File[] getSourceFiles() {
++        return mainAction.getSourceFiles();
++    }
++
++    public Class<?> junitRunnerClass() {
++        return JUnitRunner.class;
++    }
++
++    public static class JUnitRunner {
++        public static void main(String... args) throws Exception {
++            if (args.length != 1)
++                throw new Error("wrong number of arguments");
++            Class<?> mainClass = Class.forName(args[0]);
++            org.junit.runner.Result result = org.junit.runner.JUnitCore.runClasses(mainClass);
++            if (!result.wasSuccessful()) {
++                List<org.junit.runner.notification.Failure> failures = result.getFailures();
++                for (Iterator<org.junit.runner.notification.Failure>
++                                it = failures.iterator(); it.hasNext(); ) {
++                    org.junit.runner.notification.Failure failure = it.next();
++                    System.err.println("JavaTest Message: JUnit Failure: "+failure);
++                }
++                throw new Exception("JUnit test failure");
++            }
++        }
++    }
++
++    /**
++     * The method that does the work of the action.  The necessary work for the
++     * given action is defined by the tag specification.
++     *
++     * Invoke the specified class as a JUnit 4 test, using the same
++     * rules as for a {@link MainAction}.
++     *
++     * @return     The result of the action.
++     * @exception  TestRunException If an unexpected error occurs while running
++     *             the test.
++     */
++    public Status run() throws TestRunException {
++        Status status;
++
++        section = startAction("junit", mainAction.getMainClassName(), reason);
++
++        status = mainAction.run();
++
++        endAction(status, section);
++        return status;
++    } // run()
++
++    //----------internal methods------------------------------------------------
++
++    //----------member variables------------------------------------------------
++
++    private TestResult.Section section;
++    private MainAction mainAction;
++}
+diff --git a/src/share/classes/com/sun/javatest/regtest/Main.java b/src/share/classes/com/sun/javatest/regtest/Main.java
+--- a/src/share/classes/com/sun/javatest/regtest/Main.java
++++ b/src/share/classes/com/sun/javatest/regtest/Main.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright 1997-2007 Sun Microsystems, Inc.  All Rights Reserved.
++ * Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -1161,6 +1161,11 @@
+         if (jtreg_jar == null)
+             throw new Fault(i18n, "main.cantFind.jtreg.jar");
+         
++        File junit_jar = findJar("junit.jar", "lib/junit.jar", getClass());
++        // Optional jar:
++        //if (junit_jar == null)
++        //    throw new Fault(...);
++        
+         File childJDKHome = jdk.getAbsoluteFile();
+         File childJava = new File(new File(childJDKHome, "bin"), "java");
+         File childTools  = new File(new File(childJDKHome, "lib"), "tools.jar");
+@@ -1173,6 +1178,7 @@
+         c.add("-classpath");
+         List<File> classpath = new ArrayList<File>();
+         classpath.add(jtreg_jar);
++        if (junit_jar != null)  classpath.add(junit_jar);
+         classpath.add(childTools);
+         classpath.addAll(classPathAppendArg);
+         c.add(filesToAbsolutePath(classpath));
+@@ -1231,6 +1237,7 @@
+                 // Note the CLASSPATH will not be exactly the same as for otherVM tests,
+                 // because it will not have (and cannot have) the test-specific values.
+                 String cp = "CLASSPATH=" + javatest_jar + PATHSEP + jtreg_jar
++                        + (junit_jar == null ? "" : PATHSEP + junit_jar)
+                         + PATHSEP + jdk.getToolsJar();
+                 
+                 String[] env = getEnvVars();
+diff --git a/src/share/classes/com/sun/javatest/regtest/MainAction.java b/src/share/classes/com/sun/javatest/regtest/MainAction.java
+--- a/src/share/classes/com/sun/javatest/regtest/MainAction.java
++++ b/src/share/classes/com/sun/javatest/regtest/MainAction.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright 1998-2007 Sun Microsystems, Inc.  All Rights Reserved.
++ * Copyright 1998-2009 Sun Microsystems, Inc.  All Rights Reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -76,6 +76,19 @@
+                      RegressionScript script)
+         throws ParseException
+     {
++        init(opts, args, reason, script, null);
++    }
++
++    /**
++     * Local version of public init function.
++     * Supports extra driverClass option, to interpose before main class.
++     * @param driverClass actual class to invoke, with main class as first argument
++     */
++    void init(String[][] opts, String[] args, String reason,
++                     RegressionScript script,
++                     String driverClass)
++        throws ParseException
++    {
+         this.script = script;
+         this.reason = reason;
+ 
+@@ -120,6 +133,10 @@
+             timeout = 0;
+         }
+ 
++        if (driverClass != null) {
++            driverFN = driverClass;
++        }
++
+         // separate the arguments into the options to java, the
+         // classname and the parameters to the named class
+         for (int i = 0; i < args.length; i++) {
+@@ -151,6 +168,16 @@
+                 throw new ParseException(PARSE_SECURE_OTHERVM);
+         }
+     } // init()
++
++    public String getJavaArgs() {
++        return javaArgs;
++    }
++    public String getMainArgs() {
++        return mainArgs;
++    }
++    public String getMainClassName() {
++        return buildFN;
++    }
+     
+     @Override
+     public File[] getSourceFiles() {
+@@ -221,6 +248,16 @@
+     //----------internal methods------------------------------------------------
+ 
+     private Status runOtherJVM() throws TestRunException {
++        // Arguments to wrapper:
++        String mainClass = buildFN;
++        String stringifiedArgs = (mainArgs == null ? "" : mainArgs);
++        if (driverFN != null) {
++            if (stringifiedArgs.equals(""))
++                stringifiedArgs = mainClass;
++            else
++                stringifiedArgs = mainClass + " " + stringifiedArgs;
++            mainClass = driverFN;
++        }
+ 
+         // WRITE ARGUMENT FILE
+         String mainArgFileName = script.absTestClsDir() + FILESEP + buildFN
+@@ -228,8 +265,8 @@
+         FileWriter fw;
+         try {
+             fw = new FileWriter(mainArgFileName);
+-            fw.write(buildFN + "\0");
+-            fw.write((mainArgs == null ? "" : mainArgs) + "\0" );
++            fw.write(mainClass + "\0");
++            fw.write(stringifiedArgs + "\0" );
+             fw.close();
+         } catch (IOException e) {
+             return Status.error(MAIN_CANT_WRITE_ARGS);
+@@ -288,7 +325,7 @@
+         command.add("com.sun.javatest.regtest.MainWrapper");
+         command.add(mainArgFileName);
+ 
+-        String[] mArgs = StringArray.splitWS(mainArgs);
++        String[] mArgs = StringArray.splitWS(stringifiedArgs);
+         for (int i = 0; i < mArgs.length; i++)
+             command.add(mArgs[i]);
+ 
+@@ -391,6 +428,16 @@
+             }
+         }
+         
++        String mainClass = buildFN;
++        String stringifiedArgs = (mainArgs == null ? "" : mainArgs);
++        if (driverFN != null) {
++            if (stringifiedArgs.equals(""))
++                stringifiedArgs = mainClass;
++            else
++                stringifiedArgs = mainClass + " " + stringifiedArgs;
++            mainClass = driverFN;
++        }
++
+         ByteArrayOutputStream newOut = new ByteArrayOutputStream();
+         ByteArrayOutputStream newErr = new ByteArrayOutputStream();
+         PrintStream psOut = new PrintStream(newOut);
+@@ -413,13 +460,19 @@
+                     }
+                 }
+             }
+-            ClassLoader loader = new URLClassLoader(urls.toArray(new URL[urls.size()]));
+-            Class<?> c = loader.loadClass(buildFN);
++            Class<?> c;
++            if (driverFN == null) {
++                ClassLoader loader = new URLClassLoader(urls.toArray(new URL[urls.size()]));
++                c = loader.loadClass(buildFN);
++            } else {
++                c = Class.forName(driverFN);
++            }
++
+             Class<?>[] argTypes = { String[].class };
+             Method method = c.getMethod("main", argTypes);
+             
+             // XXX 4/1 possible to use splitSeparator instead?
+-            String[] tmpArgs = StringArray.splitWS(mainArgs);
++            String[] tmpArgs = StringArray.splitWS(stringifiedArgs);
+             Object[] runArgs = {tmpArgs};
+             
+             Status stat = redirectOutput(psOut, psErr);
+@@ -485,14 +538,14 @@
+             e.printStackTrace(new PrintWriter(psErr, true));
+             psErr.println();
+             psErr.println("JavaTest Message: main() method must be in a public class named");
+-            psErr.println("JavaTest Message: " + buildFN + " in file " + buildFN + ".java");
++            psErr.println("JavaTest Message: " + mainClass + " in file " + mainClass + ".java");
+             psErr.println();
+             status = Status.error(MAIN_CANT_LOAD_TEST + e);
+         } catch (NoSuchMethodException e) {
+             e.printStackTrace(new PrintWriter(psErr, true));
+             psErr.println();
+             psErr.println("JavaTest Message: main() method must be in a public class named");
+-            psErr.println("JavaTest Message: " + buildFN + " in file " + buildFN + ".java");
++            psErr.println("JavaTest Message: " + mainClass + " in file " + mainClass + ".java");
+             psErr.println();
+             status = Status.error(MAIN_CANT_FIND_MAIN);
+         } finally {
+@@ -701,6 +754,7 @@
+ 
+     private String  javaArgs = "";
+     private String  mainArgs = "";
++    private String  driverFN = null;
+     private String  buildFN  = null;
+     private String  policyFN = null;
+     private String  secureFN = null;
+diff --git a/src/share/classes/com/sun/javatest/regtest/RegressionParameters.java b/src/share/classes/com/sun/javatest/regtest/RegressionParameters.java
+--- a/src/share/classes/com/sun/javatest/regtest/RegressionParameters.java
++++ b/src/share/classes/com/sun/javatest/regtest/RegressionParameters.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright 2001-2007 Sun Microsystems, Inc.  All Rights Reserved.
++ * Copyright 2001-2009 Sun Microsystems, Inc.  All Rights Reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -438,11 +438,14 @@
+             javaTestClassPath = jtClsDir.getPath();
+             
+             int index = javaTestClassPath.indexOf("javatest.jar");
+-            if (index > 0) {        
++            if (index > 0) {
++                String installDir = javaTestClassPath.substring(0, index);
+                 // append jtreg.jar to the path 
+-                String jtregClassDir = 
+-                    javaTestClassPath.substring(0, index) + "jtreg.jar";
++                String jtregClassDir = installDir + "jtreg.jar";
+                 javaTestClassPath += PATHSEP + jtregClassDir;
++                // append junit.jar to the path, in case it exists
++                String junit4ClassDir = installDir + "junit.jar";
++                javaTestClassPath += PATHSEP + junit4ClassDir;
+             }
+         }
+         return javaTestClassPath;
+diff --git a/src/share/classes/com/sun/javatest/regtest/RegressionScript.java b/src/share/classes/com/sun/javatest/regtest/RegressionScript.java
+--- a/src/share/classes/com/sun/javatest/regtest/RegressionScript.java
++++ b/src/share/classes/com/sun/javatest/regtest/RegressionScript.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright 1997-2007 Sun Microsystems, Inc.  All Rights Reserved.
++ * Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -399,6 +399,7 @@
+         addAction("compile", CompileAction.class);
+         addAction("ignore", IgnoreAction.class);
+         addAction("main", MainAction.class);
++        addAction("junit", JUnitAction.class);
+         addAction("shell", ShellAction.class);
+     } // populateActionTable()
+ 
+@@ -744,7 +745,22 @@
+             System.arraycopy(cacheAbsSrcLibList, 0, cacheJavaSrcPath, 1,
+                              cacheAbsSrcLibList.length);
+         }
+-        return locateFile(fileName, cacheJavaSrcPath);
++        try {
++            return locateFile(fileName, cacheJavaSrcPath);
++        } catch (TestRunException ex) {
++            // Allow the file to define a class in a package,
++            // even though it is directly inside the test dir.
++            int sep = fileName.lastIndexOf(FILESEP);
++            if (sep >= 0) {
++                String baseName = fileName.substring(sep+1);
++                try {
++                    File[] path0 = { absTestSrcDir() };
++                    return locateFile(baseName, path0);
++                } catch (TestRunException ignoreEx) {
++                }
++            }
++            throw ex;
++        }
+     } // locateJavaSrc()
+ 
+     /**
+diff --git a/src/share/doc/javatest/regtest/tag-spec.txt b/src/share/doc/javatest/regtest/tag-spec.txt
+--- a/src/share/doc/javatest/regtest/tag-spec.txt
++++ b/src/share/doc/javatest/regtest/tag-spec.txt
+@@ -1,6 +1,6 @@
+ 	      The JDK Test Framework: Tag Language Specification
+               Comments and questions to: jtreg-comments@sun.com
+-			         1.25 06/10/24
++			         1.26 09/10/10
+ 
+ 
+ This is a specification document, not a tutorial.  For more basic information
+@@ -307,6 +307,33 @@
+ main/othervm actions is also discouraged; the /policy and /secure options
+ should be used instead.
+ 
++    junit[/fail][/manual][/othervm][/policy=<file>][/secure=<class>]
++        [/timeout=<seconds>] <vm-opt>* <class>
++
++Invoke the specified class as a JUnit 4 test, passing any arguments after the
++class name.  Roughly equivalent to "@run main org.junit.runner.JUnitCore <class>".
++All initial argument tokens beginning with a dash are considered to be VM options;
++the first argument not beginning with a dash is the <class> to be invoked.
++Passes only if the main method of JUnitCore returns normally and does not
++cause an exception to be thrown, from the main thread or from any other thread.
++As with a "main" action, a "junit" action is considered to be finished when the
++main method of JUnitCore returns.
++
++The named <class> will be compiled on demand, just as though an "@run build
++<class>" action had been inserted before this action.  If this action requires
++classes other than <class> to be up to date, insert an appropriate build action
++before this action.  If any <vm-opt>s are given then /othervm should be
++specified.
++
++The use of the @library tag, and of the /othervm, /manual, /policy, and /secure
++options, are the same for a "junit" action as for a "main" action; see above.
++
++In order to use a "junit" action, the JUnit 4 jar file may need to be placed
++manually alongside the jtreg and javatest jar files in the jtreg installed.
++If junit.jar file is not found, and if no class named org.junit.runner.JUnitCore
++can be found, any "junit" actions will fail, regardless of whether the /fail
++option was selected.
++
+     applet[/fail][/manual[=(yesno|done)]][/othervm][/policy=<file>]
+         [/secure=<class>][/timeout=<sec>] <html-file>
+ 
+diff --git a/src/share/test/javatest/regtest/Basic.java b/src/share/test/javatest/regtest/Basic.java
+--- a/src/share/test/javatest/regtest/Basic.java
++++ b/src/share/test/javatest/regtest/Basic.java
+@@ -143,6 +143,7 @@
+         // action counts
+         int numApplet = 0, numBuild  = 0, numClean  = 0, numCompile = 0,
+             numIgnore = 0, numMain   = 0, numShell  = 0, numMisc    = 0;
++        int numJUnit  = 0;
+ 
+         // applet
+         numPassed += 2; numFailed += 4; numError  += 11;
+@@ -169,6 +170,10 @@
+         numPassed += 0; numFailed += 0; numError  += 2;
+         numIgnore += 2;
+ 
++        // junit
++        numPassed += 5; numFailed += 6; numError  += 8 + 8 /*Pass/Fail, badarg*/;
++        numJUnit  += 27;
++
+         // main
+         numPassed += 12; numFailed += 19; numError  += 12;
+         numMain   += 43;
+@@ -192,6 +197,7 @@
+         actionTable.put("compile", Integer.valueOf(numCompile));
+         actionTable.put("ignore",  Integer.valueOf(numIgnore));
+         actionTable.put("main",    Integer.valueOf(numMain));
++        actionTable.put("junit",   Integer.valueOf(numJUnit));
+         actionTable.put("shell",   Integer.valueOf(numShell));
+         actionTable.put("misc",    Integer.valueOf(numMisc));
+ 
+@@ -407,7 +413,7 @@
+         REP_ACTION           = "action: ";
+ 
+     private static final String[] actionList = {
+-        "applet", "build", "clean", "compile", "ignore", "main", "shell", "misc"
++        "applet", "build", "clean", "compile", "ignore", "junit", "main", "shell", "misc"
+     };
+ 
+     private static final String[] statusList = {
+diff --git a/src/share/test/javatest/regtest/data/basic/junit/BadTag.java b/src/share/test/javatest/regtest/data/basic/junit/BadTag.java
+new file mode 100644
+--- /dev/null
++++ b/src/share/test/javatest/regtest/data/basic/junit/BadTag.java
+@@ -0,0 +1,65 @@
++/*
++ * Copyright 1998-2009 Sun Microsystems, Inc.  All Rights Reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
++ * CA 95054 USA or visit www.sun.com if you need additional information or
++ * have any questions.
++ */
++
++/* @test
++ * @summary Error: Parse Exception: No class provided for `junit'
++ * @run junit 
++ */
++
++/* @test
++ * @summary Error: Parse Exception: Arguments to `manual' option not supported:  bad_arg
++ * @run junit/manual=bad_arg BadTag
++ */
++
++/* @test
++ * @summary Error: Parse Exception: Bad integer specification: bruno
++ * @run junit/timeout=bruno BadTag
++ */
++
++/* @test
++ * @summary Error: Parse Exception: Bad option for junit: bad_opt
++ * @run junit/bad_opt BadTag
++ */
++
++/* @test
++ * @summary Error: Parse Exception: -vmopt: vm option(s) found, need to specify /othervm
++ * @run junit -vmopt BadTag
++ */
++
++/* @test
++ * @summary Error: Parse Exception: No class provided for `junit'
++ * @run junit/othervm -vmopt
++ */
++
++// NOTE: The following two tests should fail for different reasons when the test
++// version of JDK is changed to JDK1.2.
++
++/* @test
++ * @summary Error: Parse Exception: Option not allowed using provided test JDK: secure
++ * @run junit/secure=secure BadTag
++ */
++
++/* @test
++ * @summary Error: Parse Exception: Option not allowed using provided test JDK: policy
++ * @run junit/policy=strict.policy BadTag
++ */
+diff --git a/src/share/test/javatest/regtest/data/basic/junit/BadTestClass.java b/src/share/test/javatest/regtest/data/basic/junit/BadTestClass.java
+new file mode 100644
+--- /dev/null
++++ b/src/share/test/javatest/regtest/data/basic/junit/BadTestClass.java
+@@ -0,0 +1,36 @@
++/*
++ * Copyright 1998-2009 Sun Microsystems, Inc.  All Rights Reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
++ * CA 95054 USA or visit www.sun.com if you need additional information or
++ * have any questions.
++ */
++
++/* @test
++ * @summary Failed: `main' threw exception: java.lang.Exception: JUnit test failure
++ * @run junit BadTestClass
++ */
++
++/* @test
++ * @summary Failed: `main' threw exception: java.lang.Exception: JUnit test failure
++ * @run junit/othervm BadTestClass
++ */
++
++class BadTestClass
++{
++}
+diff --git a/src/share/test/javatest/regtest/data/basic/junit/CantFindSrc.java b/src/share/test/javatest/regtest/data/basic/junit/CantFindSrc.java
+new file mode 100644
+--- /dev/null
++++ b/src/share/test/javatest/regtest/data/basic/junit/CantFindSrc.java
+@@ -0,0 +1,27 @@
++/*
++ * Copyright 1999-2009 Sun Microsystems, Inc.  All Rights Reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
++ * CA 95054 USA or visit www.sun.com if you need additional information or
++ * have any questions.
++ */
++
++/* @test
++ * @summary Error: Can't find source file: CannotFindSrc.java  in directory-list: .../data/basic/junit
++ * @run junit CannotFindSrc
++ */
+diff --git a/src/share/test/javatest/regtest/data/basic/junit/Fail.java b/src/share/test/javatest/regtest/data/basic/junit/Fail.java
+new file mode 100644
+--- /dev/null
++++ b/src/share/test/javatest/regtest/data/basic/junit/Fail.java
+@@ -0,0 +1,81 @@
++/*
++ * Copyright 1998-2009 Sun Microsystems, Inc.  All Rights Reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
++ * CA 95054 USA or visit www.sun.com if you need additional information or
++ * have any questions.
++ */
++
++/* @test
++ * @summary Failed: `main' threw exception: java.lang.Exception: JUnit test failure
++ * @run junit Fail
++ */
++
++/* @test
++ * @summary Passed: Execution failed as expected
++ * @run junit/fail Fail
++ */
++
++/* @test
++ * @summary Error: Parse Exception: Bad argument provided for class in `junit'
++ * @run junit Fail badarg
++ */
++
++/* @test
++ * @summary Error: Parse Exception: Bad argument provided for class in `junit'
++ * @run junit/fail Fail badarg
++ */
++
++/* @test
++ * @summary Failed: `main' threw exception: java.lang.Exception: JUnit test failure
++ * @run junit/othervm Fail
++ */
++
++/* @test
++ * @summary Passed: Execution failed as expected
++ * @run junit/othervm/fail Fail
++ */
++
++/* @test
++ * @summary Error: Parse Exception: Bad argument provided for class in `junit'
++ * @run junit/othervm Fail badarg
++ */
++
++/* @test
++ * @summary Error: Parse Exception: Bad argument provided for class in `junit'
++ * @run junit/othervm/fail Fail badarg
++ */
++
++import org.junit.*;
++import static org.junit.Assert.*;
++
++public class Fail
++{
++    @Test
++    public void test1() {
++    }
++
++    @Test
++    public void test2() {
++        assertSame(2+2, 5);
++    }
++
++    @Test
++    public void test3() {
++    }
++}
+diff --git a/src/share/test/javatest/regtest/data/basic/junit/InNamedPkg.java b/src/share/test/javatest/regtest/data/basic/junit/InNamedPkg.java
+new file mode 100644
+--- /dev/null
++++ b/src/share/test/javatest/regtest/data/basic/junit/InNamedPkg.java
+@@ -0,0 +1,38 @@
++/*
++ * Copyright 1998-2009 Sun Microsystems, Inc.  All Rights Reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
++ * CA 95054 USA or visit www.sun.com if you need additional information or
++ * have any questions.
++ */
++
++/* @test
++ * @summary Passed: Execution successful
++ * @run junit org.sun.namedpkg.InNamedPkg
++ */
++package org.sun.namedpkg;
++
++import org.junit.*;
++import static org.junit.Assert.*;
++
++public class InNamedPkg
++{
++    @Test
++    public void test1() {
++    }
++}
+diff --git a/src/share/test/javatest/regtest/data/basic/junit/Pass.java b/src/share/test/javatest/regtest/data/basic/junit/Pass.java
+new file mode 100644
+--- /dev/null
++++ b/src/share/test/javatest/regtest/data/basic/junit/Pass.java
+@@ -0,0 +1,80 @@
++/*
++ * Copyright 1998-2009 Sun Microsystems, Inc.  All Rights Reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
++ * CA 95054 USA or visit www.sun.com if you need additional information or
++ * have any questions.
++ */
++
++/* @test
++ * @summary Passed: Execution successful
++ * @run junit Pass
++ */
++
++/* @test
++ * @summary Failed: Execution passed unexpectedly
++ * @run junit/fail Pass
++ */
++
++/* @test
++ * @summary Error: Parse Exception: Bad argument provided for class in `junit'
++ * @run junit Pass badarg
++ */
++
++/* @test
++ * @summary Error: Parse Exception: Bad argument provided for class in `junit'
++ * @run junit/fail Pass badarg
++ */
++
++/* @test
++ * @summary Passed: Execution successful
++ * @run junit/othervm Pass
++ */
++
++/* @test
++ * @summary Failed: Execution passed unexpectedly
++ * @run junit/othervm/fail Pass
++ */
++
++/* @test
++ * @summary Error: Parse Exception: Bad argument provided for class in `junit'
++ * @run junit/othervm Pass badarg
++ */
++
++/* @test
++ * @summary Error: Parse Exception: Bad argument provided for class in `junit'
++ * @run junit/othervm/fail Pass badarg
++ */
++
++import org.junit.*;
++import static org.junit.Assert.*;
++
++public class Pass
++{
++    @Test
++    public void test1() {
++    }
++
++    @Test
++    public void test2() {
++    }
++
++    @Test
++    public void test3() {
++    }
++}
+diff --git a/src/share/test/javatest/regtest/data/basic/junit/VMOptsPassed.java b/src/share/test/javatest/regtest/data/basic/junit/VMOptsPassed.java
+new file mode 100644
+--- /dev/null
++++ b/src/share/test/javatest/regtest/data/basic/junit/VMOptsPassed.java
+@@ -0,0 +1,48 @@
++/*
++ * Copyright 1998-2009 Sun Microsystems, Inc.  All Rights Reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
++ * CA 95054 USA or visit www.sun.com if you need additional information or
++ * have any questions.
++ */
++
++/* @test
++ * @summary Passed: Execution successful
++ * @run junit/othervm -DtestSysProp=testVal VMOptsPassed
++ */
++
++import org.junit.*;
++import static org.junit.Assert.*;
++
++public class VMOptsPassed
++{
++    @Test
++    public void test1() {
++        String sysprop = System.getProperty("testSysProp");
++        if (sysprop == null) {
++            throw new RuntimeException("unable to find passed system property!");
++        } else {
++            if (!sysprop.equals("testVal"))
++                throw new RuntimeException("passed system property incorrectly set " +
++                                           "expected: testVal " +
++                                           "found: " + sysprop);
++            else
++                System.out.println("found passed system property:  testSysProp=" + sysprop);
++        }
++    }
++}
+diff --git a/src/share/test/javatest/regtest/data/basic/main/BadTag.java b/src/share/test/javatest/regtest/data/basic/main/BadTag.java
+--- a/src/share/test/javatest/regtest/data/basic/main/BadTag.java
++++ b/src/share/test/javatest/regtest/data/basic/main/BadTag.java
+@@ -32,7 +32,7 @@
+  */
+ 
+ /* @test
+- * @summary Error: Parse Exception: Bad integer speciication: bruno
++ * @summary Error: Parse Exception: Bad integer specification: bruno
+  * @run main/timeout=bruno BadTag
+  */
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jtreg/junitsupport.txt	Mon Oct 12 16:27:58 2009 -0700
@@ -0,0 +1,29 @@
+Patches to JTReg test harness to allow OpenJDK unit tests to use JUnit.
+
+To build JTReg:
+* start with http://openjdk.java.net/jtreg/build.html
+* fetch sources & dependencies as noted
+* fetch junit-4.5.jar from http://sourceforge.net/projects/junit/files/junit/4.5/junit-4.5.jar/download
+* apply these patches
+* build (see example script below)
+
+Or, to use the pre-build image:
+* unzip jtreg-no-junit.zip
+* fetch junit-4.5.jar from http://sourceforge.net/projects/junit/files/junit/4.5/junit-4.5.jar/download
+* copy junit-4.5.jar to jtreg-no-junit/lib/junit.jar
+
+#! /bin/sh
+
+sets="
+CHMOD=chmod CP=cp DIFF=diff ECHO=echo FIND=find GREP=grep
+MKDIR=mkdir PERL=perl SED=sed SH=sh TEST=test UNZIP=unzip ZIP=zip
+JDK15HOME=$JAVA5_HOME
+JDK16HOME=$JAVA6_HOME
+XALANHOME=$XALAN_HOME
+ANTHOME=$ANT_HOME
+JTHARNESS_HOME=$JAVATEST_HOME
+JUNIT_JAR=$JUNIT4_JAR
+"
+
+exec \
+make -C make $sets "$@"