You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kr...@apache.org on 2012/11/17 11:24:59 UTC
[1/3] git commit: Added licence headers, javadoc,
did some minor renaming
Updated Branches:
refs/heads/master 0b27dc20a -> 05aa3a600
Added licence headers, javadoc, did some minor renaming
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/05aa3a60
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/05aa3a60
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/05aa3a60
Branch: refs/heads/master
Commit: 05aa3a60015883588f47f48a8bc92a05c1efb075
Parents: 9c6ce9b
Author: agudian <an...@gmail.com>
Authored: Fri Nov 16 23:09:52 2012 +0100
Committer: Kristian Rosenvold <kr...@apache.org>
Committed: Sat Nov 17 11:16:01 2012 +0100
----------------------------------------------------------------------
.../surefire/booterclient/ForkConfiguration.java | 8 +-
.../plugin/surefire/booterclient/ForkStarter.java | 4 +-
.../lazytestprovider/FlushReceiver.java | 30 ++++++
.../lazytestprovider/FlushReceiverProvider.java | 29 ++++++
.../OutputStreamFlushableCommandline.java | 73 +++++++++++++++
.../lazytestprovider/ProcessAwareCommandline.java | 41 --------
.../lazytestprovider/TestProvidingInputStream.java | 44 +++++++++
.../apache/maven/surefire/util/LazyTestsToRun.java | 37 +++++++-
8 files changed, 215 insertions(+), 51 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/05aa3a60/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 fef053a..66a11a1 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
@@ -29,7 +29,7 @@ import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
import org.apache.maven.plugin.surefire.AbstractSurefireMojo;
-import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.ProcessAwareCommandline;
+import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.OutputStreamFlushableCommandline;
import org.apache.maven.plugin.surefire.util.Relocator;
import org.apache.maven.shared.utils.StringUtils;
import org.apache.maven.shared.utils.cli.Commandline;
@@ -128,17 +128,17 @@ public class ForkConfiguration
* @throws org.apache.maven.surefire.booter.SurefireBooterForkException
* when unable to perform the fork
*/
- public ProcessAwareCommandline createCommandLine( List<String> classPath, ClassLoaderConfiguration classpathConfiguration,
+ public OutputStreamFlushableCommandline createCommandLine( List<String> classPath, ClassLoaderConfiguration classpathConfiguration,
boolean shadefire, int threadNumber )
throws SurefireBooterForkException
{
return createCommandLine( classPath, classpathConfiguration.isManifestOnlyJarRequestedAndUsable(), shadefire, threadNumber );
}
- public ProcessAwareCommandline createCommandLine( List<String> classPath, boolean useJar, boolean shadefire, int threadNumber )
+ public OutputStreamFlushableCommandline createCommandLine( List<String> classPath, boolean useJar, boolean shadefire, int threadNumber )
throws SurefireBooterForkException
{
- ProcessAwareCommandline cli = new ProcessAwareCommandline();
+ OutputStreamFlushableCommandline cli = new OutputStreamFlushableCommandline();
cli.setExecutable( jvmExecutable );
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/05aa3a60/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
index 6c135b3..19bfff3 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
@@ -40,7 +40,7 @@ import org.apache.maven.plugin.surefire.AbstractSurefireMojo;
import org.apache.maven.plugin.surefire.CommonReflector;
import org.apache.maven.plugin.surefire.StartupReportConfiguration;
import org.apache.maven.plugin.surefire.SurefireProperties;
-import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.ProcessAwareCommandline;
+import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.OutputStreamFlushableCommandline;
import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.TestProvidingInputStream;
import org.apache.maven.plugin.surefire.booterclient.output.ForkClient;
import org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer;
@@ -365,7 +365,7 @@ public class ForkStarter
// Surefire-booter if !useSystemClassLoader
Classpath bootClasspath = Classpath.join( bootClasspathConfiguration, additionlClassPathUrls );
- @SuppressWarnings( "unchecked" ) ProcessAwareCommandline cli =
+ @SuppressWarnings( "unchecked" ) OutputStreamFlushableCommandline cli =
forkConfiguration.createCommandLine( bootClasspath.getClassPath(),
startupConfiguration.getClassLoaderConfiguration(),
startupConfiguration.isShadefire(), threadNumber );
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/05aa3a60/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/FlushReceiver.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/FlushReceiver.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/FlushReceiver.java
index 5269d7a..0c0bcdd 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/FlushReceiver.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/FlushReceiver.java
@@ -1,7 +1,37 @@
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.
+ */
+
import java.io.IOException;
+/**
+ * Something that can be flushed.
+ *
+ * @author Andreas Gudian
+ *
+ */
public interface FlushReceiver {
+ /**
+ * Performs a flush, releasing any buffered resources.
+ *
+ * @throws IOException in case the flush operation failed
+ */
void flush() throws IOException;
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/05aa3a60/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/FlushReceiverProvider.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/FlushReceiverProvider.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/FlushReceiverProvider.java
index f285a66..052bb44 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/FlushReceiverProvider.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/FlushReceiverProvider.java
@@ -1,5 +1,34 @@
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.
+ */
+
+/**
+ * Provides a {@link FlushReceiver}.
+ *
+ * @author Andreas Gudian
+ *
+ */
public interface FlushReceiverProvider {
+
+ /**
+ * @return a {@link FlushReceiver}
+ */
FlushReceiver getFlushReceiver();
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/05aa3a60/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/OutputStreamFlushableCommandline.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/OutputStreamFlushableCommandline.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/OutputStreamFlushableCommandline.java
new file mode 100644
index 0000000..3149566
--- /dev/null
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/OutputStreamFlushableCommandline.java
@@ -0,0 +1,73 @@
+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.
+ */
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.maven.shared.utils.cli.CommandLineException;
+import org.apache.maven.shared.utils.cli.Commandline;
+
+/**
+ * A {@link Commandline} implementation that provides the output stream of
+ * the executed process in form of a {@link FlushReceiver}, for it to be
+ * flushed on demand.
+ *
+ * @author Andreas Gudian
+ *
+ */
+public class OutputStreamFlushableCommandline extends Commandline implements FlushReceiverProvider {
+ /**
+ * Wraps an output stream in order to delegate a flush.
+ *
+ */
+ private final class OutputStreamFlushReceiver implements FlushReceiver {
+ private final OutputStream outputStream;
+
+ private OutputStreamFlushReceiver(OutputStream outputStream) {
+ this.outputStream = outputStream;
+ }
+
+ public void flush() throws IOException {
+ outputStream.flush();
+ }
+ }
+
+ private FlushReceiver flushReceiver;
+
+ @Override
+ public Process execute() throws CommandLineException {
+ Process process = super.execute();
+
+ if (process.getOutputStream() != null) {
+ flushReceiver = new OutputStreamFlushReceiver(process.getOutputStream());
+ }
+
+ return process;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.maven.plugin.surefire.booterclient.lazytestprovider.FlushReceiverProvider#getFlushReceiver()
+ */
+ public FlushReceiver getFlushReceiver() {
+ return flushReceiver;
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/05aa3a60/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/ProcessAwareCommandline.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/ProcessAwareCommandline.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/ProcessAwareCommandline.java
deleted file mode 100644
index 5182107..0000000
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/ProcessAwareCommandline.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package org.apache.maven.plugin.surefire.booterclient.lazytestprovider;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-import org.apache.maven.shared.utils.cli.CommandLineException;
-import org.apache.maven.shared.utils.cli.Commandline;
-
-
-
-public class ProcessAwareCommandline extends Commandline implements FlushReceiverProvider {
- private final class OutputStreamFlushReceiver implements FlushReceiver {
- private final OutputStream outputStream;
-
- private OutputStreamFlushReceiver(OutputStream outputStream) {
- this.outputStream = outputStream;
- }
-
- public void flush() throws IOException {
- outputStream.flush();
- }
- }
-
- private FlushReceiver flushReceiver;
-
- @Override
- public Process execute() throws CommandLineException {
- Process process = super.execute();
-
- if (process.getOutputStream() != null) {
- flushReceiver = new OutputStreamFlushReceiver(process.getOutputStream());
- }
-
- return process;
- }
-
- public FlushReceiver getFlushReceiver() {
- return flushReceiver;
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/05aa3a60/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 a4e899d..8b6f396 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
@@ -1,10 +1,43 @@
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.
+ */
+
import java.io.IOException;
import java.io.InputStream;
import java.util.Queue;
import java.util.concurrent.Semaphore;
+/**
+ * An {@link InputStream} that, when read, provides test class names out of
+ * a queue.
+ * <p>
+ * The Stream provides only one test at a time, but only after {@link #provideNewTest()}
+ * has been invoked.
+ * <p>
+ * After providing each test class name, followed by a newline character, a flush is
+ * performed on the {@link FlushReceiver} provided by the {@link FlushReceiverProvider}
+ * that can be set using {@link #setFlushReceiverProvider(FlushReceiverProvider)}.
+ *
+ * @author Andreas Gudian
+ *
+ */
public class TestProvidingInputStream extends InputStream {
private final Queue<String> testItemQueue;
private byte[] currentBuffer;
@@ -12,10 +45,18 @@ public class TestProvidingInputStream extends InputStream {
private Semaphore semaphore = new Semaphore(0);
private FlushReceiverProvider flushReceiverProvider;
+ /**
+ * C'tor
+ *
+ * @param testItemQueue source of the tests to be read from this stream
+ */
public TestProvidingInputStream(Queue<String> testItemQueue) {
this.testItemQueue = testItemQueue;
}
+ /**
+ * @param flushReceiverProvider the provider for a flush receiver.
+ */
public void setFlushReceiverProvider(FlushReceiverProvider flushReceiverProvider) {
this.flushReceiverProvider = flushReceiverProvider;
}
@@ -46,6 +87,9 @@ public class TestProvidingInputStream extends InputStream {
}
}
+ /**
+ * Signal that a new test is to be provided.
+ */
public void provideNewTest() {
semaphore.release();
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/05aa3a60/surefire-api/src/main/java/org/apache/maven/surefire/util/LazyTestsToRun.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/LazyTestsToRun.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/LazyTestsToRun.java
index dabe1ae..24fe675 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/LazyTestsToRun.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/LazyTestsToRun.java
@@ -1,8 +1,24 @@
-/**
- *
- */
package org.apache.maven.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.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@@ -16,7 +32,7 @@ import java.util.List;
import org.apache.maven.surefire.booter.ForkingRunListener;
/**
- * A variant of TestsToRun that is provided with test class names asynchronously
+ * A variant of TestsToRun that is provided with test class names
* from an {@link InputStream} (e.g. {@code System.in}). The method
* {@link #iterator()} returns an Iterator that blocks on calls to
* {@link Iterator#hasNext()} until new classes are available, or no more
@@ -35,6 +51,13 @@ public class LazyTestsToRun extends TestsToRun {
private ClassLoader testClassLoader;
private PrintStream originalOutStream;
+ /**
+ * C'tor
+ *
+ * @param testSource source to read the tests from
+ * @param testClassLoader class loader to load the test classes
+ * @param originalOutStream the output stream to use when requesting new new tests
+ */
public LazyTestsToRun(InputStream testSource, ClassLoader testClassLoader, PrintStream originalOutStream) {
super(Collections.emptyList());
@@ -104,6 +127,9 @@ public class LazyTestsToRun extends TestsToRun {
}
+ /* (non-Javadoc)
+ * @see org.apache.maven.surefire.util.TestsToRun#iterator()
+ */
public Iterator iterator() {
return new BlockingIterator();
}
@@ -122,6 +148,9 @@ public class LazyTestsToRun extends TestsToRun {
throw new UnsupportedOperationException("use method iterator()");
}
+ /* (non-Javadoc)
+ * @see org.apache.maven.surefire.util.TestsToRun#toString()
+ */
public String toString() {
StringBuffer sb = new StringBuffer("LazyTestsToRun ");
synchronized (workQueue) {