--- /dev/null
+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();
+ }
+}
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
{
reporter = (ArtifactReporter) lookup( ArtifactReporter.ROLE, "default" );
}
- public void testAddSuccess()
+ public void testAddSuccess() throws Exception
{
- assertTrue( true );
+ assertTrue( writeTestArtifact( "valid-poms/", "test" ) );
}
protected void tearDown()
* @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
{