1 package org.apache.maven.cli;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import junit.framework.TestCase;
23
24 import org.apache.maven.wagon.ConnectionException;
25 import org.apache.maven.wagon.authentication.AuthenticationException;
26 import org.apache.maven.wagon.events.TransferEvent;
27 import org.apache.maven.wagon.providers.file.FileWagon;
28 import org.apache.maven.wagon.repository.Repository;
29 import org.apache.maven.wagon.resource.Resource;
30
31
32
33
34
35
36
37 public abstract class AbstractConsoleDownloadMonitorTest
38 extends TestCase
39 {
40
41 private AbstractConsoleDownloadMonitor monitor;
42
43 public AbstractConsoleDownloadMonitorTest()
44 {
45 super();
46 }
47
48 public void setMonitor( AbstractConsoleDownloadMonitor monitor )
49 {
50 this.monitor = monitor;
51 }
52
53 public AbstractConsoleDownloadMonitor getMonitor()
54 {
55 return monitor;
56 }
57
58 public void testTransferInitiated()
59 throws Exception
60 {
61 monitor.transferInitiated( new TransferEventMock() );
62 }
63
64 public void testTransferStarted()
65 throws Exception
66 {
67 monitor.transferStarted( new TransferEventMock() );
68 }
69
70 public void testTransferProgress()
71 throws Exception
72 {
73 byte[] buffer = new byte[1000];
74 monitor.transferProgress( new TransferEventMock(), buffer, 1000 );
75 }
76
77 public void testTransferCompleted()
78 throws Exception
79 {
80 monitor.transferCompleted( new TransferEventMock() );
81 }
82
83 public void testTransferError()
84 throws Exception
85 {
86 monitor.transferError( new TransferEventMock( new RuntimeException() ) );
87 }
88
89 public void testDebug()
90 throws Exception
91 {
92 monitor.debug( "msg" );
93 }
94
95 private class TransferEventMock
96 extends TransferEvent
97 {
98 public TransferEventMock()
99 throws ConnectionException, AuthenticationException
100 {
101 super( new FileWagon(), new Resource(), TransferEvent.TRANSFER_INITIATED, TransferEvent.REQUEST_GET );
102 getResource().setContentLength( 100000 );
103 Repository repository = new Repository();
104 getWagon().connect( repository );
105 }
106
107 public TransferEventMock( Exception exception )
108 throws ConnectionException, AuthenticationException
109 {
110 super( new FileWagon(), new Resource(), exception, TransferEvent.REQUEST_GET );
111 getResource().setContentLength( 100000 );
112 Repository repository = new Repository();
113 getWagon().connect( repository );
114 }
115 }
116 }