incubator-droids-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rfrov...@apache.org
Subject svn commit: r1089152 - in /incubator/droids/trunk/droids-core/src: main/java/org/apache/droids/impl/SimpleTaskQueueWithHistory.java test/java/org/apache/droids/impl/TestSimpleTaskQueueWithHistory.java
Date Tue, 05 Apr 2011 18:21:46 GMT
Author: rfrovarp
Date: Tue Apr  5 18:21:45 2011
New Revision: 1089152

URL: http://svn.apache.org/viewvc?rev=1089152&view=rev
Log:
This fixes the add() and offer() error in the SimpleTaskQueueWithHistory as reported by Giulio
Cesare Solaroli.
Thanks to Giulio for also providing the patch in DROIDS-139.

Added:
    incubator/droids/trunk/droids-core/src/test/java/org/apache/droids/impl/TestSimpleTaskQueueWithHistory.java
Modified:
    incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/impl/SimpleTaskQueueWithHistory.java

Modified: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/impl/SimpleTaskQueueWithHistory.java
URL: http://svn.apache.org/viewvc/incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/impl/SimpleTaskQueueWithHistory.java?rev=1089152&r1=1089151&r2=1089152&view=diff
==============================================================================
--- incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/impl/SimpleTaskQueueWithHistory.java
(original)
+++ incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/impl/SimpleTaskQueueWithHistory.java
Tue Apr  5 18:21:45 2011
@@ -43,18 +43,14 @@ public class SimpleTaskQueueWithHistory<
   @Override
   public boolean offer(T e)
   {
-    if (previous.add(e.getId())) {
-      return super.offer(e);
-    } else {
-      return false;
-    }
+      return add(e);
   }
 
   @Override
   public boolean add(T e)
   {
     if (previous.add(e.getId())) {
-      return super.offer(e);
+      return super.add(e);
     } else {
       return false;
     }

Added: incubator/droids/trunk/droids-core/src/test/java/org/apache/droids/impl/TestSimpleTaskQueueWithHistory.java
URL: http://svn.apache.org/viewvc/incubator/droids/trunk/droids-core/src/test/java/org/apache/droids/impl/TestSimpleTaskQueueWithHistory.java?rev=1089152&view=auto
==============================================================================
--- incubator/droids/trunk/droids-core/src/test/java/org/apache/droids/impl/TestSimpleTaskQueueWithHistory.java
(added)
+++ incubator/droids/trunk/droids-core/src/test/java/org/apache/droids/impl/TestSimpleTaskQueueWithHistory.java
Tue Apr  5 18:21:45 2011
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+package org.apache.droids.impl;
+
+import java.net.URI;
+import java.util.LinkedList;
+import junit.framework.Assert;
+import org.apache.droids.LinkTask;
+import org.apache.droids.robot.walker.FileTask;
+import org.junit.Test;
+
+public class TestSimpleTaskQueueWithHistory
+{
+  @Test
+  public void testOffer() throws Exception
+  {
+    LinkedList<LinkTask> queue;
+    URI	uri;
+    LinkTask task;
+
+    queue = new SimpleTaskQueueWithHistory<LinkTask>();
+    Assert.assertEquals(0, queue.size());
+    uri = new URI("http://www.example.com");
+    Assert.assertNotNull(uri);
+    task = new LinkTask(null, uri, 1);
+    Assert.assertNotNull(task);
+    queue.offer(task);
+    Assert.assertEquals(1, queue.size());
+
+  }
+}



Mime
View raw message