mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 21:11:28 +07:00
[maven] IDEA-358622 test Incremental Sync queries for SNAPSHOT Artifacts updates with "Always update snapshots" enabled
GitOrigin-RevId: eef7bb3564706c238ccbd5c95e5748e849894964
This commit is contained in:
committed by
intellij-monorepo-bot
parent
0c507c9ca3
commit
4b1e4cb6cc
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata modelVersion="1.1.0">
|
||||
<groupId>org.mytest</groupId>
|
||||
<artifactId>myartifact</artifactId>
|
||||
<versioning>
|
||||
<lastUpdated>20240912201701</lastUpdated>
|
||||
<snapshot>
|
||||
<timestamp>20240912.201701</timestamp>
|
||||
<buildNumber>3</buildNumber>
|
||||
</snapshot>
|
||||
<snapshotVersions>
|
||||
<snapshotVersion>
|
||||
<extension>pom</extension>
|
||||
<value>1.0-20240912.201701-3</value>
|
||||
<updated>20240912201701</updated>
|
||||
</snapshotVersion>
|
||||
<snapshotVersion>
|
||||
<extension>jar</extension>
|
||||
<value>1.0-20240912.201701-3</value>
|
||||
<updated>20240912201701</updated>
|
||||
</snapshotVersion>
|
||||
</snapshotVersions>
|
||||
</versioning>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</metadata>
|
||||
@@ -0,0 +1 @@
|
||||
6316ec46488a779955825a188a70d128092f921f -
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
72cfe5ed1baeae1f6637c923e8e35f751e71650c -
|
||||
@@ -0,0 +1,17 @@
|
||||
<?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.mytest</groupId>
|
||||
<artifactId>myartifact</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>19</maven.compiler.source>
|
||||
<maven.compiler.target>19</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1 @@
|
||||
2e10cf1b96634c767ab169344339ab31d4c13ce5 -
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata modelVersion="1.1.0">
|
||||
<groupId>org.mytest</groupId>
|
||||
<artifactId>myartifact</artifactId>
|
||||
<versioning>
|
||||
<lastUpdated>20240912201843</lastUpdated>
|
||||
<snapshot>
|
||||
<timestamp>20240912.201843</timestamp>
|
||||
<buildNumber>4</buildNumber>
|
||||
</snapshot>
|
||||
<snapshotVersions>
|
||||
<snapshotVersion>
|
||||
<extension>pom</extension>
|
||||
<value>1.0-20240912.201843-4</value>
|
||||
<updated>20240912201843</updated>
|
||||
</snapshotVersion>
|
||||
<snapshotVersion>
|
||||
<extension>jar</extension>
|
||||
<value>1.0-20240912.201843-4</value>
|
||||
<updated>20240912201843</updated>
|
||||
</snapshotVersion>
|
||||
</snapshotVersions>
|
||||
</versioning>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</metadata>
|
||||
@@ -0,0 +1 @@
|
||||
e80cade94740ca6346b3e5d86ec050641afac5e1 -
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
77fff484adddb2065b73ab78c00658343d380c95 -
|
||||
@@ -0,0 +1,17 @@
|
||||
<?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.mytest</groupId>
|
||||
<artifactId>myartifact</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>19</maven.compiler.source>
|
||||
<maven.compiler.target>19</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1 @@
|
||||
2e10cf1b96634c767ab169344339ab31d4c13ce5 -
|
||||
@@ -40,8 +40,12 @@ public class MavenCustomRepositoryHelper {
|
||||
}
|
||||
|
||||
public void addTestData(String relativePath) throws IOException {
|
||||
File to = new File(myWorkingData, relativePath);
|
||||
FileUtil.copyDir(new File(getOriginalTestDataPath(), relativePath), to);
|
||||
addTestData(relativePath, relativePath);
|
||||
}
|
||||
|
||||
public void addTestData(String relativePathFrom, String relativePathTo) throws IOException {
|
||||
File to = new File(myWorkingData, relativePathTo);
|
||||
FileUtil.copyDir(new File(getOriginalTestDataPath(), relativePathFrom), to);
|
||||
LocalFileSystem.getInstance().refreshIoFiles(Collections.singleton(to));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.idea.maven.importing
|
||||
|
||||
import com.intellij.maven.testFramework.MavenMultiVersionImportingTestCase
|
||||
import com.intellij.maven.testFramework.utils.MavenHttpRepositoryServerFixture
|
||||
import com.intellij.testFramework.common.runAll
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.jetbrains.idea.maven.MavenCustomRepositoryHelper
|
||||
import org.junit.Test
|
||||
|
||||
class MavenSnapshotDependenciesTest : MavenMultiVersionImportingTestCase() {
|
||||
private val httpServerFixture = MavenHttpRepositoryServerFixture()
|
||||
|
||||
public override fun setUp() {
|
||||
super.setUp()
|
||||
httpServerFixture.setUp()
|
||||
}
|
||||
|
||||
public override fun tearDown() {
|
||||
runAll(
|
||||
{ httpServerFixture.tearDown() },
|
||||
{ super.tearDown() },
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test incremental sync update snapshot dependency`() = runBlocking {
|
||||
needFixForMaven4() // TODO: fix for Maven 4
|
||||
val helper = MavenCustomRepositoryHelper(dir, "local1")
|
||||
helper.addTestData("remote_snapshot/1", "remote")
|
||||
val remoteRepoPath = helper.getTestDataPath("remote")
|
||||
val localRepoPath = helper.getTestDataPath("local1")
|
||||
httpServerFixture.startRepositoryFor(remoteRepoPath)
|
||||
repositoryPath = localRepoPath
|
||||
val settingsXml = createProjectSubFile(
|
||||
"settings.xml",
|
||||
"""
|
||||
<settings>
|
||||
<localRepository>$localRepoPath</localRepository>
|
||||
</settings>
|
||||
""".trimIndent())
|
||||
mavenGeneralSettings.setUserSettingsFile(settingsXml.canonicalPath)
|
||||
mavenGeneralSettings.isAlwaysUpdateSnapshots = true
|
||||
removeFromLocalRepository("org/mytest/myartifact/")
|
||||
|
||||
val jarSnapshot = "local1/org/mytest/myartifact/1.0-SNAPSHOT/myartifact-1.0-SNAPSHOT.jar"
|
||||
val jarVersion3 = "local1/org/mytest/myartifact/1.0-SNAPSHOT/myartifact-1.0-20240912.201701-3.jar"
|
||||
val jarVersion4 = "local1/org/mytest/myartifact/1.0-SNAPSHOT/myartifact-1.0-20240912.201843-4.jar"
|
||||
|
||||
assertFalse(helper.getTestData(jarSnapshot).isFile)
|
||||
assertFalse(helper.getTestData(jarVersion3).isFile)
|
||||
assertFalse(helper.getTestData(jarVersion4).isFile)
|
||||
importProjectAsync("""
|
||||
<groupId>test</groupId>
|
||||
<artifactId>project</artifactId>
|
||||
<version>1</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.mytest</groupId>
|
||||
<artifactId>myartifact</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>my-http-repository</id>
|
||||
<name>my-http-repository</name>
|
||||
<url>${httpServerFixture.url()}</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
""".trimIndent())
|
||||
|
||||
assertTrue(helper.getTestData(jarSnapshot).isFile)
|
||||
assertTrue(helper.getTestData(jarVersion3).isFile)
|
||||
assertFalse(helper.getTestData(jarVersion4).isFile)
|
||||
assertTrue(fileContentEqual(helper.getTestData(jarSnapshot), helper.getTestData(jarVersion3)))
|
||||
|
||||
helper.delete("remote")
|
||||
helper.addTestData("remote_snapshot/2", "remote")
|
||||
|
||||
updateAllProjects()
|
||||
updateAllProjectsFullSync() // TODO: incremental sync must be enough
|
||||
|
||||
assertTrue(helper.getTestData(jarSnapshot).isFile)
|
||||
assertTrue(helper.getTestData(jarVersion3).isFile)
|
||||
assertTrue(helper.getTestData(jarVersion4).isFile)
|
||||
assertTrue(fileContentEqual(helper.getTestData(jarSnapshot), helper.getTestData(jarVersion4)))
|
||||
}
|
||||
|
||||
}
|
||||
@@ -755,6 +755,13 @@ abstract class MavenTestCase : UsefulTestCase() {
|
||||
private val testMavenHome: String?
|
||||
get() = System.getProperty("idea.maven.test.home")
|
||||
|
||||
protected fun fileContentEqual(file1: File, file2: File): Boolean {
|
||||
val file1Bytes = file1.readBytes()
|
||||
val file2Bytes = file2.readBytes()
|
||||
|
||||
return file1Bytes.contentEquals(file2Bytes)
|
||||
}
|
||||
|
||||
companion object {
|
||||
val preimportTestMode: Boolean = java.lang.Boolean.getBoolean("MAVEN_TEST_PREIMPORT")
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class MavenHttpRepositoryServerFixture : IdeaTestFixture {
|
||||
return expectedUsername == username && expectedPassword == password && expectedPassword != null
|
||||
}
|
||||
}
|
||||
setupRemoteRepositoryServerInMemory(repo, contextPath, authenticator)
|
||||
setupRemoteRepositoryServerReadFiles(repo, contextPath, authenticator)
|
||||
}
|
||||
|
||||
fun startRepositoryFor(repo: File, expectedUsername: String, expectedPassword: String) {
|
||||
|
||||
Reference in New Issue
Block a user