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:
Edwin L. Punzalan 2005-12-02 01:38:08 +00:00
parent 649f02cc6d
commit c1678e136b
3 changed files with 102 additions and 4 deletions

View File

@ -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();
}
}

View File

@ -18,16 +18,26 @@ package org.apache.maven.repository.reporting;
import org.codehaus.plexus.PlexusTestCase;
import java.io.File;
import java.lang.System;
/**
* Test the artifact reporter.
*
* @author <a href="mailto:jtolentino@mergere.com">John Tolentino</a>
*/
public class DefaultArtifactReporterTest
extends PlexusTestCase
extends AbstractRepositoryReportsTestCase
{
private static final String[] testRepoStructure = { "valid-poms/", "invalid-poms/" };
private ArtifactReporter reporter;
public DefaultArtifactReporterTest()
{
super( System.getProperty( "basedir" ) + "/src/test/repository/", testRepoStructure );
}
protected void setUp()
throws Exception
{
@ -35,9 +45,9 @@ public class DefaultArtifactReporterTest
reporter = (ArtifactReporter) lookup( ArtifactReporter.ROLE, "default" );
}
public void testAddSuccess()
public void testAddSuccess() throws Exception
{
assertTrue( true );
assertTrue( writeTestArtifact( "valid-poms/", "test" ) );
}
protected void tearDown()

View File

@ -24,10 +24,17 @@ import org.codehaus.plexus.PlexusTestCase;
* @author <a href="mailto:jtolentino@mergere.com">John Tolentino</a>
*/
public class DefaultRepositoryQueryLayerTest
extends PlexusTestCase
extends AbstractRepositoryReportsTestCase
{
private static final String[] testRepoStructure = { "valid-poms/", "invalid-poms/" };
private RepositoryQueryLayer queryLayer;
public DefaultRepositoryQueryLayerTest()
{
super( System.getProperty( "basedir" ) + "/src/test/repository/", testRepoStructure );
}
protected void setUp()
throws Exception
{