From f01af0c97d29af4dce35aa1b575a998359c9c952 Mon Sep 17 00:00:00 2001 From: Konrad Windszus Date: Mon, 11 Sep 2023 13:25:58 +0200 Subject: [PATCH] fix failing test --- .../plugins/javadoc/JavadocReportTest.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java b/src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java index fce08966f..7d576b1f8 100644 --- a/src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java +++ b/src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java @@ -169,6 +169,10 @@ private void createTestRepo() throws IOException { assertThat(sourceDir).exists(); copyDirectory(sourceDir.toFile(), localRepo); + // + // taglet artifact referenced from tagletArtifacts-test/tagletArtifacts-test-plugin-config.xml + // + // Remove SCM files List files = FileUtils.getFileAndDirectoryNames( localRepo, FileUtils.getDefaultExcludesAsString(), null, true, true, true, true); @@ -1080,19 +1084,19 @@ public void testTagletArtifacts() throws Exception { Path testPom = unit.resolve("tagletArtifacts-test/tagletArtifacts-test-plugin-config.xml"); JavadocReport mojo = lookupMojo(testPom); - MavenSession session = spy(newMavenSession(mojo.project)); - ProjectBuildingRequest buildingRequest = mock(ProjectBuildingRequest.class); - when(buildingRequest.getRemoteRepositories()).thenReturn(mojo.project.getRemoteArtifactRepositories()); - when(session.getProjectBuildingRequest()).thenReturn(buildingRequest); - DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); - repositorySession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory() - .newInstance(repositorySession, new LocalRepository(localRepo))); - when(buildingRequest.getRepositorySession()).thenReturn(repositorySession); - when(session.getRepositorySession()).thenReturn(repositorySession); + MavenSession session = newMavenSession(mojo.project); + DefaultRepositorySystemSession repoSysSession = (DefaultRepositorySystemSession) session.getRepositorySession(); + repoSysSession + .setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory() + .newInstance( + session.getRepositorySession(), new LocalRepository(new File("target/local-repo")))); + // Ensure remote repo connection uses SSL + File globalSettingsFile = new File(getBasedir(), "target/test-classes/unit/settings.xml"); + session.getRequest().setGlobalSettingsFile(globalSettingsFile); LegacySupport legacySupport = lookup(LegacySupport.class); legacySupport.setSession(session); setVariableValueToObject(mojo, "session", session); - setVariableValueToObject(mojo, "repoSession", repositorySession); + setVariableValueToObject(mojo, "repoSession", repoSysSession); mojo.execute(); Path optionsFile = new File(mojo.getOutputDirectory(), "options").toPath();