commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nutty...@apache.org
Subject svn commit: r562657 - in /commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline: ./ config/ driver/ stage/
Date Sat, 04 Aug 2007 04:39:49 GMT
Author: nuttycom
Date: Fri Aug  3 21:39:48 2007
New Revision: 562657

URL: http://svn.apache.org/viewvc?view=rev&rev=562657
Log:
Minor changes to accomodate driver refactoring, added generics.

Modified:
    commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/PipelineTest.java
    commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/config/DigesterPipelineFactoryTest.java
    commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/driver/DedicatedThreadStageDriverTest.java
    commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/driver/SynchronousStageDriverTest.java
    commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/driver/ThreadPoolStageDriverTest.java
    commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/stage/KeyWaitBufferStageTest.java
    commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/stage/URLToInputStreamStageTest.java

Modified: commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/PipelineTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/PipelineTest.java?view=diff&rev=562657&r1=562656&r2=562657
==============================================================================
--- commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/PipelineTest.java
(original)
+++ commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/PipelineTest.java
Fri Aug  3 21:39:48 2007
@@ -17,10 +17,14 @@
 
 package org.apache.commons.pipeline;
 
-import junit.framework.*;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.EventObject;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
 import org.apache.commons.pipeline.driver.SynchronousStageDriverFactory;
 import org.apache.commons.pipeline.event.ObjectProcessedEvent;
 import org.apache.commons.pipeline.listener.ObjectProcessedEventCounter;
@@ -76,7 +80,7 @@
         
         instance.raise(ev);
         
-        Thread.currentThread().yield(); //give the notifier thread created by raise priority
+        Thread.yield(); //give the notifier thread created by raise priority
         
         assertNotNull(counter.getCounts().get(testStage));
         assertEquals(1, counter.getCounts().get(testStage).intValue());
@@ -98,7 +102,7 @@
         EventObject ev = new ObjectProcessedEvent(testStage, "Hello, World!");
         branch1.raise(ev);
         
-        Thread.currentThread().yield(); //give the notifier thread created by raise priority
+        Thread.yield(); //give the notifier thread created by raise priority
         
         assertNotNull(counter.getCounts().get(testStage));
         assertEquals(1, counter.getCounts().get(testStage).intValue());

Modified: commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/config/DigesterPipelineFactoryTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/config/DigesterPipelineFactoryTest.java?view=diff&rev=562657&r1=562656&r2=562657
==============================================================================
--- commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/config/DigesterPipelineFactoryTest.java
(original)
+++ commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/config/DigesterPipelineFactoryTest.java
Fri Aug  3 21:39:48 2007
@@ -6,21 +6,22 @@
  * 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.    
- */ 
+ * under the License.
+ */
 
 package org.apache.commons.pipeline.config;
 
 import java.net.URL;
 import java.util.ResourceBundle;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.commons.pipeline.AbstractLoggingTestCase;
@@ -65,6 +66,7 @@
             assertNotNull("Stage is not null.", stage);
             assertEquals(stage.getClass(), Class.forName(testResources.getString(keyBase
+ ".stage" + i + ".class")));
             i++;
+            
             if (stage instanceof KeyWaitBufferStage) {
                 assertTrue(((KeyWaitBufferStage) stage).getQueueFactory() instanceof BlockingQueueFactory.ArrayBlockingQueueFactory);
             }
@@ -72,17 +74,16 @@
         
         pipeline.run();
         
