public class XPathTransformerTest extends XMLTestCase {
public void testXpathQos() throws Exception {
ServerScope scope = new ServerScope();
Global glob = scope;
XPathFilter filter = new XPathFilter();
filter.initialize(scope);
String content = "SomethingFancy";
String queryStr = "/qos";
String qos = "<qos/>";
MsgUnit msgUnit = new MsgUnit("<key oid='Hello'/>", content, qos);
msgUnit.getQosData().setRcvTimestamp(new Timestamp());
SessionInfo sessionInfo = null;
PluginInfo info = new PluginInfo(glob, null, "XPathFilter", "1.0");
info.getParameters().put(XPathFilter.MATCH_AGAINST_QOS, ""+true);
filter.init(glob, info);
{
Query query = new Query(glob, queryStr);
boolean ret = filter.match(sessionInfo, msgUnit, query);
System.out.println("Match: " + ret + "\nResult: " + msgUnit.getQos());
assertTrue(queryStr + " should match", ret);
}
{
queryStr = "/a";
Query query = new Query(glob, queryStr);
boolean ret = filter.match(sessionInfo, msgUnit, query);
System.out.println("Match: " + ret + "\nResult: " + msgUnit.getQos());
assertFalse(queryStr + " shouldn't match", ret);
}
}