01: // -*- Mode: JDE -*-
02: /*
03: ******************************************************************
04: Copyright (c) 2001, Jeff Martin, Tim Bacon
05: All rights reserved.
06:
07: Redistribution and use in source and binary forms, with or without
08: modification, are permitted provided that the following conditions
09: are met:
10:
11: * Redistributions of source code must retain the above copyright
12: notice, this list of conditions and the following disclaimer.
13: * Redistributions in binary form must reproduce the above
14: copyright notice, this list of conditions and the following
15: disclaimer in the documentation and/or other materials provided
16: with the distribution.
17: * Neither the name of the xmlunit.sourceforge.net nor the names
18: of its contributors may be used to endorse or promote products
19: derived from this software without specific prior written
20: permission.
21:
22: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23: "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24: LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25: FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26: COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27: INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28: BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29: LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30: CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31: LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32: ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33: POSSIBILITY OF SUCH DAMAGE.
34:
35: ******************************************************************
36: */
37: package org.custommonkey.xmlunit.examples;
38:
39: public class test_XPathRegexAssert extends junit.framework.TestCase {
40:
41: public void testMatch() throws Exception {
42: XPathRegexAssert.assertXPathMatches("\\d", "/foo/text()",
43: "<foo>5</foo>");
44: }
45:
46: public void testNoMatch() throws Exception {
47: try {
48: XPathRegexAssert.assertXPathMatches("\\d", "/foo/text()",
49: "<foo>a</foo>");
50: } catch (junit.framework.AssertionFailedError e) {
51: return;
52: }
53: // if we get here, the assertion has passed
54: fail("a is not a number");
55: }
56:
57: }
|