-        
         boolean eventsRecorded = false;
         assertTrue("Pipeline has at least one listener.", pipeline.getRegisteredListeners().size()
> 0);
         for (StageEventListener l : pipeline.getRegisteredListeners()) {
             if (l instanceof ObjectProcessedEventCounter) {
                 log.info(((ObjectProcessedEventCounter) l).getCounts().size() + " event sources
found.");
-                assertTrue("Events were recorded by the ObjectProcessedEventListener.", ((ObjectProcessedEventCounter)
l).getCounts().size() > 0);
+                assertTrue("No events were recorded by the ObjectProcessedEventListener.",
((ObjectProcessedEventCounter) l).getCounts().size() > 0);
                 eventsRecorded = true;
             }
         }
-        assertTrue("Events were raised and properly recorded by the listener.", eventsRecorded);
+        assertTrue("Events were not raised and properly recorded by the listener.", eventsRecorded);
         
         assertNotNull(pipeline.getEnv("testDate"));
         assertEquals("Hello, World!", pipeline.getEnv("testEnvVar"));

Modified: commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/driver/DedicatedThreadStageDriverTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/driver/DedicatedThreadStageDriverTest.java?view=diff&rev=562657&r1=562656&r2=562657
==============================================================================
--- commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/driver/DedicatedThreadStageDriverTest.java
(original)
+++ commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/driver/DedicatedThreadStageDriverTest.java
Fri Aug  3 21:39:48 2007
@@ -17,13 +17,15 @@
 
 package org.apache.commons.pipeline.driver;
 
-import junit.framework.*;
 import java.util.concurrent.LinkedBlockingQueue;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.commons.pipeline.Feeder;
 import org.apache.commons.pipeline.StageDriver.State;
-import static org.apache.commons.pipeline.StageDriver.State.*;
 
 /**
  *
@@ -47,7 +49,7 @@
      */
     public void testGetFeeder() {
         log.debug("testGetFeeder ---------------------------------------------");
-        DedicatedThreadStageDriver instance = new DedicatedThreadStageDriver(stage, context,
new LinkedBlockingQueue(), 500, FaultTolerance.NONE);
+        DedicatedThreadStageDriver instance = new DedicatedThreadStageDriver(stage, context,
new LinkedBlockingQueue<Object>(), 500, FaultTolerance.NONE);
         
         Feeder feeder = instance.getFeeder();
         assertNotNull(feeder);        
@@ -61,7 +63,7 @@
      */
     public void testStartFinish() throws Exception {
         log.debug("testStartFinish -------------------------------------------");
-        DedicatedThreadStageDriver instance = new DedicatedThreadStageDriver(stage, context,
new LinkedBlockingQueue(), 500, FaultTolerance.NONE);
+        DedicatedThreadStageDriver instance = new DedicatedThreadStageDriver(stage, context,
new LinkedBlockingQueue<Object>(), 500, FaultTolerance.NONE);
         
         assertEquals(State.STOPPED, instance.getState());
         

Modified: commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/driver/SynchronousStageDriverTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/driver/SynchronousStageDriverTest.java?view=diff&rev=562657&r1=562656&r2=562657
==============================================================================
--- commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/driver/SynchronousStageDriverTest.java
(original)
+++ commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/driver/SynchronousStageDriverTest.java
Fri Aug  3 21:39:48 2007
@@ -19,6 +19,7 @@
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
+
 import org.apache.commons.pipeline.Feeder;
 import org.apache.commons.pipeline.StageDriver.State;
 
@@ -43,7 +44,7 @@
      * Test of getFeeder method, of class org.apache.commons.pipeline.driver.SynchronousStageDriver.
      */
     public void testGetFeeder() {
-        SynchronousStageDriver instance = new SynchronousStageDriver(stage, context);
+        SynchronousStageDriver instance = new SynchronousStageDriver(stage, context, FaultTolerance.NONE);
         
         Feeder feeder = instance.getFeeder();
         assertNotNull(feeder);
@@ -56,7 +57,7 @@
      * proper behavior of the getState() method.
      */
     public void testStartFinish() throws Exception {
-        SynchronousStageDriver instance = new SynchronousStageDriver(stage, context);
+        SynchronousStageDriver instance = new SynchronousStageDriver(stage, context, FaultTolerance.NONE);
         
         assertEquals(instance.getState(), State.STOPPED);
         

Modified: commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/driver/ThreadPoolStageDriverTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/driver/ThreadPoolStageDriverTest.java?view=diff&rev=562657&r1=562656&r2=562657
==============================================================================
--- commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/driver/ThreadPoolStageDriverTest.java
(original)
+++ commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/driver/ThreadPoolStageDriverTest.java
Fri Aug  3 21:39:48 2007
@@ -17,13 +17,15 @@
 
 package org.apache.commons.pipeline.driver;
 
-import junit.framework.*;
 import java.util.concurrent.LinkedBlockingQueue;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.commons.pipeline.Feeder;
 import org.apache.commons.pipeline.StageDriver.State;
-import static org.apache.commons.pipeline.StageDriver.State.*;
 
 /**
  *
@@ -48,7 +50,7 @@
      */
     public void testGetFeeder() {
         log.debug("testGetFeeder ---------------------------------------------");
-        ThreadPoolStageDriver instance = new ThreadPoolStageDriver(stage, context, new LinkedBlockingQueue(),
500, FaultTolerance.NONE, 5);
+        ThreadPoolStageDriver instance = new ThreadPoolStageDriver(stage, context, new LinkedBlockingQueue<Object>(),
500, FaultTolerance.NONE, 5);
         
         Feeder feeder = instance.getFeeder();
         assertNotNull(feeder);
@@ -62,7 +64,7 @@
      */
     public void testStartFinish() throws Exception {
         log.debug("testStartFinish -------------------------------------------");
-        ThreadPoolStageDriver instance = new ThreadPoolStageDriver(stage, context, new LinkedBlockingQueue(),
500, FaultTolerance.NONE, 5);
+        ThreadPoolStageDriver instance = new ThreadPoolStageDriver(stage, context, new LinkedBlockingQueue<Object>(),
500, FaultTolerance.NONE, 5);
         
         assertEquals(State.STOPPED, instance.getState());
         

Modified: commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/stage/KeyWaitBufferStageTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/stage/KeyWaitBufferStageTest.java?view=diff&rev=562657&r1=562656&r2=562657
==============================================================================
--- commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/stage/KeyWaitBufferStageTest.java
(original)
+++ commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/stage/KeyWaitBufferStageTest.java
Fri Aug  3 21:39:48 2007
@@ -19,16 +19,11 @@
 
 package org.apache.commons.pipeline.stage;
 
-import junit.framework.*;
 import java.util.EventObject;
-import java.util.Map;
-import java.util.Queue;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.TreeSet;
-import org.apache.commons.pipeline.StageContext;
-import org.apache.commons.pipeline.StageEventListener;
-import org.apache.commons.pipeline.StageException;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
 import org.apache.commons.pipeline.event.KeyAvailableEvent;
 import org.apache.commons.pipeline.util.KeyFactory;
 import org.apache.commons.pipeline.util.QueueFactory;
@@ -54,15 +49,13 @@
      * data waiting for notify() to be called with an appropriate event.
      */
     public void testProcessAndNotify() throws Exception {
-        System.out.println("notify");
-        
         String obj = "Hello, World!";
         KeyFactory<Object,Integer> keyFactory = new KeyFactory.HashKeyFactory();
-        EventObject ev = new KeyAvailableEvent(this, keyFactory.generateKey(obj));
+        EventObject ev = new KeyAvailableEvent<Integer>(this, keyFactory.generateKey(obj));
 
         KeyWaitBufferStage instance = new KeyWaitBufferStage();
         instance.setKeyFactory(keyFactory);
-        instance.setQueueFactory(new QueueFactory.LinkedListFactory());
+        instance.setQueueFactory(new QueueFactory.LinkedListFactory<Object>());
         
         this.init(instance);
                 

Modified: commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/stage/URLToInputStreamStageTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/stage/URLToInputStreamStageTest.java?view=diff&rev=562657&r1=562656&r2=562657
==============================================================================
--- commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/stage/URLToInputStreamStageTest.java
(original)
+++ commons/sandbox/pipeline/trunk/src/test/java/org/apache/commons/pipeline/stage/URLToInputStreamStageTest.java
Fri Aug  3 21:39:48 2007
@@ -19,12 +19,10 @@
 
 import java.io.IOException;
 import java.io.InputStream;
-import junit.framework.*;
 import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.commons.pipeline.Pipeline;
-import org.apache.commons.pipeline.Stage;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
 
 
 /**
@@ -64,8 +62,8 @@
         InputStream in = (InputStream) testFeeder.receivedValues.get(0);
         try {
             assertNotNull(in);
-        byte[] buffer = new byte[128];
-            int bytes = in.read(buffer);
+            byte[] buffer = new byte[128];
+            @SuppressWarnings("unused") int bytes = in.read(buffer);
         } finally {
             in.close();
         }
@@ -86,7 +84,7 @@
         InputStream in = (InputStream) testFeeder.receivedValues.get(0);
         try {
             byte[] buffer = new byte[128];
-            int bytes = in.read(buffer);
+            @SuppressWarnings("unused") int bytes = in.read(buffer);
             fail("input stream should have been closed, so reading should throw an exception.");
         } catch (IOException expected){
             // do nothing



Mime
View raw message