incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From liu...@apache.org
Subject svn commit: r1385278 - in /incubator/ooo/trunk/test: ./ reportstyle/ testcommon/source/org/openoffice/test/ testcommon/source/org/openoffice/test/common/
Date Sun, 16 Sep 2012 14:58:48 GMT
Author: liuzhe
Date: Sun Sep 16 14:58:48 2012
New Revision: 1385278

URL: http://svn.apache.org/viewvc?rev=1385278&view=rev
Log:
Move install openoffice & xml report generating from ant script to Java

Added:
    incubator/ooo/trunk/test/test   (with props)
    incubator/ooo/trunk/test/test.bat
    incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/Run.java
    incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/Installer.java
    incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/NamedRequest.java
    incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/ReportUploader.java
Removed:
    incubator/ooo/trunk/test/build.example.properties
    incubator/ooo/trunk/test/reportstyle/
    incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/Runner.java
Modified:
    incubator/ooo/trunk/test/build.xml
    incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/FileUtil.java
    incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/Logger.java
    incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/SystemUtil.java
    incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/XMLReporter.java
    incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/XMLReporter.xsl

Modified: incubator/ooo/trunk/test/build.xml
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/build.xml?rev=1385278&r1=1385277&r2=1385278&view=diff
==============================================================================
--- incubator/ooo/trunk/test/build.xml (original)
+++ incubator/ooo/trunk/test/build.xml Sun Sep 16 14:58:48 2012
@@ -24,55 +24,44 @@
 
 <project basedir="." default="test">
     <property environment="env" />
-    <property file="build.properties" />
-    <property name="env.DISPLAY" value=":0.0"/>
-	<property name="env.TESTSPACE" value="testspace" />
-	<property name="env.JUNIT_HOME" value="external/junit" />
 	<property name="junit.home" value="${env.JUNIT_HOME}" />
-	<property name="testspace" value="${env.TESTSPACE}" />
-    <property name="classes" value="${testspace}/class" />
-	<property name="dist" value="${testspace}" />
-	<property name="test.name" value="BVT" />
-	<property name="test.classes" value="testcase/gui/bvt/*.class" />
-	<property name="test.output" value="${testspace}/output" />
-	<property name="test.result" value="${test.output}/result" />
-	<property name="test.report" value="${test.output}/report" />
-	<property name="junit.style.dir" value="reportstyle" />
-
-	<path id="junit.classpath">
-		<fileset dir="${junit.home}" erroronmissingdir="false">
-			<include name="*.jar" />
+	<property name="dist.dir" value="." />
+	<property name="dist.name" value="aoo_test" />
+	<property name="junit.jar.repos" value="http://repo1.maven.org/maven2/junit/junit/4.10/junit-4.10.jar" />
+	
+	<path id="uno.classpath">
+		<fileset dir="${env.OUTDIR}" erroronmissingdir="false">
+			<include name="**/juh.jar" />
+			<include name="**/unoil.jar" />
+			<include name="**/ridl.jar" />
+			<include name="**/jurt.jar" />
+		</fileset>
+		<fileset dir="${openoffice.home}" erroronmissingdir="false">
+			<include name="**/juh.jar" />
+			<include name="**/unoil.jar" />
+			<include name="**/ridl.jar" />
+			<include name="**/jurt.jar" />
 		</fileset>
 	</path>
-    
-    <target name="upgrade">
-		<property name="upgrade.script" location="${java.io.tmpdir}/aoo_test_upgrade.xml"/>
-		<property name="upgrade.to" location="."/>
-		<copy file="build.xml" tofile="${upgrade.script}"/>
-        <condition property="ant.executable" value="ant.bat">
-			<os family="windows" />
-		</condition>
-        <property name="ant.executable" value="ant"/>
-        <exec executable="${ant.executable}" spawn="true">
-			<arg value="-Dupgrade.to=${upgrade.to}"/>
-			<arg value="-f"/>
-			<arg value="${upgrade.script}"/>
-			<arg value="upgrade.run"/>
-		</exec>
+				
+	<target name="check.junit">
+	    <copy todir="lib" >
+	        <fileset dir="${junit.home}" erroronmissingdir="false">
+	            <include name="junit*.jar" />
+			</fileset>
+			<globmapper from="*" to="junit.jar" />
+        </copy>
+		<available file="lib/junit.jar" property="junit.jar.exists"/>
 	</target>
 
-	<target name="upgrade.run">
-		<property name="testpack.url" value="http://9.123.117.85/testpack/trunk/aoo_test.zip"/>
-		<property name="testack.temp" location="${java.io.tmpdir}/aoo_test.zip"/>
- 		<get src="${testpack.url}" dest="${testack.temp}"/>
-		<delete dir="${upgrade.to}" failonerror="false"/>
-		<mkdir dir="${upgrade.to}"/>
-		<unzip src="${testack.temp}" dest="${upgrade.to}"/>
+	<target name="prepare.junit" depends="check.junit" unless="junit.jar.exists">
+		<mkdir dir="lib" />
+		<get src="${junit.jar.repos}" dest="lib/junit.jar" skipexisting="true" />
 	</target>
-    
-    <target name="testcommon.init">
-		<mkdir dir="${classes}" />
-		<copy includeemptydirs="false" todir="${classes}">
+	
+	<target name="testcommon.init">
+		<mkdir dir="testcommon/bin" />
+		<copy includeemptydirs="false" todir="testcommon/bin">
 			<fileset dir="testcommon/source">
 				<exclude name="**/*.java" />
 			</fileset>
@@ -80,91 +69,128 @@
 	</target>
 
 	<target name="testcommon.compile" depends="testcommon.init, prepare.junit">
-		<javac destdir="${classes}" debug="on" source="1.6" encoding="utf-8" includeantruntime="false">
+		<javac destdir="testcommon/bin" debug="on" source="1.6" encoding="utf-8" includeantruntime="false">
 			<src path="testcommon/source"/>
 			<classpath>
-				<path refid="junit.classpath"/>
+				<fileset dir="lib">
+					<include name="*.jar" />
+				</fileset>
 			</classpath>
 		</javac>
 	</target>
 
 	<target name="testgui.init">
-		<mkdir dir="${classes}" />
-		<copy includeemptydirs="false" todir="${classes}">
+		<mkdir dir="testgui/bin" />
+		<copy includeemptydirs="false" todir="testgui/bin">
 			<fileset dir="testgui/source">
 				<exclude name="**/*.java" />
 			</fileset>
 		</copy>
 	</target>
 
-	<target name="testgui.compile" depends="testgui.init, prepare.junit">
-		<javac destdir="${classes}" debug="on" source="1.6" encoding="utf-8" includeantruntime="false">
+	<target name="testgui.compile" depends="testcommon.compile, testgui.init">
+		<javac destdir="testgui/bin" debug="on" source="1.6" encoding="utf-8" includeantruntime="false">
 			<src path="testgui/source"/>
 			<classpath>
-				<pathelement location="${classes}" />
-				<path refid="junit.classpath"/>
+				<fileset dir="lib">
+				    <include name="*.jar" />
+				</fileset>
+				<pathelement location="testcommon/bin" />
 			</classpath>
 		</javac>
 	</target>
 
 	<target name="testuno.init">
-		<mkdir dir="${classes}" />
-		<copy includeemptydirs="false" todir="${classes}">
+		<mkdir dir="testuno/bin" />
+		<copy includeemptydirs="false" todir="testuno/bin">
 			<fileset dir="testuno/source">
 				<exclude name="**/*.java" />
 			</fileset>
 		</copy>
 	</target>
 
-	<target name="testuno.compile" depends="testuno.init">
-		<path id="uno.classpath">
-			<fileset dir="${openoffice.home}" erroronmissingdir="false">
-				<include name="**/juh.jar" />
-				<include name="**/unoil.jar" />
-				<include name="**/ridl.jar" />
-				<include name="**/jurt.jar" />
-			</fileset>
-		</path>
-		<javac destdir="${classes}" debug="on" source="1.6" encoding="utf-8" includeantruntime="false">
+	<target name="testuno.compile" depends="testcommon.compile, testuno.init">
+		<javac destdir="testuno/bin" debug="on" source="1.6" encoding="utf-8" includeantruntime="false">
 			<src path="testuno/source"/>
 			<classpath>
-				<pathelement location="${classes}" />
-				<path refid="junit.classpath"/>
+				<fileset dir="lib">
+					<include name="*.jar" />
+				</fileset>
+				<pathelement location="testcommon/bin" />
 				<path refid="uno.classpath"/>
 			</classpath>
 		</javac>
 	</target>
 
 	<target name="clean" description="Clean all output">
