提交 cdd9bc91 编写于 作者: X xyin

8198931: remove java.xml.bind module dependency for com/sun/jndi tests

Reviewed-by: lancea
上级 a3351fb5
......@@ -26,8 +26,7 @@
* @bug 8195976
* @summary Tests that we can get the attributes of a DNS entry using special
* qualifiers.
* @modules java.xml.bind
* java.base/sun.security.util
* @modules java.base/sun.security.util
* @library ../lib/
* @build DNSTestUtils DNSServer DNSTracer
* @run main GetAny
......
......@@ -23,7 +23,6 @@
import sun.security.util.HexDumpEncoder;
import javax.xml.bind.DatatypeConverter;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
......@@ -196,7 +195,7 @@ public class DNSServer implements Runnable {
* Add an DNS encoding to the cache (by request message key).
*/
private void addToCache(String hexString) {
byte[] encoding = DatatypeConverter.parseHexBinary(hexString);
byte[] encoding = parseHexBinary(hexString);
if (encoding.length < DNS_HEADER_SIZE) {
throw new RuntimeException("Invalid DNS message : " + hexString);
}
......@@ -261,4 +260,43 @@ public class DNSServer implements Runnable {
return payload;
}
public static byte[] parseHexBinary(String s) {
final int len = s.length();
// "111" is not a valid hex encoding.
if (len % 2 != 0) {
throw new IllegalArgumentException(
"hexBinary needs to be even-length: " + s);
}
byte[] out = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
int h = hexToBin(s.charAt(i));
int l = hexToBin(s.charAt(i + 1));
if (h == -1 || l == -1) {
throw new IllegalArgumentException(
"contains illegal character for hexBinary: " + s);
}
out[i / 2] = (byte) (h * 16 + l);
}
return out;
}
private static int hexToBin(char ch) {
if ('0' <= ch && ch <= '9') {
return ch - '0';
}
if ('A' <= ch && ch <= 'F') {
return ch - 'A' + 10;
}
if ('a' <= ch && ch <= 'f') {
return ch - 'a' + 10;
}
return -1;
}
}
......@@ -26,11 +26,10 @@
* @bug 8196770
* @summary Verify capability to add a new entry to the directory using the
* ADD operation.
* @modules java.xml.bind
* java.naming/com.sun.jndi.ldap
* @modules java.naming/com.sun.jndi.ldap
* @library ../../lib/ /javax/naming/module/src/test/test/
* @build LDAPServer LDAPTestUtils
* @run main AddNewEntry
* @run main/othervm AddNewEntry
*/
import javax.naming.NamingEnumeration;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册