You are viewing a plain text version of this content. The canonical link for it is here.
Posted to surefire-commits@maven.apache.org by kr...@apache.org on 2011/03/07 21:03:29 UTC
svn commit: r1078913 - in /maven/surefire/trunk:
surefire-api/src/main/java/org/apache/maven/surefire/report/
surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/
surefire-integration-tests/src/test/resources/surefire-697-niceSummary...
Author: krosenvold
Date: Mon Mar 7 20:03:28 2011
New Revision: 1078913
URL: http://svn.apache.org/viewvc?rev=1078913&view=rev
Log:
[SUREFIRE-697] Truncated exception summary messages to 1 line
With test.
Added:
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire697NiceSummaryIT.java (with props)
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-697-niceSummary/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-697-niceSummary/pom.xml (with props)
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-697-niceSummary/src/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-697-niceSummary/src/test/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-697-niceSummary/src/test/java/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-697-niceSummary/src/test/java/junit/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-697-niceSummary/src/test/java/junit/surefire697/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-697-niceSummary/src/test/java/junit/surefire697/BasicTest.java (with props)
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-697-niceSummary/src/test/java/junit/surefire697/TestTwo.java (with props)
Modified:
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/RunStatistics.java
Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/RunStatistics.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/RunStatistics.java?rev=1078913&r1=1078912&r2=1078913&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/RunStatistics.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/RunStatistics.java Mon Mar 7 20:03:28 2011
@@ -89,10 +89,15 @@ public class RunStatistics
void addSource( String source, StackTraceWriter stackTraceWriter )
{
String message = getMessageOfThrowable( stackTraceWriter );
- String extendedSource = StringUtils.isBlank( message ) ? source : source + ": " + message;
+ String extendedSource = StringUtils.isBlank( message ) ? source : source + ": " + trimToSingleLine(message);
addSource( extendedSource );
}
+ private String trimToSingleLine(String str){
+ int i = str.indexOf( "\n" );
+ return i >= 0 ? str.substring( 0, i ) : str;
+ }
+
Collection getListOfSources()
{
synchronized ( listOfSources )
Added: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire697NiceSummaryIT.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire697NiceSummaryIT.java?rev=1078913&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire697NiceSummaryIT.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire697NiceSummaryIT.java Mon Mar 7 20:03:28 2011
@@ -0,0 +1,44 @@
+package org.apache.maven.surefire.its;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+/**
+ * SUREFIRE-697 Asserts proper truncation of long exception messages
+ * Some say testing this is a bit over the top.
+ *
+ * @author Kristian Rosenvold
+ */
+public class Surefire697NiceSummaryIT
+ extends SurefireVerifierTestClass
+{
+ public Surefire697NiceSummaryIT()
+ {
+ super( "/surefire-697-niceSummary" );
+ }
+
+ public void testBuildFailingWhenErrors()
+ throws Exception
+ {
+ failNever( );
+ executeTest();
+ verifyTextInLog( "testShortMultiline(junit.surefire697.BasicTest): A very short multiline message" );
+ // Could assert that "Here is line 2" is not present too.
+ }
+}
Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire697NiceSummaryIT.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-697-niceSummary/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-697-niceSummary/pom.xml?rev=1078913&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-697-niceSummary/pom.xml (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-697-niceSummary/pom.xml Mon Mar 7 20:03:28 2011
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.plugins.surefire</groupId>
+ <artifactId>surefire-697-niceSummary</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <name>Tests summary with long/multiline exception messages</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${surefire.version}</version>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-697-niceSummary/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-697-niceSummary/src/test/java/junit/surefire697/BasicTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-697-niceSummary/src/test/java/junit/surefire697/BasicTest.java?rev=1078913&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-697-niceSummary/src/test/java/junit/surefire697/BasicTest.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-697-niceSummary/src/test/java/junit/surefire697/BasicTest.java Mon Mar 7 20:03:28 2011
@@ -0,0 +1,41 @@
+package junit.surefire697;
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class BasicTest
+ extends TestCase
+{
+
+ public void testShort(){
+ throw new RuntimeException( "A very short message" );
+ }
+
+ public void testShortMultiline(){
+ throw new RuntimeException( "A very short multiline message\nHere is line 2" );
+ }
+
+ public void testLong(){
+ throw new RuntimeException( "A very long single line message" +
+ "012345678900123456789001234567890012345678900123456789001234567890" +
+ "012345678900123456789001234567890012345678900123456789001234567890");
+ }
+ public void testLongMultiLineNoCr(){
+ throw new RuntimeException( "A very long multi line message" +
+ "012345678900123456789001234567890012345678900123456789001234567890" +
+ "012345678900123456789001234567890012345678900123456789001234567890\n"
+ + "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ + "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ );
+ }
+
+ public void testLongMultiLine(){
+ throw new RuntimeException( "A very long single line message" +
+ "012345678900123456789001234567890012345678900123456789001234567890" +
+ "012345678900123456789001234567890012345678900123456789001234567890\n"
+ + "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ + "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ\n"
+ );
+ }
+}
Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-697-niceSummary/src/test/java/junit/surefire697/BasicTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-697-niceSummary/src/test/java/junit/surefire697/TestTwo.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-697-niceSummary/src/test/java/junit/surefire697/TestTwo.java?rev=1078913&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-697-niceSummary/src/test/java/junit/surefire697/TestTwo.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-697-niceSummary/src/test/java/junit/surefire697/TestTwo.java Mon Mar 7 20:03:28 2011
@@ -0,0 +1,11 @@
+package junit.surefire697;
+import junit.framework.TestCase;
+
+
+public class TestTwo
+ extends TestCase
+{
+ public void testTwo() {
+
+ }
+}
Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-697-niceSummary/src/test/java/junit/surefire697/TestTwo.java
------------------------------------------------------------------------------
svn:eol-style = native