[MNG-4781] Can't deploy to Nexus staging repository

o Added IT

git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@989830 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2010-08-26 17:12:30 +00:00
parent f7af83166d
commit de93e51e31
3 changed files with 221 additions and 0 deletions

View File

@ -81,6 +81,7 @@ public class IntegrationTestSuite
// -------------------------------------------------------------------------------------------------------------
// suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
suite.addTestSuite( MavenITmng4781DeploymentToNexusStagingRepoTest.class );
suite.addTestSuite( MavenITmng4779MultipleDepsWithVersionRangeFromLocalRepoTest.class );
suite.addTestSuite( MavenITmng4776ForkedReactorPluginVersionResolutionTest.class );
suite.addTestSuite( MavenITmng4772PluginVersionResolutionDoesntTouchDisabledRepoTest.class );

View File

@ -0,0 +1,151 @@
package org.apache.maven.it;
/*
* 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.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.maven.it.Verifier;
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;
/**
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4781">MNG-4781</a>.
*
* @author Benjamin Bentmann
*/
public class MavenITmng4781DeploymentToNexusStagingRepoTest
extends AbstractMavenIntegrationTestCase
{
private Server server;
private int port;
private List requestedUris = Collections.synchronizedList( new ArrayList() );
private List deployedUris = Collections.synchronizedList( new ArrayList() );
public MavenITmng4781DeploymentToNexusStagingRepoTest()
{
super( "[2.0.3,)" );
}
public void setUp()
throws Exception
{
super.setUp();
Handler repoHandler = new AbstractHandler()
{
private boolean putSeen;
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
throws IOException, ServletException
{
System.out.println( "Handling " + request.getMethod() + " " + request.getRequestURL() );
if ( "PUT".equalsIgnoreCase( request.getMethod() ) )
{
response.setStatus( HttpServletResponse.SC_OK );
deployedUris.add( request.getRequestURI() );
putSeen = true;
}
else if ( !putSeen )
{
response.setStatus( HttpServletResponse.SC_BAD_REQUEST );
}
else
{
response.setStatus( HttpServletResponse.SC_NOT_FOUND );
requestedUris.add( request.getRequestURI() );
}
( (Request) request ).setHandled( true );
}
};
HandlerList handlerList = new HandlerList();
handlerList.addHandler( repoHandler );
server = new Server( 0 );
server.setHandler( handlerList );
server.start();
port = server.getConnectors()[0].getLocalPort();
}
protected void tearDown()
throws Exception
{
if ( server != null )
{
server.stop();
server = null;
}
requestedUris.clear();
deployedUris.clear();
super.tearDown();
}
/**
* Verify that deployment to a Nexus-like staging repository works. The subtle difference compared to an ordinary
* HTTP/WebDAV server is that those staging repos yield a HTTP 400 (and not 404) for every GET request until a
* PUT request is made (which initializes the staging repo). The bottom line is that remote metadata must not be
* requested before the first artifact is deployed.
*/
public void testit()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4781" );
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
verifier.setAutoclean( false );
verifier.getCliOptions().add( "-DdeploymentPort=" + port );
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
assertTrue( deployedUris.toString(),
deployedUris.contains( "/repo/org/apache/maven/its/mng4781/release/1.0/release-1.0.jar" ) );
assertTrue( deployedUris.toString(),
deployedUris.contains( "/repo/org/apache/maven/its/mng4781/release/1.0/release-1.0.pom" ) );
assertTrue( deployedUris.toString(),
deployedUris.contains( "/repo/org/apache/maven/its/mng4781/release/maven-metadata.xml" ) );
assertTrue( requestedUris.toString(),
deployedUris.contains( "/repo/org/apache/maven/its/mng4781/release/maven-metadata.xml" ) );
}
}

View File

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.mng4781</groupId>
<artifactId>release</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>Maven Integration Test :: MNG-4781</name>
<description>
Verify that deployment to a Nexus-like staging repository works. The subtle difference compared to an ordinary
HTTP/WebDAV server is that those staging repos yield a HTTP 400 (and not 404) for every GET request until a
PUT request is made (which initializes the staging repo). The bottom line is that remote metadata must not be
requested before the first artifact is deployed.
</description>
<distributionManagement>
<repository>
<id>maven-core-it-mng-4781</id>
<url>http://localhost:${deploymentPort}/repo</url>
</repository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-artifact</artifactId>
<version>2.1-SNAPSHOT</version>
<configuration>
<mainFile>pom.xml</mainFile>
</configuration>
<executions>
<execution>
<id>test</id>
<phase>validate</phase>
<goals>
<goal>set</goal>
<goal>attach-pom</goal>
<goal>install</goal>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>