Author: sebb
Date: Tue Jan 13 22:37:06 2015
New Revision: 1651527
URL: http://svn.apache.org/r1651527
Log:
Java 1.4 workround removed
Modified:
commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/DomainValidatorTest.java
Modified:
commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/DomainValidatorTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/DomainValidatorTest.java?rev=1651527&r1=1651526&r2=1651527&view=diff
==============================================================================
---
commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/DomainValidatorTest.java
(original)
+++
commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/DomainValidatorTest.java
Tue Jan 13 22:37:06 2015
@@ -23,9 +23,9 @@ import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
-import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.net.HttpURLConnection;
+import java.net.IDN;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -254,12 +254,6 @@ public class DomainValidatorTest extends
throw new IOException("File does not have expected Version
header");
}
final boolean generateUnicodeTlds = false; // Change this to generate
Unicode TLDs as well
- final Method toUnicode = getIDNMethod();
- if (toUnicode == null) {
- if (generateUnicodeTlds) {
- System.err.println("Cannot convert XN-- entries (no access to
java.net.IDN)");
- }
- }
// Parse html page to get entries
Map htmlInfo = getHtmlInfo(htmlFile);
@@ -270,16 +264,7 @@ public class DomainValidatorTest extends
final String unicodeTld; // only different from asciiTld if
that was punycode
final String asciiTld = line.toLowerCase(Locale.ENGLISH);
if (line.startsWith("XN--")) {
- if (toUnicode != null) {
- unicodeTld = toUnicode(toUnicode, line);
- } else {
- // allow the code to check for missing ASCII TLDs
- if (generateUnicodeTlds) {
- continue; // No translation possible
- } else {
- unicodeTld = "";
- }
- }
+ unicodeTld = IDN.toUnicode(line);
} else {
unicodeTld = asciiTld;
}
@@ -427,23 +412,6 @@ public class DomainValidatorTest extends
return f.lastModified();
}
- private static String toUnicode(Method m, String line) {
- try {
- return (String) m.invoke(null, new
String[]{line.toLowerCase(Locale.ENGLISH)});
- } catch (Exception e) {
- }
- return line;
- }
-
- private static Method getIDNMethod() {
- try {
- Class clazz = Class.forName("java.net.IDN", false,
DomainValidatorTest.class.getClassLoader());
- return clazz.getDeclaredMethod("toUnicode", new
Class[]{String.class});
- } catch (Exception e) {
- return null;
- }
- }
-
// isInIanaList and isSorted are split into two methods.
// If/when access to the arrays is possible without reflection, the
intermediate
// methods can be dropped