You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ba...@apache.org on 2009/07/21 01:28:46 UTC
svn commit: r796062 - in
/commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate:
EntityArraysTest.java EscapeUtilsTest.java NumericEntityEscaperTest.java
UnescapeUtilsTest.java UnicodeEscaperTest.java UnicodeUnescaperTest.java
Author: bayard
Date: Mon Jul 20 23:28:45 2009
New Revision: 796062
URL: http://svn.apache.org/viewvc?rev=796062&view=rev
Log:
Improving code coverage with more tests
Added:
commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/EntityArraysTest.java (with props)
commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/EscapeUtilsTest.java (with props)
commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/NumericEntityEscaperTest.java (with props)
commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/UnescapeUtilsTest.java (with props)
commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/UnicodeEscaperTest.java (with props)
commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/UnicodeUnescaperTest.java (with props)
Added: commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/EntityArraysTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/EntityArraysTest.java?rev=796062&view=auto
==============================================================================
--- commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/EntityArraysTest.java (added)
+++ commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/EntityArraysTest.java Mon Jul 20 23:28:45 2009
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.lang.text.translate;
+
+import junit.framework.TestCase;
+
+import java.io.StringWriter;
+import java.io.IOException;
+
+/**
+ * Unit tests for {@link org.apache.commons.lang.text.translate.EntityArrays}.
+ */
+public class EntityArraysTest extends TestCase {
+
+ public void testConstructorExists() {
+ new EntityArrays();
+ }
+}
Propchange: commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/EntityArraysTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/EscapeUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/EscapeUtilsTest.java?rev=796062&view=auto
==============================================================================
--- commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/EscapeUtilsTest.java (added)
+++ commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/EscapeUtilsTest.java Mon Jul 20 23:28:45 2009
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.lang.text.translate;
+
+import junit.framework.TestCase;
+
+import java.io.StringWriter;
+import java.io.IOException;
+
+/**
+ * Unit tests for {@link org.apache.commons.lang.text.translate.EscapeUtils}.
+ */
+public class EscapeUtilsTest extends TestCase {
+
+ public void testConstructorExists() {
+ new EscapeUtils();
+ }
+}
Propchange: commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/EscapeUtilsTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/NumericEntityEscaperTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/NumericEntityEscaperTest.java?rev=796062&view=auto
==============================================================================
--- commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/NumericEntityEscaperTest.java (added)
+++ commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/NumericEntityEscaperTest.java Mon Jul 20 23:28:45 2009
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.lang.text.translate;
+
+import junit.framework.TestCase;
+
+import java.io.StringWriter;
+import java.io.IOException;
+
+/**
+ * Unit tests for {@link org.apache.commons.lang.text.translate.NumericEntityEscaper}.
+ */
+public class NumericEntityEscaperTest extends TestCase {
+
+ public void testBelow() throws IOException {
+ NumericEntityEscaper nee = NumericEntityEscaper.below('F');
+
+ String input = "ADFGZ";
+ String result = nee.translate(input);
+ assertEquals("Failed to escape numeric entities via the below method", "ADFGZ", result);
+ }
+
+ public void testBetween() throws IOException {
+ NumericEntityEscaper nee = NumericEntityEscaper.between('F', 'L');
+
+ String input = "ADFGZ";
+ String result = nee.translate(input);
+ assertEquals("Failed to escape numeric entities via the between method", "ADFGZ", result);
+ }
+
+ public void testAbove() throws IOException {
+ NumericEntityEscaper nee = NumericEntityEscaper.above('F');
+
+ String input = "ADFGZ";
+ String result = nee.translate(input);
+ assertEquals("Failed to escape numeric entities via the above method", "ADFGZ", result);
+ }
+}
Propchange: commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/NumericEntityEscaperTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/UnescapeUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/UnescapeUtilsTest.java?rev=796062&view=auto
==============================================================================
--- commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/UnescapeUtilsTest.java (added)
+++ commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/UnescapeUtilsTest.java Mon Jul 20 23:28:45 2009
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.lang.text.translate;
+
+import junit.framework.TestCase;
+
+import java.io.StringWriter;
+import java.io.IOException;
+
+/**
+ * Unit tests for {@link org.apache.commons.lang.text.translate.UnescapeUtils}.
+ */
+public class UnescapeUtilsTest extends TestCase {
+
+ public void testConstructorExists() {
+ new UnescapeUtils();
+ }
+}
Propchange: commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/UnescapeUtilsTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/UnicodeEscaperTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/UnicodeEscaperTest.java?rev=796062&view=auto
==============================================================================
--- commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/UnicodeEscaperTest.java (added)
+++ commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/UnicodeEscaperTest.java Mon Jul 20 23:28:45 2009
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.lang.text.translate;
+
+import junit.framework.TestCase;
+
+import java.io.StringWriter;
+import java.io.IOException;
+
+/**
+ * Unit tests for {@link org.apache.commons.lang.text.translate.UnicodeEscaper}.
+ */
+public class UnicodeEscaperTest extends TestCase {
+
+ public void testBelow() throws IOException {
+ UnicodeEscaper nee = UnicodeEscaper.below('F');
+
+ String input = "ADFGZ";
+ String result = nee.translate(input);
+ assertEquals("Failed to escape unicode characters via the below method", "\\u0041\\u0044FGZ", result);
+ }
+
+ public void testBetween() throws IOException {
+ UnicodeEscaper nee = UnicodeEscaper.between('F', 'L');
+
+ String input = "ADFGZ";
+ String result = nee.translate(input);
+ assertEquals("Failed to escape unicode characters via the between method", "AD\\u0046\\u0047Z", result);
+ }
+
+ public void testAbove() throws IOException {
+ UnicodeEscaper nee = UnicodeEscaper.above('F');
+
+ String input = "ADFGZ";
+ String result = nee.translate(input);
+ assertEquals("Failed to escape unicode characters via the above method", "ADF\\u0047\\u005A", result);
+ }
+}
Propchange: commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/UnicodeEscaperTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/UnicodeUnescaperTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/UnicodeUnescaperTest.java?rev=796062&view=auto
==============================================================================
--- commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/UnicodeUnescaperTest.java (added)
+++ commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/UnicodeUnescaperTest.java Mon Jul 20 23:28:45 2009
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.lang.text.translate;
+
+import junit.framework.TestCase;
+
+import java.io.StringWriter;
+import java.io.IOException;
+
+/**
+ * Unit tests for {@link org.apache.commons.lang.text.translate.UnicodeEscaper}.
+ */
+public class UnicodeUnescaperTest extends TestCase {
+
+ public void testUuuuu() throws IOException {
+ UnicodeUnescaper uu = new UnicodeUnescaper();
+
+ String input = "\\uuuuuuuu0047";
+ String result = uu.translate(input);
+ assertEquals("Failed to unescape unicode characters with many 'u' characters", "G", result);
+ }
+
+ public void testLessThanFour() throws IOException {
+ UnicodeUnescaper uu = new UnicodeUnescaper();
+
+ String input = "\\0047\\u006";
+ try {
+ uu.translate(input);
+ fail("A lack of digits in a unicode escape sequence failed to throw an exception");
+ } catch(IllegalArgumentException iae) {
+ // expected
+ }
+ }
+}
Propchange: commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/UnicodeUnescaperTest.java
------------------------------------------------------------------------------
svn:eol-style = native