1 package org.apache.maven.wagon;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.ByteArrayInputStream;
23 import java.io.ByteArrayOutputStream;
24 import java.io.InputStream;
25 import java.io.OutputStream;
26 import java.util.Collections;
27 import java.util.List;
28
29 import org.apache.maven.wagon.authorization.AuthorizationException;
30
31
32
33
34
35 public class WagonMock
36 extends StreamWagon
37 {
38 private boolean errorInputStream;
39 private int timeout = 0;
40
41 public WagonMock()
42 {
43 }
44
45 public WagonMock( boolean errorInputStream )
46 {
47 this.errorInputStream = errorInputStream;
48 }
49
50
51 public void fillInputData( InputData inputData )
52 throws TransferFailedException
53 {
54
55 InputStream is;
56
57 if ( errorInputStream )
58 {
59 InputStreamMock mockInputStream = new InputStreamMock();
60
61 mockInputStream.setForcedError( true );
62
63 is = mockInputStream;
64
65 }
66 else
67 {
68 byte[] buffer = new byte[1024 * 4 * 5];
69
70 is = new ByteArrayInputStream( buffer );
71 }
72
73 inputData.setInputStream( is );
74
75 }
76
77 public void fillOutputData( OutputData outputData )
78 throws TransferFailedException
79 {
80
81 OutputStream os;
82
83 if ( errorInputStream )
84 {
85 OutputStreamMock mockOutputStream = new OutputStreamMock();
86
87 mockOutputStream.setForcedError( true );
88
89 os = mockOutputStream;
90 }
91 else
92 {
93 os = new ByteArrayOutputStream();
94 }
95
96 outputData.setOutputStream( os );
97
98 }
99
100 public void openConnectionInternal()
101 {
102 }
103
104 public void closeConnection()
105 {
106 }
107
108 public void setTimeout( int timeoutValue )
109 {
110 timeout = timeoutValue;
111 }
112
113 public int getTimeout()
114 {
115 return timeout;
116 }
117
118 public List<String> getFileList( String destinationDirectory )
119 throws TransferFailedException, AuthorizationException
120 {
121 return Collections.<String>emptyList();
122 }
123
124 public boolean resourceExists( String resourceName )
125 throws AuthorizationException
126 {
127 return false;
128 }
129
130 }