[jbossws-issues] [JBoss JIRA] (JBWS-3714) Fix test support classes for use with non compressed-zero format IPv6 addresses

Petr Sakař (JIRA) jira-events at lists.jboss.org
Fri Oct 18 04:26:02 EDT 2013


    [ https://issues.jboss.org/browse/JBWS-3714?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12823094#comment-12823094 ] 

Petr Sakař commented on JBWS-3714:
----------------------------------

FIX related to little proxy

change version in modules/testsuite/pom.xml to
{noformat}
<org.littleshoot.littleproxy.version>1.0.0-beta2</org.littleshoot.littleproxy.version>
{noformat}

and apply patch

{noformat}
Index: modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/httpproxy/HTTPProxyTestCaseForked.java
===================================================================
--- modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/httpproxy/HTTPProxyTestCaseForked.java	(revision 17948)
+++ modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/httpproxy/HTTPProxyTestCaseForked.java	(working copy)
@@ -21,16 +21,19 @@
  */
 package org.jboss.test.ws.jaxws.cxf.httpproxy;
 
+import io.netty.handler.codec.http.HttpRequest;
+
 import java.io.BufferedReader;
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.PrintStream;
 import java.net.Authenticator;
+import java.net.InetSocketAddress;
 import java.net.MalformedURLException;
 import java.net.PasswordAuthentication;
 import java.net.URL;
-import java.util.HashMap;
+import java.util.Queue;
 
 import javax.xml.namespace.QName;
 import javax.xml.ws.BindingProvider;
@@ -46,14 +49,14 @@
 import org.apache.cxf.transports.http.configuration.ProxyServerType;
 import org.jboss.wsf.test.JBossWSCXFTestSetup;
 import org.jboss.wsf.test.JBossWSTest;
-import org.littleshoot.proxy.DefaultHttpProxyServer;
-import org.littleshoot.proxy.HttpFilter;
+import org.littleshoot.proxy.ChainedProxy;
+import org.littleshoot.proxy.ChainedProxyAdapter;
+import org.littleshoot.proxy.ChainedProxyManager;
 import org.littleshoot.proxy.HttpProxyServer;
-import org.littleshoot.proxy.ProxyAuthorizationHandler;
 
 /**
  * Tests / samples for WS client using HTTP Proxy
- * 
+ *
  * @author alessio.soldano at jboss.com
  * @since 24-May-2011
  */
@@ -87,7 +90,7 @@
          e.printStackTrace(new PrintStream(baos));
          assertTrue(baos.toString().contains(testHost));
       }
-      
+
       //then setup the proxy, but provide no authentication/authorization info -> request fails because of HTTP 407
       setProxySystemProperties();
       try
@@ -101,7 +104,7 @@
          e.printStackTrace(new PrintStream(baos));
          assertTrue(baos.toString().contains("407: Proxy Authentication Required"));
       }
-      
+
       //finally setup everything
       Client client = ClientProxy.getClient(port);
       HTTPConduit conduit = (HTTPConduit)client.getConduit();
@@ -110,10 +113,10 @@
       policy.setUserName(PROXY_USER);
       policy.setPassword(PROXY_PWD);
       conduit.setProxyAuthorization(policy);
-      
+
       assertEquals(hi, port.echo(hi));
    }
-   
+
    public void testHttpProxyUsingHTTPClientPolicy() throws Exception
    {
       final String testHost = "unreachable-testHttpProxyUsingHTTPClientPolicy";
@@ -131,7 +134,7 @@
          e.printStackTrace(new PrintStream(baos));
          assertTrue(baos.toString().contains(testHost));
       }
-      
+
       //then setup the proxy, but provide no authentication/authorization info -> request fails because of HTTP 407
       Client client = ClientProxy.getClient(port);
       HTTPConduit conduit = (HTTPConduit)client.getConduit();
@@ -150,33 +153,60 @@
          e.printStackTrace(new PrintStream(baos));
          assertTrue(baos.toString().contains("407: Proxy Authentication Required"));
       }
