You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2017/04/02 11:26:45 UTC
[1/2] maven-surefire git commit: re-introduce jacoco.agent in
surefire-junit47
Repository: maven-surefire
Updated Branches:
refs/heads/master 9c417780b -> c944f2634
re-introduce jacoco.agent in surefire-junit47
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/a72ceddd
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/a72ceddd
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/a72ceddd
Branch: refs/heads/master
Commit: a72cedddc28ce97e9134271934887667390f0654
Parents: 9c41778
Author: Tibor17 <ti...@lycos.com>
Authored: Sun Apr 2 12:06:13 2017 +0200
Committer: Tibor17 <ti...@lycos.com>
Committed: Sun Apr 2 12:06:13 2017 +0200
----------------------------------------------------------------------
pom.xml | 2 +-
surefire-providers/surefire-junit47/pom.xml | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/a72ceddd/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 41e5a5a..1a9ba58 100644
--- a/pom.xml
+++ b/pom.xml
@@ -302,7 +302,7 @@
<configuration>
<!-- NOTE: Be sure to isolate the Surefire version under test from the version running the tests! -->
<useSystemClassLoader>false</useSystemClassLoader>
- <argLine>${jacoco.agent}</argLine>
+ <argLine>-Xms128m -Xmx128m ${jacoco.agent}</argLine>
</configuration>
</plugin>
<plugin>
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/a72ceddd/surefire-providers/surefire-junit47/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/pom.xml b/surefire-providers/surefire-junit47/pom.xml
index 91dc0c1..919c525 100644
--- a/surefire-providers/surefire-junit47/pom.xml
+++ b/surefire-providers/surefire-junit47/pom.xml
@@ -128,7 +128,6 @@
<includes>
<include>**/JUnit47SuiteTest.java</include>
</includes>
- <argLine>-Xms256m -Xmx256m</argLine>
</configuration>
</plugin>
<plugin>
[2/2] maven-surefire git commit: [SUREFIRE-1317] Refactoring
Posted by ti...@apache.org.
[SUREFIRE-1317] Refactoring
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/c944f263
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/c944f263
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/c944f263
Branch: refs/heads/master
Commit: c944f26340e2d8873008dbaaf67d9188b39cee11
Parents: a72cedd
Author: Tibor17 <ti...@lycos.com>
Authored: Sun Apr 2 13:26:23 2017 +0200
Committer: Tibor17 <ti...@lycos.com>
Committed: Sun Apr 2 13:26:23 2017 +0200
----------------------------------------------------------------------
maven-surefire-common/pom.xml | 4 +-
.../plugin/surefire/AbstractSurefireMojo.java | 3 +-
.../booterclient/ForkConfiguration.java | 45 ++++---
.../output/DeserializedStacktraceWriter.java | 2 +-
.../booterclient/output/ForkClient.java | 2 +
.../surefire/report/StatelessXmlReporter.java | 7 +-
.../plugin/surefire/util/ImmutableMap.java | 133 +++++++++++++++++++
.../maven/plugin/surefire/util/Relocator.java | 7 +-
.../plugin/surefire/util/ImmutableMapTest.java | 86 ++++++++++++
.../apache/maven/surefire/JUnit4SuiteTest.java | 4 +-
.../maven/plugins/surefire/report/Utils.java | 1 +
pom.xml | 12 ++
.../src/main/appended-resources/META-INF/NOTICE | 3 -
.../surefire/booter/ForkingRunListener.java | 4 +-
.../surefire/booter/MasterProcessCommand.java | 8 +-
.../surefire/report/CategorizedReportEntry.java | 17 +--
.../report/LegacyPojoStackTraceWriter.java | 2 +-
.../maven/surefire/report/SafeThrowable.java | 5 +
.../surefire/util/internal/StringUtils.java | 43 +++---
.../maven/surefire/booter/ForkedBooter.java | 3 +-
.../surefire/report/PojoStackTraceWriter.java | 4 +-
.../testng/conf/AbstractDirectConfigurator.java | 2 +-
.../testng/conf/TestNG513Configurator.java | 2 +-
23 files changed, 317 insertions(+), 82 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/c944f263/maven-surefire-common/pom.xml
----------------------------------------------------------------------
diff --git a/maven-surefire-common/pom.xml b/maven-surefire-common/pom.xml
index 54825b7..6e8ac70 100644
--- a/maven-surefire-common/pom.xml
+++ b/maven-surefire-common/pom.xml
@@ -113,8 +113,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <version>1.8.4</version>
+ <artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
@@ -141,6 +140,7 @@
</executions>
</plugin>
<plugin>
+ <!-- Remove in 3.0 -->
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/c944f263/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
index 4f7744f..8a9780c 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
@@ -234,6 +234,7 @@ public abstract class AbstractSurefireMojo
* unless overridden.
*/
@Parameter
+ // TODO use regex for fully qualified class names in 3.0 and change the filtering abilities
private List<String> excludes;
/**
@@ -2173,7 +2174,7 @@ public abstract class AbstractSurefireMojo
@SuppressWarnings( "unchecked" ) Set<Artifact> classpathArtifacts = getProject().getArtifacts();
- if ( getClasspathDependencyScopeExclude() != null && !getClasspathDependencyScopeExclude().equals( "" ) )
+ if ( getClasspathDependencyScopeExclude() != null && !getClasspathDependencyScopeExclude().isEmpty() )
{
ArtifactFilter dependencyFilter = new ScopeArtifactFilter( getClasspathDependencyScopeExclude() );
classpathArtifacts = this.filterArtifacts( classpathArtifacts, dependencyFilter );
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/c944f263/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
index 52bc928..7f2c536 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
@@ -21,6 +21,7 @@ package org.apache.maven.plugin.surefire.booterclient;
import org.apache.maven.plugin.surefire.AbstractSurefireMojo;
import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.OutputStreamFlushableCommandline;
+import org.apache.maven.plugin.surefire.util.ImmutableMap;
import org.apache.maven.plugin.surefire.util.Relocator;
import org.apache.maven.shared.utils.StringUtils;
import org.apache.maven.surefire.booter.Classpath;
@@ -31,7 +32,7 @@ import org.apache.maven.surefire.booter.SurefireBooterForkException;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.util.Enumeration;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -64,7 +65,7 @@ public class ForkConfiguration
private final String jvmExecutable;
- private Properties modelProperties;
+ private final Properties modelProperties;
private final String argLine;
@@ -91,7 +92,7 @@ public class ForkConfiguration
this.workingDirectory = workingDirectory;
this.modelProperties = modelProperties;
this.argLine = argLine;
- this.environmentVariables = environmentVariables;
+ this.environmentVariables = toImmutable( environmentVariables );
this.debug = debugEnabled;
this.forkCount = forkCount;
this.reuseForks = reuseForks;
@@ -158,16 +159,13 @@ public class ForkConfiguration
threadNumber ) );
}
- if ( environmentVariables != null )
+ for ( Map.Entry<String, String> entry : environmentVariables.entrySet() )
{
- for ( Map.Entry<String, String> entry : environmentVariables.entrySet() )
- {
- String value = entry.getValue();
- cli.addEnvironment( entry.getKey(), value == null ? "" : value );
- }
+ String value = entry.getValue();
+ cli.addEnvironment( entry.getKey(), value == null ? "" : value );
}
- if ( getDebugLine() != null && !"".equals( getDebugLine() ) )
+ if ( getDebugLine() != null && !getDebugLine().isEmpty() )
{
cli.createArg().setLine( getDebugLine() );
}
@@ -240,9 +238,8 @@ public class ForkConfiguration
return null;
}
- for ( Enumeration<?> e = modelProperties.propertyNames(); e.hasMoreElements(); )
+ for ( final String key : modelProperties.stringPropertyNames() )
{
- String key = e.nextElement().toString();
String field = "@{" + key + "}";
if ( argLine.contains( field ) )
{
@@ -314,11 +311,6 @@ public class ForkConfiguration
return debug;
}
- public String stripNewLines( String argline )
- {
- return argline.replace( "\n", " " ).replace( "\r", " " );
- }
-
public String getDebugLine()
{
return debugLine;
@@ -334,9 +326,26 @@ public class ForkConfiguration
return forkCount;
}
-
public boolean isReuseForks()
{
return reuseForks;
}
+
+ private static String stripNewLines( String argLine )
+ {
+ return argLine.replace( "\n", " " ).replace( "\r", " " );
+ }
+
+ /**
+ * Immutable map.
+ *
+ * @param map immutable map copies elements from <code>map</code>
+ * @param <K> key type
+ * @param <V> value type
+ * @return never returns null
+ */
+ private static <K, V> Map<K, V> toImmutable( Map<K, V> map )
+ {
+ return map == null ? Collections.<K, V>emptyMap() : new ImmutableMap<K, V>( map );
+ }
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/c944f263/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java
index 8832a36..952feb8 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java
@@ -64,6 +64,6 @@ public class DeserializedStacktraceWriter
public SafeThrowable getThrowable()
{
- return new SafeThrowable( new Throwable( message ) );
+ return new SafeThrowable( message );
}
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/c944f263/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
index faace0f..32fcea4 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
@@ -67,6 +67,8 @@ import static org.apache.maven.surefire.util.internal.StringUtils.isNotBlank;
import static org.apache.maven.surefire.util.internal.StringUtils.unescapeBytes;
import static org.apache.maven.surefire.util.internal.StringUtils.unescapeString;
+// todo move to the same package with ForkStarter
+
/**
* Knows how to reconstruct *all* the state transmitted over stdout by the forked process.
*
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/c944f263/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
index 8ebeb96..397c4c1 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
@@ -36,7 +36,6 @@ import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Enumeration;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -469,12 +468,8 @@ public class StatelessXmlReporter
if ( systemProperties != null )
{
- Enumeration<?> propertyKeys = systemProperties.propertyNames();
-
- while ( propertyKeys.hasMoreElements() )
+ for ( final String key : systemProperties.stringPropertyNames() )
{
- String key = (String) propertyKeys.nextElement();
-
String value = systemProperties.getProperty( key );
if ( value == null )
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/c944f263/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/ImmutableMap.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/ImmutableMap.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/ImmutableMap.java
new file mode 100644
index 0000000..576194d
--- /dev/null
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/ImmutableMap.java
@@ -0,0 +1,133 @@
+package org.apache.maven.plugin.surefire.util;
+
+/*
+ * 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.
+ */
+
+import java.util.AbstractMap;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Copies input map in {@link #ImmutableMap(Map) constructor}, and Entries are linked and thread-safe.
+ * The map is immutable.
+ *
+ * @param <K> key
+ * @param <V> value
+ * @since 2.20
+ */
+public final class ImmutableMap<K, V>
+ extends AbstractMap<K, V>
+{
+ private final Node<K, V> first;
+
+ public ImmutableMap( Map<K, V> map )
+ {
+ Node<K, V> first = null;
+ Node<K, V> previous = null;
+ for ( Entry<K, V> e : map.entrySet() )
+ {
+ Node<K, V> node = new Node<K, V>( e.getKey(), e.getValue() );
+ if ( first == null )
+ {
+ first = node;
+ }
+ else
+ {
+ previous.next = node;
+ }
+ previous = node;
+ }
+ this.first = first;
+ }
+
+ @Override
+ public Set<Entry<K, V>> entrySet()
+ {
+ Set<Entry<K, V>> entries = new LinkedHashSet<Entry<K, V>>();
+ Node<K, V> node = first;
+ while ( node != null )
+ {
+ entries.add( node );
+ node = node.next;
+ }
+ return Collections.<Entry<K, V>>unmodifiableSet( entries );
+ }
+
+ static final class Node<K, V>
+ implements Entry<K, V>
+ {
+ final K key;
+ final V value;
+ volatile Node<K, V> next;
+
+ Node( K key, V value )
+ {
+ this.key = key;
+ this.value = value;
+ }
+
+ @Override
+ public K getKey()
+ {
+ return key;
+ }
+
+ @Override
+ public V getValue()
+ {
+ return value;
+ }
+
+ @Override
+ public V setValue( V value )
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean equals( Object o )
+ {
+ if ( this == o )
+ {
+ return true;
+ }
+
+ if ( o == null || getClass() != o.getClass() )
+ {
+ return false;
+ }
+
+ Node<?, ?> node = (Node<?, ?>) o;
+
+ return getKey() != null ? getKey().equals( node.getKey() ) : node.getKey() == null
+ && getValue() != null ? getValue().equals( node.getValue() ) : node.getValue() == null;
+
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = getKey() != null ? getKey().hashCode() : 0;
+ result = 31 * result + ( getValue() != null ? getValue().hashCode() : 0 );
+ return result;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/c944f263/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/Relocator.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/Relocator.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/Relocator.java
index 89117af..2237698 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/Relocator.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/Relocator.java
@@ -30,11 +30,10 @@ import javax.annotation.Nullable;
*/
public class Relocator
{
- @Nullable
- private final String relocation;
-
private static final String RELOCATION_BASE = "org.apache.maven.surefire.";
+ @Nullable
+ private final String relocation;
public Relocator( @Nullable String relocation )
{
@@ -61,7 +60,7 @@ public class Relocator
{
return className;
}
- String rest = className.substring( "org.apache.maven.surefire.".length() );
+ String rest = className.substring( RELOCATION_BASE.length() );
final String s = RELOCATION_BASE + getRelocation() + ".";
return s + rest;
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/c944f263/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/util/ImmutableMapTest.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/util/ImmutableMapTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/util/ImmutableMapTest.java
new file mode 100644
index 0000000..8fcf2bb
--- /dev/null
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/util/ImmutableMapTest.java
@@ -0,0 +1,86 @@
+package org.apache.maven.plugin.surefire.util;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.plugin.surefire.util.ImmutableMap.Node;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * @since 2.20
+ */
+public class ImmutableMapTest
+{
+ private ImmutableMap<String, String> map;
+
+ @Before
+ public void setUp() throws Exception
+ {
+ Map<String, String> backingMap = new HashMap<String, String>();
+ backingMap.put( "a", "1" );
+ backingMap.put( "x", null );
+ backingMap.put( "b", "2" );
+ backingMap.put( "c", "3" );
+ backingMap.put( "", "" );
+ backingMap.put( null, "1" );
+ map = new ImmutableMap<String, String>( backingMap );
+ }
+
+ @Test
+ public void testEntrySet() throws Exception
+ {
+ Set<Entry<String, String>> entries = map.entrySet();
+ assertThat( entries, hasSize( 6 ) );
+ assertThat( entries, hasItem( new Node<String, String>( "a", "1" ) ) );
+ assertThat( entries, hasItem( new Node<String, String>( "x", null ) ) );
+ assertThat( entries, hasItem( new Node<String, String>( "b", "2" ) ) );
+ assertThat( entries, hasItem( new Node<String, String>( "c", "3" ) ) );
+ assertThat( entries, hasItem( new Node<String, String>( "", "" ) ) );
+ assertThat( entries, hasItem( new Node<String, String>( null, "1" ) ) );
+ }
+
+ @Test
+ public void testGetter()
+ {
+ assertThat( map.size(), is( 6 ) );
+ assertThat( map.get( "a" ), is( "1" ) );
+ assertThat( map.get( "x" ), is( (String) null ) );
+ assertThat( map.get( "b" ), is( "2" ) );
+ assertThat( map.get( "c" ), is( "3" ) );
+ assertThat( map.get( "" ), is( "" ) );
+ assertThat( map.get( null ), is( "1" ) );
+ }
+
+ @Test( expected = UnsupportedOperationException.class )
+ public void shouldNotModifyEntries()
+ {
+ map.entrySet().clear();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/c944f263/maven-surefire-common/src/test/java/org/apache/maven/surefire/JUnit4SuiteTest.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/surefire/JUnit4SuiteTest.java b/maven-surefire-common/src/test/java/org/apache/maven/surefire/JUnit4SuiteTest.java
index d03f1b9..4309ad3 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/surefire/JUnit4SuiteTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/surefire/JUnit4SuiteTest.java
@@ -35,6 +35,7 @@ import org.apache.maven.plugin.surefire.report.WrappedReportEntryTest;
import org.apache.maven.plugin.surefire.runorder.RunEntryStatisticsMapTest;
import org.apache.maven.plugin.surefire.util.DependenciesScannerTest;
import org.apache.maven.plugin.surefire.util.DirectoryScannerTest;
+import org.apache.maven.plugin.surefire.util.ImmutableMapTest;
import org.apache.maven.plugin.surefire.util.SpecificFileFilterTest;
import org.apache.maven.surefire.report.ConsoleOutputFileReporterTest;
import org.apache.maven.surefire.report.FileReporterTest;
@@ -70,7 +71,8 @@ import org.junit.runners.Suite;
TestProvidingInputStreamTest.class,
TestLessInputStreamBuilderTest.class,
SPITest.class,
- SurefireReflectorTest.class
+ SurefireReflectorTest.class,
+ ImmutableMapTest.class
} )
@RunWith( Suite.class )
public class JUnit4SuiteTest
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/c944f263/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/Utils.java
----------------------------------------------------------------------
diff --git a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/Utils.java b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/Utils.java
index 8fd91bf..d2cb04e 100644
--- a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/Utils.java
+++ b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/Utils.java
@@ -23,6 +23,7 @@ public final class Utils
{
private Utils()
{
+ throw new IllegalStateException( "no instantiable constructor" );
}
public static String toSystemNewLine( String s )
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/c944f263/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 1a9ba58..02f9b80 100644
--- a/pom.xml
+++ b/pom.xml
@@ -226,6 +226,12 @@
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.10.19</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-core</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
@@ -255,6 +261,12 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-core</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/c944f263/surefire-api/src/main/appended-resources/META-INF/NOTICE
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/appended-resources/META-INF/NOTICE b/surefire-api/src/main/appended-resources/META-INF/NOTICE
deleted file mode 100644
index 9d9184d..0000000
--- a/surefire-api/src/main/appended-resources/META-INF/NOTICE
+++ /dev/null
@@ -1,3 +0,0 @@
-
-This product includes software developed by the Spring Framework
-Project (http://www.springframework.org).
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/c944f263/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
index 7856dac..6c0842a 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
@@ -20,7 +20,6 @@ package org.apache.maven.surefire.booter;
*/
import java.io.PrintStream;
-import java.util.Enumeration;
import java.util.Properties;
import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
@@ -183,9 +182,8 @@ public class ForkingRunListener
if ( systemProperties != null )
{
- for ( Enumeration<?> propertyKeys = systemProperties.propertyNames(); propertyKeys.hasMoreElements(); )
+ for ( final String key : systemProperties.stringPropertyNames() )
{
- String key = (String) propertyKeys.nextElement();
String value = systemProperties.getProperty( key );
encodeAndWriteToTarget( toPropertyString( key, value == null ? "null" : value ) );
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/c944f263/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
index 229c8af..f985d26 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
@@ -19,8 +19,6 @@ package org.apache.maven.surefire.booter;
* under the License.
*/
-import org.apache.maven.surefire.util.internal.StringUtils;
-
import java.io.DataInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
@@ -49,7 +47,7 @@ public enum MasterProcessCommand
NOOP( 4, Void.class ),
BYE_ACK( 5, Void.class );
- private static final Charset ASCII = Charset.forName( "ASCII" );
+ private static final Charset ASCII = Charset.forName( "US-ASCII" );
private final int id;
@@ -152,7 +150,7 @@ public enum MasterProcessCommand
case RUN_CLASS:
return new String( data, FORK_STREAM_CHARSET_NAME );
case SHUTDOWN:
- return StringUtils.decode( data, ASCII );
+ return new String( data, ASCII );
default:
return null;
}
@@ -170,7 +168,7 @@ public enum MasterProcessCommand
case RUN_CLASS:
return encodeStringForForkCommunication( data );
case SHUTDOWN:
- return StringUtils.encode( data, ASCII );
+ return data.getBytes( ASCII );
default:
return new byte[0];
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/c944f263/surefire-api/src/main/java/org/apache/maven/surefire/report/CategorizedReportEntry.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/report/CategorizedReportEntry.java b/surefire-api/src/main/java/org/apache/maven/surefire/report/CategorizedReportEntry.java
index 77cfaf3..0cccd6e 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/report/CategorizedReportEntry.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/report/CategorizedReportEntry.java
@@ -67,17 +67,7 @@ public class CategorizedReportEntry
@Override
public String getNameWithGroup()
{
- StringBuilder result = new StringBuilder();
- result.append( getName() );
-
- if ( getGroup() != null && !getName().equals( getGroup() ) )
- {
- result.append( GROUP_PREFIX );
- result.append( getGroup() );
- result.append( GROUP_SUFIX );
- }
-
- return result.toString();
+ return isNameWithGroup() ? getName() + GROUP_PREFIX + getGroup() + GROUP_SUFIX : getName();
}
public boolean equals( Object o )
@@ -107,4 +97,9 @@ public class CategorizedReportEntry
result = 31 * result + ( group != null ? group.hashCode() : 0 );
return result;
}
+
+ private boolean isNameWithGroup()
+ {
+ return getGroup() != null && !getGroup().equals( getName() );
+ }
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/c944f263/surefire-api/src/main/java/org/apache/maven/surefire/report/LegacyPojoStackTraceWriter.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/report/LegacyPojoStackTraceWriter.java b/surefire-api/src/main/java/org/apache/maven/surefire/report/LegacyPojoStackTraceWriter.java
index 6ff45de..d1e1890 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/report/LegacyPojoStackTraceWriter.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/report/LegacyPojoStackTraceWriter.java
@@ -69,7 +69,7 @@ public class LegacyPojoStackTraceWriter
{
// SUREFIRE-986
String exc = t.getClass().getName() + ": ";
- if ( builder.toString().startsWith( exc ) )
+ if ( StringUtils.startsWith( builder, exc ) )
{
builder.insert( exc.length(), '\n' );
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/c944f263/surefire-api/src/main/java/org/apache/maven/surefire/report/SafeThrowable.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/report/SafeThrowable.java b/surefire-api/src/main/java/org/apache/maven/surefire/report/SafeThrowable.java
index 60c7897..b3b86f2 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/report/SafeThrowable.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/report/SafeThrowable.java
@@ -31,6 +31,11 @@ public class SafeThrowable
this.target = target;
}
+ public SafeThrowable( String message )
+ {
+ this( new Throwable( message ) );
+ }
+
public String getLocalizedMessage()
{
try
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/c944f263/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
index 830cace..d1838b2 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
@@ -345,41 +345,40 @@ public final class StringUtils
return ByteBuffer.wrap( out, 0, outPos );
}
- public static String decode( byte[] toDecode, Charset charset )
- {
- try
- {
- // @todo use new JDK 1.6 constructor String(byte bytes[], Charset charset)
- return new String( toDecode, charset.name() );
- }
- catch ( UnsupportedEncodingException e )
- {
- throw new RuntimeException( "The JVM must support Charset " + charset, e );
- }
- }
-
- public static byte[] encode( String toEncode, Charset charset )
+ public static byte[] encodeStringForForkCommunication( String string )
{
try
{
- // @todo use new JDK 1.6 method getBytes(Charset charset)
- return toEncode.getBytes( charset.name() );
+ return string.getBytes( FORK_STREAM_CHARSET_NAME );
}
catch ( UnsupportedEncodingException e )
{
- throw new RuntimeException( "The JVM must support Charset " + charset, e );
+ throw new RuntimeException( "The JVM must support Charset " + FORK_STREAM_CHARSET_NAME, e );
}
}
- public static byte[] encodeStringForForkCommunication( String string )
+ /**
+ *
+ * @param buffer Examined StringBuffer
+ * @param pattern a pattern which should start in <code>buffer</code>
+ * @return <tt>true</tt> if buffer's literal starts with given pattern
+ */
+ public static boolean startsWith( StringBuffer buffer, String pattern )
{
- try
+ if ( buffer.length() < pattern.length() )
{
- return string.getBytes( FORK_STREAM_CHARSET_NAME );
+ return false;
}
- catch ( UnsupportedEncodingException e )
+ else
{
- throw new RuntimeException( "The JVM must support Charset " + FORK_STREAM_CHARSET_NAME, e );
+ for ( int i = 0, len = pattern.length(); i < len; i++ )
+ {
+ if ( buffer.charAt( i ) != pattern.charAt( i ) )
+ {
+ return false;
+ }
+ }
+ return true;
}
}
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/c944f263/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
index 5401abf..4589088 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
@@ -239,6 +239,7 @@ public final class ForkedBooter
private static void encodeAndWriteToOutput( String string, PrintStream out )
{
byte[] encodeBytes = encodeStringForForkCommunication( string );
+ //noinspection SynchronizationOnLocalVariableOrMethodParameter
synchronized ( out )
{
out.write( encodeBytes, 0, encodeBytes.length );
@@ -352,7 +353,7 @@ public final class ForkedBooter
{
final PrintStream orgSystemOut = out;
final PrintStream orgSystemErr = err;
- // Note that System.out/System.err are also read in the "ReporterConfiguration" instatiation
+ // Note that System.out/System.err are also read in the "ReporterConfiguration" instantiation
// in createProvider below. These are the same values as here.
try
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/c944f263/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/PojoStackTraceWriter.java
----------------------------------------------------------------------
diff --git a/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/PojoStackTraceWriter.java b/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/PojoStackTraceWriter.java
index f8e4511..fdbc1be 100644
--- a/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/PojoStackTraceWriter.java
+++ b/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/PojoStackTraceWriter.java
@@ -20,6 +20,8 @@ package org.apache.maven.surefire.report;
*/
+import org.apache.maven.surefire.util.internal.StringUtils;
+
import java.io.PrintWriter;
import java.io.StringWriter;
@@ -64,7 +66,7 @@ public class PojoStackTraceWriter
{
// SUREFIRE-986
String exc = t.getClass().getName() + ": ";
- if ( builder.toString().startsWith( exc ) )
+ if ( StringUtils.startsWith( builder, exc ) )
{
builder.insert( exc.length(), '\n' );
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/c944f263/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/AbstractDirectConfigurator.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/AbstractDirectConfigurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/AbstractDirectConfigurator.java
index e89d061..a471f0d 100644
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/AbstractDirectConfigurator.java
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/AbstractDirectConfigurator.java
@@ -112,7 +112,7 @@ public abstract class AbstractDirectConfigurator
static List<Class> loadListenerClasses( String listenerClasses )
throws TestSetFailedException
{
- if ( listenerClasses == null || "".equals( listenerClasses.trim() ) )
+ if ( listenerClasses == null || listenerClasses.trim().isEmpty() )
{
return new ArrayList<Class>();
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/c944f263/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG513Configurator.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG513Configurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG513Configurator.java
index ce44dd4..b003789 100644
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG513Configurator.java
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG513Configurator.java
@@ -42,7 +42,7 @@ public class TestNG513Configurator
static String convertListenersString( String listenerClasses )
{
- if ( listenerClasses == null || "".equals( listenerClasses.trim() ) )
+ if ( listenerClasses == null || listenerClasses.trim().isEmpty() )
{
return listenerClasses;
}