cstamas commented on code in PR #203:
URL: https://github.com/apache/maven-resolver/pull/203#discussion_r1004080129
##########
maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/checksum/FileTrustedChecksumsSourceTestSupport.java:
##########
@@ -51,58 +56,79 @@
private FileTrustedChecksumsSourceSupport subject;
+ private boolean checksumWritten;
+
@Before
public void before() throws Exception
{
session = TestUtils.newSession();
// populate local repository
- Path basedir = session.getLocalRepository().getBasedir().toPath()
- .resolve(
FileTrustedChecksumsSourceSupport.LOCAL_REPO_PREFIX_DIR );
checksumAlgorithmFactory = new Sha1ChecksumAlgorithmFactory();
- subject = prepareSubject( basedir );
+ subject = prepareSubject();
+ checksumWritten = false;
+
+ try ( DefaultRepositorySystemSession prepareSession = new
DefaultRepositorySystemSession( session ) )
+ {
+ enableSource( prepareSession );
+ try ( TrustedChecksumsSource.Writer writer =
subject.getTrustedArtifactChecksumsWriter( prepareSession ) )
+ {
+ if ( writer != null )
+ {
+ HashMap<String, String> checksums = new HashMap<>();
+ checksums.put( checksumAlgorithmFactory.getName(),
ARTIFACT_TRUSTED_CHECKSUM );
+ writer.addTrustedArtifactChecksums(
ARTIFACT_WITH_CHECKSUM, prepareSession.getLocalRepository(),
+ Collections.singletonList(
checksumAlgorithmFactory ), checksums );
+ checksumWritten = true;
+ }
+ }
+ }
}
- protected abstract FileTrustedChecksumsSourceSupport prepareSubject( Path
basedir ) throws IOException;
+ protected abstract FileTrustedChecksumsSourceSupport prepareSubject();
- protected abstract void enableSource();
+ protected abstract void enableSource( DefaultRepositorySystemSession
session );
Review Comment:
You did, the session passed as param is used, may make support session
private to make it more obvious
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]