Author: brett
Date: Sun Apr 30 20:11:41 2006
New Revision: 398507
URL: http://svn.apache.org/viewcvs?rev=398507&view=rev
Log:
[MSUREFIRE-86] fix remaining issues with forking on 1.3
Added:
maven/surefire/branches/surefire-testng/surefire-api/src/main/java/org/apache/maven/surefire/util/PrettyPrintXMLWriter.java
(with props)
Modified:
maven/surefire/branches/surefire-testng/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java
maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java
maven/surefire/branches/surefire-testng/surefire-providers/surefire-testng/pom.xml
Modified:
maven/surefire/branches/surefire-testng/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java
URL:
http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java?rev=398507&r1=398506&r2=398507&view=diff
==============================================================================
---
maven/surefire/branches/surefire-testng/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java
(original)
+++
maven/surefire/branches/surefire-testng/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java
Sun Apr 30 20:11:41 2006
@@ -16,6 +16,7 @@
* limitations under the License.
*/
+import org.apache.maven.surefire.util.PrettyPrintXMLWriter;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;
@@ -121,7 +122,7 @@
try
{
- Xpp3DomWriter.write( writer, testSuite );
+ Xpp3DomWriter.write( new PrettyPrintXMLWriter( writer ), testSuite
);
}
finally
{
Added:
maven/surefire/branches/surefire-testng/surefire-api/src/main/java/org/apache/maven/surefire/util/PrettyPrintXMLWriter.java
URL:
http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire-api/src/main/java/org/apache/maven/surefire/util/PrettyPrintXMLWriter.java?rev=398507&view=auto
==============================================================================
---
maven/surefire/branches/surefire-testng/surefire-api/src/main/java/org/apache/maven/surefire/util/PrettyPrintXMLWriter.java
(added)
+++
maven/surefire/branches/surefire-testng/surefire-api/src/main/java/org/apache/maven/surefire/util/PrettyPrintXMLWriter.java
Sun Apr 30 20:11:41 2006
@@ -0,0 +1,250 @@
+package org.apache.maven.surefire.util;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.xml.XMLWriter;
+
+import java.io.PrintWriter;
+import java.io.Writer;
+import java.util.LinkedList;
+
+public class PrettyPrintXMLWriter
+ implements XMLWriter
+{
+ private PrintWriter writer;
+
+ private LinkedList elementStack = new LinkedList();
+
+ private boolean tagInProgress;
+
+ private int depth;
+
+ private String lineIndenter;
+
+ private String encoding;
+
+ private String docType;
+
+ private boolean readyForNewLine;
+
+ private boolean tagIsEmpty;
+
+ public PrettyPrintXMLWriter( PrintWriter writer, String lineIndenter )
+ {
+ this( writer, lineIndenter, null, null );
+ }
+
+ public PrettyPrintXMLWriter( Writer writer, String lineIndenter )
+ {
+ this( new PrintWriter( writer ), lineIndenter );
+ }
+
+ public PrettyPrintXMLWriter( PrintWriter writer )
+ {
+ this( writer, null, null );
+ }
+
+ public PrettyPrintXMLWriter( Writer writer )
+ {
+ this( new PrintWriter( writer ) );
+ }
+
+ public PrettyPrintXMLWriter( PrintWriter writer, String lineIndenter,
String encoding, String doctype )
+ {
+ this.writer = writer;
+
+ this.lineIndenter = lineIndenter;
+
+ this.encoding = encoding;
+
+ this.docType = doctype;
+
+ if ( docType != null || encoding != null )
+ {
+ writeDocumentHeaders();
+ }
+ }
+
+ public PrettyPrintXMLWriter( Writer writer, String lineIndenter, String
encoding, String doctype )
+ {
+ this( new PrintWriter( writer ), lineIndenter, encoding, doctype );
+ }
+
+ public PrettyPrintXMLWriter( PrintWriter writer, String encoding, String
doctype )
+ {
+ this( writer, " ", encoding, doctype );
+ }
+
+ public PrettyPrintXMLWriter( Writer writer, String encoding, String
doctype )
+ {
+ this( new PrintWriter( writer ), encoding, doctype );
+ }
+
+ public void startElement( String name )
+ {
+ tagIsEmpty = false;
+
+ finishTag();
+
+ write( "<" );
+
+ write( name );
+
+ elementStack.addLast( name );
+
+ tagInProgress = true;
+
+ depth++;
+
+ readyForNewLine = true;
+
+ tagIsEmpty = true;
+ }
+
+ public void writeText( String text )
+ {
+ writeText( text, true );
+ }
+
+ public void writeMarkup( String text )
+ {
+ writeText( text, false );
+ }
+
+ private void writeText( String text, boolean escapeXml )
+ {
+ readyForNewLine = false;
+
+ tagIsEmpty = false;
+
+ finishTag();
+
+ if ( escapeXml )
+ {
+ text = escapeXml( text );
+ }
+
+ write( text );
+ }
+
+ private static String escapeXml( String text )
+ {
+ text = StringUtils.replace( text, "&", "&" );
+ text = StringUtils.replace( text, "<", "&" );
+ text = StringUtils.replace( text, ">", "&" );
+ text = StringUtils.replace( text, "\"", """ );
+ text = StringUtils.replace( text, "\'", "'" );
+
+ return text;
+ }
+
+ public void addAttribute( String key, String value )
+ {
+ write( " " );
+
+ write( key );
+
+ write( "=\"" );
+
+ write( escapeXml( value ) );
+
+ write( "\"" );
+ }
+
+ public void endElement()
+ {
+ depth--;
+
+ if ( tagIsEmpty )
+ {
+ write( "/" );
+
+ readyForNewLine = false;
+
+ finishTag();
+
+ elementStack.removeLast();
+ }
+ else
+ {
+ finishTag();
+
+ write( "</" + elementStack.removeLast() + ">" );
+ }
+
+ readyForNewLine = true;
+ }
+
+ private void write( String str )
+ {
+ writer.write( str );
+ }
+
+ private void finishTag()
+ {
+ if ( tagInProgress )
+ {
+ write( ">" );
+ }
+
+ tagInProgress = false;
+
+ if ( readyForNewLine )
+ {
+ endOfLine();
+ }
+ readyForNewLine = false;
+
+ tagIsEmpty = false;
+ }
+
+ protected void endOfLine()
+ {
+ write( "\n" );
+
+ for ( int i = 0; i < depth; i++ )
+ {
+ write( lineIndenter );
+ }
+ }
+
+ private void writeDocumentHeaders()
+ {
+ write( "<?xml version=\"1.0\"" );
+
+ if ( encoding != null )
+ {
+ write( " encoding=\"" + encoding + "\"" );
+ }
+
+ write( "?>" );
+
+ endOfLine();
+
+ if ( docType != null )
+ {
+ write( "<!DOCTYPE " );
+
+ write( docType );
+
+ write( ">" );
+
+ endOfLine();
+ }
+ }
+}
Propchange:
maven/surefire/branches/surefire-testng/surefire-api/src/main/java/org/apache/maven/surefire/util/PrettyPrintXMLWriter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/surefire/branches/surefire-testng/surefire-api/src/main/java/org/apache/maven/surefire/util/PrettyPrintXMLWriter.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified:
maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java
URL:
http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java?rev=398507&r1=398506&r2=398507&view=diff
==============================================================================
---
maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java
(original)
+++
maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java
Sun Apr 30 20:11:41 2006
@@ -18,6 +18,7 @@
import org.apache.maven.surefire.Surefire;
import org.apache.maven.surefire.testset.TestSetFailedException;
+import org.apache.maven.surefire.util.NestedRuntimeException;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.cli.CommandLineException;
@@ -68,18 +69,18 @@
private static final int TESTS_FAILED_EXIT_CODE = 255;
- private static boolean assertionsAvailable;
+ private static Method assertionStatusMethod;
static
{
try
{
- ClassLoader.class.getMethod( "setDefaultAssertionStatus", new
Class[]{boolean.class} );
- assertionsAvailable = true;
+ assertionStatusMethod =
+ ClassLoader.class.getMethod( "setDefaultAssertionStatus", new
Class[]{boolean.class} );
}
catch ( NoSuchMethodException e )
{
- assertionsAvailable = false;
+ assertionStatusMethod = null;
}
}
@@ -532,10 +533,22 @@
}
IsolatedClassLoader classLoader = new IsolatedClassLoader( parent,
childDelegation );
- if ( assertionsAvailable )
+ if ( assertionStatusMethod != null )
{
- parent.setDefaultAssertionStatus( assertionsEnabled );
- classLoader.setDefaultAssertionStatus( assertionsEnabled );
+ try
+ {
+ Object[] args = new Object[]{assertionsEnabled ? Boolean.TRUE
: Boolean.FALSE};
+ assertionStatusMethod.invoke( parent, args );
+ assertionStatusMethod.invoke( classLoader, args );
+ }
+ catch ( IllegalAccessException e )
+ {
+ throw new NestedRuntimeException( "Unable to access the
assertion enablement method", e );
+ }
+ catch ( InvocationTargetException e )
+ {
+ throw new NestedRuntimeException( "Unable to invoke the
assertion enablement method", e );
+ }
}
for ( Iterator iter = urls.iterator(); iter.hasNext(); )
{
Modified:
maven/surefire/branches/surefire-testng/surefire-providers/surefire-testng/pom.xml
URL:
http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire-providers/surefire-testng/pom.xml?rev=398507&r1=398506&r2=398507&view=diff
==============================================================================
---
maven/surefire/branches/surefire-testng/surefire-providers/surefire-testng/pom.xml
(original)
+++
maven/surefire/branches/surefire-testng/surefire-providers/surefire-testng/pom.xml
Sun Apr 30 20:11:41 2006
@@ -53,6 +53,27 @@
</dependency>
</dependencies>
</profile>
+ <profile>
+ <id>jdk1.3</id>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <fork>false</fork>
+ <compilerVersion>1.4</compilerVersion>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <forkMode>once</forkMode>
+ <jvm>${JAVA_1_3_HOME}/bin/java</jvm>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
<build>
<plugins>
@@ -61,7 +82,6 @@
<configuration>
<source>1.4</source>
<target>1.4</target>
- <fork>false</fork>
</configuration>
</plugin>
<plugin>