Return-Path: X-Original-To: apmail-activemq-dev-archive@www.apache.org Delivered-To: apmail-activemq-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8037E11B57 for ; Fri, 18 Jul 2014 10:07:05 +0000 (UTC) Received: (qmail 23392 invoked by uid 500); 18 Jul 2014 10:07:05 -0000 Delivered-To: apmail-activemq-dev-archive@activemq.apache.org Received: (qmail 23341 invoked by uid 500); 18 Jul 2014 10:07:05 -0000 Mailing-List: contact dev-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list dev@activemq.apache.org Received: (qmail 23287 invoked by uid 99); 18 Jul 2014 10:07:05 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Jul 2014 10:07:05 +0000 Date: Fri, 18 Jul 2014 10:07:05 +0000 (UTC) From: "Timothy Bish (JIRA)" To: dev@activemq.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Closed] (AMQ-5280) Incorrect handling of unknown values in selectors MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/AMQ-5280?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Timothy Bish closed AMQ-5280. ----------------------------- Resolution: Duplicate Appears to be an accidental duplicate. > Incorrect handling of unknown values in selectors > ------------------------------------------------- > > Key: AMQ-5280 > URL: https://issues.apache.org/jira/browse/AMQ-5280 > Project: ActiveMQ > Issue Type: Bug > Affects Versions: 5.8.0 > Reporter: Grigroy Sobko > > Due to JmsMessage specification : > http://docs.oracle.com/javaee/1.4/api/javax/jms/Message.html > There are rules how unknown Values evaluates. > There how AND operator should handle unknown: > UNKNOWN AND FALSE => FALSE > FALSE AND UNKNOWN => FALSE > And that's how it is handled in ActiveMQ: > UNKNOWN AND FALSE => UNKNOWN (!!!) > FALSE AND UNKNOWN => FALSE > I've wrote test to reproduce this: > {code} > package org.activemq.test; > import org.apache.activemq.command.ActiveMQMessage; > import org.apache.activemq.command.ActiveMQTopic; > import org.apache.activemq.filter.BooleanExpression; > import org.apache.activemq.filter.MessageEvaluationContext; > import org.apache.activemq.selector.SelectorParser; > import org.junit.Before; > import org.junit.Test; > import javax.jms.JMSException; > import javax.jms.Message; > import static org.junit.Assert.assertEquals; > import static org.junit.Assert.assertTrue; > public class SelectorUnknownHandlingTest { > private Message message; > @Before > public void setUp() throws Exception { > message = createMessage(); > } > @Test > public void testUnknown() throws Exception { > // Some unset property with gt operator => unknown > assertSelectorEvaluatesToUnknown(message, "(unknownProp > 0)"); > } > @Test > public void testUnknownAndFalse() throws Exception { > // false and unknown => false > assertSelectorEvaluatesToFalse(message, "(falseProp AND unknownProp > 0)"); > // THIS ASSERTION FAILS !! IT EVALUATES TO UNKNOWN INSTEAD > // unknown and false => false > assertSelectorEvaluatesToFalse(message, "(unknownProp > 0 AND falseProp)"); > } > @Test > public void testUnknownOrTrue() throws Exception { > // unknown or true => true > assertSelectorEvaluatesToTrue(message, "(unknownProp > 0 OR trueProp)"); > // true or unknown => true > assertSelectorEvaluatesToTrue(message, "(trueProp OR unknownProp > 0)"); > } > private void assertSelectorEvaluatesToUnknown(Message message, String selector) throws JMSException { > assertSelector(message, selector, false); > assertSelector(message, "not(" + selector + ")", false); > } > private void assertSelectorEvaluatesToFalse(Message message, String selector) throws JMSException { > assertSelector(message, selector, false); > assertSelector(message, "not(" + selector + ")", true); > } > private void assertSelectorEvaluatesToTrue(Message message, String selector) throws JMSException { > assertSelector(message, selector, true); > assertSelector(message, "not(" + selector + ")", false); > } > protected Message createMessage() throws JMSException { > Message message = createMessage("FOO.BAR"); > message.setJMSType("selector-test"); > message.setJMSMessageID("connection:1:1:1:1"); > message.setBooleanProperty("trueProp", true); > message.setBooleanProperty("falseProp", false); > return message; > } > protected void assertSelector(Message message, String text, boolean expected) throws JMSException { > BooleanExpression selector = SelectorParser.parse(text); > assertTrue("Created a valid selector", selector != null); > MessageEvaluationContext context = new MessageEvaluationContext(); > context.setMessageReference((org.apache.activemq.command.Message)message); > boolean value = selector.matches(context); > assertEquals("Selector for: " + text, expected, value); > } > protected Message createMessage(String subject) throws JMSException { > ActiveMQMessage message = new ActiveMQMessage(); > message.setJMSDestination(new ActiveMQTopic(subject)); > return message; > } > } > {code} -- This message was sent by Atlassian JIRA (v6.2#6252)