[SUREFIRE] refactoring with NotifiableTestStream

Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/df7e6f3d
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/df7e6f3d
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/df7e6f3d

Branch: refs/heads/master
Commit: df7e6f3da7b3ca6924e4a5a8def3ad0df6d012b3
Parents: 4b35269
Author: Tibor17 <tibo...@lycos.com>
Authored: Mon Jul 13 21:38:17 2015 +0200
Committer: Tibor17 <tibo...@lycos.com>
Committed: Thu Jul 23 23:28:06 2015 +0200

----------------------------------------------------------------------
 .../lazytestprovider/NotifiableTestStream.java  | 32 ++++++++++++++++++++
 .../TestProvidingInputStream.java               |  1 +
 .../booterclient/output/ForkClient.java         | 11 ++++---
 3 files changed, 39 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/df7e6f3d/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/NotifiableTestStream.java
----------------------------------------------------------------------
diff --git 
a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/NotifiableTestStream.java
 
b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/NotifiableTestStream.java
new file mode 100644
index 0000000..47aa642
--- /dev/null
+++ 
b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/NotifiableTestStream.java
@@ -0,0 +1,32 @@
+package org.apache.maven.plugin.surefire.booterclient.lazytestprovider;
+
+/*
+ * 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.
+ */
+
+/**
+ * Forked jvm notifies master process to provide a new test.
+ *
+ * @author <a href="mailto:tibordig...@apache.org";>Tibor Digana (tibor17)</a>
+ * @since 2.19
+ * @see TestProvidingInputStream
+ */
+public interface NotifiableTestStream
+{
+    void provideNewTest();
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/df7e6f3d/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
----------------------------------------------------------------------
diff --git 
a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
 
b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
index 9f40bf7..0001817 100644
--- 
a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
+++ 
b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
@@ -41,6 +41,7 @@ import static 
org.apache.maven.surefire.util.internal.StringUtils.encodeStringFo
  */
 public class TestProvidingInputStream
     extends InputStream
+    implements NotifiableTestStream
 {
     private final ReentrantLock lock = new ReentrantLock();
 

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/df7e6f3d/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 8e12e04..529cf1c 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
@@ -29,6 +29,7 @@ import java.util.Properties;
 import java.util.StringTokenizer;
 import java.util.concurrent.ConcurrentHashMap;
 
+import 
org.apache.maven.plugin.surefire.booterclient.lazytestprovider.NotifiableTestStream;
 import 
org.apache.maven.plugin.surefire.booterclient.lazytestprovider.TestProvidingInputStream;
 import org.apache.maven.plugin.surefire.report.DefaultReporterFactory;
 import org.apache.maven.shared.utils.cli.StreamConsumer;
@@ -52,7 +53,7 @@ public class ForkClient
 {
     private final DefaultReporterFactory defaultReporterFactory;
 
-    private final TestProvidingInputStream testProvidingInputStream;
+    private final NotifiableTestStream notifiableTestStream;
 
     private final Map<Integer, RunListener> testSetReporters = new 
ConcurrentHashMap<Integer, RunListener>();
 
@@ -68,11 +69,11 @@ public class ForkClient
     }
 
     public ForkClient( DefaultReporterFactory defaultReporterFactory, 
Properties testVmSystemProperties,
-                       TestProvidingInputStream testProvidingInputStream )
+                       TestProvidingInputStream notifiableTestStream )
     {
         this.defaultReporterFactory = defaultReporterFactory;
         this.testVmSystemProperties = testVmSystemProperties;
-        this.testProvidingInputStream = testProvidingInputStream;
+        this.notifiableTestStream = notifiableTestStream;
     }
 
     public DefaultReporterFactory getDefaultReporterFactory()
@@ -151,9 +152,9 @@ public class ForkClient
                     getOrCreateConsoleLogger( channelNumber ).info( 
createConsoleMessage( remaining ) );
                     break;
                 case ForkingRunListener.BOOTERCODE_NEXT_TEST:
-                    if ( null != testProvidingInputStream )
+                    if ( notifiableTestStream != null )
                     {
-                        testProvidingInputStream.provideNewTest();
+                        notifiableTestStream.provideNewTest();
                     }
                     break;
                 case ForkingRunListener.BOOTERCODE_ERROR:

Reply via email to