1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package com.xpn.xwiki.util

File UtilTest.java

 

Code metrics

0
25
3
1
71
43
3
0.12
8.33
3
1

Classes

Class Line # Actions
UtilTest 30 25 0% 3 0
1.0100%
 

Contributing tests

This file is covered by 3 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package com.xpn.xwiki.util;
21   
22    import org.junit.Assert;
23    import org.junit.Test;
24   
25    /**
26    * Unit tests for {@link com.xpn.xwiki.util.Util}.
27    *
28    * @version $Id: 87dcec0722f154722c8f204a4f34b058af6611f2 $
29    */
 
30    public class UtilTest
31    {
 
32  1 toggle @Test
33    public void testConvertToAlphaNumeric()
34    {
35  1 Assert.assertEquals("Search", Util.convertToAlphaNumeric("Search"));
36  1 Assert.assertEquals("Search", Util.convertToAlphaNumeric("S.earch"));
37  1 Assert.assertEquals("e", Util.convertToAlphaNumeric("e$%\u00a3#^()"));
38  1 Assert.assertEquals("e", Util.convertToAlphaNumeric(":\u0205!"));
39    }
40   
 
41  1 toggle @Test
42    public void testIsValidXMLElementName()
43    {
44  1 Assert.assertTrue(Util.isValidXMLElementName("myprop"));
45  1 Assert.assertTrue(Util.isValidXMLElementName("my_prop"));
46  1 Assert.assertTrue(Util.isValidXMLElementName("my_prop-1"));
47  1 Assert.assertTrue(Util.isValidXMLElementName("my_prop-1.1"));
48  1 Assert.assertFalse(Util.isValidXMLElementName("ns:my_prop-1"));
49  1 Assert.assertFalse(Util.isValidXMLElementName("1prop"));
50  1 Assert.assertFalse(Util.isValidXMLElementName("xmlprop"));
51  1 Assert.assertFalse(Util.isValidXMLElementName("XMLprop"));
52  1 Assert.assertFalse(Util.isValidXMLElementName("xMLprop"));
53  1 Assert.assertFalse(Util.isValidXMLElementName("Xmlprop"));
54  1 Assert.assertFalse(Util.isValidXMLElementName("ns my_prop"));
55  1 Assert.assertFalse(Util.isValidXMLElementName("ns,my_prop"));
56    }
57   
 
58  1 toggle @Test
59    public void testNormalizeLanguage()
60    {
61  1 Assert.assertNull(Util.normalizeLanguage(null));
62  1 Assert.assertEquals("", Util.normalizeLanguage(""));
63  1 Assert.assertEquals("", Util.normalizeLanguage(" "));
64  1 Assert.assertEquals("default", Util.normalizeLanguage("default"));
65  1 Assert.assertEquals("default", Util.normalizeLanguage("DeFault"));
66  1 Assert.assertEquals("default", Util.normalizeLanguage("invalid code"));
67  1 Assert.assertEquals("en", Util.normalizeLanguage("en"));
68  1 Assert.assertEquals("en", Util.normalizeLanguage("En_"));
69  1 Assert.assertEquals("de_AT", Util.normalizeLanguage("DE_at"));
70    }
71    }