This project has retired. For details please refer to its
Attic page.
StringUtilTest xref
1/*2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements. See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership. The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License. You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing,13 * software distributed under the License is distributed on an14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY15 * KIND, either express or implied. See the License for the16 * specific language governing permissions and limitations17 * under the License.18 */19package org.apache.chemistry.opencmis.server.support.query;
2021importstatic org.junit.Assert.*;
2223import org.junit.Test;
2425publicclassStringUtilTest {
2627 @Test
28publicvoid testUnescape() {
29 String s = "abc";
30 String res = StringUtil.unescape(s, null);
31 assertEquals("abc", res);
3233 s="ab\\\\c";
34 res = StringUtil.unescape(s, null);
35 assertEquals("ab\\c", res);
3637 s="ab\\'c";
38 res = StringUtil.unescape(s, null);
39 assertEquals("ab'c", res);
4041 s="ab\\'";
42 res = StringUtil.unescape(s, null);
43 assertEquals("ab'", res);
4445 s="\\\\abc";
46 res = StringUtil.unescape(s, null);
47 assertEquals("\\abc", res);
4849 s="abc\\\\";
50 res = StringUtil.unescape(s, null);
51 assertEquals("abc\\", res);
5253 s="abc\\";
54 res = StringUtil.unescape(s, null);
55 assertNull(res);
5657 s="ab\\xc";
58 res = StringUtil.unescape(s, null);
59 assertNull(res);
6061 s="ab\\xc";
62 res = StringUtil.unescape(s, "\\'x");
63 assertEquals("abxc", res);
6465 s="abc\\x";
66 res = StringUtil.unescape(s, "\\'x");
67 assertEquals("abcx", res);
6869 s="ab\\yc";
70 res = StringUtil.unescape(s, "\\'x");
71 assertNull(res);
7273// double escaping74 s="ab\\\\\\\\c";
75 res = StringUtil.unescape(s, null);
76 assertEquals("ab\\\\c", res);
7778 s="ab\\\\'c";
79 res = StringUtil.unescape(s, null);
80 assertEquals("ab\\'c", res);
8182 s="ab\\'Johnny\\'c";
83 res = StringUtil.unescape(s, null);
84 assertEquals("ab'Johnny'c", res);
8586 s="ab\\\\'Johnny\\\\'c";
87 res = StringUtil.unescape(s, null);
88 assertEquals("ab\\'Johnny\\'c", res);
8990 s="\\\\";
91 res = StringUtil.unescape(s, null);
92 assertEquals("\\", res);
9394 s="\\";
95 res = StringUtil.unescape(s, null);
96 assertNull(res);
9798 s="a";
99 res = StringUtil.unescape(s, null);
100 assertEquals("a", res);
101102 s="";
103 res = StringUtil.unescape(s, null);
104 assertEquals("", res);
105106 res = StringUtil.unescape(null, null);
107 assertNull(res);
108 }
109110 }