-		<delete dir="${testspace}" />
-	</target>
-
-	<target name="check.junit">
-		<available file="junit.jar" property="junit.jar.exists">
-			<filepath refid="junit.classpath" />
-		</available>
+		<delete dir="testcommon/bin" />
+		<delete dir="testgui/bin" />
+		<delete dir="testuno/bin" />
+	</target>
+	
+	<target name="compile" depends="testcommon.compile,testgui.compile,testuno.compile" description="Compile source code">
+	</target>
+	
+	<target name="dist" depends="clean,compile">
+		<tstamp/>
+        <zip destfile="${dist.dir}/${dist.name}_${DSTAMP}.zip" update="false">
+			<zipfileset dir="." includes="lib/**, testcommon/**,testgui/**,testuno/**,build.xml" prefix="aoo_test/"/>
+			<zipfileset dir="." includes="test,test.bat" filemode="751" prefix="aoo_test/"/>
+        </zip>
 	</target>
-
-	<target name="prepare.junit" depends="check.junit" unless="junit.jar.exists">
-		<property name="junit.jar.repos" value="http://repo1.maven.org/maven2/junit/junit/4.10/junit-4.10.jar" />
-		<mkdir dir="${junit.home}" />
-		<get src="${junit.jar.repos}" dest="${junit.home}/junit.jar" skipexisting="true" />
+	
+	<target name="test" depends="compile" description="start test">
+        <property name="openoffice.home" value=""/>
+        <condition property="test.arg0" value="-Dopenoffice.home=${openoffice.home}">
+			<isset property="openoffice.home" />
+		</condition>
+		<pathconvert property="openoffice.pack" setonempty="false">
+			<path>
+				<fileset dir="${env.SRC_ROOT}/instsetoo_native/${env.INPATH}/OpenOffice/archive/install/en-US" includes="*.tar.gz,*.zip"  erroronmissingdir="false"/>
+			</path>
+		</pathconvert>
+		<condition property="test.arg0" value="-Dopenoffice.pack=${openoffice.pack}">
+			<isset property="openoffice.pack" />
+		</condition>
+		<fail message="No OpenOffice available!" unless="test.arg0"/>
+	    <condition property="test.executable" value="./test.bat">
+			<os family="windows" />
+		</condition>
+		<echo>${test.arg0}</echo>
+        <property name="test.executable" value="./test"/>
+        <exec executable="${test.executable}">
+			<arg value="${test.arg0}"/>
+			<arg value="-tp"/>
+			<arg value="bvt"/>
+		</exec>
 	</target>
-
-	<target name="compile" depends="testcommon.init, testcommon.compile, testgui.init, testgui.compile, testuno.init, testuno.compile" description="Compile source code">
+	
+    <target name="upgrade">
+		<property name="upgrade.script" location="${java.io.tmpdir}/aoo_test_upgrade.xml"/>
+		<property name="upgrade.to" location="."/>
+		<copy file="build.xml" tofile="${upgrade.script}"/>
+        <condition property="ant.executable" value="ant.bat">
+			<os family="windows" />
+		</condition>
+        <property name="ant.executable" value="ant"/>
+        <exec executable="${ant.executable}" spawn="true">
+			<arg value="-Dupgrade.to=${upgrade.to}"/>
+			<arg value="-f"/>
+			<arg value="${upgrade.script}"/>
+			<arg value="upgrade.run"/>
+		</exec>
 	</target>
 
-	<target name="dist">
-		<tstamp />
-        <tstamp>
-            <format property="testpack.version" pattern="yyyyMMddhhmmss"/>
-        </tstamp>
-        <property name="dist.archive" value="aoo_test_${DSTAMP}.zip" />
-        <echo file="${testpack.version}">${testpack.version}</echo>
-        <zip destfile="${dist}/${dist.archive}" basedir="." update="false" excludes="testspace/**,testassistant/**,testassistant.feature/**,**/bin/**">
-        </zip>
-        <delete file="${testpack.version}"/>
+	<target name="upgrade.run">
+		<property name="testpack.url" value="http://9.123.117.85/testpack/trunk/aoo_test.zip"/>
+		<property name="testack.temp" location="${java.io.tmpdir}/aoo_test.zip"/>
+ 		<get src="${testpack.url}" dest="${testack.temp}"/>
+		<delete dir="${upgrade.to}" failonerror="false"/>
+		<mkdir dir="${upgrade.to}"/>
+		<unzip src="${testack.temp}" dest="${upgrade.to}"/>
 	</target>
+    
+  
 
 	<target name="check.build" description="Check the build context">
 		<condition property="openoffice.pack.dir" value="${env.SRC_ROOT}/instsetoo_native/${env.INPATH}/OpenOffice/archive/install/en-US">
@@ -187,179 +213,4 @@
             <isset property="openoffice.home" />
 		</condition>
 	</target>
-
-	<target name="find.build" unless="find.build.skip" description="Find the newest build on the remote server">
-		<loadresource property="openoffice.build">
-			<url url="${openoffice.build.url}" />
-			<filterchain>
-				<deletecharacters chars=" \t\r\n" />
-			</filterchain>
-		</loadresource>
-        
-        <echo message="openoffice.pack.url=${openoffice.archive.url}" file="${testspace}/.temp.properties" />
-        <property file="${testspace}/.temp.properties"/>
-        <property name="openoffice.build.name" value="${openoffice.build}" />
-        <echo>#OpenOffice Build Name: ${openoffice.build.name}</echo>
-        <echo>#OpenOffice Package URL: ${openoffice.pack.url}</echo>
-	</target>
-
-    <target name="download" unless="${skip}">
-        <delete dir="${dest}" />
-        <mkdir dir="${dest}" />
-        <get src="${src}" dest="${dest}" verbose="false" usetimestamp="true" skipexisting="true" />
-    </target>
-
-	<target name="download.build" unless="download.build.skip" description="Download the specified build from the remote server">
-		<property name="openoffice.pack.dir" value="${testspace}/download" />
-        <property name="openoffice.pack.download.mark" value="${testspace}/download/url.txt"/>
-        <loadfile property="openoffice.pack.download.url" srcFile="${openoffice.pack.download.mark}" quiet="true" failonerror="false"/>
-        <condition property="download.build.skip" value="true" else="false">
-            <equals arg1="${openoffice.pack.download.url}" arg2="${openoffice.pack.url}"/>
-		</condition>
-        
-        <echo>#Build is Downloaded: ${download.build.skip}</echo>
-        <antcall target="download" inheritAll="false">
-            <param name="skip" value="${download.build.skip}"/>
-            <param name="src" value="${openoffice.pack.url}"/>
-            <param name="dest" value="${openoffice.pack.dir}"/>
-        </antcall>
-        <!--
-		<get src="${openoffice.pack.url}" dest="${openoffice.pack.dir}" verbose="false" usetimestamp="true" skipexisting="true" />
-        -->
-        <echo message="${openoffice.pack.url}" file="${openoffice.pack.download.mark}" />
-        <echo>#OpenOffice Package Dir: ${openoffice.pack.dir}</echo>
-	</target>
-
-	<target name="install.build" unless="install.build.skip" description="Install the build to the local">
-		<property name="openoffice.install.dir" value="${testspace}/install/aoo" />
-		<property name="openoffice.install.temp" value="${testspace}/install/temp" />
-		<delete dir="${openoffice.install.temp}" failonerror="false"/>
-		<mkdir dir="${openoffice.install.temp}" />
-		<unzip dest="${openoffice.install.temp}">
-			<fileset dir="${openoffice.pack.dir}">
-				<include name="**/Apache_OpenOffice*.zip" />
-			</fileset>
-		</unzip>
-		<pathconvert property="gz.files" pathsep=" " setonempty="false">
-			<path>
-				<fileset dir="${openoffice.pack.dir}" includes="Apache_OpenOffice*.gz" />
-			</path>
-		</pathconvert>
-		<exec dir="${openoffice.install.temp}" executable="tar" failifexecutionfails="false">
-			<arg line="-zxpf ${gz.files}" />
-		</exec>
-       		<pathconvert property="openoffice.root.dir" pathsep=" " setonempty="false">
-			<path>
-				<dirset dir="${openoffice.install.temp}">
-                    <include name="*"/>
-                </dirset>
-			</path>
-		</pathconvert>
-       		<delete dir="${openoffice.install.dir}" failonerror="false"/>
-		<move file="${openoffice.root.dir}" tofile="${openoffice.install.dir}" failonerror="false"/>
-		<delete dir="${openoffice.install.temp}"  failonerror="false"/>
-		<pathconvert property="openoffice.bin" pathsep=" " setonempty="false">
-			<path>
-				<fileset dir="${openoffice.install.dir}" includes="**/*/soffice.bin" followsymlinks="false" />
-			</path>
-		</pathconvert>
-		<dirname property="openoffice.bin.parent" file="${openoffice.bin}" />
-		<property name="openoffice.home" location="${openoffice.bin.parent}/../" />
-		<fail unless="openoffice.home" />
-		<echo>#Openoffice Home: ${openoffice.home}</echo>
-	</target>
-
-	<target name="run.test" depends="compile, detect.testenv" description="Run junit">
-		<tstamp>
-			<format property="output.stamp" pattern="yyMMdd.hhmm" />
-		</tstamp>
-
-		<move file="${test.output}" tofile="${test.output}.${output.stamp}" failonerror="false" />
-		<mkdir dir="${test.result}" />
-		<mkdir dir="${test.report}" />
-		<mkdir dir="${test.output}/temp" />
-		
-		<junit fork="yes" forkmode="once" tempdir="${test.output}/temp" printsummary="yes" showoutput="false" errorProperty="test.failed" failureProperty="test.failed" dir=".">
-			<env key="DISPLAY" value="${env.DISPLAY}"/>
-            <sysproperty key="openoffice.home" value="${openoffice.home}" />
-			<sysproperty key="testspace" value="${testspace}" />
-			<syspropertyset>
-				<propertyref builtin="commandline" />
-			</syspropertyset>
-			<batchtest todir="${test.result}">
-				<fileset dir="${classes}" includes="${test.classes}" />
-			</batchtest>
-
-			<formatter type="xml" />
-			<classpath>
-				<pathelement location="${classes}" />
-                <pathelement location="testgui/data" />
-                <pathelement location="testuno/data" />
-				<path refid="junit.classpath"/>
-				<path refid="uno.classpath"/>
-			</classpath>
-		</junit>
-        
-		<junitreport todir="${test.report}">
-			<fileset dir="${test.result}">
-				<include name="TEST-*.xml" />
-			</fileset>
-			<report format="frames" styledir="${junit.style.dir}" todir="${test.report}">
-				<param name="TITLE" expression="${test.name}: ${openoffice.build.name}, ${test.os.name}-${test.os.version}-${test.os.arch}"/>
-			</report>
-		</junitreport>
-		<property name="test.report.index" location="${test.report}/index.html" />
-		<echo>Open ${test.report.index} in browser to view the test report.</echo>
-	</target>
-
-	<target name="test" depends="check.build,find.build,download.build,install.build,run.test" description="Run testing on the specified build. The build is automatically downloaded and installed according to the context.">
-		<fail message="Test Failed" if="test.failed" />
-	</target>
-    
-	<target name="detect.testenv">
-		<exec outputproperty="test.os.name" executable="lsb_release" failifexecutionfails="false" os="Linux">
-			<arg line="-is" />
-		</exec>
-		<exec outputproperty="test.os.version" executable="lsb_release" failifexecutionfails="false" os="Linux">
-			<arg line="-rs" />
-		</exec>
-		<property name="test.os.name" value="${os.name}" />
-		<property name="test.os.version" value="${os.version}" />
-		<property name="test.os.arch" value="${os.arch}" />
-		<echo>${test.os.name}-${test.os.version}-${test.os.arch}</echo>
-        <property file="${openoffice.home}/program/versionrc" prefix="openoffice"/>
-        <property file="${openoffice.home}/program/version.ini" prefix="openoffice"/>
-        <property name="openoffice.build.name" value=""/>
-	</target>
-
-
-	<target name="report.test" unless="report.test.skip" description="Upload the testing result to report repository." depends="detect.testenv">
-		<property name="report.to" value="${openoffice.build.name}-${test.name}/${test.os.name}-${test.os.version}-${test.os.arch}" />
-		<echo>Uploading report to ${report.repos}/${report.to}</echo>
-		<property name="report.to.temp" location="${testspace}/.temp.ouput"/>
-        <delete dir="${report.to.temp}" deleteonexit="true"/>
-		<copy todir="${report.to.temp}/${report.to}">
-			<fileset dir="${test.output}" />
-		</copy>
-		<scp todir="${report.repos}" trust="true">
-			<fileset dir="${report.to.temp}"/>
-		</scp>
-        <delete dir="${report.to.temp}" deleteonexit="true"/>
-	</target>
-
-	<target name="detect.build" depends="find.build" description="Check if new build is available. If no new build is available, the target will be failed.">
-		<property name="test.mark.file" location="${testspace}/${test.name}.build"/>
-		<loadfile property="local.build" srcFile="${test.mark.file}" quiet="true" failonerror="false" />
-		<fail message="The build has been tested! We don't want to test it twice.">
-			<condition>
-				<equals arg1="${openoffice.build}" arg2="${local.build}" trim="true" />
-			</condition>
-		</fail>
-		<mkdir dir="${testspace}" />
-		<echo file="${test.mark.file}">${openoffice.build}</echo>
-	</target>
-
-	<target name="routine.test" depends="detect.build,download.build,install.build,run.test,report.test" description="Periodically run testing.">
-		<fail message="Test Failed" if="test.failed" />
-	</target>
 </project>

