maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krosenv...@apache.org
Subject svn commit: r1223023 - in /maven/surefire/trunk: maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ maven-surefire-common/src/main...
Date Sat, 24 Dec 2011 21:39:22 GMT
Author: krosenvold
Date: Sat Dec 24 21:39:21 2011
New Revision: 1223023

URL: http://svn.apache.org/viewvc?rev=1223023&view=rev
Log:
o More generics, moved a few classes

Added:
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/util/internal/
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/util/internal/BlockingQueue.java
  (contents, props changed)
      - copied, changed from r1222949, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/BlockingQueue.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/util/internal/FunkyTwoThreadBlockingQueue.java
  (contents, props changed)
      - copied, changed from r1222949, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/FunkyTwoThreadBlockingQueue.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/util/internal/Java15BlockingQueue.java
  (contents, props changed)
      - copied, changed from r1222949, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/Java15BlockingQueue.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueue.java
  (contents, props changed)
      - copied, changed from r1222949, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueue.java
    maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/surefire/util/internal/
    maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueueTest.java
  (contents, props changed)
      - copied, changed from r1222949, maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueueTest.java
Removed:
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/BlockingQueue.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/BlockingQueueFactory.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/FunkyTwoThreadBlockingQueue.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/Java13BlockingQueue.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/Java15BlockingQueue.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueue.java
    maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueueTest.java
