Skip to content

Commit

Permalink
add test for multi module project
Browse files Browse the repository at this point in the history
  • Loading branch information
sparsick committed Oct 4, 2022
1 parent 122ce21 commit 790ab5e
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package io.github.georgberky.maven.plugins.depsupdate

import com.soebes.itf.jupiter.extension.MavenGoal
import com.soebes.itf.jupiter.extension.MavenJupiterExtension
import com.soebes.itf.jupiter.extension.MavenTest
import com.soebes.itf.jupiter.maven.MavenExecutionResult
import com.soebes.itf.jupiter.maven.MavenProjectResult
import org.apache.commons.io.FileUtils
import org.assertj.core.api.Assertions.assertThat
import org.eclipse.jgit.api.Git
import org.eclipse.jgit.api.ListBranchCommand
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.io.TempDir
import java.io.File
import java.util.stream.Collectors

@MavenJupiterExtension
class Bug54MultiModuleProjectIT {
@TempDir
lateinit var remoteRepo: File

lateinit var repo: Git

@BeforeEach
internal fun setUp(result: MavenProjectResult) {
FileUtils.copyDirectory(result.targetProjectDirectory, remoteRepo)

repo = Git.init().setDirectory(remoteRepo).call()
repo.add().addFilepattern(".").call();
repo.commit()
.setAuthor("Schorsch", "georg@email.com")
.setMessage("Initial commit.")
.call()

FileUtils.deleteDirectory(result.targetProjectDirectory)

repo = Git.cloneRepository()
.setURI(remoteRepo.toURI().toString())
.setDirectory(result.targetProjectDirectory)
.call()
}

@MavenTest
@MavenGoal("\${project.groupId}:\${project.artifactId}:\${project.version}:update")
fun updateOnlyInModule(result: MavenExecutionResult) {
assertTrue(result.isSuccessful)

val branchList = repo.branchList()
.setListMode(ListBranchCommand.ListMode.ALL)
.call()
.stream()
.map { it.name }
.collect(Collectors.toList())

val updatedBranchNames = branchList.filter { it.startsWith("refs/heads/dependency-update") }

assertThat(updatedBranchNames).hasSize(2)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.github.georgberky.maven.plugins.depsupdate</groupId>
<artifactId>multi-module-test-parent</artifactId>
<version>0.6.0</version>
</parent>

<artifactId>native-git-provider-module1</artifactId>

<dependencies>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.15.0</version>
</dependency>
</dependencies>



</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.github.georgberky.maven.plugins.depsupdate</groupId>
<artifactId>multi-module-test-parent</artifactId>
<version>0.6.0</version>
</parent>

<artifactId>native-git-provider-module2</artifactId>

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.5.2</version>
</dependency>
</dependencies>



</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>io.github.georgberky.maven.plugins.depsupdate</groupId>
<artifactId>multi-module-test-parent</artifactId>
<version>0.6.0</version>
<packaging>pom</packaging>

<scm>
<connection>someConnection</connection>
<developerConnection>someDeveloperConnection</developerConnection>
</scm>

<modules>
<module>module1</module>
<module>module2</module>
</modules>


<build>
<plugins>
<plugin>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
</plugin>
</plugins>
</build>

</project>

0 comments on commit 790ab5e

Please sign in to comment.