missing files

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@516732 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2007-03-10 15:37:15 +00:00
parent badcd2287f
commit 23b0464bd7
2 changed files with 210 additions and 0 deletions

View File

@ -0,0 +1,60 @@
package org.apache.maven.artifact.manager;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.maven.wagon.TransferFailedException;
public class WagonConfigurationException
extends TransferFailedException
{
static final long serialVersionUID = 1;
private final String originalMessage;
private final String repositoryId;
public WagonConfigurationException( String repositoryId, String message, Throwable cause )
{
super( "While configuring wagon for \'" + repositoryId + "\': " + message, cause );
this.repositoryId = repositoryId;
this.originalMessage = message;
}
public WagonConfigurationException( String repositoryId, String message )
{
super( "While configuring wagon for \'" + repositoryId + "\': " + message );
this.repositoryId = repositoryId;
this.originalMessage = message;
}
public final String getRepositoryId()
{
return repositoryId;
}
public final String getOriginalMessage()
{
return originalMessage;
}
}

View File

@ -0,0 +1,150 @@
package org.apache.maven.artifact.manager;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.maven.wagon.UnsupportedProtocolException;
import org.apache.maven.wagon.Wagon;
import org.apache.maven.wagon.repository.Repository;
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.util.xml.Xpp3Dom;
/**
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
* @version $Id$
*/
public class DefaultWagonManagerTest
extends PlexusTestCase
{
private WagonManager wagonManager;
protected void setUp()
throws Exception
{
super.setUp();
wagonManager = (WagonManager) lookup( WagonManager.ROLE );
}
public void testDefaultWagonManager()
throws Exception
{
assertWagon( "a" );
assertWagon( "b1" );
assertWagon( "b2" );
assertWagon( "c" );
try
{
assertWagon( "d" );
fail( "Expected :" + UnsupportedProtocolException.class.getName() );
}
catch ( UnsupportedProtocolException e )
{
//ok
assertTrue( true );
}
}
public void testGetWagonRepository()
throws Exception
{
assertWagonRepository( "a" );
assertWagonRepository( "b1" );
assertWagonRepository( "b2" );
assertWagonRepository( "c" );
try
{
assertWagonRepository( "d" );
fail( "Expected :" + UnsupportedProtocolException.class.getName() );
}
catch ( UnsupportedProtocolException e )
{
//ok
assertTrue( true );
}
}
public void testGetWagonRepositoryNullProtocol()
throws Exception
{
try
{
Repository repository = new Repository();
repository.setProtocol( null );
Wagon wagon = (Wagon) wagonManager.getWagon( repository );
fail( "Expected :" + UnsupportedProtocolException.class.getName() );
}
catch ( UnsupportedProtocolException e )
{
//ok
assertTrue( true );
}
}
private void assertWagon( String protocol )
throws Exception
{
Wagon wagon = wagonManager.getWagon( protocol );
assertNotNull( "Check wagon, protocol=" + protocol, wagon );
}
private void assertWagonRepository( String protocol )
throws Exception
{
Repository repository = new Repository();
String s = "value=" + protocol;
repository.setId( "id=" + protocol );
repository.setProtocol( protocol );
Xpp3Dom conf = new Xpp3Dom( "configuration" );
Xpp3Dom configurableField = new Xpp3Dom( "configurableField" );
configurableField.setValue( s );
conf.addChild( configurableField );
wagonManager.addConfiguration( repository.getId(), conf );
WagonMock wagon = (WagonMock) wagonManager.getWagon( repository );
assertNotNull( "Check wagon, protocol=" + protocol, wagon );
assertEquals( "Check configuration for wagon, protocol=" + protocol, s, wagon.getConfigurableField() );
}
}