[MNG-6731] Jetty getLocalPort() returns -1 resulting in build failures

This commit is contained in:
tibordigana 2019-08-10 23:54:48 +02:00 committed by Tibor Digana
parent 2fd39c483d
commit 7c87d046e2
38 changed files with 684 additions and 861 deletions

View File

@ -110,38 +110,15 @@ under the License.
<!-- TODO: not transitive in tests artifact, so must be left in main
scope <scope>test</scope> -->
</dependency>
<!-- Should be fine to introduce this here, even if we use the embedder
as it should be using an isolated classloader Used to simplify tests that
provide a test HTTP server. -->
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
<version>6.1.14</version>
<!-- TODO: not transitive in tests artifact, so must be left in main
scope <scope>test</scope> -->
<exclusions>
<exclusion>
<artifactId>servlet-api-2.5</artifactId>
<groupId>org.mortbay.jetty</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-shared-utils</artifactId>
<version>0.9</version>
</dependency>
<!-- Jetty9 server for testing -->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jetty9Version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-security</artifactId>
<version>${jetty9Version}</version>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-shared-utils</artifactId>
<version>0.9</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
@ -149,9 +126,9 @@ under the License.
<version>${jetty9Version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.orbit</groupId>
<artifactId>javax.servlet</artifactId>
<version>3.0.0.v201112011016</version>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>${jetty9Version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>

View File

@ -5,6 +5,8 @@ import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.security.authentication.BasicAuthenticator;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
@ -66,21 +68,20 @@ public class HttpServer
public int port()
{
return ( (ServerConnector) server.getConnectors()[0] ).getLocalPort();
return ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
}
private Server server( int port )
{
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setMaxThreads( 500 );
Server server = new Server( threadPool );
server.setConnectors( new Connector[]{ new ServerConnector( server ) } );
server.addBean( new ScheduledExecutorScheduler() );
ServerConnector http = new ServerConnector( server );
http.setPort( port );
http.setIdleTimeout( 30000 );
server.addConnector( http );
ServerConnector connector = (ServerConnector) server.getConnectors()[0];
connector.setIdleTimeout( 30_000L );
connector.setPort( port );
StreamSourceHandler handler = new StreamSourceHandler( source );

View File

@ -162,6 +162,7 @@ public class IntegrationTestSuite
suite.addTestSuite( MavenITmng5230MakeReactorWithExcludesTest.class );
suite.addTestSuite( MavenITmng5224InjectedSettings.class );
suite.addTestSuite( MavenITmng5214DontMapWsdlToJar.class );
suite.addTestSuite( MavenITmng5175WagonHttpTest.class );
suite.addTestSuite( MavenITmng5137ReactorResolutionInForkedBuildTest.class );
suite.addTestSuite( MavenITmng5135AggregatorDepResolutionModuleExtensionTest.class );
suite.addTestSuite( MavenITmng5096ExclusionAtDependencyWithImpliedClassifierTest.class );
@ -663,6 +664,7 @@ public class IntegrationTestSuite
suite.addTestSuite( MavenITmng0249ResolveDepsFromReactorTest.class );
suite.addTestSuite( MavenITmng0187CollectedProjectsTest.class );
suite.addTestSuite( MavenITmng0095ReactorFailureBehaviorTest.class );
suite.addTestSuite( MavenIT0146InstallerSnapshotNaming.class );
suite.addTestSuite( MavenIT0145ReactorWithIncludesExcludesTest.class );
suite.addTestSuite( MavenIT0144LifecycleExecutionOrderTest.class );
suite.addTestSuite( MavenIT0143TransitiveDependencyScopesTest.class );

View File

@ -20,11 +20,12 @@ package org.apache.maven.it;
*/
import org.apache.maven.it.util.ResourceExtractor;
import org.mortbay.jetty.Handler;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.DefaultHandler;
import org.mortbay.jetty.handler.HandlerList;
import org.mortbay.jetty.handler.ResourceHandler;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.ResourceHandler;
import java.io.File;
import java.io.IOException;
@ -59,15 +60,11 @@ public class MavenIT0146InstallerSnapshotNaming
server = new Server( 0 );
server.setHandler( handlers );
server.start();
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
port = server.getConnectors()[0].getLocalPort();
port = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
System.out.println( "Bound server socket to the port " + port );
}
@ -86,7 +83,6 @@ public class MavenIT0146InstallerSnapshotNaming
public void testitRemoteDownloadTimestampedName()
throws Exception
{
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
Properties properties = verifier.newDefaultFilterProperties();

View File

@ -26,14 +26,21 @@ import java.util.Collections;
import java.util.List;
import java.util.Properties;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.DefaultHandler;
import org.mortbay.jetty.handler.HandlerList;
import org.mortbay.jetty.handler.ResourceHandler;
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.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.util.security.Constraint;
import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.util.security.Password;
import org.eclipse.jetty.servlet.ServletContextHandler;
import static org.eclipse.jetty.servlet.ServletContextHandler.SECURITY;
import static org.eclipse.jetty.servlet.ServletContextHandler.SESSIONS;
import static org.eclipse.jetty.util.security.Constraint.__BASIC_AUTH;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-553">MNG-553</a>.
@ -61,21 +68,21 @@ public class MavenITmng0553SettingsAuthzEncryptionTest
{
testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-0553" );
Constraint constraint = new Constraint();
constraint.setName( Constraint.__BASIC_AUTH );
constraint.setRoles( new String[] { "user" } );
Constraint constraint = new Constraint( __BASIC_AUTH, "user" );
constraint.setAuthenticate( true );
ConstraintMapping constraintMapping = new ConstraintMapping();
constraintMapping.setConstraint( constraint );
constraintMapping.setPathSpec( "/*" );
HashUserRealm userRealm = new HashUserRealm( "TestRealm" );
userRealm.put( "testuser", "testtest" );
userRealm.addUserToRole( "testuser", "user" );
HashLoginService userRealm = new HashLoginService( "TestRealm" );
userRealm.putUser( "testuser", new Password( "testtest" ), new String[] { "user" } );
SecurityHandler securityHandler = new SecurityHandler();
securityHandler.setUserRealm( userRealm );
server = new Server( 0 );
ServletContextHandler ctx = new ServletContextHandler( server, "/", SESSIONS | SECURITY );
ConstraintSecurityHandler securityHandler = (ConstraintSecurityHandler) ctx.getSecurityHandler();
securityHandler.setLoginService( userRealm );
securityHandler.setAuthMethod( __BASIC_AUTH );
securityHandler.setConstraintMappings( new ConstraintMapping[] { constraintMapping } );
ResourceHandler repoHandler = new ResourceHandler();
@ -86,18 +93,13 @@ public class MavenITmng0553SettingsAuthzEncryptionTest
handlerList.addHandler( repoHandler );
handlerList.addHandler( new DefaultHandler() );
server = new Server( 0 );
server.setHandler( handlerList );
server.start();
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
port = server.getConnectors()[0].getLocalPort();
port = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
System.out.println( "Bound server socket to the port " + port );
}

View File

@ -20,7 +20,14 @@ package org.apache.maven.it;
*/
import org.apache.maven.it.util.ResourceExtractor;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
@ -29,14 +36,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Properties;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.mortbay.jetty.Handler;
import org.mortbay.jetty.Request;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.AbstractHandler;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-768">MNG-768</a>.
*
@ -64,7 +63,8 @@ public class MavenITmng0768OfflineModeTest
Handler repoHandler = new AbstractHandler()
{
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
public void handle( String target, Request baseRequest, HttpServletRequest request,
HttpServletResponse response )
throws IOException
{
System.out.println( "Handling " + request.getMethod() + " " + request.getRequestURL() );
@ -103,17 +103,12 @@ public class MavenITmng0768OfflineModeTest
try
{
server.start();
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
int port = server.getConnectors()[0].getLocalPort();
System.out.println( "Bound server socket to the port " + port );
int port = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
{
// phase 1: run build in online mode to fill local repo
@ -176,6 +171,8 @@ public class MavenITmng0768OfflineModeTest
verifier.resetStreams();
}
System.out.println( "Bound server socket to the port " + port );
assertTrue( requestedUris.toString(), requestedUris.isEmpty() );
}
finally

View File

@ -30,11 +30,18 @@ import java.util.Properties;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Request;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.AbstractHandler;
import org.mortbay.jetty.security.SslSocketConnector;
import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.SecureRequestCustomizer;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.SslConnectionFactory;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import static org.eclipse.jetty.http.HttpVersion.HTTP_1_1;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-2305">MNG-2305</a>.
@ -71,20 +78,16 @@ public class MavenITmng2305MultipleProxiesTest
String keyPwd = "key-passwd";
Server server = new Server( 0 );
server.addConnector( newHttpsConnector( storePath, storePwd, keyPwd ) );
addHttpsConnector( server, storePath, storePwd, keyPwd );
server.setHandler( new RepoHandler() );
server.start();
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
int httpPort = server.getConnectors()[0].getLocalPort();
int httpPort = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
System.out.println( "Bound server socket to HTTP port " + httpPort );
int httpsPort = server.getConnectors()[1].getLocalPort();
int httpsPort = ( (NetworkConnector) server.getConnectors()[1] ).getLocalPort();
System.out.println( "Bound server socket to HTTPS port " + httpsPort );
TunnelingProxyServer proxy = new TunnelingProxyServer( 0, "localhost", httpsPort, "https.mngit:443" );
@ -115,6 +118,7 @@ public class MavenITmng2305MultipleProxiesTest
{
proxy.stop();
server.stop();
server.join();
}
List<String> cp = verifier.loadLines( "target/classpath.txt", "UTF-8" );
@ -122,20 +126,25 @@ public class MavenITmng2305MultipleProxiesTest
assertTrue( cp.toString(), cp.contains( "https-0.1.jar" ) );
}
private Connector newHttpsConnector( String keystore, String storepwd, String keypwd )
private void addHttpsConnector( Server server, String keyStorePath, String keyStorePassword, String keyPassword )
{
SslSocketConnector connector = new SslSocketConnector();
connector.setPort( 0 );
connector.setKeystore( keystore );
connector.setPassword( storepwd );
connector.setKeyPassword( keypwd );
return connector;
SslContextFactory sslContextFactory = new SslContextFactory( keyStorePath );
sslContextFactory.setKeyStorePassword( keyStorePassword );
sslContextFactory.setKeyManagerPassword( keyPassword );
HttpConfiguration httpConfiguration = new HttpConfiguration();
httpConfiguration.setSecureScheme( "https" );
HttpConfiguration httpsConfiguration = new HttpConfiguration( httpConfiguration );
httpsConfiguration.addCustomizer( new SecureRequestCustomizer() );
ServerConnector httpsConnector = new ServerConnector( server,
new SslConnectionFactory( sslContextFactory, HTTP_1_1.asString() ),
new HttpConnectionFactory( httpsConfiguration ) );
server.addConnector( httpsConnector );
}
static class RepoHandler extends AbstractHandler
{
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
public void handle( String target, Request baseRequest, HttpServletRequest request,
HttpServletResponse response )
throws IOException
{
PrintWriter writer = response.getWriter();

View File

@ -19,17 +19,18 @@ package org.apache.maven.it;
* under the License.
*/
import org.apache.maven.it.util.ResourceExtractor;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.ResourceHandler;
import java.io.File;
import java.net.InetAddress;
import java.util.Properties;
import org.apache.maven.it.util.ResourceExtractor;
import org.mortbay.jetty.Handler;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.DefaultHandler;
import org.mortbay.jetty.handler.HandlerList;
import org.mortbay.jetty.handler.ResourceHandler;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-2387">MNG-2387</a>.
*
@ -69,15 +70,11 @@ public class MavenITmng2387InactiveProxyTest
server = new Server( 0 );
server.setHandler( handlers );
server.start();
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
port = server.getConnectors()[0].getLocalPort();
port = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
System.out.println( "Bound server socket to the HTTP port " + port );
resourceHandler = new ResourceHandler();
@ -89,15 +86,11 @@ public class MavenITmng2387InactiveProxyTest
proxyServer = new Server( 0 );
proxyServer.setHandler( handlers );
proxyServer.start();
while ( !proxyServer.isRunning() || !proxyServer.isStarted() )
if ( proxyServer.isFailed() )
{
if ( proxyServer.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
proxyPort = proxyServer.getConnectors()[0].getLocalPort();
proxyPort = ( (NetworkConnector) proxyServer.getConnectors()[0] ).getLocalPort();
System.out.println( "Bound server socket to the HTTPS port " + port );
}

View File

@ -21,10 +21,11 @@ package org.apache.maven.it;
import org.apache.maven.it.util.ResourceExtractor;
import org.apache.maven.shared.utils.io.FileUtils;
import org.mortbay.jetty.Handler;
import org.mortbay.jetty.Request;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.AbstractHandler;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -162,7 +163,8 @@ public class MavenITmng3415JunkRepositoryMetadataTest
Handler repoHandler = new AbstractHandler()
{
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
@Override
public void handle( String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response )
{
System.out.println( "Handling " + request.getMethod() + " " + request.getRequestURL() );
@ -180,16 +182,12 @@ public class MavenITmng3415JunkRepositoryMetadataTest
try
{
server.start();
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
int port = server.getConnectors()[0].getLocalPort();
int port = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
System.out.println( "Bound server socket to the port " + port );
Properties filterProps = verifier.newDefaultFilterProperties();

View File

@ -20,18 +20,17 @@ package org.apache.maven.it;
*/
import org.apache.maven.it.util.ResourceExtractor;
import java.io.File;
import java.io.IOException;
import java.util.Properties;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.mortbay.jetty.Handler;
import org.mortbay.jetty.Request;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.AbstractHandler;
import java.io.File;
import java.io.IOException;
import java.util.Properties;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-3461">MNG-3461</a>.
@ -84,7 +83,9 @@ public class MavenITmng3461MirrorMatchingTest
Handler repoHandler = new AbstractHandler()
{
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
@Override
public void handle( String target, Request baseRequest, HttpServletRequest request,
HttpServletResponse response )
throws IOException
{
System.out.println( "Handling " + request.getMethod() + " " + request.getRequestURL() );
@ -119,16 +120,12 @@ public class MavenITmng3461MirrorMatchingTest
try
{
server.start();
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
int port = server.getConnectors()[0].getLocalPort();
int port = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
System.out.println( "Bound server socket to the port " + port );
verifier.setAutoclean( false );

View File

@ -26,10 +26,11 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.maven.it.util.ResourceExtractor;
import org.apache.maven.shared.utils.StringUtils;
import org.apache.maven.shared.utils.io.FileUtils;
import org.mortbay.jetty.Handler;
import org.mortbay.jetty.Request;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.AbstractHandler;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-3599">MNG-3599</a>.
@ -67,7 +68,8 @@ public class MavenITmng3599useHttpProxyForWebDAVMk2Test
{
Handler handler = new AbstractHandler()
{
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
public void handle( String target, Request baseRequest, HttpServletRequest request,
HttpServletResponse response )
throws IOException
{
System.out.println( "Got request for URL: '" + request.getRequestURL() + "'" );
@ -113,15 +115,11 @@ public class MavenITmng3599useHttpProxyForWebDAVMk2Test
server = new Server( 0 );
server.setHandler( handler );
server.start();
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
port = server.getConnectors()[0].getLocalPort();
port = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
System.out.println( "Bound server socket to the port " + port );
}

View File

@ -28,10 +28,11 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.maven.it.util.ResourceExtractor;
import org.apache.maven.shared.utils.StringUtils;
import org.apache.maven.shared.utils.io.FileUtils;
import org.mortbay.jetty.Handler;
import org.mortbay.jetty.Request;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.AbstractHandler;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-3599">MNG-3599</a>.
@ -69,7 +70,9 @@ public class MavenITmng3599useHttpProxyForWebDAVTest
{
Handler handler = new AbstractHandler()
{
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
@Override
public void handle( String target, Request baseRequest, HttpServletRequest request,
HttpServletResponse response )
throws IOException
{
System.out.println( "Got request for URL: '" + request.getRequestURL() + "'" );
@ -115,15 +118,11 @@ public class MavenITmng3599useHttpProxyForWebDAVTest
server = new Server( 0 );
server.setHandler( handler );
server.start();
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
port = server.getConnectors()[0].getLocalPort();
port = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
System.out.println( "Bound server socket to the port " + port );
}

View File

@ -19,18 +19,18 @@ package org.apache.maven.it;
* under the License.
*/
import java.io.File;
import java.io.IOException;
import java.util.List;
import org.apache.maven.it.util.ResourceExtractor;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.maven.it.util.ResourceExtractor;
import org.mortbay.jetty.Handler;
import org.mortbay.jetty.Request;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.AbstractHandler;
import java.io.File;
import java.io.IOException;
import java.util.List;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-3652">MNG-3652</a>.
@ -59,7 +59,9 @@ public class MavenITmng3652UserAgentHeaderTest
{
Handler handler = new AbstractHandler()
{
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
@Override
public void handle( String target, Request baseRequest, HttpServletRequest request,
HttpServletResponse response )
throws IOException
{
System.out.println( "Handling URL: '" + request.getRequestURL() + "'" );
@ -82,15 +84,11 @@ public class MavenITmng3652UserAgentHeaderTest
server = new Server( 0 );
server.setHandler( handler );
server.start();
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
port = server.getConnectors()[0].getLocalPort();
port = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
System.out.println( "Bound server socket to the port " + port );
}

View File

@ -19,21 +19,27 @@ package org.apache.maven.it;
* under the License.
*/
import java.io.File;
import org.apache.maven.it.util.ResourceExtractor;
import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.util.security.Constraint;
import org.eclipse.jetty.util.security.Password;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import org.apache.maven.it.util.ResourceExtractor;
import org.mortbay.jetty.Handler;
import org.mortbay.jetty.Request;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.AbstractHandler;
import org.mortbay.jetty.handler.HandlerList;
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 static org.eclipse.jetty.servlet.ServletContextHandler.SECURITY;
import static org.eclipse.jetty.servlet.ServletContextHandler.SESSIONS;
import static org.eclipse.jetty.util.security.Constraint.__BASIC_AUTH;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-3953">MNG-3953</a>.
@ -61,7 +67,9 @@ public class MavenITmng3953AuthenticatedDeploymentTest
{
Handler repoHandler = new AbstractHandler()
{
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
@Override
public void handle( String target, Request baseRequest, HttpServletRequest request,
HttpServletResponse response )
{
System.out.println( "Handling " + request.getMethod() + " " + request.getRequestURL() );
@ -88,30 +96,27 @@ public class MavenITmng3953AuthenticatedDeploymentTest
constraintMapping.setConstraint( constraint );
constraintMapping.setPathSpec( "/*" );
HashUserRealm userRealm = new HashUserRealm( "TestRealm" );
userRealm.put( "testuser", "testtest" );
userRealm.addUserToRole( "testuser", "deployer" );
HashLoginService userRealm = new HashLoginService( "TestRealm" );
userRealm.putUser( "testuser", new Password( "testtest" ), new String[] { "deployer" } );
SecurityHandler securityHandler = new SecurityHandler();
securityHandler.setUserRealm( userRealm );
server = new Server( 0 );
ServletContextHandler ctx = new ServletContextHandler( server, "/", SESSIONS | SECURITY );
ConstraintSecurityHandler securityHandler = (ConstraintSecurityHandler) ctx.getSecurityHandler();
securityHandler.setLoginService( userRealm );
securityHandler.setAuthMethod( __BASIC_AUTH );
securityHandler.setConstraintMappings( new ConstraintMapping[] { constraintMapping } );
HandlerList handlerList = new HandlerList();
handlerList.addHandler( securityHandler );
handlerList.addHandler( repoHandler );
server = new Server( 0 );
server.setHandler( handlerList );
server.start();
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
port = server.getConnectors()[0].getLocalPort();
port = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
System.out.println( "Bound server socket to the port " + port );
deployed = false;
}

View File

@ -19,18 +19,25 @@ package org.apache.maven.it;
* under the License.
*/
import org.apache.maven.it.util.ResourceExtractor;
import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.util.security.Constraint;
import org.eclipse.jetty.util.security.Password;
import java.io.File;
import java.util.Properties;
import org.apache.maven.it.util.ResourceExtractor;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.DefaultHandler;
import org.mortbay.jetty.handler.HandlerList;
import org.mortbay.jetty.handler.ResourceHandler;
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 static org.eclipse.jetty.servlet.ServletContextHandler.SECURITY;
import static org.eclipse.jetty.servlet.ServletContextHandler.SESSIONS;
import static org.eclipse.jetty.util.security.Constraint.__BASIC_AUTH;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-4068">MNG-4068</a>.
@ -57,8 +64,6 @@ public class MavenITmng4068AuthenticatedMirrorTest
protected void setUp()
throws Exception
{
super.setUp();
testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4068" );
Constraint constraint = new Constraint();
@ -70,12 +75,14 @@ public class MavenITmng4068AuthenticatedMirrorTest
constraintMapping.setConstraint( constraint );
constraintMapping.setPathSpec( "/*" );
HashUserRealm userRealm = new HashUserRealm( "TestRealm" );
userRealm.put( "testuser", "testtest" );
userRealm.addUserToRole( "testuser", "user" );
HashLoginService userRealm = new HashLoginService( "TestRealm" );
userRealm.putUser( "testuser", new Password( "testtest" ), new String[] { "user" } );
SecurityHandler securityHandler = new SecurityHandler();
securityHandler.setUserRealm( userRealm );
server = new Server( 0 );
ServletContextHandler ctx = new ServletContextHandler( server, "/", SESSIONS | SECURITY );
ConstraintSecurityHandler securityHandler = (ConstraintSecurityHandler) ctx.getSecurityHandler();
securityHandler.setLoginService( userRealm );
securityHandler.setAuthMethod( __BASIC_AUTH );
securityHandler.setConstraintMappings( new ConstraintMapping[] { constraintMapping } );
ResourceHandler repoHandler = new ResourceHandler();
@ -86,18 +93,13 @@ public class MavenITmng4068AuthenticatedMirrorTest
handlerList.addHandler( repoHandler );
handlerList.addHandler( new DefaultHandler() );
server = new Server( 0 );
server.setHandler( handlerList );
server.start();
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
port = server.getConnectors()[0].getLocalPort();
port = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
System.out.println( "Bound server socket to the port " + port );
}

View File

@ -22,28 +22,34 @@ package org.apache.maven.it;
import org.apache.maven.it.util.ResourceExtractor;
import org.apache.maven.it.utils.DeployedResource;
import org.codehaus.plexus.util.StringUtils;
import org.mortbay.jetty.HttpMethods;
import org.mortbay.jetty.Request;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.DefaultHandler;
import org.mortbay.jetty.handler.HandlerList;
import org.mortbay.jetty.handler.ResourceHandler;
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.resource.Resource;
import org.mortbay.util.IO;
import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.util.security.Constraint;
import org.eclipse.jetty.util.security.Password;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.nio.file.Files;
import java.util.Deque;
import java.util.Properties;
import java.util.concurrent.ConcurrentLinkedDeque;
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
import static org.eclipse.jetty.servlet.ServletContextHandler.SECURITY;
import static org.eclipse.jetty.servlet.ServletContextHandler.SESSIONS;
import static org.eclipse.jetty.util.security.Constraint.__BASIC_AUTH;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-4235">MNG-4235</a>.
@ -84,13 +90,14 @@ public class MavenITmng4235HttpAuthDeploymentChecksumsTest
constraintMapping.setConstraint( constraint );
constraintMapping.setPathSpec( "/*" );
HashUserRealm userRealm = new HashUserRealm( "TestRealm" );
userRealm.put( "testuser", "testpass" );
userRealm.addUserToRole( "testuser", "deployer" );
HashLoginService userRealm = new HashLoginService( "TestRealm" );
userRealm.putUser( "testuser", new Password( "testpass" ), new String[] { "deployer" } );
SecurityHandler securityHandler = new SecurityHandler();
securityHandler.setUserRealm( userRealm );
securityHandler.setConstraintMappings( new ConstraintMapping[]{ constraintMapping } );
ServletContextHandler ctx = new ServletContextHandler( server, "/", SESSIONS | SECURITY );
ConstraintSecurityHandler securityHandler = (ConstraintSecurityHandler) ctx.getSecurityHandler();
securityHandler.setLoginService( userRealm );
securityHandler.setAuthMethod( __BASIC_AUTH );
securityHandler.setConstraintMappings( new ConstraintMapping[] { constraintMapping } );
HandlerList handlerList = new HandlerList();
handlerList.addHandler( securityHandler );
@ -100,15 +107,11 @@ public class MavenITmng4235HttpAuthDeploymentChecksumsTest
server = new Server( 0 );
server.setHandler( handlerList );
server.start();
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
port = server.getConnectors()[0].getLocalPort();
port = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
System.out.println( "Bound server socket to the port " + port );
}
@ -176,18 +179,18 @@ public class MavenITmng4235HttpAuthDeploymentChecksumsTest
expectedHash.equalsIgnoreCase( actualHash ) );
}
public static class RepoHandler
extends ResourceHandler
private static class RepoHandler
extends ResourceHandler
{
List<DeployedResource> deployedResources = new ArrayList<>();
private final Deque<DeployedResource> deployedResources = new ConcurrentLinkedDeque<>();
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
System.out.println( request.getMethod() + " " + request.getRequestURI() );
if ( HttpMethods.PUT.equals( request.getMethod() ) )
if ( "PUT".equals( request.getMethod() ) )
{
Resource resource = getResource( request );
@ -198,12 +201,7 @@ public class MavenITmng4235HttpAuthDeploymentChecksumsTest
dir.mkdirs();
}
request.getContentLength();
try ( OutputStream os = resource.getOutputStream() )
{
IO.copy( request.getInputStream(), os );
}
Files.copy( request.getInputStream(), resource.getFile().toPath(), REPLACE_EXISTING );
DeployedResource deployedResource = new DeployedResource();
@ -220,10 +218,8 @@ public class MavenITmng4235HttpAuthDeploymentChecksumsTest
}
else
{
super.handle( target, request, response, dispatch );
super.handle( target, baseRequest, request, response );
}
}
}
}

View File

@ -20,10 +20,11 @@ package org.apache.maven.it;
*/
import org.apache.maven.it.util.ResourceExtractor;
import org.mortbay.jetty.Handler;
import org.mortbay.jetty.Request;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.AbstractHandler;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -72,7 +73,9 @@ public class MavenITmng4326LocalSnapshotSuppressesRemoteCheckTest
Handler repoHandler = new AbstractHandler()
{
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
@Override
public void handle( String target, Request baseRequest, HttpServletRequest request,
HttpServletResponse response )
throws IOException
{
PrintWriter writer = response.getWriter();
@ -135,15 +138,11 @@ public class MavenITmng4326LocalSnapshotSuppressesRemoteCheckTest
try
{
server.start();
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
int port = server.getConnectors()[0].getLocalPort();
int port = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
System.out.println( "Bound server socket to the port " + port );
// test 1: resolve snapshot, just built local copy should suppress daily remote update check
verifier = newVerifier( new File( testDir, "test" ).getAbsolutePath() );

View File

@ -32,10 +32,11 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.hamcrest.CoreMatchers;
import org.mortbay.jetty.Handler;
import org.mortbay.jetty.Request;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.AbstractHandler;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.MatcherAssert.assertThat;
@ -68,7 +69,9 @@ public class MavenITmng4343MissingReleaseUpdatePolicyTest
{
Handler repoHandler = new AbstractHandler()
{
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
@Override
public void handle( String target, Request baseRequest, HttpServletRequest request,
HttpServletResponse response )
throws IOException
{
System.out.println( "Handling " + request.getMethod() + " " + request.getRequestURL() );
@ -114,15 +117,11 @@ public class MavenITmng4343MissingReleaseUpdatePolicyTest
server = new Server( 0 );
server.setHandler( repoHandler );
server.start();
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
port = server.getConnectors()[0].getLocalPort();
port = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
System.out.println( "Bound server socket to the port " + port );
requestedUris = new ConcurrentLinkedDeque<>();
}

View File

@ -20,21 +20,20 @@ package org.apache.maven.it;
*/
import org.apache.maven.it.util.ResourceExtractor;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.mortbay.jetty.Handler;
import org.mortbay.jetty.Request;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.AbstractHandler;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-4348">MNG-4348</a>.
*
@ -65,7 +64,9 @@ public class MavenITmng4348NoUnnecessaryRepositoryAccessTest
Handler repoHandler = new AbstractHandler()
{
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
@Override
public void handle( String target, Request baseRequest, HttpServletRequest request,
HttpServletResponse response )
{
System.out.println( "Handling " + request.getMethod() + " " + request.getRequestURL() );
@ -87,15 +88,11 @@ public class MavenITmng4348NoUnnecessaryRepositoryAccessTest
try
{
server.start();
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
int port = server.getConnectors()[0].getLocalPort();
int port = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
System.out.println( "Bound server socket to the port " + port );
verifier.setAutoclean( false );
verifier.deleteArtifacts( "org.apache.maven.its.mng4348" );

View File

@ -20,21 +20,20 @@ package org.apache.maven.it;
*/
import org.apache.maven.it.util.ResourceExtractor;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import java.util.Properties;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.mortbay.jetty.Handler;
import org.mortbay.jetty.Request;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.AbstractHandler;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-4360">MNG-4360</a>.
*
@ -81,7 +80,9 @@ public class MavenITmng4360WebDavSupportTest
Handler repoHandler = new AbstractHandler()
{
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
@Override
public void handle( String target, Request baseRequest, HttpServletRequest request,
HttpServletResponse response )
throws IOException
{
System.out.println( "Handling " + request.getMethod() + " " + request.getRequestURL() );
@ -118,15 +119,11 @@ public class MavenITmng4360WebDavSupportTest
try
{
server.start();
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
int port = server.getConnectors()[0].getLocalPort();
int port = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
System.out.println( "Bound server socket to the port " + port );
verifier.setAutoclean( false );
verifier.deleteArtifacts( "org.apache.maven.its.mng4360" );

View File

@ -20,18 +20,24 @@ package org.apache.maven.it;
*/
import org.apache.maven.it.util.ResourceExtractor;
import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.util.security.Constraint;
import org.eclipse.jetty.util.security.Password;
import java.io.File;
import java.util.Properties;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.DefaultHandler;
import org.mortbay.jetty.handler.HandlerList;
import org.mortbay.jetty.handler.ResourceHandler;
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 static org.eclipse.jetty.servlet.ServletContextHandler.SECURITY;
import static org.eclipse.jetty.servlet.ServletContextHandler.SESSIONS;
import static org.eclipse.jetty.util.security.Constraint.__BASIC_AUTH;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-4413">MNG-4413</a>.
@ -65,12 +71,14 @@ public class MavenITmng4413MirroringOfDependencyRepoTest
constraintMapping.setConstraint( constraint );
constraintMapping.setPathSpec( "/*" );
HashUserRealm userRealm = new HashUserRealm( "TestRealm" );
userRealm.put( "testuser", "testtest" );
userRealm.addUserToRole( "testuser", "user" );
HashLoginService userRealm = new HashLoginService( "TestRealm" );
userRealm.putUser( "testuser", new Password( "testtest" ), new String[] { "user" } );
SecurityHandler securityHandler = new SecurityHandler();
securityHandler.setUserRealm( userRealm );
Server server = new Server( 0 );
ServletContextHandler ctx = new ServletContextHandler( server, "/", SESSIONS | SECURITY );
ConstraintSecurityHandler securityHandler = (ConstraintSecurityHandler) ctx.getSecurityHandler();
securityHandler.setLoginService( userRealm );
securityHandler.setAuthMethod( __BASIC_AUTH );
securityHandler.setConstraintMappings( new ConstraintMapping[] { constraintMapping } );
ResourceHandler repoHandler = new ResourceHandler();
@ -81,21 +89,16 @@ public class MavenITmng4413MirroringOfDependencyRepoTest
handlerList.addHandler( repoHandler );
handlerList.addHandler( new DefaultHandler() );
Server server = new Server( 0 );
server.setHandler( handlerList );
try
{
server.start();
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
int port = server.getConnectors()[0].getLocalPort();
int port = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
System.out.println( "Bound server socket to the port " + port );
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
verifier.setAutoclean( false );

View File

@ -20,21 +20,27 @@ package org.apache.maven.it;
*/
import org.apache.maven.it.util.ResourceExtractor;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.SecureRequestCustomizer;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.SslConnectionFactory;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import java.util.Properties;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Request;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.AbstractHandler;
import org.mortbay.jetty.security.SslSocketConnector;
import static org.eclipse.jetty.http.HttpVersion.HTTP_1_1;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-4428">MNG-4428</a>.
@ -124,28 +130,25 @@ public class MavenITmng4428FollowHttpRedirectTest
String keyPwd = "key-passwd";
Server server = new Server( 0 );
server.addConnector( newHttpsConnector( storePath, storePwd, keyPwd ) );
addHttpsConnector( server, storePath, storePwd, keyPwd );
Connector from = server.getConnectors()[ fromHttp ? 0 : 1 ];
Connector to = server.getConnectors()[ toHttp ? 0 : 1 ];
server.setHandler( new RedirectHandler( toHttp ? "http" : "https", relativeLocation ? null : to ) );
server.setHandler(
new RedirectHandler( toHttp ? "http" : "https", relativeLocation ? null : (NetworkConnector) to ) );
try
{
server.start();
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
verifier.setAutoclean( false );
verifier.deleteArtifacts( "org.apache.maven.its.mng4428" );
verifier.deleteDirectory( "target" );
Properties filterProps = verifier.newDefaultFilterProperties();
filterProps.setProperty( "@protocol@", fromHttp ? "http" : "https" );
filterProps.setProperty( "@port@", Integer.toString( from.getLocalPort() ) );
filterProps.setProperty( "@port@", Integer.toString( ( (NetworkConnector) from ).getLocalPort() ) );
verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", filterProps );
verifier.addCliOption( "-X --settings" );
verifier.addCliOption( "settings.xml" );
@ -166,30 +169,35 @@ public class MavenITmng4428FollowHttpRedirectTest
assertTrue( cp.toString(), cp.contains( "dep-0.1.jar" ) );
}
private Connector newHttpsConnector( String keystore, String storepwd, String keypwd )
private void addHttpsConnector( Server server, String keyStorePath, String keyStorePassword, String keyPassword )
{
SslSocketConnector connector = new SslSocketConnector();
connector.setPort( 0 );
connector.setKeystore( keystore );
connector.setPassword( storepwd );
connector.setKeyPassword( keypwd );
return connector;
SslContextFactory sslContextFactory = new SslContextFactory( keyStorePath );
sslContextFactory.setKeyStorePassword( keyStorePassword );
sslContextFactory.setKeyManagerPassword( keyPassword );
HttpConfiguration httpConfiguration = new HttpConfiguration();
httpConfiguration.setSecureScheme( "https" );
HttpConfiguration httpsConfiguration = new HttpConfiguration( httpConfiguration );
httpsConfiguration.addCustomizer( new SecureRequestCustomizer() );
ServerConnector httpsConnector = new ServerConnector( server,
new SslConnectionFactory( sslContextFactory, HTTP_1_1.asString() ),
new HttpConnectionFactory( httpsConfiguration ) );
server.addConnector( httpsConnector );
}
static class RedirectHandler extends AbstractHandler
{
private final String protocol;
private final Connector connector;
private final NetworkConnector connector;
RedirectHandler( String protocol, Connector connector )
RedirectHandler( String protocol, NetworkConnector connector )
{
this.protocol = protocol;
this.connector = connector;
}
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
public void handle( String target, Request baseRequest, HttpServletRequest request,
HttpServletResponse response )
throws IOException
{
System.out.println( "Handling " + request.getMethod() + " " + request.getRequestURL() );
@ -236,7 +244,5 @@ public class MavenITmng4428FollowHttpRedirectTest
( (Request) request ).setHandled( true );
}
}
}

View File

@ -19,21 +19,27 @@ package org.apache.maven.it;
* under the License.
*/
import java.io.File;
import org.apache.maven.it.util.ResourceExtractor;
import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.util.security.Constraint;
import org.eclipse.jetty.util.security.Password;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import org.apache.maven.it.util.ResourceExtractor;
import org.mortbay.jetty.Handler;
import org.mortbay.jetty.Request;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.AbstractHandler;
import org.mortbay.jetty.handler.HandlerList;
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 static org.eclipse.jetty.servlet.ServletContextHandler.SECURITY;
import static org.eclipse.jetty.servlet.ServletContextHandler.SESSIONS;
import static org.eclipse.jetty.util.security.Constraint.__BASIC_AUTH;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-4469">MNG-4469</a>.
@ -61,7 +67,9 @@ public class MavenITmng4469AuthenticatedDeploymentToCustomRepoTest
{
Handler repoHandler = new AbstractHandler()
{
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
@Override
public void handle( String target, Request baseRequest, HttpServletRequest request,
HttpServletResponse response )
{
System.out.println( "Handling " + request.getMethod() + " " + request.getRequestURL() );
@ -88,30 +96,27 @@ public class MavenITmng4469AuthenticatedDeploymentToCustomRepoTest
constraintMapping.setConstraint( constraint );
constraintMapping.setPathSpec( "/*" );
HashUserRealm userRealm = new HashUserRealm( "TestRealm" );
userRealm.put( "testuser", "testtest" );
userRealm.addUserToRole( "testuser", "deployer" );
HashLoginService userRealm = new HashLoginService( "TestRealm" );
userRealm.putUser( "testuser", new Password( "testtest" ), new String[] { "deployer" } );
SecurityHandler securityHandler = new SecurityHandler();
securityHandler.setUserRealm( userRealm );
server = new Server( 0 );
ServletContextHandler ctx = new ServletContextHandler( server, "/", SESSIONS | SECURITY );
ConstraintSecurityHandler securityHandler = (ConstraintSecurityHandler) ctx.getSecurityHandler();
securityHandler.setLoginService( userRealm );
securityHandler.setAuthMethod( __BASIC_AUTH );
securityHandler.setConstraintMappings( new ConstraintMapping[] { constraintMapping } );
HandlerList handlerList = new HandlerList();
handlerList.addHandler( securityHandler );
handlerList.addHandler( repoHandler );
server = new Server( 0 );
server.setHandler( handlerList );
server.start();
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
port = server.getConnectors()[0].getLocalPort();
port = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
System.out.println( "Bound server socket to the port " + port );
deployed = false;
}

View File

@ -22,24 +22,32 @@ package org.apache.maven.it;
import org.apache.maven.it.util.ResourceExtractor;
import org.apache.maven.it.utils.DeployedResource;
import org.codehaus.plexus.util.StringUtils;
import org.mortbay.jetty.Handler;
import org.mortbay.jetty.Request;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.AbstractHandler;
import org.mortbay.jetty.handler.HandlerList;
import org.mortbay.jetty.security.B64Code;
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.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.util.B64Code;
import org.eclipse.jetty.util.security.Constraint;
import org.eclipse.jetty.util.security.Password;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.Deque;
import java.util.concurrent.ConcurrentLinkedDeque;
import static org.eclipse.jetty.servlet.ServletContextHandler.SECURITY;
import static org.eclipse.jetty.servlet.ServletContextHandler.SESSIONS;
import static org.eclipse.jetty.util.security.Constraint.__BASIC_AUTH;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-4470">MNG-4470</a>.
*
@ -68,7 +76,9 @@ public class MavenITmng4470AuthenticatedDeploymentToProxyTest
{
Handler proxyHandler = new AbstractHandler()
{
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
@Override
public void handle( String target, Request baseRequest, HttpServletRequest request,
HttpServletResponse response )
{
System.out.println( "Handling " + request.getMethod() + " " + request.getRequestURL() );
@ -76,7 +86,7 @@ public class MavenITmng4470AuthenticatedDeploymentToProxyTest
if ( auth != null )
{
auth = auth.substring( auth.indexOf( ' ' ) + 1 ).trim();
auth = B64Code.decode( auth );
auth = B64Code.decode( auth, StandardCharsets.US_ASCII.name() );
}
System.out.println( "Proxy-Authorization: " + auth );
@ -100,7 +110,9 @@ public class MavenITmng4470AuthenticatedDeploymentToProxyTest
Handler repoHandler = new AbstractHandler()
{
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
@Override
public void handle( String target, Request baseRequest, HttpServletRequest request,
HttpServletResponse response )
{
System.out.println( "Handling " + request.getMethod() + " " + request.getRequestURL() );
@ -136,31 +148,28 @@ public class MavenITmng4470AuthenticatedDeploymentToProxyTest
constraintMapping.setConstraint( constraint );
constraintMapping.setPathSpec( "/*" );
HashUserRealm userRealm = new HashUserRealm( "TestRealm" );
userRealm.put( "testuser", "testtest" );
userRealm.addUserToRole( "testuser", "deployer" );
HashLoginService userRealm = new HashLoginService( "TestRealm" );
userRealm.putUser( "testuser", new Password( "testtest" ), new String[] { "deployer" } );
SecurityHandler securityHandler = new SecurityHandler();
securityHandler.setUserRealm( userRealm );
securityHandler.setConstraintMappings( new ConstraintMapping[]{ constraintMapping } );
server = new Server( 0 );
ServletContextHandler ctx = new ServletContextHandler( server, "/", SESSIONS | SECURITY );
ConstraintSecurityHandler securityHandler = (ConstraintSecurityHandler) ctx.getSecurityHandler();
securityHandler.setLoginService( userRealm );
securityHandler.setAuthMethod( __BASIC_AUTH );
securityHandler.setConstraintMappings( new ConstraintMapping[] { constraintMapping } );
HandlerList handlerList = new HandlerList();
handlerList.addHandler( proxyHandler );
handlerList.addHandler( securityHandler );
handlerList.addHandler( repoHandler );
server = new Server( 0 );
server.setHandler( handlerList );
server.start();
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
port = server.getConnectors()[0].getLocalPort();
port = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
System.out.println( "Bound server socket to the port " + port );
deployed = false;
}

View File

@ -20,18 +20,24 @@ package org.apache.maven.it;
*/
import org.apache.maven.it.util.ResourceExtractor;
import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.util.security.Constraint;
import org.eclipse.jetty.util.security.Password;
import java.io.File;
import java.util.Properties;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.DefaultHandler;
import org.mortbay.jetty.handler.HandlerList;
import org.mortbay.jetty.handler.ResourceHandler;
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 static org.eclipse.jetty.servlet.ServletContextHandler.SECURITY;
import static org.eclipse.jetty.servlet.ServletContextHandler.SESSIONS;
import static org.eclipse.jetty.util.security.Constraint.__BASIC_AUTH;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-4489">MNG-4489</a>.
@ -65,12 +71,14 @@ public class MavenITmng4489MirroringOfExtensionRepoTest
constraintMapping.setConstraint( constraint );
constraintMapping.setPathSpec( "/*" );
HashUserRealm userRealm = new HashUserRealm( "TestRealm" );
userRealm.put( "testuser", "testtest" );
userRealm.addUserToRole( "testuser", "user" );
HashLoginService userRealm = new HashLoginService( "TestRealm" );
userRealm.putUser( "testuser", new Password( "testtest" ), new String[] { "user" } );
SecurityHandler securityHandler = new SecurityHandler();
securityHandler.setUserRealm( userRealm );
Server server = new Server( 0 );
ServletContextHandler ctx = new ServletContextHandler( server, "/", SESSIONS | SECURITY );
ConstraintSecurityHandler securityHandler = (ConstraintSecurityHandler) ctx.getSecurityHandler();
securityHandler.setLoginService( userRealm );
securityHandler.setAuthMethod( __BASIC_AUTH );
securityHandler.setConstraintMappings( new ConstraintMapping[] { constraintMapping } );
ResourceHandler repoHandler = new ResourceHandler();
@ -81,21 +89,16 @@ public class MavenITmng4489MirroringOfExtensionRepoTest
handlerList.addHandler( repoHandler );
handlerList.addHandler( new DefaultHandler() );
Server server = new Server( 0 );
server.setHandler( handlerList );
try
{
server.start();
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
int port = server.getConnectors()[0].getLocalPort();
int port = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
System.out.println( "Bound server socket to the port " + port );
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
verifier.setAutoclean( false );

View File

@ -20,22 +20,22 @@ package org.apache.maven.it;
*/
import org.apache.maven.it.util.ResourceExtractor;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.ResourceHandler;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.AbstractHandler;
import org.mortbay.jetty.handler.DefaultHandler;
import org.mortbay.jetty.handler.HandlerList;
import org.mortbay.jetty.handler.ResourceHandler;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-4500">MNG-4500</a>.
*
@ -66,7 +66,9 @@ public class MavenITmng4500NoUpdateOfTimestampedSnapshotsTest
AbstractHandler logHandler = new AbstractHandler()
{
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
@Override
public void handle( String target, Request baseRequest, HttpServletRequest request,
HttpServletResponse response )
{
requestedUris.add( request.getRequestURI() );
}
@ -87,15 +89,11 @@ public class MavenITmng4500NoUpdateOfTimestampedSnapshotsTest
try
{
server.start();
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
int port = server.getConnectors()[0].getLocalPort();
int port = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
System.out.println( "Bound server socket to the port " + port );
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );

View File

@ -19,6 +19,18 @@ package org.apache.maven.it;
* under the License.
*/
import org.apache.maven.it.util.ResourceExtractor;
import org.apache.maven.shared.utils.io.FileUtils;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.ResourceHandler;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@ -26,17 +38,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Properties;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.maven.it.util.ResourceExtractor;
import org.apache.maven.shared.utils.io.FileUtils;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.AbstractHandler;
import org.mortbay.jetty.handler.DefaultHandler;
import org.mortbay.jetty.handler.HandlerList;
import org.mortbay.jetty.handler.ResourceHandler;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-4554">MNG-4554</a>.
*
@ -66,7 +67,9 @@ public class MavenITmng4554PluginPrefixMappingUpdateTest
AbstractHandler logHandler = new AbstractHandler()
{
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
@Override
public void handle( String target, Request baseRequest, HttpServletRequest request,
HttpServletResponse response )
{
requestedUris.add( request.getRequestURI() );
}
@ -87,13 +90,9 @@ public class MavenITmng4554PluginPrefixMappingUpdateTest
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
try
{
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );
@ -107,7 +106,8 @@ public class MavenITmng4554PluginPrefixMappingUpdateTest
assertFalse( new File( verifier.getArtifactMetadataPath( "org.apache.maven.its.mng4554", null, null, "maven-metadata-mng4554.xml" ) ).exists() );
}
Properties filterProps = verifier.newDefaultFilterProperties();
filterProps.setProperty( "@port@", Integer.toString( server.getConnectors()[0].getLocalPort() ) );
NetworkConnector connector = (NetworkConnector) server.getConnectors()[0];
filterProps.setProperty( "@port@", Integer.toString( connector.getLocalPort() ) );
filterProps.setProperty( "@repo@", "repo-1" );
verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", filterProps );
verifier.addCliOption( "-s" );
@ -151,7 +151,9 @@ public class MavenITmng4554PluginPrefixMappingUpdateTest
AbstractHandler logHandler = new AbstractHandler()
{
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
@Override
public void handle( String target, Request baseRequest, HttpServletRequest request,
HttpServletResponse response )
{
requestedUris.add( request.getRequestURI() );
}
@ -172,13 +174,9 @@ public class MavenITmng4554PluginPrefixMappingUpdateTest
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
try
{
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );
@ -192,7 +190,8 @@ public class MavenITmng4554PluginPrefixMappingUpdateTest
assertFalse( new File( verifier.getArtifactMetadataPath( "org.apache.maven.its.mng4554", null, null, "maven-metadata-mng4554.xml" ) ).exists() );
}
Properties filterProps = verifier.newDefaultFilterProperties();
filterProps.setProperty( "@port@", Integer.toString( server.getConnectors()[0].getLocalPort() ) );
NetworkConnector connector = (NetworkConnector) server.getConnectors()[0];
filterProps.setProperty( "@port@", Integer.toString( connector.getLocalPort() ) );
filterProps.setProperty( "@repo@", "repo-1" );
verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", filterProps );
verifier.addCliOption( "-U" );
@ -239,7 +238,9 @@ public class MavenITmng4554PluginPrefixMappingUpdateTest
AbstractHandler logHandler = new AbstractHandler()
{
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
@Override
public void handle( String target, Request baseRequest, HttpServletRequest request,
HttpServletResponse response )
{
requestedUris.add( request.getRequestURI() );
}
@ -260,13 +261,9 @@ public class MavenITmng4554PluginPrefixMappingUpdateTest
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
try
{
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );
@ -280,7 +277,8 @@ public class MavenITmng4554PluginPrefixMappingUpdateTest
assertFalse( new File( verifier.getArtifactMetadataPath( "org.apache.maven.its.mng4554", null, null, "maven-metadata-mng4554.xml" ) ).exists() );
}
Properties filterProps = verifier.newDefaultFilterProperties();
filterProps.setProperty( "@port@", Integer.toString( server.getConnectors()[0].getLocalPort() ) );
NetworkConnector connector = (NetworkConnector) server.getConnectors()[0];
filterProps.setProperty( "@port@", Integer.toString( connector.getLocalPort() ) );
filterProps.setProperty( "@repo@", "repo-it" );
verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", filterProps );
verifier.addCliOption( "-s" );

View File

@ -20,10 +20,11 @@ package org.apache.maven.it;
*/
import org.apache.maven.it.util.ResourceExtractor;
import org.mortbay.jetty.Handler;
import org.mortbay.jetty.Request;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.AbstractHandler;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -58,7 +59,9 @@ public class MavenITmng4555MetaversionResolutionOfflineTest
Handler repoHandler = new AbstractHandler()
{
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
@Override
public void handle( String target, Request baseRequest, HttpServletRequest request,
HttpServletResponse response )
{
String uri = request.getRequestURI();
@ -82,15 +85,11 @@ public class MavenITmng4555MetaversionResolutionOfflineTest
verifier.deleteArtifacts( "org.apache.maven.its.mng4555" );
try
{
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
int port = server.getConnectors()[0].getLocalPort();
int port = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
System.out.println( "Bound server socket to the port " + port );
Properties filterProps = verifier.newDefaultFilterProperties();
filterProps.setProperty( "@port@", Integer.toString( port ) );

View File

@ -20,18 +20,24 @@ package org.apache.maven.it;
*/
import org.apache.maven.it.util.ResourceExtractor;
import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.util.security.Constraint;
import org.eclipse.jetty.util.security.Password;
import java.io.File;
import java.util.Properties;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.DefaultHandler;
import org.mortbay.jetty.handler.HandlerList;
import org.mortbay.jetty.handler.ResourceHandler;
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 static org.eclipse.jetty.servlet.ServletContextHandler.SECURITY;
import static org.eclipse.jetty.servlet.ServletContextHandler.SESSIONS;
import static org.eclipse.jetty.util.security.Constraint.__BASIC_AUTH;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-4561">MNG-4561</a>.
@ -65,12 +71,14 @@ public class MavenITmng4561MirroringOfPluginRepoTest
constraintMapping.setConstraint( constraint );
constraintMapping.setPathSpec( "/*" );
HashUserRealm userRealm = new HashUserRealm( "TestRealm" );
userRealm.put( "testuser", "testtest" );
userRealm.addUserToRole( "testuser", "user" );
HashLoginService userRealm = new HashLoginService( "TestRealm" );
userRealm.putUser( "testuser", new Password( "testtest" ), new String[] { "user" } );
SecurityHandler securityHandler = new SecurityHandler();
securityHandler.setUserRealm( userRealm );
Server server = new Server( 0 );
ServletContextHandler ctx = new ServletContextHandler( server, "/", SESSIONS | SECURITY );
ConstraintSecurityHandler securityHandler = (ConstraintSecurityHandler) ctx.getSecurityHandler();
securityHandler.setLoginService( userRealm );
securityHandler.setAuthMethod( __BASIC_AUTH );
securityHandler.setConstraintMappings( new ConstraintMapping[] { constraintMapping } );
ResourceHandler repoHandler = new ResourceHandler();
@ -81,22 +89,17 @@ public class MavenITmng4561MirroringOfPluginRepoTest
handlerList.addHandler( repoHandler );
handlerList.addHandler( new DefaultHandler() );
Server server = new Server( 0 );
server.setHandler( handlerList );
server.start();
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
try
{
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
int port = server.getConnectors()[0].getLocalPort();
int port = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
System.out.println( "Bound server socket to the port " + port );
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );

View File

@ -20,18 +20,24 @@ package org.apache.maven.it;
*/
import org.apache.maven.it.util.ResourceExtractor;
import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.util.security.Constraint;
import org.eclipse.jetty.util.security.Password;
import java.io.File;
import java.util.Properties;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.DefaultHandler;
import org.mortbay.jetty.handler.HandlerList;
import org.mortbay.jetty.handler.ResourceHandler;
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 static org.eclipse.jetty.servlet.ServletContextHandler.SECURITY;
import static org.eclipse.jetty.servlet.ServletContextHandler.SESSIONS;
import static org.eclipse.jetty.util.security.Constraint.__BASIC_AUTH;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-4729">MNG-4729</a>.
@ -65,12 +71,14 @@ public class MavenITmng4729MirrorProxyAuthUsedByProjectBuilderTest
constraintMapping.setConstraint( constraint );
constraintMapping.setPathSpec( "/*" );
HashUserRealm userRealm = new HashUserRealm( "TestRealm" );
userRealm.put( "testuser", "testtest" );
userRealm.addUserToRole( "testuser", "user" );
HashLoginService userRealm = new HashLoginService( "TestRealm" );
userRealm.putUser( "testuser", new Password( "testtest" ), new String[] { "user" } );
SecurityHandler securityHandler = new SecurityHandler();
securityHandler.setUserRealm( userRealm );
Server server = new Server( 0 );
ServletContextHandler ctx = new ServletContextHandler( server, "/", SESSIONS | SECURITY );
ConstraintSecurityHandler securityHandler = (ConstraintSecurityHandler) ctx.getSecurityHandler();
securityHandler.setLoginService( userRealm );
securityHandler.setAuthMethod( __BASIC_AUTH );
securityHandler.setConstraintMappings( new ConstraintMapping[] { constraintMapping } );
ResourceHandler repoHandler = new ResourceHandler();
@ -81,22 +89,17 @@ public class MavenITmng4729MirrorProxyAuthUsedByProjectBuilderTest
handlerList.addHandler( repoHandler );
handlerList.addHandler( new DefaultHandler() );
Server server = new Server( 0 );
server.setHandler( handlerList );
server.start();
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
try
{
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
int port = server.getConnectors()[0].getLocalPort();
int port = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
System.out.println( "Bound server socket to the port " + port );
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );

View File

@ -20,20 +20,20 @@ package org.apache.maven.it;
*/
import org.apache.maven.it.util.ResourceExtractor;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.Deque;
import java.util.Properties;
import java.util.concurrent.ConcurrentLinkedDeque;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.AbstractHandler;
import org.mortbay.jetty.handler.DefaultHandler;
import org.mortbay.jetty.handler.HandlerList;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-4771">MNG-4771</a>.
*
@ -61,7 +61,9 @@ public class MavenITmng4771PluginPrefixResolutionDoesntTouchDisabledRepoTest
AbstractHandler logHandler = new AbstractHandler()
{
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
@Override
public void handle( String target, Request baseRequest, HttpServletRequest request,
HttpServletResponse response )
{
requestedUris.add( request.getRequestURI() );
}
@ -78,15 +80,11 @@ public class MavenITmng4771PluginPrefixResolutionDoesntTouchDisabledRepoTest
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
try
{
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
int port = server.getConnectors()[0].getLocalPort();
int port = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
System.out.println( "Bound server socket to the port " + port );
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );

View File

@ -20,21 +20,21 @@ package org.apache.maven.it;
*/
import org.apache.maven.it.util.ResourceExtractor;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.AbstractHandler;
import org.mortbay.jetty.handler.DefaultHandler;
import org.mortbay.jetty.handler.HandlerList;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-4772">MNG-4772</a>.
*
@ -62,7 +62,9 @@ public class MavenITmng4772PluginVersionResolutionDoesntTouchDisabledRepoTest
AbstractHandler logHandler = new AbstractHandler()
{
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
@Override
public void handle( String target, Request baseRequest, HttpServletRequest request,
HttpServletResponse response )
{
requestedUris.add( request.getRequestURI() );
}
@ -79,15 +81,11 @@ public class MavenITmng4772PluginVersionResolutionDoesntTouchDisabledRepoTest
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
try
{
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
int port = server.getConnectors()[0].getLocalPort();
int port = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
System.out.println( "Bound server socket to the port " + port );
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );

View File

@ -19,19 +19,19 @@ package org.apache.maven.it;
* under the License.
*/
import java.io.File;
import java.util.Deque;
import java.util.concurrent.ConcurrentLinkedDeque;
import org.apache.maven.it.util.ResourceExtractor;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.maven.it.util.ResourceExtractor;
import org.mortbay.jetty.Handler;
import org.mortbay.jetty.Request;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.AbstractHandler;
import org.mortbay.jetty.handler.HandlerList;
import java.io.File;
import java.util.Deque;
import java.util.concurrent.ConcurrentLinkedDeque;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.MatcherAssert.assertThat;
@ -64,7 +64,8 @@ public class MavenITmng4781DeploymentToNexusStagingRepoTest
{
private volatile boolean putSeen;
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
@Override
public void handle( String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response )
{
System.out.println( "Handling " + request.getMethod() + " " + request.getRequestURL() );
@ -94,15 +95,11 @@ public class MavenITmng4781DeploymentToNexusStagingRepoTest
server = new Server( 0 );
server.setHandler( handlerList );
server.start();
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
port = server.getConnectors()[0].getLocalPort();
port = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
System.out.println( "Bound server socket to the port " + port );
}

View File

@ -20,11 +20,12 @@ package org.apache.maven.it;
*/
import org.apache.maven.it.util.ResourceExtractor;
import org.mortbay.jetty.Handler;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.DefaultHandler;
import org.mortbay.jetty.handler.HandlerList;
import org.mortbay.jetty.handler.ResourceHandler;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.ResourceHandler;
import java.io.File;
import java.net.InetAddress;
@ -73,31 +74,25 @@ public class MavenITmng4991NonProxyHostsTest
try
{
server.start();
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
proxy.start();
while ( !proxy.isRunning() || !proxy.isStarted() )
if ( proxy.isFailed() )
{
if ( proxy.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );
verifier.deleteArtifacts( "org.apache.maven.its.mng4991" );
Properties filterProps = verifier.newDefaultFilterProperties();
filterProps.setProperty( "@port@", Integer.toString( server.getConnectors()[0].getLocalPort() ) );
filterProps.setProperty( "@proxyPort@", Integer.toString( proxy.getConnectors()[0].getLocalPort() ) );
int port = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
filterProps.setProperty( "@port@", Integer.toString( port ) );
int proxyPort = ( (NetworkConnector) proxy.getConnectors()[0] ).getLocalPort();
filterProps.setProperty( "@proxyPort@", Integer.toString( proxyPort ) );
filterProps.setProperty( "@localhost@", InetAddress.getLocalHost().getCanonicalHostName() );
verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", filterProps );
verifier.addCliOption( "-s" );

View File

@ -20,22 +20,22 @@ package org.apache.maven.it;
*/
import org.apache.maven.it.util.ResourceExtractor;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.ResourceHandler;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.AbstractHandler;
import org.mortbay.jetty.handler.DefaultHandler;
import org.mortbay.jetty.handler.HandlerList;
import org.mortbay.jetty.handler.ResourceHandler;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-5064">MNG-5064</a>.
*
@ -65,7 +65,9 @@ public class MavenITmng5064SuppressSnapshotUpdatesTest
AbstractHandler logHandler = new AbstractHandler()
{
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
@Override
public void handle( String target, Request baseRequest, HttpServletRequest request,
HttpServletResponse response )
{
if ( request.getRequestURI().startsWith( "/repo/" ) )
{
@ -89,15 +91,11 @@ public class MavenITmng5064SuppressSnapshotUpdatesTest
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
try
{
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
int port = server.getConnectors()[0].getLocalPort();
int port = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
System.out.println( "Bound server socket to the port " + port );
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );

View File

@ -20,10 +20,11 @@ package org.apache.maven.it;
*/
import org.apache.maven.it.util.ResourceExtractor;
import org.mortbay.jetty.Handler;
import org.mortbay.jetty.Request;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.AbstractHandler;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@ -56,7 +57,9 @@ public class MavenITmng5175WagonHttpTest
{
Handler handler = new AbstractHandler()
{
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
@Override
public void handle( String target, Request baseRequest, HttpServletRequest request,
HttpServletResponse response )
throws IOException, ServletException
{
try
@ -79,15 +82,11 @@ public class MavenITmng5175WagonHttpTest
server = new Server( 0 );
server.setHandler( handler );
server.start();
while ( !server.isRunning() || !server.isStarted() )
if ( server.isFailed() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
fail( "Couldn't bind the server socket to a free port!" );
}
port = server.getConnectors()[0].getLocalPort();
port = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
System.out.println( "Bound server socket to the port " + port );
}
@ -121,9 +120,13 @@ public class MavenITmng5175WagonHttpTest
verifier.addCliOption( "-U" );
verifier.addCliOption( "--settings" );
verifier.addCliOption( "settings.xml" );
//verifier.
verifier.addCliOption( "--fail-never" );
verifier.addCliOption( "--errors" );
verifier.setMavenDebug( true );
verifier.executeGoal( "validate" );
verifier.verifyTextInLog(
"Could not transfer artifact org.apache.maven.its.mng5175:fake-dependency:pom:1.0-SNAPSHOT" );
verifier.verifyTextInLog( "Read timed out" );
verifier.resetStreams();
}

View File

@ -19,6 +19,14 @@ package org.apache.maven.it;
* under the License.
*/
import org.apache.maven.it.util.ResourceExtractor;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@ -27,14 +35,6 @@ import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Properties;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.maven.it.util.ResourceExtractor;
import org.mortbay.jetty.Request;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.AbstractHandler;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-5280">MNG-5280</a>.
*
@ -47,8 +47,6 @@ public class MavenITmng5280SettingsProfilesRepositoriesOrderTest
private Server server;
private int httpPort;
public MavenITmng5280SettingsProfilesRepositoriesOrderTest()
{
super( "[3.1-A,)" );
@ -59,19 +57,7 @@ public class MavenITmng5280SettingsProfilesRepositoriesOrderTest
throws Exception
{
testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5280" );
server = new Server( 0 );
server.start();
while ( !server.isRunning() || !server.isStarted() )
{
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
Thread.sleep( 100L );
}
httpPort = server.getConnectors()[0].getLocalPort();
System.out.println( "Bound server socket to the port " + httpPort );
}
@Override
@ -93,6 +79,13 @@ public class MavenITmng5280SettingsProfilesRepositoriesOrderTest
{
RepoHandler repoHandler = new RepoHandler();
server.setHandler( repoHandler );
server.start();
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
int httpPort = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
System.out.println( "Bound server socket to the port " + httpPort );
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
@ -120,6 +113,13 @@ public class MavenITmng5280SettingsProfilesRepositoriesOrderTest
{
PluginRepoHandler pluginRepoHandler = new PluginRepoHandler();
server.setHandler( pluginRepoHandler );
server.start();
if ( server.isFailed() )
{
fail( "Couldn't bind the server socket to a free port!" );
}
int httpPort = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
System.out.println( "Bound server socket to the port " + httpPort );
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
@ -145,7 +145,8 @@ public class MavenITmng5280SettingsProfilesRepositoriesOrderTest
private volatile boolean artifactRequestedFromRepo2;
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
public void handle( String target, Request baseRequest, HttpServletRequest request,
HttpServletResponse response )
throws IOException
{
String uri = request.getRequestURI();
@ -202,7 +203,8 @@ public class MavenITmng5280SettingsProfilesRepositoriesOrderTest
private volatile boolean pluginRequestedFromRepo2;
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
public void handle( String target, Request baseRequest, HttpServletRequest request,
HttpServletResponse response )
throws IOException
{
String uri = request.getRequestURI();

View File

@ -1,157 +0,0 @@
package org.mortbay.log;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import java.io.PrintStream;
/**
* A modified version of the original Jetty logger which treats info level the same as debug level. This is merely meant
* as a cosmetic tweak to reduce the log noise from Jetty on the console during our tests.
*
* @author Benjamin Bentmann
* @version $Id$
*/
public class StdErrLog
implements Logger
{
private static boolean debug = System.getProperty( "DEBUG" ) != null;
private String name;
private boolean hideStacks;
private PrintStream out = System.err;
private static final String PREFIX = "[JETTY] ";
public StdErrLog()
{
this( null );
}
public StdErrLog( String name )
{
this.name = ( name == null ) ? "" : name;
}
public boolean isDebugEnabled()
{
return debug;
}
public void setDebugEnabled( boolean enabled )
{
debug = enabled;
}
public boolean isHideStacks()
{
return hideStacks;
}
public void setHideStacks( boolean hideStacks )
{
this.hideStacks = hideStacks;
}
public void debug( String msg, Throwable th )
{
if ( debug )
{
this.out.println( PREFIX + msg );
if ( th != null )
{
if ( hideStacks )
this.out.println( th );
else
th.printStackTrace( this.out );
}
}
}
public void debug( String msg, Object arg0, Object arg1 )
{
if ( debug )
{
this.out.println( PREFIX + format( msg, arg0, arg1 ) );
}
}
public void info( String msg, Object arg0, Object arg1 )
{
if ( debug )
{
this.out.println( PREFIX + format( msg, arg0, arg1 ) );
}
}
public void warn( String msg, Object arg0, Object arg1 )
{
this.out.println( PREFIX + format( msg, arg0, arg1 ) );
}
public void warn( String msg, Throwable th )
{
this.out.println( PREFIX + msg );
if ( th != null )
{
if ( this.hideStacks )
{
this.out.println( th );
}
else
{
th.printStackTrace( this.out );
}
}
}
private String format( String msg, Object arg0, Object arg1 )
{
int i0 = msg.indexOf( "{}" );
int i1 = i0 < 0 ? -1 : msg.indexOf( "{}", i0 + 2 );
if ( arg1 != null && i1 >= 0 )
{
msg = msg.substring( 0, i1 ) + arg1 + msg.substring( i1 + 2 );
}
if ( arg0 != null && i0 >= 0 )
{
msg = msg.substring( 0, i0 ) + arg0 + msg.substring( i0 + 2 );
}
return msg;
}
public Logger getLogger( String name )
{
if ( ( name == null && this.name == null ) || ( name != null && name.equals( this.name ) ) )
{
return this;
}
return new StdErrLog( name );
}
public String toString()
{
return "STDERR" + this.name;
}
}