Author: asoldano
Date: 2015-03-12 10:06:19 -0400 (Thu, 12 Mar 2015)
New Revision: 19557
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3713/ClientServlet.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3713/ClientServletUsignThreadLocal.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/wsf/test/TestServlet.java
Log:
Fix a bunch of failures with IPv6
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3713/ClientServlet.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3713/ClientServlet.java 2015-03-12
11:37:00 UTC (rev 19556)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3713/ClientServlet.java 2015-03-12
14:06:19 UTC (rev 19557)
@@ -24,6 +24,9 @@
import java.io.IOException;
import java.io.PrintWriter;
import java.net.URL;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
@@ -35,6 +38,19 @@
public class ClientServlet extends HttpServlet
{
private static final long serialVersionUID = 1L;
+ private static final Pattern VALID_IPV6_PATTERN;
+ private static final String ipv6Pattern =
"^([\\dA-F]{1,4}:|((?=.*(::))(?!.*\\3.+\\3))\\3?)([\\dA-F]{1,4}(\\3|:\\b)|\\2){5}(([\\dA-F]{1,4}(\\3|:\\b|$)|\\2){2}|(((2[0-4]|1\\d|[1-9])?\\d|25[0-5])\\.?\\b){4})\\z";
+ static
+ {
+ try
+ {
+ VALID_IPV6_PATTERN = Pattern.compile(ipv6Pattern, Pattern.CASE_INSENSITIVE);
+ }
+ catch (PatternSyntaxException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException
@@ -53,8 +69,24 @@
throw new ServletException("calls not specified!");
PrintWriter w = res.getWriter();
- final URL wsdlURL = new URL("http://" + req.getLocalAddr() +
":" + req.getLocalPort() + path + "?wsdl");
+ final URL wsdlURL = new URL("http://" +
toIPv6URLFormat(req.getLocalAddr()) + ":" + req.getLocalPort() + path +
"?wsdl");
Helper helper = new Helper();
w.write(helper.run(wsdlURL, strategy, Integer.parseInt(threads),
Integer.parseInt(calls)).toString());
}
+
+ private String toIPv6URLFormat(final String host)
+ {
+ boolean isIPv6URLFormatted = false;
+ //strip out IPv6 URL formatting if already provided...
+ if (host.startsWith("[") && host.endsWith("]")) {
+ isIPv6URLFormatted = true;
+ }
+ //return IPv6 URL formatted address
+ if (isIPv6URLFormatted) {
+ return host;
+ } else {
+ Matcher m = VALID_IPV6_PATTERN.matcher(host);
+ return m.matches() ? "[" + host + "]" : host;
+ }
+ }
}
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3713/ClientServletUsignThreadLocal.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3713/ClientServletUsignThreadLocal.java 2015-03-12
11:37:00 UTC (rev 19556)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3713/ClientServletUsignThreadLocal.java 2015-03-12
14:06:19 UTC (rev 19557)
@@ -24,6 +24,9 @@
import java.io.IOException;
import java.io.PrintWriter;
import java.net.URL;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
@@ -35,6 +38,19 @@
public class ClientServletUsignThreadLocal extends HttpServlet
{
private static final long serialVersionUID = 1L;
+ private static final Pattern VALID_IPV6_PATTERN;
+ private static final String ipv6Pattern =
"^([\\dA-F]{1,4}:|((?=.*(::))(?!.*\\3.+\\3))\\3?)([\\dA-F]{1,4}(\\3|:\\b)|\\2){5}(([\\dA-F]{1,4}(\\3|:\\b|$)|\\2){2}|(((2[0-4]|1\\d|[1-9])?\\d|25[0-5])\\.?\\b){4})\\z";
+ static
+ {
+ try
+ {
+ VALID_IPV6_PATTERN = Pattern.compile(ipv6Pattern, Pattern.CASE_INSENSITIVE);
+ }
+ catch (PatternSyntaxException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException
@@ -53,8 +69,24 @@
throw new ServletException("calls not specified!");
PrintWriter w = res.getWriter();
- final URL wsdlURL = new URL("http://" + req.getLocalAddr() +
":" + req.getLocalPort() + path + "?wsdl");
+ final URL wsdlURL = new URL("http://" +
toIPv6URLFormat(req.getLocalAddr()) + ":" + req.getLocalPort() + path +
"?wsdl");
HelperUsignThreadLocal helper = new HelperUsignThreadLocal();
w.write(helper.run(wsdlURL, strategy, Integer.parseInt(threads),
Integer.parseInt(calls)).toString());
}
+
+ private String toIPv6URLFormat(final String host)
+ {
+ boolean isIPv6URLFormatted = false;
+ //strip out IPv6 URL formatting if already provided...
+ if (host.startsWith("[") && host.endsWith("]")) {
+ isIPv6URLFormatted = true;
+ }
+ //return IPv6 URL formatted address
+ if (isIPv6URLFormatted) {
+ return host;
+ } else {
+ Matcher m = VALID_IPV6_PATTERN.matcher(host);
+ return m.matches() ? "[" + host + "]" : host;
+ }
+ }
}
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/wsf/test/TestServlet.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/wsf/test/TestServlet.java 2015-03-12
11:37:00 UTC (rev 19556)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/wsf/test/TestServlet.java 2015-03-12
14:06:19 UTC (rev 19557)
@@ -74,7 +74,7 @@
try
{
ClientHelper helper = (ClientHelper)
Class.forName(helperClassName).newInstance();
- helper.setTargetEndpoint("http://" + req.getLocalAddr() +
":" + req.getLocalPort() + path);
+ helper.setTargetEndpoint("http://" +
toIPv6URLFormat(req.getLocalAddr()) + ":" + req.getLocalPort() + path);
List<String> failedTests = new LinkedList<String>();
List<String> errorTests = new LinkedList<String>();
Method[] methods = helper.getClass().getMethods();
Show replies by date