Author: timfox
Date: 2010-09-24 08:16:25 -0400 (Fri, 24 Sep 2010)
New Revision: 9722
Modified:
trunk/src/main/org/hornetq/jms/client/SelectorTranslator.java
trunk/tests/jms-tests/src/org/hornetq/jms/tests/selector/SelectorTest.java
trunk/tests/src/org/hornetq/tests/unit/jms/client/SelectorTranslatorTest.java
Log:
https://jira.jboss.org/browse/HORNETQ-528
Modified: trunk/src/main/org/hornetq/jms/client/SelectorTranslator.java
===================================================================
--- trunk/src/main/org/hornetq/jms/client/SelectorTranslator.java 2010-09-24 07:35:56 UTC
(rev 9721)
+++ trunk/src/main/org/hornetq/jms/client/SelectorTranslator.java 2010-09-24 12:16:25 UTC
(rev 9722)
@@ -50,6 +50,7 @@
filterString = SelectorTranslator.parse(filterString, "JMSPriority",
"HQPriority");
filterString = SelectorTranslator.parse(filterString, "JMSTimestamp",
"HQTimestamp");
filterString = SelectorTranslator.parse(filterString, "JMSMessageID",
"HQUserID");
+ filterString = SelectorTranslator.parse(filterString, "JMSExpiration",
"HQExpiration");
return filterString;
Modified: trunk/tests/jms-tests/src/org/hornetq/jms/tests/selector/SelectorTest.java
===================================================================
--- trunk/tests/jms-tests/src/org/hornetq/jms/tests/selector/SelectorTest.java 2010-09-24
07:35:56 UTC (rev 9721)
+++ trunk/tests/jms-tests/src/org/hornetq/jms/tests/selector/SelectorTest.java 2010-09-24
12:16:25 UTC (rev 9722)
@@ -846,6 +846,54 @@
}
}
+ public void testJMSExpirationOnSelector() throws Exception
+ {
+ Connection conn = null;
+
+ try
+ {
+ conn = getConnectionFactory().createConnection();
+ conn.start();
+
+ Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer prod = session.createProducer(HornetQServerTestCase.queue1);
+
+ TextMessage msg1 = session.createTextMessage("msg1");
+ prod.send(msg1);
+
+ prod.setTimeToLive(100000);
+
+ TextMessage msg2 = session.createTextMessage("msg2");
+
+ prod.send(msg2);
+
+ long expire = msg2.getJMSExpiration();
+
+ String selector = "JMSExpiration = " + expire;
+
+ MessageConsumer cons = session.createConsumer(HornetQServerTestCase.queue1,
selector);
+
+ conn.start();
+
+ TextMessage rec = (TextMessage)cons.receive(10000);
+
+ assertNotNull(rec);
+
+ assertEquals("msg2", rec.getText());
+
+ assertNull(cons.receiveNoWait());
+
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ }
+ }
+
public void testJMSTypeOnSelector() throws Exception
{
Connection conn = null;
Modified: trunk/tests/src/org/hornetq/tests/unit/jms/client/SelectorTranslatorTest.java
===================================================================
---
trunk/tests/src/org/hornetq/tests/unit/jms/client/SelectorTranslatorTest.java 2010-09-24
07:35:56 UTC (rev 9721)
+++
trunk/tests/src/org/hornetq/tests/unit/jms/client/SelectorTranslatorTest.java 2010-09-24
12:16:25 UTC (rev 9722)
@@ -141,7 +141,31 @@
SelectorTranslator.convertToHornetQFilterString(selector));
}
+
+ public void testParseJMSExpiration()
+ {
+ String selector = "JMSExpiration=12345678";
+ Assert.assertEquals("HQExpiration=12345678",
SelectorTranslator.convertToHornetQFilterString(selector));
+
+ selector = " JMSExpiration=12345678";
+
+ Assert.assertEquals(" HQExpiration=12345678",
SelectorTranslator.convertToHornetQFilterString(selector));
+
+ selector = " JMSExpiration=12345678 OR 78766 = JMSExpiration AND
(JMSExpiration= 1 + 4878787)";
+
+ Assert.assertEquals(" HQExpiration=12345678 OR 78766 = HQExpiration AND
(HQExpiration= 1 + 4878787)",
+ SelectorTranslator.convertToHornetQFilterString(selector));
+
+ checkNoSubstitute("JMSExpiration");
+
+ selector = "animal = 'lion' JMSExpiration = 321 OR animal_name =
'xyzJMSExpirationxyz'";
+
+ Assert.assertEquals("animal = 'lion' HQExpiration = 321 OR animal_name
= 'xyzJMSExpirationxyz'",
+ SelectorTranslator.convertToHornetQFilterString(selector));
+
+ }
+
public void testParseJMSCorrelationID()
{
String selector = "JMSCorrelationID='ID:HQ-12435678";
@@ -191,6 +215,8 @@
checkNoSubstitute("JMSType");
}
+
+
// Private
-------------------------------------------------------------------------------------