1 package org.apache.archiva.repository.maven.metadata.storage;
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
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
21 import org.apache.commons.io.FileUtils;
22 import org.apache.maven.wagon.ConnectionException;
23 import org.apache.maven.wagon.ResourceDoesNotExistException;
24 import org.apache.maven.wagon.TransferFailedException;
25 import org.apache.maven.wagon.Wagon;
26 import org.apache.maven.wagon.authentication.AuthenticationException;
27 import org.apache.maven.wagon.authentication.AuthenticationInfo;
28 import org.apache.maven.wagon.authorization.AuthorizationException;
29 import org.apache.maven.wagon.events.SessionListener;
30 import org.apache.maven.wagon.events.TransferListener;
31 import org.apache.maven.wagon.proxy.ProxyInfo;
32 import org.apache.maven.wagon.proxy.ProxyInfoProvider;
33 import org.apache.maven.wagon.repository.Repository;
36 import java.io.IOException;
37 import java.util.List;
39 public class MockWagon
43 public void get( String s, File file )
44 throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
46 String sourceFile = getBasedir() + "/src/test/resources/" + s;
50 FileUtils.copyFile( new File( sourceFile ), file );
51 assert( file.exists() );
53 catch( IOException e )
55 throw new ResourceDoesNotExistException( e.getMessage() );
60 public boolean getIfNewer( String s, File file, long l )
61 throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
67 public void put( File file, String s )
68 throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
74 public void putDirectory( File file, String s )
75 throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
81 public boolean resourceExists( String s )
82 throws TransferFailedException, AuthorizationException
88 public List<String> getFileList( String s )
89 throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
95 public boolean supportsDirectoryCopy()
101 public Repository getRepository()
107 public void connect( Repository repository )
108 throws ConnectionException, AuthenticationException
114 public void connect( Repository repository, ProxyInfo proxyInfo )
115 throws ConnectionException, AuthenticationException
121 public void connect( Repository repository, ProxyInfoProvider proxyInfoProvider )
122 throws ConnectionException, AuthenticationException
128 public void connect( Repository repository, AuthenticationInfo authenticationInfo )
129 throws ConnectionException, AuthenticationException
135 public void connect( Repository repository, AuthenticationInfo authenticationInfo, ProxyInfo proxyInfo )
136 throws ConnectionException, AuthenticationException
142 public void connect( Repository repository, AuthenticationInfo authenticationInfo,
143 ProxyInfoProvider proxyInfoProvider )
144 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();