1 package org.apache.maven.wagon.providers.file;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.wagon.ConnectionException;
23 import org.apache.maven.wagon.FileTestUtils;
24 import org.apache.maven.wagon.StreamingWagonTestCase;
25 import org.apache.maven.wagon.Wagon;
26 import org.apache.maven.wagon.authentication.AuthenticationException;
27 import org.apache.maven.wagon.repository.Repository;
28 import org.apache.maven.wagon.resource.Resource;
29
30 import java.io.File;
31 import java.io.IOException;
32
33
34
35
36
37 public class FileWagonTest
38 extends StreamingWagonTestCase
39 {
40 protected String getProtocol()
41 {
42 return "file";
43 }
44
45 protected String getTestRepositoryUrl()
46 throws IOException
47 {
48 File file = FileTestUtils.createUniqueDir( getName() + ".file-repository." );
49
50 return file.toPath().toUri().toASCIIString();
51 }
52
53
54
55
56
57
58
59
60 public void testNullFileWagon() throws ConnectionException, AuthenticationException
61 {
62 Wagon wagon = new FileWagon();
63 Resource resource = new Resource();
64 resource.setContentLength( 100000 );
65 Repository repository = new Repository();
66 wagon.connect( repository );
67 wagon.disconnect();
68 }
69
70 protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource )
71 {
72 return new File( repository.getBasedir(), resource.getName() ).lastModified();
73 }
74
75 public void testResourceExists()
76 throws Exception
77 {
78 String url = new File( getBasedir() ).toPath().toUri().toASCIIString();
79
80 Wagon wagon = new FileWagon();
81 Repository repository = new Repository( "someID", url );
82 wagon.connect( repository );
83
84 assertTrue( wagon.resourceExists( "target" ) );
85 assertTrue( wagon.resourceExists( "target/" ) );
86 assertTrue( wagon.resourceExists( "pom.xml" ) );
87
88 assertFalse( wagon.resourceExists( "pom.xml/" ) );
89
90 wagon.disconnect();
91 }
92 }