2121
2222import java .io .File ;
2323import java .io .Reader ;
24- import java .util .Map ;
2524
2625import org .apache .maven .execution .MavenSession ;
2726import org .apache .maven .model .Model ;
3231import org .apache .maven .project .ProjectBuildingRequest ;
3332import org .apache .maven .shared .utils .ReaderFactory ;
3433import org .apache .maven .shared .utils .io .FileUtils ;
35- import org .apache .maven .shared .utils .io .IOUtil ;
3634import org .sonatype .aether .impl .internal .EnhancedLocalRepositoryManager ;
37- import org .sonatype .aether .util .ChecksumUtils ;
3835import org .sonatype .aether .util .DefaultRepositorySystemSession ;
3936
4037import static org .mockito .Mockito .mock ;
@@ -66,11 +63,6 @@ public void setUp()
6663 super .setUp ();
6764
6865 FileUtils .deleteDirectory ( new File ( getBasedir () + "/" + LOCAL_REPO ) );
69-
70- // LegacySupport legacySupport = lookup( LegacySupport.class );
71- // RepositorySystemSession repositorySession = new DefaultRepositorySystemSession();
72- // MavenExecutionRequest executionRequest = new DefaultMavenExecutionRequest();
73- // legacySupport.setSession( new MavenSession( getContainer(), repositorySession, executionRequest, null ) );
7466 }
7567
7668 public void testInstallFileTestEnvironment ()
@@ -166,29 +158,18 @@ public void testInstallFileWithGeneratePom()
166158 File installedPom = new File ( getBasedir (), LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" +
167159 artifactId + "-" + version + "." + "pom" );
168160
169- Model model ;
161+ try ( Reader reader = ReaderFactory .newXmlReader ( installedPom ) ) {
162+ Model model = new MavenXpp3Reader ().read ( reader );
170163
171- Reader reader = null ;
172- try
173- {
174- reader = ReaderFactory .newXmlReader ( installedPom );
175- model = new MavenXpp3Reader ().read ( reader );
176- reader .close ();
177- reader = null ;
178- }
179- finally
180- {
181- IOUtil .close ( reader );
164+ assertEquals ( "4.0.0" , model .getModelVersion () );
165+
166+ assertEquals ( (String ) getVariableValueFromObject ( mojo , "groupId" ), model .getGroupId () );
167+
168+ assertEquals ( artifactId , model .getArtifactId () );
169+
170+ assertEquals ( version , model .getVersion () );
182171 }
183172
184- assertEquals ( "4.0.0" , model .getModelVersion () );
185-
186- assertEquals ( (String ) getVariableValueFromObject ( mojo , "groupId" ), model .getGroupId () );
187-
188- assertEquals ( artifactId , model .getArtifactId () );
189-
190- assertEquals ( version , model .getVersion () );
191-
192173 assertEquals ( 5 , FileUtils .getFiles ( new File ( LOCAL_REPO ), null , null ).size () );
193174 }
194175
@@ -253,7 +234,7 @@ public void testInstallFileWithPomAsPackaging()
253234 assertEquals ( 4 , FileUtils .getFiles ( new File ( LOCAL_REPO ), null , null ).size () );
254235 }
255236
256- public void testInstallFileWithChecksum ()
237+ public void testInstallFile ()
257238 throws Exception
258239 {
259240 File testPom =
@@ -267,30 +248,15 @@ public void testInstallFileWithChecksum()
267248
268249 assignValuesForParameter ( mojo );
269250
270- // boolean createChecksum = (Boolean) getVariableValueFromObject( mojo, "createChecksum" );
271- //
272- // assertTrue( createChecksum );
273-
274251 mojo .execute ();
275252
276253 String localPath = getBasedir () + "/" + LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" +
277254 artifactId + "-" + version ;
278255
279256 File installedArtifact = new File ( localPath + "." + "jar" );
280257
281- //get the actual checksum of the artifact
282- // Map<String, Object> csums = ChecksumUtils.calc( file, Utils.CHECKSUM_ALGORITHMS );
283- // for (Map.Entry<String, Object> csum : csums.entrySet()) {
284- // Object actualSum = csum.getValue();
285- // File sum = new File( localPath + ".jar." + csum.getKey().toLowerCase().replace( "-", "" ) );
286- // assertTrue( sum.exists() );
287- // String generatedSum = FileUtils.fileRead( sum, "UTF-8" );
288- // assertEquals( actualSum, generatedSum );
289- // }
290-
291258 assertTrue ( installedArtifact .exists () );
292259
293- // assertEquals( 9, FileUtils.getFiles( new File( LOCAL_REPO ), null, null ).size() );
294260 assertEquals ( 5 , FileUtils .getFiles ( new File ( LOCAL_REPO ), null , null ).size () );
295261 }
296262
0 commit comments