maven-wagon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdca...@apache.org
Subject svn commit: r826745 [2/2] - in /maven/wagon/trunk: ./ wagon-tcks/ wagon-tcks/wagon-tck-http/ wagon-tcks/wagon-tck-http/Test Plan.html/ wagon-tcks/wagon-tck-http/src/ wagon-tcks/wagon-tck-http/src/main/ wagon-tcks/wagon-tck-http/src/main/java/ wagon-tck...
Date Mon, 19 Oct 2009 18:14:36 GMT
Added: maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/WagonTestCaseConfigurator.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/WagonTestCaseConfigurator.java?rev=826745&view=auto
==============================================================================
--- maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/WagonTestCaseConfigurator.java
(added)
+++ maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/WagonTestCaseConfigurator.java
Mon Oct 19 18:14:35 2009
@@ -0,0 +1,112 @@
+package org.apache.maven.wagon.tck.http;
+
+import org.apache.maven.wagon.Wagon;
+import org.codehaus.classworlds.ClassRealm;
+import org.codehaus.plexus.PlexusConstants;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
+import org.codehaus.plexus.component.configurator.ComponentConfigurator;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import org.codehaus.plexus.configuration.PlexusConfiguration;
+import org.codehaus.plexus.context.Context;
+import org.codehaus.plexus.context.ContextException;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
+
+public class WagonTestCaseConfigurator
+    implements Contextualizable
+{
+    private static final String UNSUPPORTED_ELEMENT = "unsupported";
+
+    private PlexusConfiguration useCaseConfigs;
+
+    private ComponentConfigurator configurator;
+
+    private ClassRealm realm;
+
+    private String wagonHint;
+
+    public boolean isSupported( final String useCaseId )
+    {
+        if ( useCaseConfigs != null )
+        {
+            PlexusConfiguration config = useCaseConfigs.getChild( useCaseId, false );
+
+            if ( config != null && config.getChild( UNSUPPORTED_ELEMENT, false )
!= null )
+            {
+                System.out.println( "Test case '" + useCaseId + "' is marked as unsupported
by this wagon." );
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    public boolean configureWagonForTest( final Wagon wagon, final String useCaseId )
+        throws ComponentConfigurationException
+    {
+        if ( useCaseConfigs != null )
+        {
+            PlexusConfiguration config = useCaseConfigs.getChild( useCaseId, false );
+
+            if ( config != null )
+            {
+                if ( config.getChild( UNSUPPORTED_ELEMENT, false ) != null )
+                {
+                    System.out.println( "Test case '" + useCaseId + "' is marked as unsupported
by this wagon." );
+                    return false;
+                }
+                else
+                {
+                    System.out.println( "Configuring wagon for test case: " + useCaseId +
" with:\n\n" + config );
+                    configurator.configureComponent( wagon, useCaseConfigs.getChild( useCaseId,
false ), realm );
+                }
+            }
+            else
+            {
+                System.out.println( "No wagon configuration found for test case: " + useCaseId
);
+            }
+        }
+        else
+        {
+            System.out.println( "No test case configurations found." );
+        }
+
+        return true;
+    }
+
+    public void contextualize( final Context context )
+        throws ContextException
+    {
+        PlexusContainer container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY
);
+        this.realm = container.getContainerRealm();
+        try
+        {
+            configurator = (ComponentConfigurator) container.lookup( ComponentConfigurator.ROLE
);
+        }
+        catch ( ComponentLookupException e )
+        {
+            throw new ContextException( "Failed to lookup component configurator: " + e.getMessage(),
e );
+        }
+    }
+
+    public PlexusConfiguration getUseCaseConfigs()
+    {
+        return useCaseConfigs;
+    }
+
+    public void setUseCaseConfigs( final PlexusConfiguration useCaseConfigs )
+    {
+        this.useCaseConfigs = useCaseConfigs;
+    }
+
+    public String getWagonHint()
+    {
+        return wagonHint;
+    }
+
+    public void setWagonHint( final String wagonHint )
+    {
+        this.wagonHint = wagonHint;
+    }
+
+}

Propchange: maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/WagonTestCaseConfigurator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/AuthSnoopFilter.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/AuthSnoopFilter.java?rev=826745&view=auto
==============================================================================
--- maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/AuthSnoopFilter.java
(added)
+++ maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/AuthSnoopFilter.java
Mon Oct 19 18:14:35 2009
@@ -0,0 +1,46 @@
+package org.apache.maven.wagon.tck.http.fixture;
+
+import org.apache.commons.codec.binary.Base64;
+
+import java.io.IOException;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+public class AuthSnoopFilter
+    implements Filter
+{
+
+    public void destroy()
+    {
+    }
+
+    public void doFilter( final ServletRequest req, final ServletResponse response, final
FilterChain chain )
+        throws IOException, ServletException
+    {
+        HttpServletRequest request = (HttpServletRequest) req;
+        String authHeader = request.getHeader( "Authorization" );
+
+        if ( authHeader != null )
+        {
+            System.out.println( "Authorization: " + authHeader );
+            String data = authHeader.substring( "BASIC ".length() );
+            String decoded = new String( Base64.decodeBase64( data ) );
+            System.out.println( decoded );
+            String[] creds = decoded.split( ":" );
+
+            System.out.println( "User: " + creds[0] + "\nPassword: " + creds[1] );
+        }
+    }
+
+    public void init( final FilterConfig filterConfig )
+        throws ServletException
+    {
+    }
+
+}

Propchange: maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/AuthSnoopFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ErrorCodeServlet.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ErrorCodeServlet.java?rev=826745&view=auto
==============================================================================
--- maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ErrorCodeServlet.java
(added)
+++ maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ErrorCodeServlet.java
Mon Oct 19 18:14:35 2009
@@ -0,0 +1,33 @@
+package org.apache.maven.wagon.tck.http.fixture;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class ErrorCodeServlet
+    extends HttpServlet
+{
+
+    private static final long serialVersionUID = 1L;
+
+    private final int code;
+
+    private final String message;
+
+    public ErrorCodeServlet( final int code, final String message )
+    {
+        this.code = code;
+        this.message = message;
+    }
+
+    @Override
+    protected void service( final HttpServletRequest req, final HttpServletResponse resp
)
+        throws ServletException, IOException
+    {
+        resp.sendError( code, message );
+    }
+
+}

Propchange: maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ErrorCodeServlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/LatencyServlet.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/LatencyServlet.java?rev=826745&view=auto
==============================================================================
--- maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/LatencyServlet.java
(added)
+++ maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/LatencyServlet.java
Mon Oct 19 18:14:35 2009
@@ -0,0 +1,98 @@
+package org.apache.maven.wagon.tck.http.fixture;
+
+import org.codehaus.plexus.util.IOUtil;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class LatencyServlet
+    extends HttpServlet
+{
+
+    private static final long serialVersionUID = 1L;
+
+    private static final int BUFFER_SIZE = 32;
+
+    private final int latencyMs;
+
+    public LatencyServlet( final int latencyMs )
+    {
+        this.latencyMs = latencyMs;
+    }
+
+    @Override
+    protected void doGet( final HttpServletRequest req, final HttpServletResponse resp )
+        throws ServletException, IOException
+    {
+        if ( latencyMs < 0 )
+        {
+            System.out.println( "Starting infinite wait." );
+            synchronized ( this )
+            {
+                try
+                {
+                    wait();
+                }
+                catch ( InterruptedException e )
+                {
+                }
+            }
+
+            return;
+        }
+
+        String path = req.getPathInfo();
+
+        // ignore the servlet's path here, since the servlet path is really only to provide
a
+        // binding for the servlet.
+        String realPath = getServletContext().getRealPath( path );
+        File f = new File( realPath );
+
+        FileInputStream in = null;
+        long total = 0;
+        long start = System.currentTimeMillis();
+        try
+        {
+            in = new FileInputStream( f );
+            OutputStream out = resp.getOutputStream();
+
+            System.out.println( "Starting high-latency transfer. This should take about "
+                + ( ( f.length() / BUFFER_SIZE * latencyMs / 1000 ) + ( latencyMs / 1000
) ) + " seconds." );
+
+            int read = -1;
+            byte[] buf = new byte[BUFFER_SIZE];
+            while ( ( read = in.read( buf ) ) > -1 )
+            {
+                try
+                {
+                    Thread.sleep( latencyMs );
+                }
+                catch ( InterruptedException e )
+                {
+                    e.printStackTrace();
+                }
+
+                System.out.println( "Writing bytes " + total + "-" + ( total + read - 1 )
+ " of " + f.length()
+                    + ". Elapsed time so far: " + ( ( System.currentTimeMillis() - start
) / 1000 ) + " seconds" );
+
+                out.write( buf, 0, read );
+
+                total += read;
+            }
+        }
+        finally
+        {
+            IOUtil.close( in );
+        }
+
+        System.out.println( "High-latency transfer done in " + ( System.currentTimeMillis()
- start ) + "ms" );
+    }
+
+}

Propchange: maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/LatencyServlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ProxyAuthenticationFilter.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ProxyAuthenticationFilter.java?rev=826745&view=auto
==============================================================================
--- maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ProxyAuthenticationFilter.java
(added)
+++ maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ProxyAuthenticationFilter.java
Mon Oct 19 18:14:35 2009
@@ -0,0 +1,67 @@
+package org.apache.maven.wagon.tck.http.fixture;
+
+import org.apache.commons.codec.binary.Base64;
+
+import java.io.IOException;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class ProxyAuthenticationFilter
+    implements Filter
+{
+
+    private final String username;
+
+    private final String password;
+
+    public ProxyAuthenticationFilter( final String username, final String password )
+    {
+        this.username = username;
+        this.password = password;
+    }
+
+    public void destroy()
+    {
+    }
+
+    public void doFilter( final ServletRequest req, final ServletResponse resp, final FilterChain
chain )
+        throws IOException, ServletException
+    {
+        HttpServletRequest request = (HttpServletRequest) req;
+        HttpServletResponse response = (HttpServletResponse) resp;
+
+        String header = request.getHeader( "Proxy-Authorization" );
+        if ( header == null )
+        {
+            response.setStatus( HttpServletResponse.SC_PROXY_AUTHENTICATION_REQUIRED );
+            response.addHeader( "Proxy-Authenticate", "Basic realm=\"Squid proxy-caching
web server\"" );
+            return;
+        }
+        else
+        {
+            String data = header.substring( "BASIC ".length() );
+            data = new String( Base64.decodeBase64( data ) );
+            String[] creds = data.split( ":" );
+
+            if ( !creds[0].equals( username ) || !creds[1].equals( password ) )
+            {
+                response.sendError( HttpServletResponse.SC_UNAUTHORIZED );
+            }
+        }
+
+        chain.doFilter( req, resp );
+    }
+
+    public void init( final FilterConfig filterConfig )
+        throws ServletException
+    {
+    }
+
+}

Propchange: maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ProxyAuthenticationFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ProxyConnectionVerifierFilter.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ProxyConnectionVerifierFilter.java?rev=826745&view=auto
==============================================================================
--- maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ProxyConnectionVerifierFilter.java
(added)
+++ maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ProxyConnectionVerifierFilter.java
Mon Oct 19 18:14:35 2009
@@ -0,0 +1,56 @@
+package org.apache.maven.wagon.tck.http.fixture;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Enumeration;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+public class ProxyConnectionVerifierFilter
+    implements Filter
+{
+
+    public void destroy()
+    {
+    }
+
+    @SuppressWarnings( "unchecked" )
+    public void doFilter( final ServletRequest req, final ServletResponse resp, final FilterChain
chain )
+        throws IOException, ServletException
+    {
+        HttpServletRequest request = (HttpServletRequest) req;
+        // HttpServletResponse response = (HttpServletResponse) resp;
+
+        Enumeration<String> kEn = request.getHeaderNames();
+        for ( String key : Collections.list( kEn ) )
+        {
+            if ( key == null )
+            {
+                continue;
+            }
+
+            Enumeration<String> vEn = request.getHeaders( key );
+            if ( vEn != null )
+            {
+                for ( String val : Collections.list( vEn ) )
+                {
+                    System.out.println( key + ": " + val );
+                }
+            }
+        }
+
+        chain.doFilter( req, resp );
+    }
+
+    public void init( final FilterConfig filterConfig )
+        throws ServletException
+    {
+    }
+
+}

Propchange: maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ProxyConnectionVerifierFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/RedirectionServlet.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/RedirectionServlet.java?rev=826745&view=auto
==============================================================================
--- maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/RedirectionServlet.java
(added)
+++ maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/RedirectionServlet.java
Mon Oct 19 18:14:35 2009
@@ -0,0 +1,75 @@
+package org.apache.maven.wagon.tck.http.fixture;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class RedirectionServlet
+    extends HttpServlet
+{
+
+    private static final long serialVersionUID = 1L;
+
+    private final String targetPath;
+
+    private final int code;
+
+    private final int maxRedirects;
+
+    private int redirectCount = 0;
+
+    private final String myPath;
+
+    public RedirectionServlet( final int code, final String path )
+    {
+        this.code = code;
+        this.targetPath = path;
+        this.maxRedirects = 1;
+        this.myPath = null;
+    }
+
+    public RedirectionServlet( final int code, final String myPath, final String targetPath,
final int maxRedirects )
+    {
+        this.code = code;
+        this.myPath = myPath;
+        this.targetPath = targetPath;
+        this.maxRedirects = maxRedirects;
+    }
+
+    public int getRedirectCount()
+    {
+        return redirectCount;
+    }
+
+    @Override
+    protected void service( final HttpServletRequest req, final HttpServletResponse resp
)
+        throws ServletException, IOException
+    {
+        redirectCount++;
+
+        if ( myPath == null )
+        {
+            resp.setStatus( code );
+            resp.setHeader( "Location", targetPath );
+        }
+        else if ( maxRedirects < 0 )
+        {
+            resp.setStatus( code );
+            resp.setHeader( "Location", myPath );
+        }
+        else if ( redirectCount <= maxRedirects )
+        {
+            resp.setStatus( code );
+            resp.setHeader( "Location", myPath );
+        }
+        else
+        {
+            resp.setStatus( code );
+            resp.setHeader( "Location", targetPath );
+        }
+    }
+
+}

Propchange: maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/RedirectionServlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ServerFixture.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ServerFixture.java?rev=826745&view=auto
==============================================================================
--- maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ServerFixture.java
(added)
+++ maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ServerFixture.java
Mon Oct 19 18:14:35 2009
@@ -0,0 +1,169 @@
+package org.apache.maven.wagon.tck.http.fixture;
+
+import static org.apache.maven.wagon.tck.http.util.TestUtil.getResource;
+
+import org.mortbay.jetty.Connector;
+import org.mortbay.jetty.Handler;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.handler.DefaultHandler;
+import org.mortbay.jetty.handler.HandlerCollection;
+import org.mortbay.jetty.nio.SelectChannelConnector;
+import org.mortbay.jetty.security.Constraint;
+import org.mortbay.jetty.security.ConstraintMapping;
+import org.mortbay.jetty.security.HashUserRealm;
+import org.mortbay.jetty.security.SecurityHandler;
+import org.mortbay.jetty.security.SslSocketConnector;
+import org.mortbay.jetty.servlet.AbstractSessionManager;
+import org.mortbay.jetty.servlet.FilterHolder;
+import org.mortbay.jetty.servlet.FilterMapping;
+import org.mortbay.jetty.servlet.ServletHolder;
+import org.mortbay.jetty.servlet.SessionHandler;
+import org.mortbay.jetty.webapp.WebAppContext;
+
+import java.io.File;
+import java.net.URISyntaxException;
+
+import javax.servlet.Filter;
+import javax.servlet.Servlet;
+
+public class ServerFixture
+{
+    public static final String SERVER_ROOT_RESOURCE_PATH = "default-server-root";
+
+    public static final String SERVER_SSL_KEYSTORE_RESOURCE_PATH = "ssl/keystore";
+
+    public static final String SERVER_SSL_KEYSTORE_PASSWORD = "password";
+
+    public static final String SERVER_HOST = "localhost";
+
+    private final Server server;
+
+    private final WebAppContext webappContext;
+
+    private final HashUserRealm securityRealm;
+
+    private final SecurityHandler securityHandler;
+
+    private int filterCount = 0;;
+
+    public ServerFixture( final int port, final boolean ssl )
+        throws URISyntaxException
+    {
+        server = new Server();
+        if ( ssl )
+        {
+            SslSocketConnector connector = new SslSocketConnector();
+            String keystore = getResource( SERVER_SSL_KEYSTORE_RESOURCE_PATH ).getAbsolutePath();
+
+            // connector.setHost( SERVER_HOST );
+            connector.setPort( port );
+            connector.setKeystore( keystore );
+            connector.setPassword( SERVER_SSL_KEYSTORE_PASSWORD );
+            connector.setKeyPassword( SERVER_SSL_KEYSTORE_PASSWORD );
+
+            server.addConnector( connector );
+        }
+        else
+        {
+            Connector connector = new SelectChannelConnector();
+            connector.setHost( "localhost" );
+            connector.setPort( port );
+            server.addConnector( connector );
+        }
+
+        Constraint constraint = new Constraint();
+        constraint.setName( Constraint.__BASIC_AUTH );
+
+        constraint.setRoles( new String[] { "allowed" } );
+        constraint.setAuthenticate( true );
+
+        ConstraintMapping cm = new ConstraintMapping();
+        cm.setConstraint( constraint );
+        cm.setPathSpec( "/protected/*" );
+
+        securityHandler = new SecurityHandler();
+
+        securityRealm = new HashUserRealm( "Test Server" );
+
+        securityHandler.setUserRealm( securityRealm );
+        securityHandler.setConstraintMappings( new ConstraintMapping[] { cm } );
+
+        webappContext = new WebAppContext();
+        webappContext.setContextPath( "/" );
+
+        File base = getResource( SERVER_ROOT_RESOURCE_PATH );
+        webappContext.setWar( base.getAbsolutePath() );
+        webappContext.addHandler( securityHandler );
+
+        SessionHandler sessionHandler = webappContext.getSessionHandler();
+        ( (AbstractSessionManager) sessionHandler.getSessionManager() ).setUsingCookies(
false );
+
+        HandlerCollection handlers = new HandlerCollection();
+        handlers.setHandlers( new Handler[] { webappContext, new DefaultHandler() } );
+
+        server.setHandler( handlers );
+    }
+
+    public void addFilter( final String pathSpec, final Filter filter )
+    {
+        String name = "filter" + filterCount++;
+
+        FilterMapping fm = new FilterMapping();
+        fm.setPathSpec( pathSpec );
+        fm.setFilterName( name );
+
+        FilterHolder fh = new FilterHolder( filter );
+        fh.setName( name );
+
+        webappContext.getServletHandler().addFilter( fh, fm );
+    }
+
+    public void addServlet( final String pathSpec, final Servlet servlet )
+    {
+        webappContext.getServletHandler().addServletWithMapping( new ServletHolder( servlet
), pathSpec );
+    }
+
+    public void addUser( final String user, final String password )
+    {
+        securityRealm.put( user, password );
+        securityRealm.addUserToRole( user, "allowed" );
+    }
+
+    public Server getServer()
+    {
+        return server;
+    }
+
+    public WebAppContext getWebappContext()
+    {
+        return webappContext;
+    }
+
+    public void stop()
+        throws Exception
+    {
+        if ( server != null )
+        {
+            server.stop();
+        }
+    }
+
+    public void start()
+        throws Exception
+    {
+        server.start();
+
+        int total = 0;
+        while ( total < 3000 && !server.isStarted() )
+        {
+            server.wait( 10 );
+            total += 10;
+        }
+
+        if ( !server.isStarted() )
+        {
+            throw new IllegalStateException( "Server didn't start in: " + total + "ms." );
+        }
+    }
+
+}

Propchange: maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ServerFixture.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ServletExceptionServlet.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ServletExceptionServlet.java?rev=826745&view=auto
==============================================================================
--- maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ServletExceptionServlet.java
(added)
+++ maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ServletExceptionServlet.java
Mon Oct 19 18:14:35 2009
@@ -0,0 +1,30 @@
+package org.apache.maven.wagon.tck.http.fixture;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class ServletExceptionServlet
+    extends HttpServlet
+{
+
+    private static final long serialVersionUID = 1L;
+
+    private final String message;
+
+    public ServletExceptionServlet( final String message )
+    {
+        this.message = message;
+    }
+
+    @Override
+    protected void service( final HttpServletRequest request, final HttpServletResponse response
)
+        throws ServletException, IOException
+    {
+        throw new ServletException( message );
+    }
+
+}

Propchange: maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ServletExceptionServlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/util/TestUtil.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/util/TestUtil.java?rev=826745&view=auto
==============================================================================
--- maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/util/TestUtil.java
(added)
+++ maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/util/TestUtil.java
Mon Oct 19 18:14:35 2009
@@ -0,0 +1,26 @@
+package org.apache.maven.wagon.tck.http.util;
+
+import java.io.File;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+public final class TestUtil
+{
+
+    private TestUtil()
+    {
+    }
+
+    public static File getResource( final String path )
+        throws URISyntaxException
+    {
+        URL resource = Thread.currentThread().getContextClassLoader().getResource( path );
+        if ( resource == null )
+        {
+            throw new IllegalStateException( "Cannot find classpath resource: " + path );
+        }
+
+        return new File( resource.toURI().normalize() );
+    }
+
+}

Propchange: maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/util/TestUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/util/ValueHolder.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/util/ValueHolder.java?rev=826745&view=auto
==============================================================================
--- maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/util/ValueHolder.java
(added)
+++ maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/util/ValueHolder.java
Mon Oct 19 18:14:35 2009
@@ -0,0 +1,25 @@
+package org.apache.maven.wagon.tck.http.util;
+
+public class ValueHolder<T>
+{
+    private T value;
+
+    public ValueHolder()
+    {
+    }
+
+    public ValueHolder( final T initial )
+    {
+        this.value = initial;
+    }
+
+    public void setValue( final T value )
+    {
+        this.value = value;
+    }
+
+    public T getValue()
+    {
+        return value;
+    }
+}

Propchange: maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/util/ValueHolder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/resources/META-INF/plexus/components.xml?rev=826745&view=auto
==============================================================================
--- maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/resources/META-INF/plexus/components.xml
(added)
+++ maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/resources/META-INF/plexus/components.xml
Mon Oct 19 18:14:35 2009
@@ -0,0 +1,20 @@
+<component-set>
+  <!-- TODO: Split this out into a sample project that shows how to use this TCK. -->
+  <components>
+    <component>
+      <role>org.apache.maven.wagon.tck.http.WagonTestCaseConfigurator</role>
+      <implementation>org.apache.maven.wagon.tck.http.WagonTestCaseConfigurator</implementation>
+      <configuration>
+        <wagonHint>http</wagonHint>
+        <useCaseConfigs>
+          <highLatencyLowTimeout>
+            <unsupported/>
+          </highLatencyLowTimeout>
+          <inifiniteLatencyTimeout>
+            <unsupported/>
+          </inifiniteLatencyTimeout>
+        </useCaseConfigs>
+      </configuration>
+    </component>
+  </components>
+</component-set>
\ No newline at end of file

Propchange: maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/resources/default-server-root/base.txt
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/resources/default-server-root/base.txt?rev=826745&view=auto
==============================================================================
--- maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/resources/default-server-root/base.txt
(added)
+++ maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/resources/default-server-root/base.txt
Mon Oct 19 18:14:35 2009
@@ -0,0 +1 @@
+This is just a basic file.
\ No newline at end of file

Propchange: maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/resources/default-server-root/base.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/resources/default-server-root/large.txt
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/resources/default-server-root/large.txt?rev=826745&view=auto
==============================================================================
--- maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/resources/default-server-root/large.txt
(added)
+++ maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/resources/default-server-root/large.txt
Mon Oct 19 18:14:35 2009
@@ -0,0 +1,2 @@
+a;sldkfja;ldfkja;ldfkjas;ldfkjas;dflkjasdg;lkasjdgpaeiortjuawpoefnasd;lgknasropt;iahsdgpoasdgijn;alsdgknzsd;lgkhszdoiahjsetpoaijnsdgf;laskdnga;lsdkghjas;lktjae;toiaehwgrpoaigh;alskdgnas;ldghkast;ahiletpoaihtpoasghaposghia
+a;sldkfja;ldfkja;ldfkjas;ldfkjas;dflkjasdg;lkasjdgpaeiortjuawpoefnasd;lgknasropt;iahsdgpoasdgijn;alsdgknzsd;lgkhszdoiahjsetpoaijnsdgf;laskdnga;lsdkghjas;lktjae;toiaehwgrpoaigh;alskdgnas;ldghkast;ahiletpoaihtpoasghaposghia

Propchange: maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/resources/default-server-root/large.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/resources/default-server-root/protected/base.txt
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/resources/default-server-root/protected/base.txt?rev=826745&view=auto
==============================================================================
--- maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/resources/default-server-root/protected/base.txt
(added)
+++ maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/resources/default-server-root/protected/base.txt
Mon Oct 19 18:14:35 2009
@@ -0,0 +1 @@
+This is just a basic file.
\ No newline at end of file

Propchange: maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/resources/default-server-root/protected/base.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/resources/ssl/keystore
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/resources/ssl/keystore?rev=826745&view=auto
==============================================================================
Binary file - no diff available.

Propchange: maven/wagon/trunk/wagon-tcks/wagon-tck-http/src/main/resources/ssl/keystore
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



---------------------------------------------------------------------
To unsubscribe, e-mail: wagon-commits-unsubscribe@maven.apache.org
For additional commands, e-mail: wagon-commits-help@maven.apache.org


Mime
View raw message