1 package org.apache.maven.model.building;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23 import java.io.IOException;
24
25 import org.codehaus.plexus.util.Os;
26 import org.junit.jupiter.api.Test;
27
28 import static org.junit.jupiter.api.Assertions.assertFalse;
29 import static org.junit.jupiter.api.Assertions.assertTrue;
30 import static org.junit.jupiter.api.Assumptions.assumeTrue;
31
32
33
34
35
36
37 public class FileModelSourceTest
38 {
39
40
41
42
43 @Test
44 public void testEquals()
45 throws Exception
46 {
47 File tempFile = createTempFile( "pomTest" );
48 FileModelSource instance = new FileModelSource( tempFile );
49
50 assertFalse( instance.equals( null ) );
51 assertFalse( instance.equals( new Object() ) );
52 assertTrue( instance.equals( instance ) );
53 assertTrue( instance.equals( new FileModelSource( tempFile ) ) );
54 }
55
56 @Test
57 public void testWindowsPaths()
58 throws Exception
59 {
60 assumeTrue( Os.isFamily( "Windows" ) );
61
62 File upperCaseFile = createTempFile( "TESTE" );
63 String absolutePath = upperCaseFile.getAbsolutePath();
64 File lowerCaseFile = new File( absolutePath.toLowerCase() );
65
66 FileModelSource upperCaseFileSource = new FileModelSource( upperCaseFile );
67 FileModelSource lowerCaseFileSource = new FileModelSource( lowerCaseFile );
68
69 assertTrue( upperCaseFileSource.equals( lowerCaseFileSource ) );
70 }
71
72 private File createTempFile( String name ) throws IOException
73 {
74 File tempFile = File.createTempFile( name, ".xml" );
75 tempFile.deleteOnExit();
76 return tempFile;
77 }
78
79 }