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
43 public void get( String s, File file )
44 throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
46 String sourceFile = getBasedir() + "/target/test-classes/" + s;
50 FileUtils.copyFile( new File( sourceFile ), file );
51 assert( file.exists() );
53 catch( IOException e )
55 throw new ResourceDoesNotExistException( e.getMessage() );
59 public boolean getIfNewer( String s, File file, long l )
60 throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
65 public void put( File file, String s )
66 throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
71 public void putDirectory( File file, String s )
72 throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
77 public boolean resourceExists( String s )
78 throws TransferFailedException, AuthorizationException
83 public List getFileList( String s )
84 throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
89 public boolean supportsDirectoryCopy()
94 public Repository getRepository()
99 public void connect( Repository repository )
100 throws ConnectionException, AuthenticationException
105 public void connect( Repository repository, ProxyInfo proxyInfo )
106 throws ConnectionException, AuthenticationException
111 public void connect( Repository repository, ProxyInfoProvider proxyInfoProvider )
112 throws ConnectionException, AuthenticationException
117 public void connect( Repository repository, AuthenticationInfo authenticationInfo )
118 throws ConnectionException, AuthenticationException
123 public void connect( Repository repository, AuthenticationInfo authenticationInfo, ProxyInfo proxyInfo )
124 throws ConnectionException, AuthenticationException
129 public void connect( Repository repository, AuthenticationInfo authenticationInfo,
130 ProxyInfoProvider proxyInfoProvider )
131 throws ConnectionException, AuthenticationException
136 public void openConnection()
137 throws ConnectionException, AuthenticationException
142 public void disconnect()
143 throws ConnectionException
148 public void setTimeout( int i )
153 public int getTimeout()
158 public void addSessionListener( SessionListener sessionListener )
163 public void removeSessionListener( SessionListener sessionListener )
168 public boolean hasSessionListener( SessionListener sessionListener )
173 public void addTransferListener( TransferListener transferListener )
178 public void removeTransferListener( TransferListener transferListener )
183 public boolean hasTransferListener( TransferListener transferListener )
188 public boolean isInteractive()
193 public void setInteractive( boolean b )
198 public String getBasedir()
200 String basedir = System.getProperty( "basedir" );
202 if ( basedir == null )
204 basedir = new File( "" ).getAbsolutePath();