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.util.LinkedList;
22: import java.util.List;
23: import junit.framework.Assert;
24: import org.junit.Test;
25: import org.mactor.brokers.Message;
26: import org.mactor.extensions.xml.XPathIgnoreNsValidator;
27: import org.mactor.framework.MactorException;
28: import org.mactor.framework.TestContextImpl;
29:
30: public class XPathIgnoreNsValidatorTest {
31: @Test
32: public void test1() throws Exception {
33: List<String> l = new LinkedList<String>();
34: l.add("//x==4");
35: TestContextImpl context = new TestContextImpl(null, null);
36: context.addReceivedMessage("x", Message
37: .createMessage("<a><x>4</x></a>"));
38: XPathIgnoreNsValidator b = new XPathIgnoreNsValidator();
39: b.perform(context, l);
40: try {
41: context.addReceivedMessage("x", Message
42: .createMessage("<a><x>3</x></a>"));
43: b.perform(context, l);
44: Assert.fail();
45: } catch (MactorException me) {
46: System.out.println("SUCCESS: " + me.getMessage());
47: }
48: }
49:
50: @Test
51: public void test2() throws Exception {
52: List<String> l = new LinkedList<String>();
53: l.add("//c[@a=2]==6");
54: TestContextImpl context = new TestContextImpl(null, null);
55: context
56: .addReceivedMessage(
57: "x",
58: Message
59: .createMessage("<a><x><c a=\"1\">4</c><c a=\"2\">6</c></x></a>"));
60: XPathIgnoreNsValidator b = new XPathIgnoreNsValidator();
61: b.perform(context, l);
62: }
63:
64: }
|