mirror of https://github.com/apache/archiva.git
Added some unit test objects
git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@353953 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1c688ebb30
commit
8f8b59ff02
|
@ -40,4 +40,18 @@
|
|||
</dependency>
|
||||
-->
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/Abstract*.java</exclude>
|
||||
<exclude>**/Test*.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
|
@ -17,9 +17,8 @@ package org.apache.maven.repository.reporting;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
|
||||
import java.io.File;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
package org.apache.maven.repository.reporting;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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 java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.List;
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
|
||||
public class BadMetadataReportProcessorTest extends PlexusTestCase
|
||||
{
|
||||
protected ArtifactFactory artifactFactory;
|
||||
private BadMetadataReportProcessor badMetadataReportProcessor;
|
||||
|
||||
public BadMetadataReportProcessorTest(String testName)
|
||||
{
|
||||
super(testName);
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
artifactFactory = (ArtifactFactory) getContainer().lookup( ArtifactFactory.ROLE );
|
||||
|
||||
badMetadataReportProcessor = new TestBadMetadataReportProcessor( artifactFactory,
|
||||
new DefaultRepositoryQueryLayer() );
|
||||
}
|
||||
|
||||
protected RepositoryQueryLayer getRepositoryQueryLayer( List returnValues ) throws NoSuchMethodException
|
||||
{
|
||||
GenericMockObject mockObject = new GenericMockObject();
|
||||
Method method = RepositoryQueryLayer.class.getMethod( "containsArtifact", null );
|
||||
mockObject.setExpectedReturns( method, returnValues );
|
||||
RepositoryQueryLayer queryLayer = (RepositoryQueryLayer) Proxy.newProxyInstance( this.getClassLoader(),
|
||||
new Class[] { RepositoryQueryLayer.class },
|
||||
new GenericMockObject() );
|
||||
return queryLayer;
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception
|
||||
{
|
||||
release( artifactFactory );
|
||||
}
|
||||
|
||||
public void testProcessMetadata()
|
||||
{
|
||||
}
|
||||
|
||||
public void testCheckPluginMetadata()
|
||||
{
|
||||
}
|
||||
|
||||
public void testCheckSnapshotMetadata()
|
||||
{
|
||||
}
|
||||
|
||||
public void testCheckMetadataVersions()
|
||||
{
|
||||
}
|
||||
|
||||
public void testCheckRepositoryVersions()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package org.apache.maven.repository.reporting;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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 java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edwin Punzalan
|
||||
*/
|
||||
public class GenericMockObject implements InvocationHandler
|
||||
{
|
||||
Map invocations = new HashMap();
|
||||
|
||||
public GenericMockObject()
|
||||
{
|
||||
//default constructor
|
||||
}
|
||||
|
||||
public GenericMockObject( Map returnMap )
|
||||
{
|
||||
invocations = returnMap;
|
||||
}
|
||||
|
||||
public void setExpectedReturns( Method method, List returnList )
|
||||
{
|
||||
invocations.put( method, returnList );
|
||||
}
|
||||
|
||||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
|
||||
{
|
||||
if ( !invocations.containsKey( method ) )
|
||||
throw new UnsupportedOperationException( "No expected return values defined." );
|
||||
|
||||
List returnList = (List) invocations.get( method );
|
||||
if ( returnList.size() < 1 ) throw new UnsupportedOperationException( "Too few expected return values defined." );
|
||||
return returnList.remove( 0 );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package org.apache.maven.repository.reporting;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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.artifact.factory.ArtifactFactory;
|
||||
|
||||
public class TestBadMetadataReportProcessor extends BadMetadataReportProcessor
|
||||
{
|
||||
public TestBadMetadataReportProcessor( ArtifactFactory factory, RepositoryQueryLayer layer )
|
||||
{
|
||||
artifactFactory = factory ;
|
||||
repositoryQueryLayer = layer ;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue