01: /**********************************************************************
02: Copyright (c) 2004 Erik Bengtson and others. All rights reserved.
03: Licensed under the Apache License, Version 2.0 (the "License");
04: you may not use this file except in compliance with the License.
05: You may obtain a copy of the License at
06:
07: http://www.apache.org/licenses/LICENSE-2.0
08:
09: Unless required by applicable law or agreed to in writing, software
10: distributed under the License is distributed on an "AS IS" BASIS,
11: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: See the License for the specific language governing permissions and
13: limitations under the License.
14:
15:
16: Contributors:
17: ...
18: **********************************************************************/package org.jpox.store.expression;
19:
20: import org.jpox.store.expression.MatchExpressionParser;
21:
22: import junit.framework.TestCase;
23:
24: /**
25: * Series of tests for the String "matches" function.
26: * @version $Revision: 1.4 $
27: */
28: public class MatchExpressionParserTest extends TestCase {
29: public void testParsePattern() {
30: //testZZteteAAyyy.dede\--
31: String str = "test.*tete.yyy\\.dede\\\\--";
32: MatchExpressionParser parser = new MatchExpressionParser(str,
33: 'Z', 'A', '\\');
34: String parsed = parser.parsePattern();
35: String str_correct = "testZteteAyyy.dede\\\\\\\\--";
36: assertTrue("Parsing mised expression gave erroneous string : "
37: + parsed + " but should have been " + str_correct,
38: parsed.equals(str_correct));
39:
40: // Empty string
41: MatchExpressionParser parser2 = new MatchExpressionParser("",
42: 'Z', 'A', '\\');
43: assertEquals("", parser2.parsePattern());
44:
45: // Any character
46: str = ".output.";
47: MatchExpressionParser parser3 = new MatchExpressionParser(
48: ".putput.", 'Z', 'A', '\\');
49: parsed = parser3.parsePattern();
50: str_correct = "AputputA";
51: assertEquals(str_correct, parsed);
52:
53: // "slash\city"
54: str = "\"slash\\city\"";
55: MatchExpressionParser parser4 = new MatchExpressionParser(str,
56: 'Z', 'A', '\\');
57: parsed = parser4.parsePattern();
58: str_correct = "\"slash\\\\city\"";
59: assertEquals(str_correct, parsed);
60: }
61: }
|