Skip to content

Commit

Permalink
ARTEMIS-2761 Supporting Quoted IDs to allow complex names in AMQP
Browse files Browse the repository at this point in the history
copied/borrowed from apache/qpid-jms@fd2139c
  • Loading branch information
clebertsuconic committed May 13, 2020
1 parent 47d0b6b commit 88b7ee3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
15 changes: 15 additions & 0 deletions artemis-selector/src/main/javacc/StrictParser.jj
Expand Up @@ -131,6 +131,7 @@ TOKEN [IGNORE_CASE] :
TOKEN [IGNORE_CASE] :
{
< ID : ["a"-"z", "_", "$"] (["a"-"z","0"-"9","_", "$"])* >
| < QUOTED_ID : "\"" ( ("\"\"") | ~["\""] )* "\"" >
}

// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -556,6 +557,20 @@ PropertyExpression variable() :
{
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;
Expand Down
Expand Up @@ -192,6 +192,16 @@ public void testJMSPropertySelectors() throws Exception {
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
public void testBasicSelectors() throws Exception {
MockMessage message = createMessage();
Expand Down

0 comments on commit 88b7ee3

Please sign in to comment.