qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kw...@apache.org
Subject [1/2] qpid-broker-j git commit: QPID-8067: [Broker-J] Fix an evaluation of start time for queue default arrival time filter
Date Thu, 01 Feb 2018 17:35:50 GMT
Repository: qpid-broker-j
Updated Branches:
  refs/heads/7.0.x 5fc361733 -> 0d6b0897d


QPID-8067: [Broker-J] Fix an evaluation of start time for queue default arrival time filter


Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/e5dce3c1
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/e5dce3c1
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/e5dce3c1

Branch: refs/heads/7.0.x
Commit: e5dce3c10fc96278a89661d490cdff9e506fbd01
Parents: 5fc3617
Author: Alex Rudyy <orudyy@apache.org>
Authored: Thu Feb 1 10:56:00 2018 +0000
Committer: Keith Wall <kwall@apache.org>
Committed: Thu Feb 1 17:35:12 2018 +0000

----------------------------------------------------------------------
 .../server/filter/ArrivalTimeFilterFactory.java |  6 +--
 .../filter/ArrivalTimeFilterFactoryTest.java    | 50 ++++++++++++++++++++
 2 files changed, 52 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/e5dce3c1/broker-core/src/main/java/org/apache/qpid/server/filter/ArrivalTimeFilterFactory.java
----------------------------------------------------------------------
diff --git a/broker-core/src/main/java/org/apache/qpid/server/filter/ArrivalTimeFilterFactory.java
b/broker-core/src/main/java/org/apache/qpid/server/filter/ArrivalTimeFilterFactory.java
index 382a3ac..fc965db 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/filter/ArrivalTimeFilterFactory.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/filter/ArrivalTimeFilterFactory.java
@@ -36,10 +36,8 @@ public final class ArrivalTimeFilterFactory implements MessageFilterFactory
         {
             throw new IllegalArgumentException("Cannot create a filter from these arguments:
" + arguments);
         }
-        String arg = arguments.get(0);
-        long startingFrom= Long.parseLong(arg);
-
-        return new ArrivalTimeFilter(System.currentTimeMillis() + startingFrom, startingFrom==0l);
+        long periodInSeconds = Long.parseLong(arguments.get(0));
+        return new ArrivalTimeFilter(System.currentTimeMillis() - periodInSeconds * 1000L,
periodInSeconds == 0L);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/e5dce3c1/broker-core/src/test/java/org/apache/qpid/server/filter/ArrivalTimeFilterFactoryTest.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/filter/ArrivalTimeFilterFactoryTest.java
b/broker-core/src/test/java/org/apache/qpid/server/filter/ArrivalTimeFilterFactoryTest.java
new file mode 100644
index 0000000..7c3cee0
--- /dev/null
+++ b/broker-core/src/test/java/org/apache/qpid/server/filter/ArrivalTimeFilterFactoryTest.java
@@ -0,0 +1,50 @@
+/*
+ *
+ * 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.qpid.server.filter;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.Collections;
+
+import org.apache.qpid.test.utils.QpidTestCase;
+
+public class ArrivalTimeFilterFactoryTest extends QpidTestCase
+{
+    public void testNewInstance() throws Exception
+    {
+        long currentTime = System.currentTimeMillis();
+        int periodInSeconds = 60;
+        MessageFilter filter =
+                new ArrivalTimeFilterFactory().newInstance(Collections.singletonList(String.valueOf(periodInSeconds)));
+
+        Filterable message = mock(Filterable.class);
+        when(message.getArrivalTime()).thenReturn(currentTime - periodInSeconds * 1000 -
1);
+
+        assertFalse("Message arrived before '1 minute before filter creation' should not
be accepted",
+                    filter.matches(message));
+        when(message.getArrivalTime()).thenReturn(currentTime - periodInSeconds  * 1000 /
2);
+        assertTrue("Message arrived after '1 minute before filter creation' should be accepted",
+                   filter.matches(message));
+        when(message.getArrivalTime()).thenReturn(System.currentTimeMillis());
+        assertTrue("Message arrived after filter creation should be accepted", filter.matches(message));
+    }
+}
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message