1 package org.apache.archiva.metadata.repository.storage.maven2;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.commons.io.FileUtils;
23 import org.apache.maven.wagon.ConnectionException;
24 import org.apache.maven.wagon.ResourceDoesNotExistException;
25 import org.apache.maven.wagon.TransferFailedException;
26 import org.apache.maven.wagon.Wagon;
27 import org.apache.maven.wagon.authentication.AuthenticationException;
28 import org.apache.maven.wagon.authentication.AuthenticationInfo;
29 import org.apache.maven.wagon.authorization.AuthorizationException;
30 import org.apache.maven.wagon.events.SessionListener;
31 import org.apache.maven.wagon.events.TransferListener;
32 import org.apache.maven.wagon.proxy.ProxyInfo;
33 import org.apache.maven.wagon.proxy.ProxyInfoProvider;
34 import org.apache.maven.wagon.repository.Repository;
37 import java.io.IOException;
38 import java.util.List;
40 public class MockWagon
44 public void get( String s, File file )
45 throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
47 String sourceFile = getBasedir() + "/src/test/resources/" + s;
51 FileUtils.copyFile( new File( sourceFile ), file );
52 assert( file.exists() );
54 catch( IOException e )
56 throw new ResourceDoesNotExistException( e.getMessage() );
61 public boolean getIfNewer( String s, File file, long l )
62 throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
68 public void put( File file, String s )
69 throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
75 public void putDirectory( File file, String s )
76 throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
82 public boolean resourceExists( String s )
83 throws TransferFailedException, AuthorizationException
89 public List<String> getFileList( String s )
90 throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
96 public boolean supportsDirectoryCopy()
102 public Repository getRepository()
108 public void connect( Repository repository )
109 throws ConnectionException, AuthenticationException
115 public void connect( Repository repository, ProxyInfo proxyInfo )
116 throws ConnectionException, AuthenticationException
122 public void connect( Repository repository, ProxyInfoProvider proxyInfoProvider )
123 throws ConnectionException, AuthenticationException
129 public void connect( Repository repository, AuthenticationInfo authenticationInfo )
130 throws ConnectionException, AuthenticationException
136 public void connect( Repository repository, AuthenticationInfo authenticationInfo, ProxyInfo proxyInfo )
137 throws ConnectionException, AuthenticationException
143 public void connect( Repository repository, AuthenticationInfo authenticationInfo,
144 ProxyInfoProvider proxyInfoProvider )
145 throws ConnectionException, AuthenticationException
151 public void openConnection()
152 throws ConnectionException, AuthenticationException
158 public void disconnect()
159 throws ConnectionException
165 public void setTimeout( int i )
171 public int getTimeout()
177 public void setReadTimeout( int timeoutValue )
183 public int getReadTimeout()
189 public void addSessionListener( SessionListener sessionListener )
195 public void removeSessionListener( SessionListener sessionListener )
201 public boolean hasSessionListener( SessionListener sessionListener )
207 public void addTransferListener( TransferListener transferListener )
213 public void removeTransferListener( TransferListener transferListener )
219 public boolean hasTransferListener( TransferListener transferListener )
225 public boolean isInteractive()
231 public void setInteractive( boolean b )
236 public String getBasedir()
238 String basedir = System.getProperty( "basedir" );
240 if ( basedir == null )
242 basedir = new File( "" ).getAbsolutePath();