diff --git a/pom.xml b/pom.xml index 6542f9c038..03c52b9fef 100644 --- a/pom.xml +++ b/pom.xml @@ -152,11 +152,6 @@ junit-vintage-engine - - org.junit-pioneer - junit-pioneer - - org.hamcrest hamcrest-core @@ -402,13 +397,6 @@ test - - org.junit-pioneer - junit-pioneer - 0.5.6 - test - - junit junit diff --git a/scm-core/src/test/java/sonia/scm/BasicContextProviderTest.java b/scm-core/src/test/java/sonia/scm/BasicContextProviderTest.java index 18ad14b5f6..babba7dd3d 100644 --- a/scm-core/src/test/java/sonia/scm/BasicContextProviderTest.java +++ b/scm-core/src/test/java/sonia/scm/BasicContextProviderTest.java @@ -27,15 +27,13 @@ package sonia.scm; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import java.nio.file.Path; import java.nio.file.Paths; import static org.assertj.core.api.Assertions.assertThat; -@ExtendWith(TempDirectory.class) class BasicContextProviderTest { @Nested @@ -68,13 +66,13 @@ class BasicContextProviderTest { private BasicContextProvider context; @BeforeEach - void setUpContext(@TempDirectory.TempDir Path baseDirectory) { + void setUpContext(@TempDir Path baseDirectory) { this.baseDirectory = baseDirectory; context = new BasicContextProvider(baseDirectory.toFile(), "x.y.z", Stage.PRODUCTION); } @Test - void shouldReturnAbsolutePathAsIs(@TempDirectory.TempDir Path path) { + void shouldReturnAbsolutePathAsIs(@TempDir Path path) { Path absolutePath = path.toAbsolutePath(); Path resolved = context.resolve(absolutePath); diff --git a/scm-core/src/test/java/sonia/scm/repository/api/ModifyCommandBuilderTest.java b/scm-core/src/test/java/sonia/scm/repository/api/ModifyCommandBuilderTest.java index abbfd0a638..a374a2272c 100644 --- a/scm-core/src/test/java/sonia/scm/repository/api/ModifyCommandBuilderTest.java +++ b/scm-core/src/test/java/sonia/scm/repository/api/ModifyCommandBuilderTest.java @@ -21,14 +21,14 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.repository.api; import com.google.common.io.ByteSource; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.invocation.InvocationOnMock; @@ -57,7 +57,6 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -@ExtendWith(TempDirectory.class) class ModifyCommandBuilderTest { @Mock @@ -71,7 +70,7 @@ class ModifyCommandBuilderTest { Path workdir; @BeforeEach - void initWorkdir(@TempDirectory.TempDir Path temp) throws IOException { + void initWorkdir(@TempDir Path temp) throws IOException { workdir = Files.createDirectory(temp.resolve("workdir")); lenient().when(workdirProvider.createNewWorkdir()).thenReturn(workdir.toFile()); commandBuilder = new ModifyCommandBuilder(command, workdirProvider); @@ -207,7 +206,7 @@ class ModifyCommandBuilderTest { } @Test - void shouldDeleteTemporaryFiles(@TempDirectory.TempDir Path temp) throws IOException { + void shouldDeleteTemporaryFiles(@TempDir Path temp) throws IOException { ArgumentCaptor nameCaptor = ArgumentCaptor.forClass(String.class); ArgumentCaptor fileCaptor = ArgumentCaptor.forClass(File.class); doNothing().when(worker).modify(nameCaptor.capture(), fileCaptor.capture()); diff --git a/scm-core/src/test/java/sonia/scm/repository/spi/ModifyWorkerHelperTest.java b/scm-core/src/test/java/sonia/scm/repository/spi/ModifyWorkerHelperTest.java index a4fbc1770b..1d675e0743 100644 --- a/scm-core/src/test/java/sonia/scm/repository/spi/ModifyWorkerHelperTest.java +++ b/scm-core/src/test/java/sonia/scm/repository/spi/ModifyWorkerHelperTest.java @@ -21,12 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.repository.spi; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import sonia.scm.repository.Repository; import java.io.File; @@ -36,11 +35,10 @@ import java.nio.file.Path; import static org.assertj.core.api.Assertions.assertThat; -@ExtendWith(TempDirectory.class) class ModifyWorkerHelperTest { @Test - void shouldKeepExecutableFlag(@TempDirectory.TempDir Path temp) throws IOException { + void shouldKeepExecutableFlag(@TempDir Path temp) throws IOException { File target = createFile(temp, "executable.sh"); File newFile = createFile(temp, "other"); diff --git a/scm-core/src/test/java/sonia/scm/security/DefaultCipherHandlerTest.java b/scm-core/src/test/java/sonia/scm/security/DefaultCipherHandlerTest.java index 985e8eb1a8..6f88f71597 100644 --- a/scm-core/src/test/java/sonia/scm/security/DefaultCipherHandlerTest.java +++ b/scm-core/src/test/java/sonia/scm/security/DefaultCipherHandlerTest.java @@ -27,7 +27,7 @@ package sonia.scm.security; import com.google.common.io.Files; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import sonia.scm.SCMContextProvider; @@ -45,7 +45,7 @@ import static org.mockito.Mockito.when; * * @author Sebastian Sdorra */ -@ExtendWith({MockitoExtension.class, TempDirectory.class}) +@ExtendWith({MockitoExtension.class}) public class DefaultCipherHandlerTest { @Mock @@ -58,7 +58,7 @@ public class DefaultCipherHandlerTest { * Tests loading and storing default key. */ @Test - void shouldLoadAndStoreDefaultKey(@TempDirectory.TempDir Path tempDir) throws IOException { + void shouldLoadAndStoreDefaultKey(@TempDir Path tempDir) throws IOException { File baseDirectory = tempDir.toFile(); when(context.getBaseDirectory()).thenReturn(baseDirectory); @@ -84,7 +84,7 @@ public class DefaultCipherHandlerTest { @Test @SuppressWarnings("UnstableApiUsage") // is ok for unit test - void shouldReEncodeOldFormattedDefaultKey(@TempDirectory.TempDir Path tempDir) throws IOException { + void shouldReEncodeOldFormattedDefaultKey(@TempDir Path tempDir) throws IOException { String oldKey = "17eXopruTtX3S4dJ9KTEmbZ-vfZztw=="; String encryptedValue = "A11kQF7wytpWCkjPflxJB-zUWJ1CVKU3qhwhRFq4Pvl6XqiS9V2w-gqNktqMX6YNDw=="; String plainValue = "Marvin The Paranoid Android - RAM"; diff --git a/scm-core/src/test/java/sonia/scm/xml/XmlInstantAdapterTest.java b/scm-core/src/test/java/sonia/scm/xml/XmlInstantAdapterTest.java index 917022c42e..3abac6c132 100644 --- a/scm-core/src/test/java/sonia/scm/xml/XmlInstantAdapterTest.java +++ b/scm-core/src/test/java/sonia/scm/xml/XmlInstantAdapterTest.java @@ -21,12 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.xml; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import javax.xml.bind.JAXB; import javax.xml.bind.annotation.XmlAccessType; @@ -36,13 +35,12 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import java.nio.file.Path; import java.time.Instant; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; -@ExtendWith(TempDirectory.class) class XmlInstantAdapterTest { @Test - void shouldMarshalAndUnmarshalInstant(@TempDirectory.TempDir Path tempDirectory) { + void shouldMarshalAndUnmarshalInstant(@TempDir Path tempDirectory) { Path path = tempDirectory.resolve("instant.xml"); Instant instant = Instant.now(); diff --git a/scm-dao-xml/src/test/java/sonia/scm/repository/xml/PathBasedRepositoryLocationResolverTest.java b/scm-dao-xml/src/test/java/sonia/scm/repository/xml/PathBasedRepositoryLocationResolverTest.java index 019c4de862..7c474ea95c 100644 --- a/scm-dao-xml/src/test/java/sonia/scm/repository/xml/PathBasedRepositoryLocationResolverTest.java +++ b/scm-dao-xml/src/test/java/sonia/scm/repository/xml/PathBasedRepositoryLocationResolverTest.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.repository.xml; import com.google.common.base.Charsets; @@ -29,7 +29,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoSettings; @@ -52,7 +52,6 @@ import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -@ExtendWith(TempDirectory.class) @MockitoSettings(strictness = Strictness.LENIENT) class PathBasedRepositoryLocationResolverTest { @@ -74,7 +73,7 @@ class PathBasedRepositoryLocationResolverTest { private PathBasedRepositoryLocationResolver resolver; @BeforeEach - void beforeEach(@TempDirectory.TempDir Path temp) { + void beforeEach(@TempDir Path temp) { this.basePath = temp; when(contextProvider.getBaseDirectory()).thenReturn(temp.toFile()); when(contextProvider.resolve(any(Path.class))).thenAnswer(invocation -> invocation.getArgument(0)); diff --git a/scm-dao-xml/src/test/java/sonia/scm/repository/xml/XmlRepositoryDAOTest.java b/scm-dao-xml/src/test/java/sonia/scm/repository/xml/XmlRepositoryDAOTest.java index c90a61d874..4b7bce2093 100644 --- a/scm-dao-xml/src/test/java/sonia/scm/repository/xml/XmlRepositoryDAOTest.java +++ b/scm-dao-xml/src/test/java/sonia/scm/repository/xml/XmlRepositoryDAOTest.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.repository.xml; @@ -31,7 +31,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import org.mockito.Mock; import org.mockito.invocation.InvocationOnMock; import org.mockito.junit.jupiter.MockitoExtension; @@ -61,7 +61,7 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -@ExtendWith({MockitoExtension.class, TempDirectory.class}) +@ExtendWith({MockitoExtension.class}) @MockitoSettings(strictness = Strictness.LENIENT) class XmlRepositoryDAOTest { @@ -76,7 +76,7 @@ class XmlRepositoryDAOTest { private XmlRepositoryDAO dao; @BeforeEach - void createDAO(@TempDirectory.TempDir Path basePath) { + void createDAO(@TempDir Path basePath) { when(locationResolver.create(Path.class)).thenReturn( new RepositoryLocationResolver.RepositoryLocationResolverInstance() { @Override @@ -103,7 +103,7 @@ class XmlRepositoryDAOTest { when(locationResolver.remove(anyString())).thenAnswer(invocation -> basePath.resolve(invocation.getArgument(0).toString())); } - private Path createMockedRepoPath(@TempDirectory.TempDir Path basePath, InvocationOnMock invocation) { + private Path createMockedRepoPath(@TempDir Path basePath, InvocationOnMock invocation) { Path resolvedPath = basePath.resolve(invocation.getArgument(0).toString()); try { Files.createDirectories(resolvedPath); @@ -337,7 +337,7 @@ class XmlRepositoryDAOTest { private Path repositoryPath; @BeforeEach - void createMetadataFileForRepository(@TempDirectory.TempDir Path basePath) throws IOException { + void createMetadataFileForRepository(@TempDir Path basePath) throws IOException { repositoryPath = basePath.resolve("existing"); Files.createDirectories(repositoryPath); diff --git a/scm-dao-xml/src/test/java/sonia/scm/store/CopyOnWriteTest.java b/scm-dao-xml/src/test/java/sonia/scm/store/CopyOnWriteTest.java index e66fcd5b60..b2d9143655 100644 --- a/scm-dao-xml/src/test/java/sonia/scm/store/CopyOnWriteTest.java +++ b/scm-dao-xml/src/test/java/sonia/scm/store/CopyOnWriteTest.java @@ -21,13 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.store; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import java.io.FileOutputStream; import java.io.IOException; @@ -38,11 +37,10 @@ import java.nio.file.Paths; import static org.junit.jupiter.api.Assertions.assertThrows; import static sonia.scm.store.CopyOnWrite.withTemporaryFile; -@ExtendWith(TempDirectory.class) class CopyOnWriteTest { @Test - void shouldCreateNewFile(@TempDirectory.TempDir Path tempDir) { + void shouldCreateNewFile(@TempDir Path tempDir) { Path expectedFile = tempDir.resolve("toBeCreated.txt"); withTemporaryFile( @@ -53,7 +51,7 @@ class CopyOnWriteTest { } @Test - void shouldOverwriteExistingFile(@TempDirectory.TempDir Path tempDir) throws IOException { + void shouldOverwriteExistingFile(@TempDir Path tempDir) throws IOException { Path expectedFile = tempDir.resolve("toBeOverwritten.txt"); Files.createFile(expectedFile); @@ -65,7 +63,7 @@ class CopyOnWriteTest { } @Test - void shouldFailForDirectory(@TempDirectory.TempDir Path tempDir) { + void shouldFailForDirectory(@TempDir Path tempDir) { assertThrows(IllegalArgumentException.class, () -> withTemporaryFile( file -> new FileOutputStream(file.toFile()).write("should not be written".getBytes()), @@ -82,7 +80,7 @@ class CopyOnWriteTest { } @Test - void shouldKeepBackupIfTemporaryFileCouldNotBeWritten(@TempDirectory.TempDir Path tempDir) throws IOException { + void shouldKeepBackupIfTemporaryFileCouldNotBeWritten(@TempDir Path tempDir) throws IOException { Path unchangedOriginalFile = tempDir.resolve("notToBeDeleted.txt"); new FileOutputStream(unchangedOriginalFile.toFile()).write("this should be kept".getBytes()); @@ -98,7 +96,7 @@ class CopyOnWriteTest { } @Test - void shouldNotWrapRuntimeExceptions(@TempDirectory.TempDir Path tempDir) throws IOException { + void shouldNotWrapRuntimeExceptions(@TempDir Path tempDir) throws IOException { Path someFile = tempDir.resolve("something.txt"); assertThrows( @@ -111,7 +109,7 @@ class CopyOnWriteTest { } @Test - void shouldKeepBackupIfTemporaryFileIsMissing(@TempDirectory.TempDir Path tempDir) throws IOException { + void shouldKeepBackupIfTemporaryFileIsMissing(@TempDir Path tempDir) throws IOException { Path backedUpFile = tempDir.resolve("notToBeDeleted.txt"); new FileOutputStream(backedUpFile.toFile()).write("this should be kept".getBytes()); @@ -125,7 +123,7 @@ class CopyOnWriteTest { } @Test - void shouldDeleteExistingFile(@TempDirectory.TempDir Path tempDir) throws IOException { + void shouldDeleteExistingFile(@TempDir Path tempDir) throws IOException { Path expectedFile = tempDir.resolve("toBeReplaced.txt"); new FileOutputStream(expectedFile.toFile()).write("this should be removed".getBytes()); diff --git a/scm-dao-xml/src/test/java/sonia/scm/store/JAXBPropertyFileAccessTest.java b/scm-dao-xml/src/test/java/sonia/scm/store/JAXBPropertyFileAccessTest.java index bc498a9e04..0c6f4ac982 100644 --- a/scm-dao-xml/src/test/java/sonia/scm/store/JAXBPropertyFileAccessTest.java +++ b/scm-dao-xml/src/test/java/sonia/scm/store/JAXBPropertyFileAccessTest.java @@ -21,14 +21,14 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.store; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import sonia.scm.SCMContextProvider; @@ -48,7 +48,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.lenient; -@ExtendWith(TempDirectory.class) @ExtendWith(MockitoExtension.class) class JAXBPropertyFileAccessTest { @@ -63,7 +62,7 @@ class JAXBPropertyFileAccessTest { JAXBPropertyFileAccess fileAccess; @BeforeEach - void initTempDir(@TempDirectory.TempDir Path tempDir) { + void initTempDir(@TempDir Path tempDir) { lenient().when(contextProvider.getBaseDirectory()).thenReturn(tempDir.toFile()); lenient().when(contextProvider.resolve(any())).thenAnswer(invocation -> tempDir.resolve(invocation.getArgument(0).toString())); @@ -99,7 +98,7 @@ class JAXBPropertyFileAccessTest { } @Test - void shouldMoveStoreFileToRepositoryBasedLocation(@TempDirectory.TempDir Path tempDir) throws IOException { + void shouldMoveStoreFileToRepositoryBasedLocation(@TempDir Path tempDir) throws IOException { createV1StoreFile(tempDir, "myStore.xml"); fileAccess.forStoreName(STORE_NAME).moveAsRepositoryStore(Paths.get("myStore.xml"), REPOSITORY_ID); @@ -108,7 +107,7 @@ class JAXBPropertyFileAccessTest { } @Test - void shouldMoveAllStoreFilesToRepositoryBasedLocations(@TempDirectory.TempDir Path tempDir) throws IOException { + void shouldMoveAllStoreFilesToRepositoryBasedLocations(@TempDir Path tempDir) throws IOException { locationResolver.forClass(Path.class).createLocation("repoId2"); createV1StoreFile(tempDir, REPOSITORY_ID + ".xml"); @@ -122,7 +121,7 @@ class JAXBPropertyFileAccessTest { } } - private void createV1StoreFile(@TempDirectory.TempDir Path tempDir, String name) throws IOException { + private void createV1StoreFile(@TempDir Path tempDir, String name) throws IOException { Path v1Dir = tempDir.resolve("var").resolve("data").resolve(STORE_NAME); IOUtil.mkdirs(v1Dir.toFile()); Files.createFile(v1Dir.resolve(name)); @@ -132,7 +131,7 @@ class JAXBPropertyFileAccessTest { class ForMissingRepository { @Test - void shouldIgnoreStoreFile(@TempDirectory.TempDir Path tempDir) throws IOException { + void shouldIgnoreStoreFile(@TempDir Path tempDir) throws IOException { createV1StoreFile(tempDir, "myStore.xml"); fileAccess.forStoreName(STORE_NAME).moveAsRepositoryStore(Paths.get("myStore.xml"), REPOSITORY_ID); diff --git a/scm-it/src/test/java/sonia/scm/it/AnonymousAccessITCase.java b/scm-it/src/test/java/sonia/scm/it/AnonymousAccessITCase.java index afda4475fd..0994ca0dcb 100644 --- a/scm-it/src/test/java/sonia/scm/it/AnonymousAccessITCase.java +++ b/scm-it/src/test/java/sonia/scm/it/AnonymousAccessITCase.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.it; import io.restassured.RestAssured; @@ -31,14 +31,9 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.io.TempDir; import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.ArgumentsProvider; import org.junit.jupiter.params.provider.ArgumentsSource; -import org.junit.jupiter.params.provider.MethodSource; -import org.junitpioneer.jupiter.TempDirectory; import sonia.scm.it.utils.RepositoryUtil; import sonia.scm.it.utils.RestUtil; import sonia.scm.it.utils.ScmRequests; @@ -50,12 +45,10 @@ import sonia.scm.repository.client.api.RepositoryClientException; import javax.json.Json; import javax.json.JsonArray; import javax.servlet.http.HttpServletResponse; - import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.Objects; -import java.util.stream.Stream; import static java.util.Collections.emptyMap; import static org.junit.Assert.assertEquals; @@ -65,7 +58,6 @@ import static sonia.scm.it.utils.TestData.USER_ANONYMOUS; import static sonia.scm.it.utils.TestData.WRITE; import static sonia.scm.it.utils.TestData.getDefaultRepositoryUrl; -@ExtendWith(TempDirectory.class) class AnonymousAccessITCase { @Test @@ -118,7 +110,7 @@ class AnonymousAccessITCase { @ParameterizedTest @ArgumentsSource(ScmTypes.class) - void shouldNotCloneRepository(String type, @TempDirectory.TempDir Path temporaryFolder) { + void shouldNotCloneRepository(String type, @TempDir Path temporaryFolder) { assertThrows(RepositoryClientException.class, () -> RepositoryUtil.createAnonymousRepositoryClient(type, Files.createDirectories(temporaryFolder).toFile())); } } @@ -142,7 +134,7 @@ class AnonymousAccessITCase { @ParameterizedTest @ArgumentsSource(ScmTypes.class) - void shouldCloneRepository(String type, @TempDirectory.TempDir Path temporaryFolder) throws IOException { + void shouldCloneRepository(String type, @TempDir Path temporaryFolder) throws IOException { RepositoryClient client = RepositoryUtil.createAnonymousRepositoryClient(type, Files.createDirectories(temporaryFolder).toFile()); assertEquals(1, Objects.requireNonNull(client.getWorkingCopy().list()).length); } diff --git a/scm-webapp/src/test/java/sonia/scm/ScmLogFilePropertyDefinerTest.java b/scm-webapp/src/test/java/sonia/scm/ScmLogFilePropertyDefinerTest.java index 6372c75aa1..4ad33b9697 100644 --- a/scm-webapp/src/test/java/sonia/scm/ScmLogFilePropertyDefinerTest.java +++ b/scm-webapp/src/test/java/sonia/scm/ScmLogFilePropertyDefinerTest.java @@ -26,7 +26,7 @@ package sonia.scm; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; @@ -36,14 +36,14 @@ import java.util.Properties; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.when; -@ExtendWith({MockitoExtension.class, TempDirectory.class}) +@ExtendWith({MockitoExtension.class}) class ScmLogFilePropertyDefinerTest { @Mock private SCMContextProvider context; @Test - void shouldReturnPath(@TempDirectory.TempDir Path tempDir) { + void shouldReturnPath(@TempDir Path tempDir) { when(context.getBaseDirectory()).thenReturn(tempDir.toFile()); ScmLogFilePropertyDefiner definer = builder().create(); @@ -52,7 +52,7 @@ class ScmLogFilePropertyDefinerTest { } @Test - void shouldReturnOsxPath(@TempDirectory.TempDir Path tempDir) { + void shouldReturnOsxPath(@TempDir Path tempDir) { ScmLogFilePropertyDefiner definer = builder() .withOs("Mac OS X") .withUserHome(tempDir.toAbsolutePath().toString()) diff --git a/scm-webapp/src/test/java/sonia/scm/lifecycle/VersionsTest.java b/scm-webapp/src/test/java/sonia/scm/lifecycle/VersionsTest.java index a59de4fa25..c865d5e5cb 100644 --- a/scm-webapp/src/test/java/sonia/scm/lifecycle/VersionsTest.java +++ b/scm-webapp/src/test/java/sonia/scm/lifecycle/VersionsTest.java @@ -21,12 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.lifecycle; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; @@ -41,7 +41,7 @@ import java.nio.file.Paths; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.doReturn; -@ExtendWith({MockitoExtension.class, TempDirectory.class}) +@ExtendWith({MockitoExtension.class}) class VersionsTest { @Mock @@ -51,7 +51,7 @@ class VersionsTest { private Versions versions; @Test - void shouldReturnTrueForVersionsPreviousTo160(@TempDirectory.TempDir Path directory) throws IOException { + void shouldReturnTrueForVersionsPreviousTo160(@TempDir Path directory) throws IOException { setVersion(directory, "1.59"); assertThat(versions.isPreviousVersionTooOld()).isTrue(); @@ -60,19 +60,19 @@ class VersionsTest { } @Test - void shouldReturnFalseForVersion160(@TempDirectory.TempDir Path directory) throws IOException { + void shouldReturnFalseForVersion160(@TempDir Path directory) throws IOException { setVersion(directory, "1.60"); assertThat(versions.isPreviousVersionTooOld()).isFalse(); } @Test - void shouldNotFailIfVersionContainsLineBreak(@TempDirectory.TempDir Path directory) throws IOException { + void shouldNotFailIfVersionContainsLineBreak(@TempDir Path directory) throws IOException { setVersion(directory, "1.59\n"); assertThat(versions.isPreviousVersionTooOld()).isTrue(); } @Test - void shouldReturnFalseForVersionsNewerAs160(@TempDirectory.TempDir Path directory) throws IOException { + void shouldReturnFalseForVersionsNewerAs160(@TempDir Path directory) throws IOException { setVersion(directory, "1.61"); assertThat(versions.isPreviousVersionTooOld()).isFalse(); @@ -81,13 +81,13 @@ class VersionsTest { } @Test - void shouldReturnFalseForNonExistingVersionFile(@TempDirectory.TempDir Path directory) { + void shouldReturnFalseForNonExistingVersionFile(@TempDir Path directory) { setVersionFile(directory.resolve("version.txt")); assertThat(versions.isPreviousVersionTooOld()).isFalse(); } @Test - void shouldWriteNewVersion(@TempDirectory.TempDir Path directory) { + void shouldWriteNewVersion(@TempDir Path directory) { Path config = directory.resolve("config"); doReturn(config).when(contextProvider).resolve(Paths.get("config")); doReturn("2.0.0").when(contextProvider).getVersion(); diff --git a/scm-webapp/src/test/java/sonia/scm/plugin/DefaultPluginManagerTest.java b/scm-webapp/src/test/java/sonia/scm/plugin/DefaultPluginManagerTest.java index da7fce6527..afb7c4eea1 100644 --- a/scm-webapp/src/test/java/sonia/scm/plugin/DefaultPluginManagerTest.java +++ b/scm-webapp/src/test/java/sonia/scm/plugin/DefaultPluginManagerTest.java @@ -34,7 +34,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.InjectMocks; @@ -48,7 +48,6 @@ import sonia.scm.lifecycle.Restarter; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.util.Collections; import java.util.List; import java.util.Optional; @@ -56,7 +55,6 @@ import static java.util.Arrays.asList; import static java.util.Collections.singleton; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.in; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.any; import static org.mockito.Mockito.doNothing; @@ -72,7 +70,6 @@ import static sonia.scm.plugin.PluginTestHelper.createAvailable; import static sonia.scm.plugin.PluginTestHelper.createInstalled; @ExtendWith(MockitoExtension.class) -@ExtendWith(TempDirectory.class) class DefaultPluginManagerTest { @Mock @@ -372,7 +369,7 @@ class DefaultPluginManagerTest { } @Test - void shouldCreateUninstallFile(@TempDirectory.TempDir Path temp) { + void shouldCreateUninstallFile(@TempDir Path temp) { InstalledPlugin mailPlugin = createInstalled("scm-mail-plugin"); when(mailPlugin.getDirectory()).thenReturn(temp); @@ -384,7 +381,7 @@ class DefaultPluginManagerTest { } @Test - void shouldMarkPluginForUninstall(@TempDirectory.TempDir Path temp) { + void shouldMarkPluginForUninstall(@TempDir Path temp) { InstalledPlugin mailPlugin = createInstalled("scm-mail-plugin"); when(mailPlugin.getDirectory()).thenReturn(temp); @@ -414,7 +411,7 @@ class DefaultPluginManagerTest { } @Test - void shouldThrowExceptionWhenUninstallingCorePlugin(@TempDirectory.TempDir Path temp) { + void shouldThrowExceptionWhenUninstallingCorePlugin(@TempDir Path temp) { InstalledPlugin mailPlugin = createInstalled("scm-mail-plugin"); when(mailPlugin.getDirectory()).thenReturn(temp); when(mailPlugin.isCore()).thenReturn(true); @@ -484,7 +481,7 @@ class DefaultPluginManagerTest { } @Test - void shouldUndoPendingInstallations(@TempDirectory.TempDir Path temp) throws IOException { + void shouldUndoPendingInstallations(@TempDir Path temp) throws IOException { InstalledPlugin mailPlugin = createInstalled("scm-ssh-plugin"); Path mailPluginPath = temp.resolve("scm-mail-plugin"); Files.createDirectories(mailPluginPath); diff --git a/scm-webapp/src/test/java/sonia/scm/plugin/PendingPluginInstallationTest.java b/scm-webapp/src/test/java/sonia/scm/plugin/PendingPluginInstallationTest.java index ba275bc820..b668870488 100644 --- a/scm-webapp/src/test/java/sonia/scm/plugin/PendingPluginInstallationTest.java +++ b/scm-webapp/src/test/java/sonia/scm/plugin/PendingPluginInstallationTest.java @@ -21,12 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.plugin; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import org.mockito.Answers; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; @@ -39,14 +39,14 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.when; -@ExtendWith({MockitoExtension.class, TempDirectory.class}) +@ExtendWith({MockitoExtension.class}) class PendingPluginInstallationTest { @Mock(answer = Answers.RETURNS_DEEP_STUBS) private AvailablePlugin plugin; @Test - void shouldDeleteFileOnCancel(@TempDirectory.TempDir Path directory) throws IOException { + void shouldDeleteFileOnCancel(@TempDir Path directory) throws IOException { Path file = directory.resolve("file"); Files.write(file, "42".getBytes()); @@ -59,7 +59,7 @@ class PendingPluginInstallationTest { } @Test - void shouldThrowExceptionIfCancelFailed(@TempDirectory.TempDir Path directory) { + void shouldThrowExceptionIfCancelFailed(@TempDir Path directory) { Path file = directory.resolve("file"); when(plugin.getDescriptor().getInformation().getName()).thenReturn("scm-awesome-plugin"); diff --git a/scm-webapp/src/test/java/sonia/scm/plugin/PluginInstallerTest.java b/scm-webapp/src/test/java/sonia/scm/plugin/PluginInstallerTest.java index 14bb26f87c..bccbb67f3c 100644 --- a/scm-webapp/src/test/java/sonia/scm/plugin/PluginInstallerTest.java +++ b/scm-webapp/src/test/java/sonia/scm/plugin/PluginInstallerTest.java @@ -21,13 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.plugin; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import org.mockito.Answers; import org.mockito.InjectMocks; import org.mockito.Mock; @@ -45,9 +45,13 @@ import java.util.Collections; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.RETURNS_DEEP_STUBS; +import static org.mockito.Mockito.anyInt; +import static org.mockito.Mockito.lenient; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; -@ExtendWith({MockitoExtension.class, TempDirectory.class}) +@ExtendWith({MockitoExtension.class}) class PluginInstallerTest { @Mock @@ -65,7 +69,7 @@ class PluginInstallerTest { private Path directory; @BeforeEach - void setUpContext(@TempDirectory.TempDir Path directory) throws IOException { + void setUpContext(@TempDir Path directory) throws IOException { this.directory = directory; lenient().when(context.resolve(any())).then(ic -> { Path arg = ic.getArgument(0); diff --git a/scm-webapp/src/test/java/sonia/scm/plugin/SmpDescriptorExtractorTest.java b/scm-webapp/src/test/java/sonia/scm/plugin/SmpDescriptorExtractorTest.java index eea0a2f681..dd8dad5eca 100644 --- a/scm-webapp/src/test/java/sonia/scm/plugin/SmpDescriptorExtractorTest.java +++ b/scm-webapp/src/test/java/sonia/scm/plugin/SmpDescriptorExtractorTest.java @@ -21,13 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.plugin; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import java.io.IOException; import java.nio.file.Files; @@ -38,7 +37,6 @@ import java.util.zip.ZipOutputStream; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.jupiter.api.Assertions.assertThrows; -@ExtendWith(TempDirectory.class) class SmpDescriptorExtractorTest { private static final String PLUGIN_XML = "\n" + @@ -66,7 +64,7 @@ class SmpDescriptorExtractorTest { "\n"; @Test - void shouldExtractPluginXml(@TempDirectory.TempDir Path tempDir) throws IOException { + void shouldExtractPluginXml(@TempDir Path tempDir) throws IOException { Path pluginFile = createZipFile(tempDir, "META-INF/scm/plugin.xml", PLUGIN_XML); InstalledPluginDescriptor installedPluginDescriptor = new SmpDescriptorExtractor().extractPluginDescriptor(pluginFile); @@ -75,14 +73,14 @@ class SmpDescriptorExtractorTest { } @Test - void shouldFailWithoutPluginXml(@TempDirectory.TempDir Path tempDir) throws IOException { + void shouldFailWithoutPluginXml(@TempDir Path tempDir) throws IOException { Path pluginFile = createZipFile(tempDir, "META-INF/wrong/plugin.xml", PLUGIN_XML); assertThrows(IOException.class, () -> new SmpDescriptorExtractor().extractPluginDescriptor(pluginFile)); } @Test - void shouldFailWithIllegalPluginXml(@TempDirectory.TempDir Path tempDir) throws IOException { + void shouldFailWithIllegalPluginXml(@TempDir Path tempDir) throws IOException { Path pluginFile = createZipFile(tempDir, "META-INF/scm/plugin.xml", "content"); assertThrows(IOException.class, () -> new SmpDescriptorExtractor().extractPluginDescriptor(pluginFile)); diff --git a/scm-webapp/src/test/java/sonia/scm/plugin/UberClassLoaderTest.java b/scm-webapp/src/test/java/sonia/scm/plugin/UberClassLoaderTest.java index 59b8432882..375304e74a 100644 --- a/scm-webapp/src/test/java/sonia/scm/plugin/UberClassLoaderTest.java +++ b/scm-webapp/src/test/java/sonia/scm/plugin/UberClassLoaderTest.java @@ -21,14 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.plugin; import com.google.common.collect.ImmutableSet; import com.google.common.io.Resources; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import java.io.IOException; import java.net.URL; @@ -43,13 +42,12 @@ import java.util.UUID; import static org.assertj.core.api.Assertions.assertThat; -@ExtendWith(TempDirectory.class) class UberClassLoaderTest { private final URLClassLoader parentClassLoader = new URLClassLoader(new URL[0]); @Test - void shouldOnlyUseClassloaderOnce(@TempDirectory.TempDir Path tempDir) throws IOException { + void shouldOnlyUseClassloaderOnce(@TempDir Path tempDir) throws IOException { ClassLoader mailClassLoader = createClassLoader(tempDir, "plugin.txt", "mail"); ClassLoader reviewClassLoader = createClassLoader(mailClassLoader, tempDir, "plugin.txt", "review"); @@ -61,7 +59,7 @@ class UberClassLoaderTest { } @Test - void shouldReturnResourceFromEachPluginClassLoader(@TempDirectory.TempDir Path tempDir) throws IOException { + void shouldReturnResourceFromEachPluginClassLoader(@TempDir Path tempDir) throws IOException { ClassLoader mailClassLoader = createClassLoader(tempDir, "scm.txt", "mail"); ClassLoader reviewClassLoader = createClassLoader(tempDir, "scm.txt", "review"); diff --git a/scm-webapp/src/test/java/sonia/scm/update/group/XmlGroupV1UpdateStepTest.java b/scm-webapp/src/test/java/sonia/scm/update/group/XmlGroupV1UpdateStepTest.java index 95e0dc12bf..434dc075d5 100644 --- a/scm-webapp/src/test/java/sonia/scm/update/group/XmlGroupV1UpdateStepTest.java +++ b/scm-webapp/src/test/java/sonia/scm/update/group/XmlGroupV1UpdateStepTest.java @@ -21,14 +21,14 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.update.group; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; @@ -39,7 +39,6 @@ import sonia.scm.store.ConfigurationEntryStore; import sonia.scm.store.InMemoryConfigurationEntryStoreFactory; import sonia.scm.update.UpdateStepTestUtil; import sonia.scm.update.V1Properties; -import sonia.scm.update.V1Property; import javax.xml.bind.JAXBException; import java.io.IOException; @@ -55,7 +54,6 @@ import static org.mockito.Mockito.verify; import static sonia.scm.store.InMemoryConfigurationEntryStoreFactory.create; @ExtendWith(MockitoExtension.class) -@ExtendWith(TempDirectory.class) class XmlGroupV1UpdateStepTest { @Mock @@ -72,7 +70,7 @@ class XmlGroupV1UpdateStepTest { @BeforeEach - void mockScmHome(@TempDirectory.TempDir Path tempDir) { + void mockScmHome(@TempDir Path tempDir) { testUtil = new UpdateStepTestUtil(tempDir); updateStep = new XmlGroupV1UpdateStep(testUtil.getContextProvider(), groupDAO, storeFactory); } diff --git a/scm-webapp/src/test/java/sonia/scm/update/repository/CopyMigrationStrategyTest.java b/scm-webapp/src/test/java/sonia/scm/update/repository/CopyMigrationStrategyTest.java index 267b2876da..1766c288f9 100644 --- a/scm-webapp/src/test/java/sonia/scm/update/repository/CopyMigrationStrategyTest.java +++ b/scm-webapp/src/test/java/sonia/scm/update/repository/CopyMigrationStrategyTest.java @@ -21,13 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.update.repository; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import sonia.scm.SCMContextProvider; @@ -44,7 +44,6 @@ import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -@ExtendWith(TempDirectory.class) @ExtendWith(MockitoExtension.class) class CopyMigrationStrategyTest { @@ -54,30 +53,30 @@ class CopyMigrationStrategyTest { RepositoryLocationResolver locationResolver; @BeforeEach - void mockContextProvider(@TempDirectory.TempDir Path tempDir) { + void mockContextProvider(@TempDir Path tempDir) { when(contextProvider.getBaseDirectory()).thenReturn(tempDir.toFile()); } @BeforeEach - void createV1Home(@TempDirectory.TempDir Path tempDir) throws IOException { + void createV1Home(@TempDir Path tempDir) throws IOException { V1RepositoryFileSystem.createV1Home(tempDir); } @BeforeEach - void mockLocationResolver(@TempDirectory.TempDir Path tempDir) { + void mockLocationResolver(@TempDir Path tempDir) { RepositoryLocationResolver.RepositoryLocationResolverInstance instanceMock = mock(RepositoryLocationResolver.RepositoryLocationResolverInstance.class); when(locationResolver.forClass(Path.class)).thenReturn(instanceMock); when(instanceMock.createLocation(anyString())).thenAnswer(invocation -> tempDir.resolve((String) invocation.getArgument(0))); } @Test - void shouldUseStandardDirectory(@TempDirectory.TempDir Path tempDir) { + void shouldUseStandardDirectory(@TempDir Path tempDir) { Path target = new CopyMigrationStrategy(contextProvider, locationResolver).migrate("b4f-a9f0-49f7-ad1f-37d3aae1c55f", "some/more/directories/than/one", "git").get(); assertThat(target).isEqualTo(tempDir.resolve("b4f-a9f0-49f7-ad1f-37d3aae1c55f")); } @Test - void shouldCopyDataDirectory(@TempDirectory.TempDir Path tempDir) { + void shouldCopyDataDirectory(@TempDir Path tempDir) { Path target = new CopyMigrationStrategy(contextProvider, locationResolver).migrate("b4f-a9f0-49f7-ad1f-37d3aae1c55f", "some/more/directories/than/one", "git").get(); assertThat(target.resolve("data")).exists(); Path originalDataDir = tempDir diff --git a/scm-webapp/src/test/java/sonia/scm/update/repository/DefaultMigrationStrategyDAOTest.java b/scm-webapp/src/test/java/sonia/scm/update/repository/DefaultMigrationStrategyDAOTest.java index f9596d3a67..1bbba6317e 100644 --- a/scm-webapp/src/test/java/sonia/scm/update/repository/DefaultMigrationStrategyDAOTest.java +++ b/scm-webapp/src/test/java/sonia/scm/update/repository/DefaultMigrationStrategyDAOTest.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.update.repository; import org.assertj.core.api.Assertions; @@ -29,7 +29,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import sonia.scm.SCMContextProvider; @@ -43,7 +43,6 @@ import static org.mockito.Mockito.when; import static sonia.scm.update.repository.MigrationStrategy.INLINE; @ExtendWith(MockitoExtension.class) -@ExtendWith(TempDirectory.class) class DefaultMigrationStrategyDAOTest { @Mock @@ -52,7 +51,7 @@ class DefaultMigrationStrategyDAOTest { private ConfigurationStoreFactory storeFactory; @BeforeEach - void initStore(@TempDirectory.TempDir Path tempDir) { + void initStore(@TempDir Path tempDir) { when(contextProvider.getBaseDirectory()).thenReturn(tempDir.toFile()); storeFactory = new JAXBConfigurationStoreFactory(contextProvider, null); } diff --git a/scm-webapp/src/test/java/sonia/scm/update/repository/InlineMigrationStrategyTest.java b/scm-webapp/src/test/java/sonia/scm/update/repository/InlineMigrationStrategyTest.java index 2d4a1ba03f..d236859af9 100644 --- a/scm-webapp/src/test/java/sonia/scm/update/repository/InlineMigrationStrategyTest.java +++ b/scm-webapp/src/test/java/sonia/scm/update/repository/InlineMigrationStrategyTest.java @@ -21,13 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.update.repository; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import sonia.scm.SCMContextProvider; @@ -41,7 +41,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -@ExtendWith(TempDirectory.class) @ExtendWith(MockitoExtension.class) class InlineMigrationStrategyTest { @@ -53,25 +52,25 @@ class InlineMigrationStrategyTest { RepositoryLocationResolver.RepositoryLocationResolverInstance locationResolverInstance; @BeforeEach - void mockContextProvider(@TempDirectory.TempDir Path tempDir) { + void mockContextProvider(@TempDir Path tempDir) { when(locationResolver.forClass(Path.class)).thenReturn(locationResolverInstance); when(contextProvider.getBaseDirectory()).thenReturn(tempDir.toFile()); } @BeforeEach - void createV1Home(@TempDirectory.TempDir Path tempDir) throws IOException { + void createV1Home(@TempDir Path tempDir) throws IOException { V1RepositoryFileSystem.createV1Home(tempDir); } @Test - void shouldUseExistingDirectory(@TempDirectory.TempDir Path tempDir) { + void shouldUseExistingDirectory(@TempDir Path tempDir) { Path target = new InlineMigrationStrategy(contextProvider, locationResolver).migrate("b4f-a9f0-49f7-ad1f-37d3aae1c55f", "some/more/directories/than/one", "git").get(); assertThat(target).isEqualTo(resolveOldDirectory(tempDir)); verify(locationResolverInstance).setLocation("b4f-a9f0-49f7-ad1f-37d3aae1c55f", target); } @Test - void shouldMoveDataDirectory(@TempDirectory.TempDir Path tempDir) { + void shouldMoveDataDirectory(@TempDir Path tempDir) { new InlineMigrationStrategy(contextProvider, locationResolver).migrate("b4f-a9f0-49f7-ad1f-37d3aae1c55f", "some/more/directories/than/one", "git"); assertThat(resolveOldDirectory(tempDir).resolve("data")).exists(); } diff --git a/scm-webapp/src/test/java/sonia/scm/update/repository/MigrateVerbsToPermissionRolesTest.java b/scm-webapp/src/test/java/sonia/scm/update/repository/MigrateVerbsToPermissionRolesTest.java index 81dd03b4ed..72cabf5d8b 100644 --- a/scm-webapp/src/test/java/sonia/scm/update/repository/MigrateVerbsToPermissionRolesTest.java +++ b/scm-webapp/src/test/java/sonia/scm/update/repository/MigrateVerbsToPermissionRolesTest.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.update.repository; import com.google.common.io.Resources; @@ -29,7 +29,7 @@ import org.assertj.core.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; @@ -51,7 +51,6 @@ import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -@ExtendWith(TempDirectory.class) class MigrateVerbsToPermissionRolesTest { private static final String EXISTING_REPOSITORY_ID = "id"; @@ -65,7 +64,7 @@ class MigrateVerbsToPermissionRolesTest { private MigrateVerbsToPermissionRoles migration; @BeforeEach - void init(@TempDirectory.TempDir Path tempDir) throws IOException { + void init(@TempDir Path tempDir) throws IOException { URL metadataUrl = Resources.getResource("sonia/scm/update/repository/metadataWithoutRoles.xml"); Files.copy(metadataUrl.openStream(), tempDir.resolve("metadata.xml")); doAnswer(invocation -> { @@ -76,7 +75,7 @@ class MigrateVerbsToPermissionRolesTest { } @Test - void shouldUpdateToRolesIfPossible(@TempDirectory.TempDir Path tempDir) throws IOException { + void shouldUpdateToRolesIfPossible(@TempDir Path tempDir) throws IOException { migration.doUpdate(); List newMetadata = Files.readAllLines(tempDir.resolve("metadata.xml")); diff --git a/scm-webapp/src/test/java/sonia/scm/update/repository/MoveMigrationStrategyTest.java b/scm-webapp/src/test/java/sonia/scm/update/repository/MoveMigrationStrategyTest.java index 02beffed00..658360d234 100644 --- a/scm-webapp/src/test/java/sonia/scm/update/repository/MoveMigrationStrategyTest.java +++ b/scm-webapp/src/test/java/sonia/scm/update/repository/MoveMigrationStrategyTest.java @@ -21,13 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.update.repository; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import sonia.scm.SCMContextProvider; @@ -41,7 +41,6 @@ import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -@ExtendWith(TempDirectory.class) @ExtendWith(MockitoExtension.class) class MoveMigrationStrategyTest { @@ -51,30 +50,30 @@ class MoveMigrationStrategyTest { RepositoryLocationResolver locationResolver; @BeforeEach - void mockContextProvider(@TempDirectory.TempDir Path tempDir) { + void mockContextProvider(@TempDir Path tempDir) { when(contextProvider.getBaseDirectory()).thenReturn(tempDir.toFile()); } @BeforeEach - void createV1Home(@TempDirectory.TempDir Path tempDir) throws IOException { + void createV1Home(@TempDir Path tempDir) throws IOException { V1RepositoryFileSystem.createV1Home(tempDir); } @BeforeEach - void mockLocationResolver(@TempDirectory.TempDir Path tempDir) { + void mockLocationResolver(@TempDir Path tempDir) { RepositoryLocationResolver.RepositoryLocationResolverInstance instanceMock = mock(RepositoryLocationResolver.RepositoryLocationResolverInstance.class); when(locationResolver.forClass(Path.class)).thenReturn(instanceMock); when(instanceMock.createLocation(anyString())).thenAnswer(invocation -> tempDir.resolve((String) invocation.getArgument(0))); } @Test - void shouldUseStandardDirectory(@TempDirectory.TempDir Path tempDir) { + void shouldUseStandardDirectory(@TempDir Path tempDir) { Path target = new MoveMigrationStrategy(contextProvider, locationResolver).migrate("b4f-a9f0-49f7-ad1f-37d3aae1c55f", "some/more/directories/than/one", "git").get(); assertThat(target).isEqualTo(tempDir.resolve("b4f-a9f0-49f7-ad1f-37d3aae1c55f")); } @Test - void shouldMoveDataDirectory(@TempDirectory.TempDir Path tempDir) { + void shouldMoveDataDirectory(@TempDir Path tempDir) { Path target = new MoveMigrationStrategy(contextProvider, locationResolver).migrate("b4f-a9f0-49f7-ad1f-37d3aae1c55f", "some/more/directories/than/one", "git").get(); assertThat(target.resolve("data")).exists(); Path originalDataDir = tempDir diff --git a/scm-webapp/src/test/java/sonia/scm/update/repository/PublicFlagUpdateStepTest.java b/scm-webapp/src/test/java/sonia/scm/update/repository/PublicFlagUpdateStepTest.java index 9d7c4333fe..54c5460c6e 100644 --- a/scm-webapp/src/test/java/sonia/scm/update/repository/PublicFlagUpdateStepTest.java +++ b/scm-webapp/src/test/java/sonia/scm/update/repository/PublicFlagUpdateStepTest.java @@ -21,13 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.update.repository; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; @@ -35,7 +35,6 @@ import org.mockito.junit.jupiter.MockitoExtension; import sonia.scm.SCMContext; import sonia.scm.repository.Repository; import sonia.scm.repository.RepositoryPermission; -import sonia.scm.repository.RepositoryRolePermissions; import sonia.scm.repository.RepositoryTestData; import sonia.scm.repository.xml.XmlRepositoryDAO; import sonia.scm.update.UpdateStepTestUtil; @@ -49,7 +48,6 @@ import java.nio.file.Path; import java.util.Collections; import static org.assertj.core.api.Assertions.assertThat; -import static org.junitpioneer.jupiter.TempDirectory.TempDir; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.never; @@ -58,7 +56,6 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -@ExtendWith(TempDirectory.class) class PublicFlagUpdateStepTest { @Mock diff --git a/scm-webapp/src/test/java/sonia/scm/update/repository/XmlRepositoryFileNameUpdateStepTest.java b/scm-webapp/src/test/java/sonia/scm/update/repository/XmlRepositoryFileNameUpdateStepTest.java index 7e6d912336..3475fffac0 100644 --- a/scm-webapp/src/test/java/sonia/scm/update/repository/XmlRepositoryFileNameUpdateStepTest.java +++ b/scm-webapp/src/test/java/sonia/scm/update/repository/XmlRepositoryFileNameUpdateStepTest.java @@ -21,14 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.update.repository; import com.google.common.io.Resources; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import sonia.scm.SCMContextProvider; import sonia.scm.repository.xml.PathBasedRepositoryLocationResolver; import sonia.scm.repository.xml.XmlRepositoryDAO; @@ -43,19 +42,18 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -@ExtendWith(TempDirectory.class) class XmlRepositoryFileNameUpdateStepTest { SCMContextProvider contextProvider = mock(SCMContextProvider.class); XmlRepositoryDAO repositoryDAO = mock(XmlRepositoryDAO.class); @BeforeEach - void mockScmHome(@TempDirectory.TempDir Path tempDir) { + void mockScmHome(@TempDir Path tempDir) { when(contextProvider.getBaseDirectory()).thenReturn(tempDir.toFile()); } @Test - void shouldCopyRepositoriesFileToRepositoryPathsFile(@TempDirectory.TempDir Path tempDir) throws IOException { + void shouldCopyRepositoriesFileToRepositoryPathsFile(@TempDir Path tempDir) throws IOException { XmlRepositoryFileNameUpdateStep updateStep = new XmlRepositoryFileNameUpdateStep(contextProvider, repositoryDAO); URL url = Resources.getResource("sonia/scm/update/repository/formerV2RepositoryFile.xml"); Path configDir = tempDir.resolve("config"); diff --git a/scm-webapp/src/test/java/sonia/scm/update/repository/XmlRepositoryV1UpdateStepTest.java b/scm-webapp/src/test/java/sonia/scm/update/repository/XmlRepositoryV1UpdateStepTest.java index d9ea7d5766..6b0d2176f7 100644 --- a/scm-webapp/src/test/java/sonia/scm/update/repository/XmlRepositoryV1UpdateStepTest.java +++ b/scm-webapp/src/test/java/sonia/scm/update/repository/XmlRepositoryV1UpdateStepTest.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.update.repository; import com.google.common.io.Resources; @@ -30,7 +30,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; @@ -63,7 +63,6 @@ import static org.mockito.Mockito.when; import static sonia.scm.update.repository.MigrationStrategy.MOVE; @ExtendWith(MockitoExtension.class) -@ExtendWith(TempDirectory.class) class XmlRepositoryV1UpdateStepTest { Injector injectorMock = MigrationStrategyMock.init(); @@ -85,7 +84,7 @@ class XmlRepositoryV1UpdateStepTest { XmlRepositoryV1UpdateStep updateStep; @BeforeEach - void createUpdateStepFromMocks(@TempDirectory.TempDir Path tempDir) { + void createUpdateStepFromMocks(@TempDir Path tempDir) { testUtil = new UpdateStepTestUtil(tempDir); updateStep = new XmlRepositoryV1UpdateStep( testUtil.getContextProvider(), @@ -100,7 +99,7 @@ class XmlRepositoryV1UpdateStepTest { class WithExistingDatabase { @BeforeEach - void createV1Home(@TempDirectory.TempDir Path tempDir) throws IOException { + void createV1Home(@TempDir Path tempDir) throws IOException { V1RepositoryFileSystem.createV1Home(tempDir); } @@ -165,7 +164,7 @@ class XmlRepositoryV1UpdateStepTest { } @Test - void shouldUseDirectoryFromStrategy(@TempDirectory.TempDir Path tempDir) throws JAXBException { + void shouldUseDirectoryFromStrategy(@TempDir Path tempDir) throws JAXBException { Path targetDir = tempDir.resolve("someDir"); MigrationStrategy.Instance strategyMock = injectorMock.getInstance(MoveMigrationStrategy.class); when(strategyMock.migrate("454972da-faf9-4437-b682-dc4a4e0aa8eb", "simple", "git")).thenReturn(of(targetDir)); @@ -195,7 +194,7 @@ class XmlRepositoryV1UpdateStepTest { } @Test - void shouldBackupOldRepositoryDatabaseFile(@TempDirectory.TempDir Path tempDir) throws JAXBException { + void shouldBackupOldRepositoryDatabaseFile(@TempDir Path tempDir) throws JAXBException { updateStep.doUpdate(); assertThat(tempDir.resolve("config").resolve("repositories.xml")).doesNotExist(); @@ -209,14 +208,14 @@ class XmlRepositoryV1UpdateStepTest { } @Test - void shouldNotFailIfFormerV2DatabaseExists(@TempDirectory.TempDir Path tempDir) throws JAXBException, IOException { + void shouldNotFailIfFormerV2DatabaseExists(@TempDir Path tempDir) throws JAXBException, IOException { createFormerV2RepositoriesFile(tempDir); updateStep.doUpdate(); } @Test - void shouldNotBackupFormerV2DatabaseFile(@TempDirectory.TempDir Path tempDir) throws JAXBException, IOException { + void shouldNotBackupFormerV2DatabaseFile(@TempDir Path tempDir) throws JAXBException, IOException { createFormerV2RepositoriesFile(tempDir); updateStep.doUpdate(); @@ -226,14 +225,14 @@ class XmlRepositoryV1UpdateStepTest { } @Test - void shouldGetNoMissingStrategiesWithFormerV2DatabaseFile(@TempDirectory.TempDir Path tempDir) throws IOException { + void shouldGetNoMissingStrategiesWithFormerV2DatabaseFile(@TempDir Path tempDir) throws IOException { createFormerV2RepositoriesFile(tempDir); assertThat(updateStep.getRepositoriesWithoutMigrationStrategies()).isEmpty(); } @Test - void shouldFindMissingStrategies(@TempDirectory.TempDir Path tempDir) throws IOException { + void shouldFindMissingStrategies(@TempDir Path tempDir) throws IOException { V1RepositoryFileSystem.createV1Home(tempDir); assertThat(updateStep.getRepositoriesWithoutMigrationStrategies()) @@ -244,7 +243,7 @@ class XmlRepositoryV1UpdateStepTest { "454972da-faf9-4437-b682-dc4a4e0aa8eb"); } - private void createFormerV2RepositoriesFile(@TempDirectory.TempDir Path tempDir) throws IOException { + private void createFormerV2RepositoriesFile(@TempDir Path tempDir) throws IOException { URL url = Resources.getResource("sonia/scm/update/repository/formerV2RepositoryFile.xml"); Path configDir = tempDir.resolve("config"); Files.createDirectories(configDir); diff --git a/scm-webapp/src/test/java/sonia/scm/update/security/XmlSecurityV1UpdateStepTest.java b/scm-webapp/src/test/java/sonia/scm/update/security/XmlSecurityV1UpdateStepTest.java index aa1a19df7d..559b181199 100644 --- a/scm-webapp/src/test/java/sonia/scm/update/security/XmlSecurityV1UpdateStepTest.java +++ b/scm-webapp/src/test/java/sonia/scm/update/security/XmlSecurityV1UpdateStepTest.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.update.security; import com.google.common.io.Resources; @@ -29,7 +29,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import sonia.scm.SCMContextProvider; @@ -50,7 +50,6 @@ import static org.mockito.Mockito.when; import static sonia.scm.store.InMemoryConfigurationEntryStoreFactory.create; @ExtendWith(MockitoExtension.class) -@ExtendWith(TempDirectory.class) class XmlSecurityV1UpdateStepTest { @Mock @@ -60,7 +59,7 @@ class XmlSecurityV1UpdateStepTest { ConfigurationEntryStore assignedPermissionStore; @BeforeEach - void mockScmHome(@TempDirectory.TempDir Path tempDir) { + void mockScmHome(@TempDir Path tempDir) { when(contextProvider.getBaseDirectory()).thenReturn(tempDir.toFile()); InMemoryConfigurationEntryStoreFactory inMemoryConfigurationEntryStoreFactory = create(); assignedPermissionStore = inMemoryConfigurationEntryStoreFactory.get("security"); @@ -71,7 +70,7 @@ class XmlSecurityV1UpdateStepTest { class WithExistingDatabase { @BeforeEach - void createConfigV1XML(@TempDirectory.TempDir Path tempDir) throws IOException { + void createConfigV1XML(@TempDir Path tempDir) throws IOException { Path configDir = tempDir.resolve("config"); Files.createDirectories(configDir); copyTestDatabaseFile(configDir, "config.xml"); @@ -109,7 +108,7 @@ class XmlSecurityV1UpdateStepTest { class WithExistingSecurityXml { @BeforeEach - void createSecurityV1XML(@TempDirectory.TempDir Path tempDir) throws IOException { + void createSecurityV1XML(@TempDir Path tempDir) throws IOException { Path configDir = tempDir.resolve("config"); Files.createDirectories(configDir); copyTestDatabaseFile(configDir, "securityV1.xml"); diff --git a/scm-webapp/src/test/java/sonia/scm/update/user/XmlUserV1UpdateStepTest.java b/scm-webapp/src/test/java/sonia/scm/update/user/XmlUserV1UpdateStepTest.java index 98ab3dfadd..da9e3ccb7d 100644 --- a/scm-webapp/src/test/java/sonia/scm/update/user/XmlUserV1UpdateStepTest.java +++ b/scm-webapp/src/test/java/sonia/scm/update/user/XmlUserV1UpdateStepTest.java @@ -21,14 +21,14 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.update.user; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.junitpioneer.jupiter.TempDirectory; +import org.junit.jupiter.api.io.TempDir; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; @@ -38,7 +38,6 @@ import sonia.scm.store.ConfigurationEntryStore; import sonia.scm.store.InMemoryConfigurationEntryStoreFactory; import sonia.scm.update.UpdateStepTestUtil; import sonia.scm.update.V1Properties; -import sonia.scm.update.V1Property; import sonia.scm.user.User; import sonia.scm.user.xml.XmlUserDAO; @@ -55,7 +54,6 @@ import static org.mockito.Mockito.verify; import static sonia.scm.store.InMemoryConfigurationEntryStoreFactory.create; @ExtendWith(MockitoExtension.class) -@ExtendWith(TempDirectory.class) class XmlUserV1UpdateStepTest { @Mock @@ -71,7 +69,7 @@ class XmlUserV1UpdateStepTest { private UpdateStepTestUtil testUtil; @BeforeEach - void mockScmHome(@TempDirectory.TempDir Path tempDir) { + void mockScmHome(@TempDir Path tempDir) { testUtil = new UpdateStepTestUtil(tempDir); updateStep = new XmlUserV1UpdateStep(testUtil.getContextProvider(), userDAO, storeFactory); }