Added: incubator/ooo/trunk/test/test
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/test?rev=1385278&view=auto
==============================================================================
--- incubator/ooo/trunk/test/test (added)
+++ incubator/ooo/trunk/test/test Sun Sep 16 14:58:48 2012
@@ -0,0 +1,5 @@
+#! /bin/sh
+. /etc/profile
+export DISPLAY=:0.0
+BASE=$(cd `dirname "$0"`; pwd)
+eval java -cp \"$BASE/lib/junit.jar:$BASE/testcommon/bin:$BASE/testgui/bin:$BASE/testuno/bin:$BASE/testgui/data:$BASE/testuno/data\" org.openoffice.test.Run -r org.openoffice.test.common.Installer -l org.openoffice.test.common.XMLReporter -l org.openoffice.test.common.ReportUploader \"-Dtestspace=$BASE/testspace\" -Dsingleton=true "$*"

Propchange: incubator/ooo/trunk/test/test
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/ooo/trunk/test/test.bat
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/test.bat?rev=1385278&view=auto
==============================================================================
--- incubator/ooo/trunk/test/test.bat (added)
+++ incubator/ooo/trunk/test/test.bat Sun Sep 16 14:58:48 2012
@@ -0,0 +1,3 @@
+@echo OFF
+set BASE=%~pd0%
+java -cp %BASE%/lib/junit.jar;%BASE%/testcommon/bin;%BASE%/testgui/bin;%BASE%/testuno/bin;%BASE%/testgui/data;%BASE%/testuno/data org.openoffice.test.Run -r org.openoffice.test.common.Installer -l org.openoffice.test.common.XMLReporter -l org.openoffice.test.common.ReportUploader "$*"

Added: incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/Run.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/Run.java?rev=1385278&view=auto
==============================================================================
--- incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/Run.java (added)
+++ incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/Run.java Sun Sep 16 14:58:48 2012
@@ -0,0 +1,117 @@
+package org.openoffice.test;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Result;
+import org.junit.runner.notification.RunListener;
+import org.openoffice.test.common.Logger;
+import org.openoffice.test.common.NamedRequest;
+
+public class Run {
+	
+	private static void addRequest(List<NamedRequest> requests, NamedRequest request) {
+		for (NamedRequest r : requests) {
+			if (r.getName().equals(request.getName())) {
+				r.merge(request);
+				return;
+			}
+		}
+		
+		requests.add(request);
+	}
+	
+	private static void printUsage(String msg, int code) {
+		if (msg != null)
+			System.out.println(msg);
+		System.out.println("Usage: [options]");
+		System.out.println("	-D<property>=<value>	Set system property");
+		System.out.println("	-r	Set a runnable which will be executed before all tests start.");
+		System.out.println("	-l	Set a test listeners.");
+		System.out.println("	-tp	Define a test suite with test packages separated by comma. Format: [name]:org.package1,org.package2...");
+		System.out.println("	-tc	Define a test suite with test classes separated by comma. Format: [name]:org.package.Class1,org.package.Class2...");
+		System.out.println("	-tc	Define a test suite with test methods separated by comma. Format: [name]:org.package.Class1.method1,org.package.Class2.method1...");
+		System.out.println("Example:");
+		System.out.println("-tp mytest:com.test");
+		System.out.println("-tc mytest:com.test.TestName1,com.test.TestName2");
+		System.exit(code);
+	}
+	
+	public static void main(String... args) {
+		ArrayList<String> runnableClasses = new ArrayList<String>();
+		ArrayList<String> listenerClasses = new ArrayList<String>();
+		List<NamedRequest> requests = new ArrayList<NamedRequest>();
+		for (int i = 0; i < args.length; i++) {
+			String arg = args[i];
+			if ("-help".equals(arg)) {
+				printUsage(null, 0);
+			} else if (arg.startsWith("-D")) {
+				String propEntry = arg.substring(2);
+				String key = propEntry;
+				String value = null;
+				int in = propEntry.indexOf("=");
+				if (in >= 0) {
+					key = propEntry.substring(0, in);
+					value = propEntry.substring(++in);
+				}
+				System.setProperty(key, value);
+			} else if (arg.equals("-r")) {
+				if (++i >= args.length)
+					printUsage("Invalid arguments", 1);
+				runnableClasses.add(args[i]);
+			} else if (arg.equals("-l")) {
+				if (++i >= args.length)
+					printUsage("Invalid arguments", 1);
+				listenerClasses.add(args[i]);
+			} else if (arg.equals("-tc")) {
+				if (++i >= args.length)
+					printUsage("Invalid arguments", 1);
+				NamedRequest request = NamedRequest.tc(args[i]);
+				addRequest(requests, request);
+			} else if (arg.equals("-tp")) {
+				if (++i >= args.length)
+					printUsage("Invalid arguments", 1);
+				NamedRequest request = NamedRequest.tp(args[i]);
+				addRequest(requests, request);
+			} else if (arg.equals("-tm")) {
+				if (++i >= args.length)
+					printUsage("Invalid arguments", 1);
+				NamedRequest request = NamedRequest.tm(args[i]);
+				addRequest(requests, request);
+			}
+		}
+		
+		Logger log = Logger.getLogger(Run.class);
+		for (String r : runnableClasses) {
+			try {
+				((Runnable) Class.forName(r).newInstance()).run();
+			} catch (Exception e) {
+				log.log(Level.SEVERE, "Runnable is failed!", e);
+				System.exit(2);
+			}
+		}
+		
+		JUnitCore core = new JUnitCore();
+//		core.addListener(new XMLReporter());
+//		core.addListener(new CSVReporter());
+		for (String l : listenerClasses)  {
+			try {
+				core.addListener((RunListener) Class.forName(l).newInstance());
+			} catch (Exception e) {
+				// Ignore
+				log.log(Level.WARNING, "Listener is not added!", e);
+			}
+		}
+		
+		int code = 0;
+		for (NamedRequest request : requests) {
+			Result result = core.run(request.getRunner());
+			if (!result.wasSuccessful())
+				code = 1;
+		}
+		
+		System.exit(code);
+	}
+}