-      
+
       //finally setup authorization info too
       ProxyAuthorizationPolicy authPolicy = new ProxyAuthorizationPolicy();
       authPolicy.setAuthorizationType("Basic");
       authPolicy.setUserName(PROXY_USER);
       authPolicy.setPassword(PROXY_PWD);
       conduit.setProxyAuthorization(authPolicy);
-      
+
       assertEquals(hi, port.echo(hi));
    }
-   
+
    @Override
    protected void setUp() throws Exception
    {
-      proxyServer = new DefaultHttpProxyServer(++proxyPort, new HashMap<String, HttpFilter>(),
-            getServerHost() + ":8080", null, null);
-      ProxyAuthorizationHandler authorizationHandler = new ProxyAuthorizationHandler()
+
+      org.littleshoot.proxy.ProxyAuthenticator proxyAuthenticator = new org.littleshoot.proxy.ProxyAuthenticator()
       {
 
          @Override
-         public boolean authenticate(String user, String pwd)
+         public boolean authenticate(String userName, String password)
          {
-            return (PROXY_USER.equals(user) && PROXY_PWD.equals(pwd));
+            return (PROXY_USER.equals(userName) && PROXY_PWD.equals(password));
          }
       };
-      proxyServer.addProxyAuthenticationHandler(authorizationHandler);
-      proxyServer.start();
+      InetSocketAddress address = new InetSocketAddress(getServerHost(), ++proxyPort);
+      ChainedProxyManager chainProxyManager = new ChainedProxyManager()
+      {
+
+         @Override
+         public void lookupChainedProxies(HttpRequest httpRequest, Queue<ChainedProxy> chainedProxies)
+         {
+            chainedProxies.add(new ChainedProxyAdapter()
+            {
+
+
+               @Override
+               public InetSocketAddress getChainedProxyAddress()
+               {
+                  return new InetSocketAddress(getServerHost(), 8080);
+               }
+
+            });
+         }
+      };
+      proxyServer = org.littleshoot.proxy.impl.DefaultHttpProxyServer
+                            .bootstrap()
+                            .withChainProxyManager(chainProxyManager)
+                            .withAddress(address)
+                            .withProxyAuthenticator(proxyAuthenticator)
+                            .start();
+
+
+
+//            return getServerHost() + ":8080";
    }
 
    @Override
@@ -188,7 +218,7 @@
          proxyServer.stop();
       }
    }
-   
+
    private HelloWorld getPort(URL wsdlURL, String endpointAddressHost) throws MalformedURLException
    {
       QName serviceName = new QName("http://org.jboss.ws/jaxws/cxf/httpproxy", "HelloWorldService");
@@ -199,13 +229,13 @@
       provider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://" + endpointAddressHost + "/jaxws-cxf-httpproxy/HelloWorldService/HelloWorldImpl");
       return port;
    }
-   
+
    private static void setProxySystemProperties()
    {
       System.getProperties().setProperty("http.proxyHost", getServerHost());
       System.getProperties().setProperty("http.proxyPort", String.valueOf(proxyPort));
    }
-   
+
    private static void clearProxySystemProperties()
    {
       System.clearProperty("http.proxyHost");
@@ -242,7 +272,7 @@
          assertTrue(e.getMessage().contains("unreachable-testWSDLNoHttpProxy"));
       }
    }
-   
+
    private static StringBuffer readContent(URL url) throws Exception
    {
       StringBuffer sb = new StringBuffer();
@@ -264,7 +294,7 @@
       }
       return sb;
    }
-   
+
    private static class ProxyAuthenticator extends Authenticator
    {
       private String user, password;
{noformat}
                
> Fix test support classes for use with non compressed-zero format IPv6 addresses
> -------------------------------------------------------------------------------
>
>                 Key: JBWS-3714
>                 URL: https://issues.jboss.org/browse/JBWS-3714
>             Project: JBoss Web Services
>          Issue Type: Task
>      Security Level: Public(Everyone can see) 
>          Components: jbossws-cxf
>            Reporter: Alessio Soldano
>            Assignee: Alessio Soldano
>             Fix For: jbossws-cxf-4.2.2
>
>


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira



More information about the jbossws-issues mailing list