ARTEMIS-2761 Supporting Quoted IDs to allow complex names in AMQP

copied/borrowed from fd2139c27d
This commit is contained in:
Clebert Suconic 2020-05-13 10:46:06 -04:00
parent 47d0b6b84b
commit 88b7ee36a3
2 changed files with 25 additions and 0 deletions

View File

@ -131,6 +131,7 @@ TOKEN [IGNORE_CASE] :
TOKEN [IGNORE_CASE] : TOKEN [IGNORE_CASE] :
{ {
< ID : ["a"-"z", "_", "$"] (["a"-"z","0"-"9","_", "$"])* > < ID : ["a"-"z", "_", "$"] (["a"-"z","0"-"9","_", "$"])* >
| < QUOTED_ID : "\"" ( ("\"\"") | ~["\""] )* "\"" >
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -556,6 +557,20 @@ PropertyExpression variable() :
{ {
left = new PropertyExpression(t.image); left = new PropertyExpression(t.image);
} }
|
t = <QUOTED_ID>
{
// Decode the string value.
StringBuffer rc = new StringBuffer();
String image = t.image;
for( int i=1; i < image.length()-1; i++ ) {
char c = image.charAt(i);
if( c == '"' )
i++;
rc.append(c);
}
return new PropertyExpression(rc.toString());
}
) )
{ {
return left; return left;

View File

@ -192,6 +192,16 @@ public class SelectorTest {
assertSelector(message, "JMSType = 'crap'", false); assertSelector(message, "JMSType = 'crap'", false);
} }
@Test
public void testDottedProperty() throws Exception {
MockMessage message = createMessage();
message.setJMSType("selector-test");
message.setStringProperty("a.test", "value");
message.setJMSMessageID("id:test:1:1:1:1");
assertSelector(message, "\"a.test\" = 'value'", true);
}
@Test @Test
public void testBasicSelectors() throws Exception { public void testBasicSelectors() throws Exception {
MockMessage message = createMessage(); MockMessage message = createMessage();