source: trunk/java-utils-test/src/test/java/de/ugoe/cs/util/StringToolsTest.java @ 927

Last change on this file since 927 was 927, checked in by sherbold, 12 years ago
  • added copyright under the Apache License, Version 2.0
  • Property svn:mime-type set to text/plain
File size: 4.1 KB
Line 
1//   Copyright 2012 Georg-August-Universität Göttingen, Germany
2//
3//   Licensed under the Apache License, Version 2.0 (the "License");
4//   you may not use this file except in compliance with the License.
5//   You may obtain a copy of the License at
6//
7//       http://www.apache.org/licenses/LICENSE-2.0
8//
9//   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
15package de.ugoe.cs.util;
16
17import org.junit.*;
18import static org.junit.Assert.*;
19
20/**
21 * The class <code>StringToolsTest</code> contains tests for the class
22 * <code>{@link StringTools}</code>.
23 *
24 * @author Steffen Herbold
25 * @version 1.0
26 */
27public class StringToolsTest {
28
29        @Test
30        public void testXmlEntityReplacement_1() throws Exception {
31                String str = "abc";
32
33                String result = StringTools.xmlEntityReplacement(str);
34
35                // add additional test code here
36                assertEquals("abc", result);
37        }
38
39        @Test
40        public void testXmlEntityReplacement_2() throws Exception {
41                String str = "a&bc";
42                String result = StringTools.xmlEntityReplacement(str);
43                assertEquals("a&amp;bc", result);
44        }
45
46        @Test
47        public void testXmlEntityReplacement_3() throws Exception {
48                String str = "a\"bc";
49                String result = StringTools.xmlEntityReplacement(str);
50                assertEquals("a&quot;bc", result);
51        }
52
53        @Test
54        public void testXmlEntityReplacement_4() throws Exception {
55                String str = "a'bc";
56                String result = StringTools.xmlEntityReplacement(str);
57                assertEquals("a&apos;bc", result);
58        }
59
60        @Test
61        public void testXmlEntityReplacement_5() throws Exception {
62                String str = "a<bc";
63                String result = StringTools.xmlEntityReplacement(str);
64                assertEquals("a&lt;bc", result);
65        }
66
67        @Test
68        public void testXmlEntityReplacement_6() throws Exception {
69                String str = "a>bc";
70                String result = StringTools.xmlEntityReplacement(str);
71                assertEquals("a&gt;bc", result);
72        }
73
74        @Test
75        public void testXmlEntityReplacement_7() throws Exception {
76                String str = "a&amp;bc";
77                String result = StringTools.xmlEntityReplacement(str);
78                assertEquals("a&amp;bc", result);
79        }
80
81        @Test
82        public void testXmlEntityReplacement_8() throws Exception {
83                String str = "a&quot;bc";
84                String result = StringTools.xmlEntityReplacement(str);
85                assertEquals("a&quot;bc", result);
86        }
87
88        @Test
89        public void testXmlEntityReplacement_9() throws Exception {
90                String str = "a&apos;bc";
91                String result = StringTools.xmlEntityReplacement(str);
92                assertEquals("a&apos;bc", result);
93        }
94
95        @Test
96        public void testXmlEntityReplacement_10() throws Exception {
97                String str = "a&lt;bc";
98                String result = StringTools.xmlEntityReplacement(str);
99                assertEquals("a&lt;bc", result);
100        }
101
102        @Test
103        public void testXmlEntityReplacement_11() throws Exception {
104                String str = "a&gt;bc";
105                String result = StringTools.xmlEntityReplacement(str);
106                assertEquals("a&gt;bc", result);
107        }
108
109        @Test
110        public void testXmlEntityReplacement_12() throws Exception {
111                String str = "a&foo;bc";
112                String result = StringTools.xmlEntityReplacement(str);
113                assertEquals("a&amp;foo;bc", result);
114        }
115
116        @Test
117        public void testXmlEntityReplacement_13() throws Exception {
118                String str = "a&b&c";
119                String result = StringTools.xmlEntityReplacement(str);
120                assertEquals("a&amp;b&amp;c", result);
121        }
122       
123        @Test
124        public void testXmlEntityReplacement_14() throws Exception {
125                String str = "";
126                String result = StringTools.xmlEntityReplacement(str);
127                assertEquals("", result);
128        }
129       
130        @Test
131        public void testXmlEntityReplacement_15() throws Exception {
132                String str = null;
133                String result = StringTools.xmlEntityReplacement(str);
134                assertNull(result);
135        }
136
137        @Before
138        public void setUp() throws Exception {
139                // add additional set up code here
140        }
141
142        @After
143        public void tearDown() throws Exception {
144                // Add additional tear down code here
145        }
146
147        public static void main(String[] args) {
148                new org.junit.runner.JUnitCore().run(StringToolsTest.class);
149        }
150}
Note: See TracBrowser for help on using the repository browser.