mirror of https://github.com/apache/maven.git
[MNG-7819] Add IT that excercise the bug (#271)
Template/reproducer: https://gist.github.com/cstamas/3f15775bd4785a5f4b157399f52af6fc While local repo is empty. --- https://issues.apache.org/jira/browse/MNG-7819
This commit is contained in:
parent
0226d93b9e
commit
24f25a0a71
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.apache.maven.it;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.maven.shared.verifier.Verifier;
|
||||
import org.apache.maven.shared.verifier.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.HandlerList;
|
||||
import org.eclipse.jetty.server.handler.ResourceHandler;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class MavenITmng7819FileLockingWithSnapshotsTest extends AbstractMavenIntegrationTestCase {
|
||||
|
||||
private Server server;
|
||||
|
||||
private int port;
|
||||
|
||||
protected MavenITmng7819FileLockingWithSnapshotsTest() {
|
||||
// broken: maven 3.9.2 and 4.0.0-alpha-5
|
||||
super("[3.9.0,3.9.2),(3.9.2,3.999.999],[4.0.0-alpha-6,)");
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
protected void setUp() throws Exception {
|
||||
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-7819-file-locking-with-snapshots");
|
||||
server = new Server(0);
|
||||
ResourceHandler resourceHandler = new ResourceHandler();
|
||||
resourceHandler.setWelcomeFiles(new String[] {"index.html"});
|
||||
resourceHandler.setDirectoriesListed(true);
|
||||
resourceHandler.setResourceBase(new File(testDir, "repo").getAbsolutePath());
|
||||
HandlerList handlerList = new HandlerList();
|
||||
handlerList.setHandlers(new Handler[] {resourceHandler});
|
||||
server.setHandler(handlerList);
|
||||
server.start();
|
||||
if (server.isFailed()) {
|
||||
fail("Couldn't bind the server socket to a free port!");
|
||||
}
|
||||
port = ((NetworkConnector) server.getConnectors()[0]).getLocalPort();
|
||||
System.out.println("Bound server socket to the port " + port);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
protected void tearDown() throws Exception {
|
||||
if (server != null) {
|
||||
server.stop();
|
||||
server.join();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFileLockingAndSnapshots() throws Exception {
|
||||
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-7819-file-locking-with-snapshots");
|
||||
|
||||
Verifier verifier = newVerifier(testDir.getAbsolutePath());
|
||||
verifier.setForkJvm(true);
|
||||
|
||||
// produce required precondition state: local repository must not have any of the org.apache.maven.its.mng7819
|
||||
// artifacts
|
||||
String path = verifier.getArtifactPath("org.apache.maven.its.mng7819", "dependency", "1.0.0-SNAPSHOT", "pom");
|
||||
File groupDirectory = new File(path).getParentFile().getParentFile().getParentFile();
|
||||
FileUtils.deleteDirectory(groupDirectory);
|
||||
|
||||
Map<String, String> properties = new HashMap<>();
|
||||
properties.put("@port@", Integer.toString(port));
|
||||
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8", properties);
|
||||
|
||||
verifier.addCliArgument("-e");
|
||||
verifier.addCliArgument("-s");
|
||||
verifier.addCliArgument(new File(testDir, "settings.xml").getAbsolutePath());
|
||||
verifier.addCliArgument("-Pmaven-core-it-repo");
|
||||
|
||||
verifier.addCliArgument("-Daether.syncContext.named.nameMapper=file-gav");
|
||||
verifier.addCliArgument("-Daether.syncContext.named.factory=file-lock");
|
||||
verifier.addCliArgument("package");
|
||||
|
||||
verifier.execute();
|
||||
|
||||
verifier.verifyErrorFreeLog();
|
||||
}
|
||||
}
|
|
@ -120,6 +120,7 @@ public class TestSuiteOrdering implements ClassOrderer {
|
|||
* the tests are to finishing. Newer tests are also more likely to fail, so this is
|
||||
* a fail fast technique as well.
|
||||
*/
|
||||
suite.addTestSuite(MavenITmng7819FileLockingWithSnapshotsTest.class);
|
||||
suite.addTestSuite(MavenITmng5600DependencyManagementImportExclusionsTest.class);
|
||||
suite.addTestSuite(MavenITmng7740ConsumerBuildShouldCleanUpOldFilesTest.class);
|
||||
suite.addTestSuite(MavenITmng7587Jsr330.class);
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.apache.maven.its.mng7819</groupId>
|
||||
<artifactId>test</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.its.mng7819</groupId>
|
||||
<artifactId>dependency</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1 @@
|
|||
FAKEJAR
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.apache.maven.its.mng7819</groupId>
|
||||
<artifactId>parent</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>dependency</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</project>
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata modelVersion="1.1.0">
|
||||
<groupId>org.apache.maven.its.mng7819</groupId>
|
||||
<artifactId>dependency</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<versioning>
|
||||
<snapshot>
|
||||
<timestamp>20221014.203717</timestamp>
|
||||
<buildNumber>12</buildNumber>
|
||||
</snapshot>
|
||||
<lastUpdated>20221014203717</lastUpdated>
|
||||
<snapshotVersions>
|
||||
<snapshotVersion>
|
||||
<extension>jar</extension>
|
||||
<value>1.0.0-20221014.203717-12</value>
|
||||
<updated>20221014203717</updated>
|
||||
</snapshotVersion>
|
||||
<snapshotVersion>
|
||||
<extension>pom</extension>
|
||||
<value>1.0.0-20221014.203717-12</value>
|
||||
<updated>20221014203717</updated>
|
||||
</snapshotVersion>
|
||||
</snapshotVersions>
|
||||
</versioning>
|
||||
</metadata>
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata modelVersion="1.1.0">
|
||||
<groupId>org.apache.maven.its.mng7819</groupId>
|
||||
<artifactId>parent</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<versioning>
|
||||
<snapshot>
|
||||
<timestamp>20221014.203717</timestamp>
|
||||
<buildNumber>12</buildNumber>
|
||||
</snapshot>
|
||||
<lastUpdated>20221014203717</lastUpdated>
|
||||
<snapshotVersions>
|
||||
<snapshotVersion>
|
||||
<extension>pom</extension>
|
||||
<value>1.0.0-20221014.203717-12</value>
|
||||
<updated>20221014203717</updated>
|
||||
</snapshotVersion>
|
||||
</snapshotVersions>
|
||||
</versioning>
|
||||
</metadata>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.apache.maven.its.mng7819</groupId>
|
||||
<artifactId>dependency</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</project>
|
|
@ -0,0 +1,60 @@
|
|||
<?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.
|
||||
-->
|
||||
|
||||
<settings>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>maven-core-it-repo</id>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>maven-core-it</id>
|
||||
<url>http://localhost:@port@</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
<checksumPolicy>ignore</checksumPolicy>
|
||||
<updatePolicy>never</updatePolicy>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<checksumPolicy>ignore</checksumPolicy>
|
||||
<updatePolicy>never</updatePolicy>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>maven-core-it</id>
|
||||
<url>http://localhost:@port@</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
<checksumPolicy>ignore</checksumPolicy>
|
||||
<updatePolicy>never</updatePolicy>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<checksumPolicy>ignore</checksumPolicy>
|
||||
<updatePolicy>never</updatePolicy>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</profile>
|
||||
</profiles>
|
||||
</settings>
|
Loading…
Reference in New Issue