01: /******************************************************************************
02: * Copyright (C) Lars Ivar Almli. All rights reserved. *
03: * ---------------------------------------------------------------------------*
04: * This file is part of MActor. *
05: * *
06: * MActor is free software; you can redistribute it and/or modify *
07: * it under the terms of the GNU General Public License as published by *
08: * the Free Software Foundation; either version 2 of the License, or *
09: * (at your option) any later version. *
10: * *
11: * MActor is distributed in the hope that it will be useful, *
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14: * GNU General Public License for more details. *
15: * *
16: * You should have received a copy of the GNU General Public License *
17: * along with MActor; if not, write to the Free Software *
18: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
19: ******************************************************************************/package org.mactor.tests;
20:
21: import java.io.File;
22: import java.util.LinkedList;
23: import java.util.List;
24: import junit.framework.Assert;
25: import org.junit.Test;
26: import org.mactor.brokers.Message;
27: import org.mactor.extensions.xml.XPathIgnoreNsMessageSelector;
28:
29: public class XPathIgnoreNsMessageSelectorTest {
30: @Test
31: public void test() throws Exception {
32: XPathIgnoreNsMessageSelector b = new XPathIgnoreNsMessageSelector();
33: List<String> l = new LinkedList<String>();
34: l.add("//x==3");
35: b.setParams(l);
36: Assert.assertFalse(b.isAcceptableMessage(Message
37: .createMessage("<a><x>11</x></a>")));
38: Assert.assertTrue(b.isAcceptableMessage(Message
39: .createMessage("<a><x>3</x></a>")));
40: b = new XPathIgnoreNsMessageSelector();
41: l = new LinkedList<String>();
42: l.add("/a/x==3");
43: b.setParams(l);
44: Assert.assertFalse(b.isAcceptableMessage(Message
45: .createMessage("<a><x>11</x></a>")));
46: Assert.assertTrue(b.isAcceptableMessage(Message
47: .createMessage("<a><x>3</x></a>")));
48: }
49:
50: @Test
51: public void test2() throws Exception {
52: XPathIgnoreNsMessageSelector b = new XPathIgnoreNsMessageSelector();
53: List<String> l = new LinkedList<String>();
54: l.add("//x==3.*");
55: b.setParams(l);
56: Assert.assertFalse(b.isAcceptableMessage(Message
57: .createMessage("<a><x>11</x></a>")));
58: Assert.assertTrue(b.isAcceptableMessage(Message
59: .createMessage("<a><x>3;lkdjsaldlak</x></a>")));
60:
61: }
62:
63: /* private XPathIgnoreNsMessageSelector getSel() throws Exception {
64: XPathIgnoreNsMessageSelector sel = new XPathIgnoreNsMessageSelector();
65: List<String> params = new LinkedList<String>();
66: params.add("//MessageId==xxx");
67: sel.setParams(params);
68: return sel;
69: }
70: @Test
71: public void testNoNs() throws Exception {
72: Assert.assertTrue(getSel().isAcceptableMessage(Message.createMessage(new File("tests/mactor_sample_test/templates/order_status.xml"))));
73: }
74: @Test
75: public void testDefNs() throws Exception {
76: Assert.assertTrue(getSel().isAcceptableMessage(Message.createMessage(new File("tests/mactor_sample_test/templates/order_status_def_ns.xml"))));
77: }
78: @Test
79: public void testNs() throws Exception {
80: Assert.assertTrue(getSel().isAcceptableMessage(Message.createMessage(new File("tests/mactor_sample_test/templates/order_status_ns.xml"))));
81: }
82: */
83:
84: }
|