mirror of https://github.com/apache/archiva.git
PR: MRM-50
Submitted by: John Tolentino Additional unit tests git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@351553 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
649f02cc6d
commit
c1678e136b
|
@ -0,0 +1,81 @@
|
||||||
|
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.codehaus.plexus.PlexusTestCase;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import org.codehaus.plexus.util.FileUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="mailto:jtolentino@mergere.com">John Tolentino</a>
|
||||||
|
*/
|
||||||
|
public abstract class AbstractRepositoryReportsTestCase
|
||||||
|
extends PlexusTestCase
|
||||||
|
{
|
||||||
|
private static String JAR = ".jar";
|
||||||
|
|
||||||
|
private static String basedir;
|
||||||
|
|
||||||
|
private static String[] directoryStructure;
|
||||||
|
|
||||||
|
public AbstractRepositoryReportsTestCase( String basedir, String[] directoryStructure )
|
||||||
|
{
|
||||||
|
this.basedir = basedir;
|
||||||
|
this.directoryStructure = directoryStructure;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setUp()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
super.setUp();
|
||||||
|
buildTestRepoPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buildTestRepoPath()
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < directoryStructure.length; i++ )
|
||||||
|
{
|
||||||
|
File dir = new File( basedir + directoryStructure[i] );
|
||||||
|
if ( !dir.exists() )
|
||||||
|
{
|
||||||
|
dir.mkdirs();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteTestRepoPath() throws Exception
|
||||||
|
{
|
||||||
|
FileUtils.deleteDirectory( basedir );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean writeTestArtifact( String relativePath, String artifactId )
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
File artifact = new File( basedir + relativePath + artifactId + JAR );
|
||||||
|
System.out.println( "" + basedir + relativePath + artifactId );
|
||||||
|
return artifact.createNewFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void tearDown()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
deleteTestRepoPath();
|
||||||
|
super.tearDown();
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,16 +18,26 @@ package org.apache.maven.repository.reporting;
|
||||||
|
|
||||||
import org.codehaus.plexus.PlexusTestCase;
|
import org.codehaus.plexus.PlexusTestCase;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.System;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the artifact reporter.
|
* Test the artifact reporter.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jtolentino@mergere.com">John Tolentino</a>
|
* @author <a href="mailto:jtolentino@mergere.com">John Tolentino</a>
|
||||||
*/
|
*/
|
||||||
public class DefaultArtifactReporterTest
|
public class DefaultArtifactReporterTest
|
||||||
extends PlexusTestCase
|
extends AbstractRepositoryReportsTestCase
|
||||||
{
|
{
|
||||||
|
private static final String[] testRepoStructure = { "valid-poms/", "invalid-poms/" };
|
||||||
|
|
||||||
private ArtifactReporter reporter;
|
private ArtifactReporter reporter;
|
||||||
|
|
||||||
|
public DefaultArtifactReporterTest()
|
||||||
|
{
|
||||||
|
super( System.getProperty( "basedir" ) + "/src/test/repository/", testRepoStructure );
|
||||||
|
}
|
||||||
|
|
||||||
protected void setUp()
|
protected void setUp()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
@ -35,9 +45,9 @@ public class DefaultArtifactReporterTest
|
||||||
reporter = (ArtifactReporter) lookup( ArtifactReporter.ROLE, "default" );
|
reporter = (ArtifactReporter) lookup( ArtifactReporter.ROLE, "default" );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAddSuccess()
|
public void testAddSuccess() throws Exception
|
||||||
{
|
{
|
||||||
assertTrue( true );
|
assertTrue( writeTestArtifact( "valid-poms/", "test" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void tearDown()
|
protected void tearDown()
|
||||||
|
|
|
@ -24,10 +24,17 @@ import org.codehaus.plexus.PlexusTestCase;
|
||||||
* @author <a href="mailto:jtolentino@mergere.com">John Tolentino</a>
|
* @author <a href="mailto:jtolentino@mergere.com">John Tolentino</a>
|
||||||
*/
|
*/
|
||||||
public class DefaultRepositoryQueryLayerTest
|
public class DefaultRepositoryQueryLayerTest
|
||||||
extends PlexusTestCase
|
extends AbstractRepositoryReportsTestCase
|
||||||
{
|
{
|
||||||
|
private static final String[] testRepoStructure = { "valid-poms/", "invalid-poms/" };
|
||||||
|
|
||||||
private RepositoryQueryLayer queryLayer;
|
private RepositoryQueryLayer queryLayer;
|
||||||
|
|
||||||
|
public DefaultRepositoryQueryLayerTest()
|
||||||
|
{
|
||||||
|
super( System.getProperty( "basedir" ) + "/src/test/repository/", testRepoStructure );
|
||||||
|
}
|
||||||
|
|
||||||
protected void setUp()
|
protected void setUp()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue