Search in sources :

Example 1 with BooleanExpression

use of org.apache.activemq.filter.BooleanExpression in project activemq-artemis by apache.

the class SelectorParserTest method testParseXPath.

public void testParseXPath() throws Exception {
    BooleanExpression filter = parse("XPATH '//title[@lang=''eng'']'");
    assertTrue("Created XPath expression", filter instanceof XPathExpression);
    LOG.info("Expression: " + filter);
}
Also used : XPathExpression(org.apache.activemq.filter.XPathExpression) BooleanExpression(org.apache.activemq.filter.BooleanExpression)

Example 2 with BooleanExpression

use of org.apache.activemq.filter.BooleanExpression in project activemq-artemis by apache.

the class SelectorTest method assertSelector.

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);
}
Also used : BooleanExpression(org.apache.activemq.filter.BooleanExpression) MessageEvaluationContext(org.apache.activemq.filter.MessageEvaluationContext)

Example 3 with BooleanExpression

use of org.apache.activemq.filter.BooleanExpression in project activemq-artemis by apache.

the class SelectorParserTest method testParseWithParensAround.

public void testParseWithParensAround() throws Exception {
    String[] values = { "x = 1 and y = 2", "(x = 1) and (y = 2)", "((x = 1) and (y = 2))" };
    for (int i = 0; i < values.length; i++) {
        String value = values[i];
        LOG.info("Parsing: " + value);
        BooleanExpression andExpression = parse(value);
        assertTrue("Created LogicExpression expression", andExpression instanceof LogicExpression);
        LogicExpression logicExpression = (LogicExpression) andExpression;
        Expression left = logicExpression.getLeft();
        Expression right = logicExpression.getRight();
        assertTrue("Left is a binary filter", left instanceof ComparisonExpression);
        assertTrue("Right is a binary filter", right instanceof ComparisonExpression);
        ComparisonExpression leftCompare = (ComparisonExpression) left;
        ComparisonExpression rightCompare = (ComparisonExpression) right;
        assertPropertyExpression("left", leftCompare.getLeft(), "x");
        assertPropertyExpression("right", rightCompare.getLeft(), "y");
    }
}
Also used : ComparisonExpression(org.apache.activemq.filter.ComparisonExpression) BooleanExpression(org.apache.activemq.filter.BooleanExpression) Expression(org.apache.activemq.filter.Expression) XPathExpression(org.apache.activemq.filter.XPathExpression) ComparisonExpression(org.apache.activemq.filter.ComparisonExpression) PropertyExpression(org.apache.activemq.filter.PropertyExpression) LogicExpression(org.apache.activemq.filter.LogicExpression) BooleanExpression(org.apache.activemq.filter.BooleanExpression) LogicExpression(org.apache.activemq.filter.LogicExpression)

Example 4 with BooleanExpression

use of org.apache.activemq.filter.BooleanExpression in project activemq-artemis by apache.

the class UnknownHandlingSelectorTest method assertSelector.

protected void assertSelector(String text, boolean matches) 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, matches, value);
}
Also used : BooleanExpression(org.apache.activemq.filter.BooleanExpression) MessageEvaluationContext(org.apache.activemq.filter.MessageEvaluationContext)

Aggregations

BooleanExpression (org.apache.activemq.filter.BooleanExpression)4 MessageEvaluationContext (org.apache.activemq.filter.MessageEvaluationContext)2 XPathExpression (org.apache.activemq.filter.XPathExpression)2 ComparisonExpression (org.apache.activemq.filter.ComparisonExpression)1 Expression (org.apache.activemq.filter.Expression)1 LogicExpression (org.apache.activemq.filter.LogicExpression)1 PropertyExpression (org.apache.activemq.filter.PropertyExpression)1