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 2011/06/17 13:37:53 UTC
svn commit: r1136850 - in
/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore:
AsynchronousRunner.java ConfigurableParallelComputer.java
SynchronousRunner.java
Author: krosenvold
Date: Fri Jun 17 11:37:52 2011
New Revision: 1136850
URL: http://svn.apache.org/viewvc?rev=1136850&view=rev
Log:
o Extracted inner classes to separate class file, switched to using Executors.callable
Added:
maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/AsynchronousRunner.java (with props)
maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/SynchronousRunner.java (with props)
Modified:
maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConfigurableParallelComputer.java
Added: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/AsynchronousRunner.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/AsynchronousRunner.java?rev=1136850&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/AsynchronousRunner.java (added)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/AsynchronousRunner.java Fri Jun 17 11:37:52 2011
@@ -0,0 +1,81 @@
+package org.apache.maven.surefire.junitcore;
+
+/*
+ * 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.surefire.util.NestedRuntimeException;
+import org.junit.runners.model.RunnerScheduler;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+/**
+* @author <a href="mailto:kristian@zenior.no">Kristian Rosenvold</a>
+*/
+public class AsynchronousRunner
+ implements RunnerScheduler
+{
+ private final List<Future<Object>> futures = Collections.synchronizedList(new ArrayList<Future<Object>>());
+
+ private final ExecutorService fService;
+
+ public AsynchronousRunner(ExecutorService fService)
+ {
+ this.fService = fService;
+ }
+
+ public void schedule( final Runnable childStatement )
+ {
+ futures.add( fService.submit( Executors.callable(childStatement) ) );
+ }
+
+
+ public void finished()
+ {
+ try
+ {
+ waitForCompletion();
+ }
+ catch ( ExecutionException e )
+ {
+ throw new NestedRuntimeException( e );
+ }
+ }
+
+ public void waitForCompletion()
+ throws ExecutionException
+ {
+ for ( Future<Object> each : futures )
+ {
+ try
+ {
+ each.get();
+ }
+ catch ( InterruptedException e )
+ {
+ throw new NestedRuntimeException( e );
+ }
+ }
+ }
+}
Propchange: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/AsynchronousRunner.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConfigurableParallelComputer.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConfigurableParallelComputer.java?rev=1136850&r1=1136849&r2=1136850&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConfigurableParallelComputer.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConfigurableParallelComputer.java Fri Jun 17 11:37:52 2011
@@ -22,11 +22,9 @@ package org.apache.maven.surefire.junitc
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
import org.apache.maven.surefire.util.NestedRuntimeException;
import org.junit.runner.Computer;
@@ -151,72 +149,4 @@ public class ConfigurableParallelCompute
+ fixedPool + '}';
}
- private class SynchronousRunner
- implements RunnerScheduler
- {
- public void schedule( final Runnable childStatement )
- {
- childStatement.run();
- }
-
- public void finished()
- {
- }
- }
-
- public class AsynchronousRunner
- implements RunnerScheduler
- {
- private final List<Future<Object>> futures = Collections.synchronizedList( new ArrayList<Future<Object>>() );
-
- private final ExecutorService fService;
-
- public AsynchronousRunner( ExecutorService fService )
- {
- this.fService = fService;
- }
-
- public void schedule( final Runnable childStatement )
- {
- final Callable<Object> objectCallable = new Callable<Object>()
- {
- public Object call()
- throws Exception
- {
- childStatement.run();
- return null;
- }
- };
- futures.add( fService.submit( objectCallable ) );
- }
-
-
- public void finished()
- {
- try
- {
- waitForCompletion();
- }
- catch ( ExecutionException e )
- {
- throw new NestedRuntimeException( e );
- }
- }
-
- public void waitForCompletion()
- throws ExecutionException
- {
- for ( Future<Object> each : futures )
- {
- try
- {
- each.get();
- }
- catch ( InterruptedException e )
- {
- throw new NestedRuntimeException( e );
- }
- }
- }
- }
}
Added: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/SynchronousRunner.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/SynchronousRunner.java?rev=1136850&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/SynchronousRunner.java (added)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/SynchronousRunner.java Fri Jun 17 11:37:52 2011
@@ -0,0 +1,19 @@
+package org.apache.maven.surefire.junitcore;
+
+import org.junit.runners.model.RunnerScheduler;
+
+/**
+* @author <a href="mailto:kristian@zenior.no">Kristian Rosenvold</a>
+*/
+class SynchronousRunner
+ implements RunnerScheduler
+{
+ public void schedule( final Runnable childStatement )
+ {
+ childStatement.run();
+ }
+
+ public void finished()
+ {
+ }
+}
Propchange: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/SynchronousRunner.java
------------------------------------------------------------------------------
svn:eol-style = native