Modified: incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/FileUtil.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/FileUtil.java?rev=1385278&r1=1385277&r2=1385278&view=diff
==============================================================================
--- incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/FileUtil.java (original)
+++ incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/FileUtil.java Sun Sep 16 14:58:48 2012
@@ -23,31 +23,33 @@
 
 package org.openoffice.test.common;
 
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
-import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLConnection;
 import java.text.DateFormat;
+import java.text.MessageFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Properties;
 import java.util.logging.Level;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
@@ -270,16 +272,25 @@ public class FileUtil {
 	 * @return 
 	 */
 	public static String readFileAsString(File file) {
+		try {
+			return readStreamAsString(new FileInputStream(file), null);
+		} catch (FileNotFoundException e) {
+			return "";
+		}
+	}
+	
+	public static String readStreamAsString(InputStream inputStream, String charsetName) {
 		StringBuffer strBuffer = new StringBuffer(10240);
 		BufferedReader reader = null;
 		try {
-			reader = new BufferedReader(new FileReader(file));
+			reader = new BufferedReader(charsetName == null ? new InputStreamReader(inputStream) : new InputStreamReader(inputStream, charsetName));
 			char[] buf = new char[1024];
 			int count = 0;
 			while ((count = reader.read(buf)) != -1) {
 				strBuffer.append(buf, 0, count);
 			}
 		} catch (IOException e) {
+			
 		} finally {
 			if (reader != null)
 				try {
@@ -292,6 +303,8 @@ public class FileUtil {
 		return strBuffer.toString();
 	}
 	
+	
+	
 	/**
 	 * Find the first file matching the given name.
 	 * @param dir The directory to search in
@@ -404,13 +417,21 @@ public class FileUtil {
 
 	/**
 	 * Write string into a file
-	 * @param filePath
+	 * @param path
 	 * @param contents
 	 */
-	public static void writeStringToFile(String filePath, String contents) {
+	public static void writeStringToFile(String path, String contents) {
+		writeStringToFile(new File(path), contents);
+	}
+	
+	/**
+	 * Write string into a file
+	 * @param file
+	 * @param contents
+	 */
+	public static void writeStringToFile(File file, String contents) {
 		FileWriter writer = null;
 		try {
-			File file = new File(filePath);
 			file.getParentFile().mkdirs();
 			writer = new FileWriter(file);
 			if (contents != null)
@@ -426,7 +447,6 @@ public class FileUtil {
 		}
 	}
 	
-	
 	/**
 	 * Appeand a string to the tail of a file
 	 * @param file
@@ -729,14 +749,24 @@ public class FileUtil {
 	
 	/**
 	 * Unzip a zip file into the destination directory
-	 * @param zipFile
+	 * @param zip
 	 * @param dest
+	 * @return
+	 */
+	public static boolean unzip(String zip, String dest) {
+		return unzip(new File(zip), new File(dest));
+	}
+	
+	/**
+	 * Unzip a zip file into the destination directory
+	 * @param zipFile
+	 * @param destFile
+	 * @return
 	 */
-	public static void unzip(String zipFile, String dest) {
+	public static boolean unzip(File zipFile, File destFile) {
 		ZipInputStream zin = null;
 		FileOutputStream fos = null;
 		try {
-			File destFile = new File(dest);
 			zin = new ZipInputStream(new FileInputStream(zipFile));
 			ZipEntry entry;
 			while ((entry = zin.getNextEntry()) != null) {
@@ -754,8 +784,10 @@ public class FileUtil {
 					zin.closeEntry();
 				}
 			}
+			return true;
 		} catch (IOException e) {
-			log.log(Level.SEVERE, "unzip [" + zipFile + "] -> [" + dest + "] Fail!", e);
+			log.log(Level.SEVERE, MessageFormat.format(" Fail! Unzip [{0}] -> [{1}]", zipFile, destFile), e);
+			return false;
 		} finally {
 			if (zin != null)
 				try {
@@ -770,6 +802,58 @@ public class FileUtil {
 		}
 	}
 	
+	private static void zip(File dir, ZipOutputStream out, String prefix) throws Exception {
+		File[] files = dir.listFiles();
+		for (File f : files) {
+			if (f.isFile()) {
+				BufferedInputStream bis = null;
+				try {
+					bis = new BufferedInputStream(new FileInputStream(f));
+					ZipEntry entry = new ZipEntry(prefix + f.getName());
+					out.putNextEntry(entry);
+					int count;
+					byte data[] = new byte[8192];
+					while ((count = bis.read(data)) != -1) {
+						out.write(data, 0, count);
+					}
+					bis.close();
+				} finally {
+					if (bis != null)
+						bis.close();
+				}
+				
+			} else {
+				zip(f, out, prefix + f.getName() + "/");
+			}
+		}
+	}
+	
+	public static void zip(File workingDir, File zipFile) {
+		zip(workingDir, zipFile, null);
+	}
+	
+	public static void zip(File workingDir, File zipFile, String prefix) {
+		if (!workingDir.isDirectory())
+			return;
+		
+		if (prefix == null)
+			prefix = "";
+		
+		ZipOutputStream out = null;
+		try {
+			out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipFile)));
+			zip(workingDir, out, prefix);
+		} catch (Exception e) {
+
+		} finally {
+			if (out != null)
+				try {
+					out.close();
+				} catch (IOException e) {
+				}
+		}
+	       
+	 }
 	/**
 	 * Get an unique name under the specified directory
 	 * @param dir
@@ -800,7 +884,6 @@ public class FileUtil {
 		return getUniqueFile(new File(dir), prefix, suffix);
 	}
 	
-	
 	/**
 	 * Download a file from a url to the local file system
 	 * @param urlString
@@ -808,6 +891,17 @@ public class FileUtil {
 	 * @return
 	 */
 	public static File download(String urlString, File output) {
+		return download(urlString, output, false);
+	}
+	
+	/**
+	 * Download a file from a url to the local file system
+	 * @param urlString
+	 * @param output
+	 * @param usetimestamp
+	 * @return
+	 */
+	public static File download(String urlString, File output, boolean usetimestamp) {
 		InputStream in = null;
 		OutputStream out = null;
 		try {
@@ -816,8 +910,15 @@ public class FileUtil {
 			int totalSize = urlConnection.getContentLength();
 			in = urlConnection.getInputStream();
 			if (output.isDirectory()) 
-				output = new File(output, url.getPath());
+				output = new File(output, new File(url.getPath()).getName());
 			output.getParentFile().mkdirs();
+			if (usetimestamp && output.exists()) {
+				if (output.lastModified() == urlConnection.getLastModified()) {
+					log.info(MessageFormat.format(" Skip! Download {0} -> {1}", urlString, output));
+					return output;
+				}
+			}
+			
 			out = new FileOutputStream(output);
 			byte[] buffer = new byte[1024 * 100]; // 100k
 			int count = 0;
@@ -835,10 +936,12 @@ public class FileUtil {
 				}
 				
 			}
-			log.info("Download [" + urlString + "] -> [" + output + "] OK!");
+			if (urlConnection.getLastModified() >= 0)
+				output.setLastModified(urlConnection.getLastModified());
+			log.info(MessageFormat.format("OK! Download {0} -> {1}", urlString, output));
 			return output;
 		} catch (Exception e) {
-			log.log(Level.SEVERE, "Download [" + urlString + "] -> [" + output + "] Fail!", e);
+			log.log(Level.SEVERE, MessageFormat.format("Fail! Download {0} -> {1}", urlString, output), e);
 			return null;
 		} finally {
 			if (in != null)
@@ -889,6 +992,8 @@ public class FileUtil {
 	 * @return
 	 */
 	public static boolean isUrl(String address) {
+		if (address == null)
+			return false;
 		try {
 			new URL(address);
 			return true;

Added: incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/Installer.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/Installer.java?rev=1385278&view=auto
==============================================================================
--- incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/Installer.java (added)
+++ incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/Installer.java Sun Sep 16 14:58:48 2012
@@ -0,0 +1,82 @@
+package org.openoffice.test.common;
+
+import java.io.File;
+import java.io.IOException;
+import java.text.MessageFormat;
+import java.util.logging.Level;
+
+public class Installer implements Runnable {
+	private static Logger log = Logger.getLogger(Installer.class);
+	File downloadDir = Testspace.getFile("download");
+	File downloadUrl = Testspace.getFile("download/url");
+	File installDir = Testspace.getFile("install");
+	File installTempDir = Testspace.getFile("install_temp");
+	
+	@Override
+	public void run() {
+		String prop = System.getProperty("singleton");
+		if ("true".equalsIgnoreCase(prop) || "yes".equalsIgnoreCase(prop)) {
+			if (SystemUtil.findProcesses(".*org\\.openoffice\\.test\\.common\\.Installer.*").size() > 1) {
+				throw new RuntimeException("Only allow one running test instance!");
+			}
+		}
+		if ((prop = System.getProperty("openoffice.pack")) != null) {
+			File packFile = null;
+			if (FileUtil.isUrl(prop)) {
+				String url = FileUtil.readFileAsString(downloadUrl);
+				if (!prop.equals(url)) {
+					FileUtil.deleteFile(downloadDir);
+					downloadDir.mkdirs();
+					packFile = FileUtil.download(prop, downloadDir);
+					if (packFile == null)
+						throw new RuntimeException(MessageFormat.format("{0} can not be downloaded!", prop));
+					FileUtil.writeStringToFile(downloadUrl, prop);
+				} else {
+					packFile = FileUtil.download(prop, downloadDir, true);
+					if (packFile == null)
+						throw new RuntimeException(MessageFormat.format("{0} can not be downloaded!", prop));
+				}
+			} else {
+				packFile = new File(prop);
+				if (!packFile.isFile())
+					throw new RuntimeException(MessageFormat.format("{0} does not exists or is not a file!", prop));
+			}
+			
+			try {
+				FileUtil.deleteFile(installDir);
+				FileUtil.deleteFile(installTempDir);
+				installTempDir.mkdirs();
+				if (packFile.getName().endsWith(".gz")) {
+					StringBuffer output = new StringBuffer();
+					if (SystemUtil.exec(new String[]{"tar", "-zxpf", packFile.getAbsolutePath(), "-C", installTempDir.getAbsolutePath()}, output) != 0)
+						throw new RuntimeException(MessageFormat.format("{0} can not be installed! Cause: {1}" , packFile, output));
+				} else {
+					if (!FileUtil.unzip(packFile, installTempDir))
+						throw new RuntimeException(MessageFormat.format("{0} can not be installed!", packFile));
+				}
+				// On windows, if path is too long, openoffice can not be started.
+				File[] files = installTempDir.listFiles();
+				if (files != null && files.length == 1 && files[0].isDirectory()) {
+					files[0].renameTo(installDir);
+				}
+				File sofficeBin = FileUtil.findFile(installDir, "soffice.bin");
+				if (sofficeBin == null) 
+					throw new RuntimeException(MessageFormat.format("{0} is not a valid openoffice installation package!" , packFile));
+				try {
+					String openofficeHome = sofficeBin.getParentFile().getParentFile().getCanonicalPath();
+					log.log(Level.INFO, MessageFormat.format("{0} is installed to {1}", prop, openofficeHome));
+					System.setProperty("openoffice.home", openofficeHome);
+				} catch (IOException e) {
+					//ignore, never occurs
+				}
+		
+			} finally {
+				FileUtil.deleteFile(installTempDir);
+			}
+		}
+	}
+
+	public static void main(String... args) {
+		new Installer().run();
+	}
+}

Modified: incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/Logger.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/Logger.java?rev=1385278&r1=1385277&r2=1385278&view=diff
==============================================================================
--- incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/Logger.java (original)
+++ incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/Logger.java Sun Sep 16 14:58:48 2012
@@ -24,6 +24,7 @@ package org.openoffice.test.common;
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.InputStream;
+import java.text.MessageFormat;
 import java.util.logging.Level;
 import java.util.logging.LogManager;
 
@@ -114,12 +115,13 @@ public class Logger extends java.util.lo
 	}
 
 	protected void fail(Throwable e, Description description) {
-		String screenshotType = e instanceof AssertionError ? "failure" : "error";
-		File screenshotOutput = Testspace.getFile(SCREENSHOT_DIR);
-		screenshotOutput.mkdirs();
-		File file = new File(screenshotOutput, description.getClassName() + "." + description.getMethodName() + "." + screenshotType + ".png");
-		GraphicsUtil.screenShot(file.getAbsolutePath());
-		log(Level.SEVERE, "[" + description.getMethodName() + "] is failed. Screenshot [" + file.getAbsolutePath() + "]. Cause: ", e);
+		String screenshotPath = "";
+		if (screenshotEnabled) {
+			screenshotPath = Testspace.getPath(SCREENSHOT_DIR + "/" + description.getDisplayName() + ".png");
+			GraphicsUtil.screenShot(screenshotPath);
+		}
+		
+		log(Level.SEVERE, MessageFormat.format("[{0}] is failed. Screenshot: {1}", description.getMethodName(), screenshotPath), e);
 		// Check if crash occurs!
 		// if (e instanceof CommunicationException) {
 		// logger.severe("Pay attention! OpenOffice maybe crashed or freezed. ");

Added: incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/NamedRequest.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/NamedRequest.java?rev=1385278&view=auto
==============================================================================
--- incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/NamedRequest.java (added)
+++ incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/NamedRequest.java Sun Sep 16 14:58:48 2012
@@ -0,0 +1,162 @@
+package org.openoffice.test.common;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+
+import org.junit.runner.Description;
+import org.junit.runner.Request;
+import org.junit.runner.Runner;
+import org.junit.runner.notification.RunNotifier;
+import org.junit.runners.ParentRunner;
+import org.junit.runners.model.InitializationError;
+import org.openoffice.test.Run;
+
+public class NamedRequest extends Request {
+	
+	private static Logger log = Logger.getLogger(Run.class);
+	
+	private Suite suite = null;
+	
+	protected NamedRequest() {
+		
+	}
+	
+	private String init(String arg) throws InitializationError {
+		String name = null;
+		int ci = arg.indexOf(":");
+		if (ci >= 0) {
+			name = arg.substring(0, ci);
+			arg = arg.substring(++ci);
+		} else {
+			name = arg;
+			if (name.length() > 128) {
+				name = name.substring(0, 128) + "...";
+			}
+		}
+		suite = new Suite(name);
+		return arg;
+	}
+	
+	private void addRunner(Runner runner) {
+		suite.getChildren().add(runner);
+	}
+	
+	public static NamedRequest tc(String arg) {
+		NamedRequest namedRequest = new NamedRequest();
+		try {
+			arg = namedRequest.init(arg);
+		} catch (InitializationError e1) {
+			return null;
+		}
+		
+		String[] klasses = arg.split(",");
+		List<Class<?>> classes = new ArrayList<Class<?>>();
+		for (String k : klasses) {
+			try {
+				classes.add(Class.forName(k));
+			} catch (Throwable e) {
+				log.log(Level.WARNING, MessageFormat.format("Test class {0} can not be tested!", k), e);
+			}
+		}
+		
+		namedRequest.addRunner(Request.classes(classes.toArray(new Class[0])).getRunner());
+		return namedRequest;
+	}
+	
+	public static NamedRequest tp(String arg) {
+		NamedRequest namedRequest = new NamedRequest();
+		try {
+			arg = namedRequest.init(arg);
+		} catch (InitializationError e1) {
+			return null;
+		}
+		
+		String[] packages = arg.split(",");
+		List<Class<?>> classes = new ArrayList<Class<?>>();
+		for (String p : packages) {
+			List<String> klasses = SystemUtil.getClassesInPackage(p);
+			for (String k : klasses) {
+				if (k.matches(".+[$]{1}.*"))
+					continue;
+				try {
+					classes.add(Class.forName(k));
+				} catch (Throwable e) {
+					log.log(Level.WARNING, MessageFormat.format("Test class {0} can not be tested!", k), e);
+				}
+			}
+		}
+		
+		namedRequest.addRunner(Request.classes(classes.toArray(new Class[0])).getRunner());
+		return namedRequest;
+	}
+
+	public static NamedRequest tm(String arg) {
+		NamedRequest namedRequest = new NamedRequest();
+		try {
+			arg = namedRequest.init(arg);
+		} catch (InitializationError e1) {
+			return null;
+		}
+		
+		String[] methods = arg.split(",");
+		for (String m : methods) {
+			int i = m.lastIndexOf(".");
+			String className = m.substring(0, i);
+			String methodName = m.substring(++i);
+			try {
+				namedRequest.addRunner(Request.method(Class.forName(className), methodName).getRunner());
+			} catch (Throwable e) {
+				log.log(Level.WARNING, MessageFormat.format("Test method {0} can not be tested!", m), e);
+			}
+			
+		}
+		return namedRequest;
+	}
+
+	public void merge(NamedRequest other) {
+		suite.getChildren().addAll(other.suite.getChildren());
+	}
+
+	public String getName() {
+		return suite.getName();
+	}
+
+	@Override
+	public Runner getRunner() {
+		return suite;
+	}
+	
+	public static class Suite extends ParentRunner<Runner> {
+		
+		protected final List<Runner> fRunners = new ArrayList<Runner>();
+
+		protected String name;
+		
+		protected Suite(String name) throws InitializationError {
+			super(null);
+			this.name = name;
+		}
+
+		protected String getName() {
+			return name;
+		}
+		
+		@Override
+		protected List<Runner> getChildren() {
+			return fRunners;
+		}
+
+		@Override
+		protected Description describeChild(Runner child) {
+			return child.getDescription();
+		}
+
+		@Override
+		protected void runChild(Runner runner, final RunNotifier notifier) {
+			runner.run(notifier);
+		}
+	}
+
+}
\ No newline at end of file

Added: incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/ReportUploader.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/ReportUploader.java?rev=1385278&view=auto
==============================================================================
--- incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/ReportUploader.java (added)
+++ incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/ReportUploader.java Sun Sep 16 14:58:48 2012
@@ -0,0 +1,126 @@
+package org.openoffice.test.common;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.logging.Level;
+
+import org.junit.runner.Description;
+import org.junit.runner.Result;
+import org.junit.runner.notification.RunListener;
+
+public class ReportUploader extends RunListener {
+	
+	private Logger log = Logger.getLogger(this);
+	
+	private File outputDir = Testspace.getFile("output");
+	
+	private String suiteName = null;
+	
+	private File reportZip = null;
+	
+	private String url = null;
+	
+	public ReportUploader() {
+		url = System.getProperty("report.to");
+		System.setProperty("report.to", ""); // 
+	}
+	
+	@Override
+	public void testRunStarted(Description description) throws Exception {
+		suiteName = description.getDisplayName();
+	}
+	
+	@Override
+	public void testRunFinished(Result result) throws Exception {
+		if (!FileUtil.isUrl(url))
+			return;
+		
+		// upload
+		File output = new File(outputDir.getAbsolutePath() + "." + suiteName);
+		if (!output.exists())
+			return;
+		try {
+			reportZip = File.createTempFile("aoo_test_report", ".zip");
+			FileUtil.zip(output, reportZip);
+			upload();
+		} finally {
+			if (reportZip != null)
+				reportZip.delete();
+		}
+	}
+
+
+
+	private static final String boundary = "-----AOOAOOAOO1d226f500d0";
+	private static final String prefix = "--";
+	private static final String newLine = "\r\n";
+
+	private void upload() {
+		InputStream fis = null;
+		OutputStream out = null;
+		try {
+			HttpURLConnection connection = (HttpURLConnection)  new URL(url).openConnection();
+			connection.setDoInput(true);
+			connection.setDoOutput(true);
+			connection.setConnectTimeout(20 * 1000);
+			connection.setRequestMethod("POST");
+			connection.setRequestProperty("Content-type", "multipart/form-data;boundary=" + boundary);
+			
+			out = connection.getOutputStream();
+			fis = new FileInputStream(reportZip);
+			
+			StringBuffer params = new StringBuffer();
+			params.append(prefix + boundary + newLine);
+			params.append("Content-Disposition: form-data; name=\"name\"");
+			params.append(newLine + newLine);
+			params.append("aoo");
+			params.append(newLine);
+		
+			params.append(prefix + boundary + newLine);
+			params.append("Content-Disposition: form-data; name=\"file\"; filename=\"report.zip\"");
+			params.append(newLine);
+			params.append("Content-Type: application/zip");
+			params.append(newLine + newLine);
+			
+			out.write(params.toString().getBytes());
+			
+			byte[] buffer = new byte[1024];
+			int len = 0;
+			while ((len = fis.read(buffer)) != -1) {
+				out.write(buffer, 0, len);
+			}
+			
+			params.setLength(0);
+			params.append(newLine);
+			params.append(prefix + boundary + prefix + newLine);
+			
+			out.write(params.toString().getBytes());
+			out.flush();
+			out.close();
+		
+			String response = FileUtil.readStreamAsString(connection.getInputStream(), "UTF-8");
+			log.log(Level.INFO, "Upload report: \n" + response);
+		} catch (Exception e) {
+			log.log(Level.SEVERE, "Fail to upload report!", e);
+		} finally {
+			if (fis != null)
+				try {
+					fis.close();
+				} catch (IOException e) {
+				}
+			if (out != null)
+				try {
+					out.close();
+				} catch (IOException e) {
+				}
+		}
+	}
+
+
+
+}

Modified: incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/SystemUtil.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/SystemUtil.java?rev=1385278&r1=1385277&r2=1385278&view=diff
==============================================================================
--- incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/SystemUtil.java (original)
+++ incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/SystemUtil.java Sun Sep 16 14:58:48 2012
@@ -31,12 +31,18 @@ import java.io.File;
 import java.io.IOException;
 import java.io.StringReader;
 import java.net.InetAddress;
+import java.net.URL;
 import java.net.UnknownHostException;
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.List;
 import java.util.StringTokenizer;
+import java.util.logging.Level;
 import java.util.logging.Logger;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
 
 /**
  * Utilities related to system
@@ -243,8 +249,10 @@ public class SystemUtil {
 	public static int exec(String[] cmd, String[] env, File dir, StringBuffer output, StringBuffer error) {
 		Process process = null;
 		try {
+			LOG.log(Level.FINE,  "exec: " + Arrays.toString(cmd));
 			process = Runtime.getRuntime().exec(cmd, env, dir);
 		} catch (Exception e) {
+			e.printStackTrace();
 			return -1;
 		}
 		
@@ -368,6 +376,19 @@ public class SystemUtil {
 		return null;
 	}
 	
+	public static List<HashMap<String, Object>> findProcesses(String pattern) {
+		List<HashMap<String, Object>> result = new ArrayList<HashMap<String, Object>>();
+		List<HashMap<String, Object>> processes = SystemUtil.getProcesses();
+		for (HashMap<String, Object> p : processes) {
+			String command = (String) p.get("command");
+			if (command != null && command.matches(pattern)) {
+				result.add(p);
+			}
+		}
+		
+		return result;
+	}
+	
 	/**
 	 * Get Information of running processes
 	 * 
@@ -503,4 +524,70 @@ public class SystemUtil {
 		}
 		
 	}
+	
+	public static List<String> getClassesInPackage(String packageName) {
+		ArrayList<String> classes = new ArrayList<String>();
+		ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+		String path = packageName.replace('.', '/');
+		try {
+			Enumeration<URL> urls = classLoader.getResources(path);
+			while (urls.hasMoreElements()) {
+				URL url = urls.nextElement();
+				if ("file".equals(url.getProtocol())) {
+					findClasses(packageName, new File(url.getFile()), classes);
+				} else if ("jar".equals(url.getProtocol())) {
+					String urlStr = url.toString();
+					int i = urlStr.indexOf('!');
+					if (i > 0)
+						findClasses(packageName, new URL(urlStr.substring(4, i)), classes);
+				}
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+//		TreeSet classes = new TreeSet();
+//		for (String directory : dirs) {
+//			classes.addAll(findClasses(directory, packageName));
+//		}
+//		ArrayList classList = new ArrayList();
+//		for (String clazz : classes) {
+//			classList.add(Class.forName(clazz));
+//		}
+//		return classList;
+		return classes;
+	}
+	private static void findClasses(String packageName, File dir, List<String> classes) {
+		if (!dir.isDirectory())
+			return;
+		File[] files = dir.listFiles();
+		for (File file : files) {
+			String name = file.getName();
+			if (file.isDirectory()) {
+				findClasses(packageName + '.'+ name, file, classes);
+			}  else if (name.endsWith(".class")) {
+				String className = packageName + '.' + name.substring(0, name.length() - 6);
+				classes.add(className);
+			}
+		}
+	}
+	
+	
+	private static void findClasses(String packageName, URL jar, List<String> classes) {
+		try {
+			ZipInputStream zip = new ZipInputStream(jar.openStream());
+			ZipEntry entry;
+			while ((entry = zip.getNextEntry()) != null) {
+				String name = entry.getName();
+				if (name.endsWith(".class")) {
+					name = name.replace('/', '.').substring(0, name.length() - 6);
+					if (name.startsWith(packageName)) {
+						classes.add(name);
+					}
+				}
+			}
+
+		} catch (Exception e) {
+
+		}
+	}
 }

Modified: incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/XMLReporter.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/XMLReporter.java?rev=1385278&r1=1385277&r2=1385278&view=diff
==============================================================================
--- incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/XMLReporter.java (original)
+++ incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/XMLReporter.java Sun Sep 16 14:58:48 2012
@@ -12,11 +12,12 @@ import org.junit.runner.notification.Fai
 import org.junit.runner.notification.RunListener;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
-import org.w3c.dom.ProcessingInstruction;
 
 public class XMLReporter extends RunListener {
 
-	private File reportDir = Testspace.getFile("output/result");
+	private File outputDir = Testspace.getFile("output");
+	
+	private File reportDir = new File(outputDir, "result");
 	
 	private File file = null;
 	
@@ -26,7 +27,7 @@ public class XMLReporter extends RunList
 	
 	private Element testcaseEl = null;
 	
-	private String testClassName = null;
+	private String suiteName = null;
 	
 	private long suiteStart = 0;
 	
@@ -42,11 +43,11 @@ public class XMLReporter extends RunList
 	
 	@Override
 	public void testStarted(Description description) throws Exception {
-		System.out.println("testStarted");
-		if (!description.getClassName().equals(testClassName)) {
-			finishSuite();
-			startSuite(description);
-		}
+//		if (!description.getClassName().equals(testClassName)) {
+//			finishSuite();
+//			startSuite(description);
+//			testClassName = description.getClassName();
+//		}
 		testcaseEl = doc.createElement("testcase");
 		testcaseEl.setAttribute("name", description.getDisplayName());
 		testcaseEl.setAttribute("classname", description.getClassName());
@@ -62,7 +63,6 @@ public class XMLReporter extends RunList
 
 	@Override
 	public void testFailure(Failure failure) throws Exception {
-		System.out.println("testFailure");
 		if (failure.getException() instanceof AssertionError) {
 			failures++;
 			Element failureEl = doc.createElement("failure");
@@ -82,7 +82,6 @@ public class XMLReporter extends RunList
 
 	@Override
 	public void testFinished(Description description) throws Exception {
-		System.out.println("testFinished");
 		tests++;
 		testcaseEl.setAttribute("time", Double.toString((System.currentTimeMillis() - testStart) / 1000.0));
 		store();
@@ -91,48 +90,49 @@ public class XMLReporter extends RunList
 	@Override
 	public void testIgnored(Description description) throws Exception {
 		testStarted(description);
-		System.out.println("testIgnored");
 		ignored++;
 		Ignore ignore = description.getAnnotation(Ignore.class);
 		Element ignoredEl = doc.createElement("ignored");
 		ignoredEl.setAttribute("message", ignore.value());
 		testcaseEl.appendChild(ignoredEl);
-		
 		testFinished(description);
 	}
 
 	@Override
 	public void testRunFinished(Result result) throws Exception {
-		System.out.println("testRunFinished");
 		finishSuite();
+		File outputBackupDir = new File(outputDir.getAbsolutePath() + "." + suiteName);
+		if (outputBackupDir.exists()) {
+			FileUtil.deleteFile(outputBackupDir);
+		}
+		
+		outputDir.renameTo(outputBackupDir);
 	}
 
 	@Override
 	public void testRunStarted(Description description) throws Exception {
-		System.out.println("testRunStarted");
+		suiteName = description.getDisplayName();
+		FileUtil.deleteFile(outputDir);//clear all old output
+		startSuite();
 	}
 
-	private void startSuite(Description description) {
-		testClassName = description.getClassName();
+	private void startSuite() {
 		suiteStart = System.currentTimeMillis();
 		failures = 0;
 		errors = 0;
 		tests = 0;
 		ignored = 0;
 		
-		file = new File(reportDir, testClassName + ".xml");
+		file = new File(reportDir, suiteName + ".xml");
 		doc = FileUtil.newXML();
 	
 		testsuiteEl = doc.createElement("testsuite");
-		testsuiteEl.setAttribute("name", testClassName);
+		testsuiteEl.setAttribute("name", suiteName);
 		testsuiteEl.setAttribute("start", Long.toString(suiteStart));
 		doc.appendChild(testsuiteEl);
 	}
 	
 	private void finishSuite() {
-		if (testClassName == null)
-			return;
-		
 		testsuiteEl.setAttribute("time", Double.toString((System.currentTimeMillis() - testStart) / 1000.0));
 		testsuiteEl.setAttribute("failures", Long.toString(failures));
 		testsuiteEl.setAttribute("errors", Long.toString(errors));
@@ -154,7 +154,7 @@ public class XMLReporter extends RunList
 	private void store() {
 		if (doc != null) {
 			FileUtil.storeXML(doc, file);
-			File htmlFile = new File(reportDir, testClassName + ".html");
+			File htmlFile = new File(reportDir, file.getName() + ".html");
 			InputStream is = getClass().getResourceAsStream("XMLReporter.xsl");
 			if (is != null) {
 				FileUtil.storeXML(doc, htmlFile, is);

Modified: incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/XMLReporter.xsl
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/XMLReporter.xsl?rev=1385278&r1=1385277&r2=1385278&view=diff
==============================================================================
--- incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/XMLReporter.xsl (original)
+++ incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/XMLReporter.xsl Sun Sep 16 14:58:48 2012
@@ -1,68 +1,209 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="xml" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" />
+<xsl:output method="html" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" />
 <xsl:template match="/">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
-	<style>
-.Success {
-	background:#22cc22;
-}
-.Failure {
-	background:#FF4444;
-}
-.Ignored {
-	background:#FFFF44;
-}
-.Error {
-	background:#FF0000;
-}
-.recordTable {
-    border-collapse:collapse;
-}
-.recordTable thead th{
-    padding:5px 10px 5px 10px;
-    color:#fff;
-    font-size: 14px;
-    background-color:#222;
-    border-right:1px dotted #666;
-}
-
-.recordTable tbody td{
-    padding:5px 10px 5px 10px;
-    background-color:#f0f0f0;
-    border-right:1px dotted #999;
-    color:#333;
+<style>
+body {
+	font: 90% Arial, sans-serif;
+}
+
+tr.Success {
+	color:#118811;
+}
+
+tr.Failure {
+	color:#F27D15;
+}
+
+tr.Ignored {
+	color:#F4C700;
+}
+
+tr.Error {
+	color:#FC130F;
+}
+
+th.Success {
+	background:#118811;
+}
+
+th.Failure {
+	background: #F27D15;
+}
+
+th.Ignored {
+	background:#F4C700;
+}
+
+th.Error {
+	background:#FC130F;
+}
+
+a.unchecked {
+	text-decoration: none;
+	padding: 0px 4px;
+	color: #000000;
+	font-weight: bold;
+	border-bottom: 2px solid #AAAAAA;
+}
+
+a.checked {
+	text-decoration: none;
+	border-bottom: 2px solid #E6820E;
+	padding: 0px 4px;
+	color: #000000;
+	font-weight: bold;
+}
+
+.container {
+	width: 100%;
+	float: left;
+	margin-right: -300px;
+}
+
+.content {
+	margin-right: 300px;
+}
+
+.sidebar {
+	width: 300px;
+	float: right;
+}
+
+table {
+	font-size: 90%;
+	border-collapse:collapse;
+    width:100%;
+    background: white;
+	border: 1px solid #666;
+}
+
+td {
+	border: 1px solid #BBB;
+	padding: 4px;
+	text-align: left;
+	vertical-align: top;
+}
+
+th {
+	background: #DDD;
+	border: 1px solid #BBB;
+	padding: 4px;
+	width: 80px;
+	font-weight: bold;
+	text-align: left;
+}
+
+.pieContainer {
+     height: 100px;
+}
+.pieBackground {
+     background-color: grey;
+     position: absolute;
+     width: 100px;
+     height: 100px;
+     -moz-border-radius: 50px;
+     -webkit-border-radius: 50px;
+     -o-border-radius: 50px;
+     border-radius: 50px;
+     -moz-box-shadow: -1px 1px 3px #000;
+     -webkit-box-shadow: -1px 1px 3px #000;
+     -o-box-shadow: -1px 1px 3px #000;
+     box-shadow: -1px 1px 3px #000;
+} 
+
+.pie {
+         position: absolute;
+         width: 100px;
+         height: 100px;
+         -moz-border-radius: 50px;
+         -webkit-border-radius: 50px;
+         -o-border-radius: 50px;
+         border-radius: 50px;
+         clip: rect(0px, 50px, 100px, 0px);
+    }
+.hold {
+     position: absolute;
+     width: 100px;
+     height: 100px;
+     -moz-border-radius: 50px;
+     -webkit-border-radius: 50px;
+     -o-border-radius: 50px;
+     border-radius: 50px;
+     clip: rect(0px, 100px, 100px, 50px);
+}
+#pieSlice1 .pie {
+     background-color: #1b458b;
+     -webkit-transform:rotate(50deg);
+     -moz-transform:rotate(50deg);
+     -o-transform:rotate(50deg);
+     transform:rotate(50deg);
 }
 
 	</style>
 	<title>JUnit Report</title>
 </head>
-<body>
-<xml id="data" style="display:none">
-	<xsl:copy-of select="*" />
-</xml>
-
-<table>
-	<thead>
-		<tr><th>Class</th><th>Name</th><th>Platform</th><th>Platform</th><th>Platform</th><th>Platform</th></tr>
-	</thead>
-	<tbody>
-	</tbody>
-</table>
-
-<table class="recordTable">
-	<thead>
-		<tr><th>Name</th><th>Status</th><th width="80%">Message</th><th>Time</th><th>Screenshot</th></tr>
-	</thead>
-	<tbody id="recordTable">
-	</tbody>
-</table>
+<body onload="onload()">
 
+<div class="container">
+	<div class="content">
+		<div style="font-weight: bold;padding: 6px">Information</div>
+		<div style="padding: 6px">
+		<table class="infoTable">
+		<tr><th>Build ID</th><td><span id="info.app.buildid">Unknown</span> (<span id="info.app.AllLanguages"></span>)</td></tr>
+		<tr><th>Revision</th><td id="info.app.Revision">Unknown</td></tr>
+		<tr><th>OS</th><td><span id="info.os.name">Unknown</span>-<span id="info.os.version">Unknown</span>-<span id="info.os.arch">Unknown</span></td></tr>
+		<tr><th>Host Name</th><td><span id="info.hostname">Unknown</span> (<span id="info.ip"></span>)</td></tr>
+		<tr><th>Java</th><td id="java.runtime.version">Unknown</td></tr>
+		</table>
+		</div>
+	</div>
+</div>
+
+<div class="sidebar">
+	<div style="font-weight: bold;padding: 6px">Summary</div>
+	<div style="padding: 6px">
+	<table class="summaryTable">
+		<tr><th>All</th><td><a href="#" onclick="showAllRecord()" id="AllNo" class="checked" >0</a></td></tr>
+		<tr><th class="Success">Success</th><td><a href="#" onclick="toggleRecord('Success')" class="checked" id="SuccessNo">0</a></td></tr>
+		<tr><th class="Failure">Failure</th><td><a href="#" onclick="toggleRecord('Failure')" class="checked" id="FailureNo">0</a></td></tr>
+		<tr><th class="Error">Error</th><td><a href="#" onclick="toggleRecord('Error')" class="checked" id="ErrorNo">0</a></td></tr>
+		<tr><th class="Ignored">Ignored</th><td><a href="#" onclick="toggleRecord('Ignored')" class="checked" id="IgnoredNo">0</a></td></tr>
+	</table>
+	</div>
+</div>
+<div style="clear:both; padding: 6px;font-weight: bold">
+	<div style="float:left">Record</div>
+	<div style="float:right;">
+	View:
+	</div>
+</div>
+<div style="clear:both;padding: 6px">
+	<table class="recordTable">
+		<thead>
+			<tr><th>Class</th><th>Method</th><th>Status</th><th width="80%">Message</th><th>Time</th><th>Screenshot</th></tr>
+		</thead>
+		<tbody id="recordTable">
+		</tbody>
+	</table>
+</div>
 
 <script>
 <xsl:text disable-output-escaping='yes'>
 <![CDATA[
+function ajax(url, callback) {
+	var xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
+	xmlhttp.onreadystatechange = callback;
+	xmlhttp.open("GET", url, true);
+	xmlhttp.send();
+}
+
+function text(s) {
+	return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
+}
+
 function $(id) {
 	return document.getElementById(id);
 }
@@ -79,33 +220,109 @@ function $$s(e, tag) {
 function refresh() {
 	var data = $('data');
 	var testsuiteEl = $$(data, 'testsuite');
+	var allNo = testsuiteEl.getAttribute("tests");
+	$('AllNo').innerHTML = allNo;
+	var failureNo = testsuiteEl.getAttribute("failures");
+	$('FailureNo').innerHTML = failureNo;
+	var errorNo = testsuiteEl.getAttribute("errors");
+	$('ErrorNo').innerHTML = errorNo;
+	var ignoredNo = testsuiteEl.getAttribute("ignored");
+	$('IgnoredNo').innerHTML = ignoredNo;
+	$('SuccessNo').innerHTML = parseInt(allNo) - parseInt(failureNo) - parseInt(errorNo) - parseInt(ignoredNo);
+	
+	var propEls = $$s(testsuiteEl, "property");
+	var props = {};
+	for (var i = 0; i < propEls.length; i++) {
+		var e = propEls[i];
+		props[e.getAttribute("name")] = e.getAttribute("value");
+	}
+	
+	$('info.app.buildid').innerHTML = props['info.app.buildid'] || 'Unknown';
+	$('info.app.AllLanguages').innerHTML = props['info.app.AllLanguages'] || '';
+	$('info.os.name').innerHTML = props['info.os.name'] || 'Unknown';
+	$('info.os.version').innerHTML = props['info.os.version'] || 'Unknown';
+	$('info.os.arch').innerHTML = props['info.os.arch'] || 'Unknown';
+	if (props['info.app.Revision']) 
+		$('info.app.Revision').innerHTML = '<a href="https://fisheye6.atlassian.com/changelog/~br=trunk/ooo/?showid=' + props['info.app.Revision'] + '">'  + props['info.app.Revision'] + '</a>';
+	$('info.hostname').innerHTML = props['info.hostname'] || 'Unknown';
+	$('info.ip').innerHTML = props['info.ip'] || '0.0.0.0';
+	$('java.runtime.version').innerHTML = props['java.runtime.version'] || 'Unknown';
+	
 	var testcaseEls = $$s(data, 'testcase');
 	var html = '';
 	for (var i = 0; i < testcaseEls.length; i++){
-		var e = testcaseEls[i], c;
-		var status = 'Success', message = '';
+		var e = testcaseEls[i], c = null;
+		var status = 'Success', message = '', screenshot= '';
 		if (c = $$(e, 'failure')) {
 			status = 'Failure';
-			message = c.getAttribute("message");
+			message = text(c.getAttribute("message"));
+			screenshot = '<a href="../screenshot/' + e.getAttribute("name") + '.png">Screenshot</a>';
 		} else if (c = $$(e, 'error')) {
 			status = 'Error';
-			message = c.getAttribute("message");
+			message = text(c.getAttribute("message"));
+			screenshot = '<a href="../screenshot/' + e.getAttribute("name") + '.png">Screenshot</a>';
 		} else if (c = $$(e, 'ignored')) {
 			status = 'Ignored';
-			message = c.getAttribute("message");
+			message = text(c.getAttribute("message"));
+		    var bugPattern = /(.*)#(\d+)(.*)/;
+		    bugPattern.test(message);
+		    message = '<a href="https://issues.apache.org/ooo/show_bug.cgi?id=' + RegExp.$2 + '">' + RegExp.$1 + RegExp.$2 + '</a>' + RegExp.$3;
 		}
-		message = message.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
-		html += '<tr class="' + status + '"><td>' + e.getAttribute("name") + '</td><td>' + status + '</td><td>' + message + '</td><td>' + e.getAttribute("time") + '</td><td>' + '*' + '</td></tr>';
+		
+		html += '<tr class="' + status + '"><td>' 
+			+ e.getAttribute("classname") + '</td><td>' 
+			+ e.getAttribute("methodname") + '</td><td>' 
+			+ status + '</td><td>' 
+			+ message + '</td><td>' 
+			+ e.getAttribute("time") + '</td><td>' 
+			+ screenshot + '</td></tr>';
 	}
 	
-	$("recordTable").innerHTML = html;
+	$('recordTable').innerHTML = html;
+}
+
+function showAllRecord() {
+	var trEls = $$s($('recordTable'), 'tr');
+	for (var i = 0; i < trEls.length; i++){
+		var e = trEls[i];
+		e.style.display = '';
+	}
+	$("ErrorNo").className = 'checked';
+	$("FailureNo").className = 'checked';
+	$("IgnoredNo").className = 'checked';
+	$("SuccessNo").className = 'checked';
+}
+
+function toggleRecord(status) {
+	var display = '';
+	var el = $(status + "No");
+	if (el.className == 'unchecked') {
+		el.className = 'checked';
+	} else {
+		el.className = 'unchecked';
+		display = 'none';
+	}
+	
+	var trEls = $$s($('recordTable'), 'tr');
+	for (var i = 0; i < trEls.length; i++){
+		var e = trEls[i];
+		if (e.className == status) {
+			e.style.display = display;
+		}
+	}
+}
+
+function onload() {
+	refresh();
 }
 
-refresh();
 
 ]]>
 </xsl:text>
 </script>
+<xml id="data" style="display:none">
+	<xsl:copy-of select="*" />
+</xml>
 </body>
 </html>
 </xsl:template>



Mime
View raw message