]> source.dussan.org Git - archiva.git/commitdiff
PR: MRM-50
authorEdwin L. Punzalan <epunzalan@apache.org>
Fri, 2 Dec 2005 01:38:08 +0000 (01:38 +0000)
committerEdwin L. Punzalan <epunzalan@apache.org>
Fri, 2 Dec 2005 01:38:08 +0000 (01:38 +0000)
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

maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/AbstractRepositoryReportsTestCase.java [new file with mode: 0644]
maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/DefaultArtifactReporterTest.java
maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/DefaultRepositoryQueryLayerTest.java

diff --git a/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/AbstractRepositoryReportsTestCase.java b/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/AbstractRepositoryReportsTestCase.java
new file mode 100644 (file)
index 0000000..9be7f49
--- /dev/null
@@ -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();
+    }
+}
index 62ff1cba107dff72785be6026befd7d5404a3867..8efee560f13e8603a18beb5f3e88de8197ef3575 100644 (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()
index f67a67cdd37b0c74e49d6891cec910d7301931b0..bbba7ba19d789dc17e2f955229708f67423550f1 100644 (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
     {