Modified:
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/MockReporter.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/MockReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/MockReporter.java?rev=1223023&r1=1223022&r2=1223023&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/MockReporter.java
(original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/MockReporter.java
Sat Dec 24 21:39:21 2011
@@ -33,9 +33,9 @@ import org.apache.maven.surefire.report.
 public class MockReporter
     implements RunListener, ConsoleLogger, ConsoleOutputReceiver
 {
-    private final List events = new ArrayList();
+    private final List<String> events = new ArrayList<String>();
 
-    private final List data = new ArrayList();
+    private final List<Object> data = new ArrayList<Object>();
 
     public static final String SET_STARTING = "SET_STARTED";
 
@@ -117,7 +117,7 @@ public class MockReporter
     }
 
 
-    public List getEvents()
+    public List<String> getEvents()
     {
         return events;
     }
@@ -129,7 +129,7 @@ public class MockReporter
 
     public String getFirstEvent()
     {
-        return (String) events.get( 0 );
+        return events.get( 0 );
     }
 
     public ReportEntry getFirstData()
@@ -150,7 +150,6 @@ public class MockReporter
     {
         events.add( CONSOLE_OUTPUT );
         data.add( message );
-        //To change body of implemented methods use File | Settings | File Templates.
     }
 
     public void writeTestOutput( byte[] buf, int off, int len, boolean stdout )

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java?rev=1223023&r1=1223022&r2=1223023&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
(original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
Sat Dec 24 21:39:21 2011
@@ -28,6 +28,7 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
 import java.util.StringTokenizer;
+
 import org.apache.maven.surefire.booter.ForkingRunListener;
 import org.apache.maven.surefire.report.CategorizedReportEntry;
 import org.apache.maven.surefire.report.ConsoleOutputReceiver;
@@ -52,7 +53,8 @@ public class ForkClient
 {
     private final ReporterFactory providerReporterFactory;
 
-    private final Map testSetReporters = Collections.synchronizedMap( new HashMap() );
+    private final Map<Integer, RunListener> testSetReporters =
+        Collections.synchronizedMap( new HashMap<Integer, RunListener>() );
 
     private final Properties testVmSystemProperties;
 
@@ -77,8 +79,8 @@ public class ForkClient
                 System.out.println( s );
                 return;
             }
-            final Integer channelNumber = new Integer( Integer.parseInt( s.substring( 2,
commma ), 16 ) );
-            RunListener reporter = (RunListener) testSetReporters.get( channelNumber );
+            final Integer channelNumber = Integer.parseInt( s.substring( 2, commma ), 16
);
+            RunListener reporter = testSetReporters.get( channelNumber );
             if ( reporter == null )
             {
                 reporter = providerReporterFactory.createReporter();
@@ -97,7 +99,7 @@ public class ForkClient
                     reporter.testSetCompleted( createReportEntry( remaining ) );
                     break;
                 case ForkingRunListener.BOOTERCODE_TEST_STARTING:
-                    reporter.testStarting( createReportEntry( remaining) );
+                    reporter.testStarting( createReportEntry( remaining ) );
                     break;
                 case ForkingRunListener.BOOTERCODE_TEST_SUCCEEDED:
                     reporter.testSucceeded( createReportEntry( remaining ) );
@@ -169,9 +171,9 @@ public class ForkClient
         return unescape( remaining );
     }
 
-    private ReportEntry createReportEntry( String untokenized)
+    private ReportEntry createReportEntry( String untokenized )
     {
-        StringTokenizer tokens = new StringTokenizer(untokenized, ",");
+        StringTokenizer tokens = new StringTokenizer( untokenized, "," );
         try
         {
             String source = tokens.nextToken();
@@ -227,7 +229,7 @@ public class ForkClient
      */
     public RunListener getReporter( Integer channelNumber )
     {
-        return (RunListener) testSetReporters.get( channelNumber );
+        return testSetReporters.get( channelNumber );
     }
 
 

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java?rev=1223023&r1=1223022&r2=1223023&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java
(original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java
Sat Dec 24 21:39:21 2011
@@ -20,7 +20,7 @@ package org.apache.maven.plugin.surefire
  */
 
 import org.apache.maven.surefire.util.internal.BlockingQueue;
-import org.apache.maven.surefire.util.internal.BlockingQueueFactory;
+import org.apache.maven.surefire.util.internal.Java15BlockingQueue;
 import org.codehaus.plexus.util.cli.StreamConsumer;
 
 /**
@@ -32,7 +32,7 @@ public class ThreadedStreamConsumer
     implements StreamConsumer
 {
 
-    private final BlockingQueue items = BlockingQueueFactory.createBlockingQueue();
+    private final BlockingQueue items = new Java15BlockingQueue();
 
     private static final String poison = "Pioson";
 

Copied: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/util/internal/BlockingQueue.java
(from r1222949, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/BlockingQueue.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/util/internal/BlockingQueue.java?p2=maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/util/internal/BlockingQueue.java&p1=maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/BlockingQueue.java&r1=1222949&r2=1223023&rev=1223023&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/BlockingQueue.java
(original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/util/internal/BlockingQueue.java
Sat Dec 24 21:39:21 2011
@@ -25,8 +25,8 @@ package org.apache.maven.surefire.util.i
  */
 public interface BlockingQueue
 {
-    void add( Object object );
+    void add( String object );
 
-    Object take()
+    String take()
         throws InterruptedException;
 }

Propchange: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/util/internal/BlockingQueue.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/util/internal/BlockingQueue.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Copied: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/util/internal/FunkyTwoThreadBlockingQueue.java
(from r1222949, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/FunkyTwoThreadBlockingQueue.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/util/internal/FunkyTwoThreadBlockingQueue.java?p2=maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/util/internal/FunkyTwoThreadBlockingQueue.java&p1=maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/FunkyTwoThreadBlockingQueue.java&r1=1222949&r2=1223023&rev=1223023&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/FunkyTwoThreadBlockingQueue.java
(original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/util/internal/FunkyTwoThreadBlockingQueue.java
Sat Dec 24 21:39:21 2011
@@ -33,6 +33,7 @@ package org.apache.maven.surefire.util.i
  * ArrayList insert 5000000 elements in  = 18
  * LinkedList insert 5000000 elements in  = 334
  *
+ * Todo: Determine if this design actually works ;)
  * @author Kristian Rosenvold
  */
 public class FunkyTwoThreadBlockingQueue implements BlockingQueue
@@ -50,7 +51,7 @@ public class FunkyTwoThreadBlockingQueue
     private volatile boolean memoryModelGuard;
 
 
-    public void put( Object object )
+    public void put( String object )
     {
         insertChunk.elements[insertPos] = object;
         if ( ++insertPos == chunkSize)
@@ -63,13 +64,13 @@ public class FunkyTwoThreadBlockingQueue
         memoryModelGuard = true;
     }
 
-    public void add( Object object )
+    public void add( String object )
     {
         put(  object );
     }
 
 
-    public Object take()
+    public String take()
         throws InterruptedException
     {
         if ( takePos >= chunkSize )
@@ -79,7 +80,7 @@ public class FunkyTwoThreadBlockingQueue
         }
 
         boolean fud = memoryModelGuard;
-        Object next = takeChunk.elements[takePos];
+        String next = takeChunk.elements[takePos];
         while ( next == null )
         {
             Thread.sleep( 1 );
@@ -92,7 +93,7 @@ public class FunkyTwoThreadBlockingQueue
 
     final class Chunk
     {
-        final Object[] elements = new Object[chunkSize];
+        final String[] elements = new String[chunkSize];
 
         volatile Chunk next;
     }

Propchange: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/util/internal/FunkyTwoThreadBlockingQueue.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/util/internal/Java15BlockingQueue.java
(from r1222949, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/Java15BlockingQueue.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/util/internal/Java15BlockingQueue.java?p2=maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/util/internal/Java15BlockingQueue.java&p1=maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/Java15BlockingQueue.java&r1=1222949&r2=1223023&rev=1223023&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/Java15BlockingQueue.java
(original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/util/internal/Java15BlockingQueue.java
Sat Dec 24 21:39:21 2011
@@ -25,16 +25,17 @@ import java.util.concurrent.LinkedBlocki
 /**
  * @author Kristian Rosenvold
  */
-public class Java15BlockingQueue implements BlockingQueue
+public class Java15BlockingQueue
+    implements BlockingQueue
 {
-    private final java.util.concurrent.BlockingQueue blockingQueue = new LinkedBlockingQueue(
 );
+    private final java.util.concurrent.BlockingQueue<String> blockingQueue = new LinkedBlockingQueue<String>();
 
-    public void add( Object object )
+    public void add( String object )
     {
-        blockingQueue.add(  object );
+        blockingQueue.add( object );
     }
 
-    public Object take()
+    public String take()
         throws InterruptedException
     {
         return blockingQueue.take();

Propchange: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/util/internal/Java15BlockingQueue.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueue.java
(from r1222949, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueue.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueue.java?p2=maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueue.java&p1=maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueue.java&r1=1222949&r2=1223023&rev=1223023&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueue.java
(original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueue.java
Sat Dec 24 21:39:21 2011
@@ -46,9 +46,9 @@ public class TwoThreadBlockingQueue
     private volatile Element lastTaken;
     private volatile Element first;
 
-    public static final Object poison = new Object();
+    public static final String poison = "poison";
 
-    public void add( Object object )
+    public void add( String object )
     {
         Element next = new Element( object);
         if (lastInserted == null){
@@ -59,7 +59,7 @@ public class TwoThreadBlockingQueue
         }
     }
 
-    public Object take()
+    public String take()
         throws InterruptedException
     {
         if (lastTaken == null){
@@ -81,11 +81,11 @@ public class TwoThreadBlockingQueue
 
     private static class Element
     {
-        private final Object object;
+        private final String object;
 
         private volatile Element next;
 
-        Element( Object object )
+        Element( String object )
         {
             this.object = object;
         }

Propchange: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueue.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueueTest.java
(from r1222949, maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueueTest.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueueTest.java?p2=maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueueTest.java&p1=maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueueTest.java&r1=1222949&r2=1223023&rev=1223023&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueueTest.java
(original)
+++ maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueueTest.java
Sat Dec 24 21:39:21 2011
@@ -25,6 +25,7 @@ import java.util.concurrent.Callable;
 import java.util.concurrent.FutureTask;
 import java.util.concurrent.LinkedBlockingQueue;
 
+import junit.framework.Assert;
 import junit.framework.TestCase;
 
 /**
@@ -84,7 +85,7 @@ public class TwoThreadBlockingQueueTest
                 {
                     taken = twoThreadBlockingQueue.take();
                     if (taken != TwoThreadBlockingQueue.poison) {
-                        assertEquals( "item" + num++, taken );
+                        Assert.assertEquals( "item" + num++, taken );
                     }
                 }
                 while ( taken != TwoThreadBlockingQueue.poison);

Propchange: maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueueTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message