[ 
https://issues.apache.org/jira/browse/MRESOLVER-279?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17622678#comment-17622678
 ] 

ASF GitHub Bot commented on MRESOLVER-279:
------------------------------------------

gnodet commented on code in PR #203:
URL: https://github.com/apache/maven-resolver/pull/203#discussion_r1002547214


##########
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:
   I don't see the `session` parameter used.  Did I miss something ?





> Simplify and improve trusted checksum sources
> ---------------------------------------------
>
>                 Key: MRESOLVER-279
>                 URL: https://issues.apache.org/jira/browse/MRESOLVER-279
>             Project: Maven Resolver
>          Issue Type: Task
>          Components: Resolver
>            Reporter: Tamas Cservenak
>            Assignee: Tamas Cservenak
>            Priority: Major
>             Fix For: 1.9.0
>
>
> High level changes:
>  * support class should meddle way less, it is here to provide some utils and 
> protect from future API changes
>  * sparse source: use `FileProcessor` both both, checksum read and write 
> (instead to mix in `Files.write`)
>  * summary source: heavily enhanced, on save it truncate or merges with 
> existing summary file, added change detection (prevents save when no change 
> to save), summary file is written out atomically, and finally file format is 
> made GNU Coreutils formatted, hence is usable with GNU sha1sum and alike OS 
> tools
>  * introduce FileUtils, Java NIO2 based file writing utility
> For both checksum sources the semantics of concurrent lookup/write is cleared 
> up and documented (and fixed in summary). For both purposes (lookup or 
> write), the source must be explicitly enabled.
> Tests redone as well, and should work with any writable trusted checksum 
> source.
> ----



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to