archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joak...@apache.org
Subject svn commit: r511053 [4/6] - in /maven/archiva/trunk: ./ archiva-applet/ archiva-cli/ archiva-cli/src/main/java/org/apache/maven/archiva/cli/ archiva-common/ archiva-common/src/ archiva-common/src/main/ archiva-common/src/main/java/ archiva-common/src/m...
Date Fri, 23 Feb 2007 19:05:37 GMT
Modified: maven/archiva/trunk/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/processor/DuplicateArtifactFileReportProcessor.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/processor/DuplicateArtifactFileReportProcessor.java?view=diff&rev=511053&r1=511052&r2=511053
==============================================================================
--- maven/archiva/trunk/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/processor/DuplicateArtifactFileReportProcessor.java (original)
+++ maven/archiva/trunk/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/processor/DuplicateArtifactFileReportProcessor.java Fri Feb 23 11:05:21 2007
@@ -27,7 +27,7 @@
 import org.apache.maven.archiva.indexer.lucene.LuceneQuery;
 import org.apache.maven.archiva.indexer.record.StandardArtifactIndexRecord;
 import org.apache.maven.archiva.indexer.record.StandardIndexRecordFields;
-import org.apache.maven.archiva.reporting.database.ReportingDatabase;
+import org.apache.maven.archiva.reporting.database.ArtifactResultsDatabase;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.model.Model;
@@ -62,9 +62,14 @@
      */
     private String indexDirectory;
 
+    /**
+     * @plexus.requirement
+     */
+    private ArtifactResultsDatabase database;
+
     private static final String ROLE_HINT = "duplicate";
 
-    public void processArtifact( Artifact artifact, Model model, ReportingDatabase reporter )
+    public void processArtifact( Artifact artifact, Model model )
     {
         ArtifactRepository repository = artifact.getRepository();
         if ( artifact.getFile() != null )
@@ -82,16 +87,16 @@
             }
             catch ( DigesterException e )
             {
-                addWarning( reporter, artifact, null,
-                            "Unable to generate checksum for " + artifact.getFile() + ": " + e );
+                addWarning( artifact, null, "Unable to generate checksum for " + artifact.getFile() + ": " + e );
             }
 
             if ( checksum != null )
             {
                 try
                 {
-                    List results = index.search( new LuceneQuery(
-                        new TermQuery( new Term( StandardIndexRecordFields.MD5, checksum.toLowerCase() ) ) ) );
+                    List results = index
+                        .search( new LuceneQuery( new TermQuery( new Term( StandardIndexRecordFields.MD5, checksum
+                            .toLowerCase() ) ) ) );
 
                     if ( !results.isEmpty() )
                     {
@@ -106,8 +111,7 @@
                                 String groupId = artifact.getGroupId();
                                 if ( groupId.equals( result.getGroupId() ) )
                                 {
-                                    addFailure( reporter, artifact, "duplicate",
-                                                "Found duplicate for " + artifact.getId() );
+                                    addFailure( artifact, "duplicate", "Found duplicate for " + artifact.getId() );
                                 }
                             }
                         }
@@ -115,25 +119,25 @@
                 }
                 catch ( RepositoryIndexSearchException e )
                 {
-                    addWarning( reporter, artifact, null, "Failed to search in index" + e );
+                    addWarning( artifact, null, "Failed to search in index" + e );
                 }
             }
         }
         else
         {
-            addWarning( reporter, artifact, null, "Artifact file is null" );
+            addWarning( artifact, null, "Artifact file is null" );
         }
     }
 
-    private static void addFailure( ReportingDatabase reporter, Artifact artifact, String problem, String reason )
+    private void addFailure( Artifact artifact, String problem, String reason )
     {
         // TODO: reason could be an i18n key derived from the processor and the problem ID and the
-        reporter.addFailure( artifact, ROLE_HINT, problem, reason );
+        database.addFailure( artifact, ROLE_HINT, problem, reason );
     }
 
-    private static void addWarning( ReportingDatabase reporter, Artifact artifact, String problem, String reason )
+    private void addWarning( Artifact artifact, String problem, String reason )
     {
         // TODO: reason could be an i18n key derived from the processor and the problem ID and the
-        reporter.addWarning( artifact, ROLE_HINT, problem, reason );
+        database.addWarning( artifact, ROLE_HINT, problem, reason );
     }
 }

Modified: maven/archiva/trunk/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/processor/InvalidPomArtifactReportProcessor.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/processor/InvalidPomArtifactReportProcessor.java?view=diff&rev=511053&r1=511052&r2=511053
==============================================================================
--- maven/archiva/trunk/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/processor/InvalidPomArtifactReportProcessor.java (original)
+++ maven/archiva/trunk/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/processor/InvalidPomArtifactReportProcessor.java Fri Feb 23 11:05:21 2007
@@ -20,7 +20,7 @@
  */
 
 import org.apache.commons.io.IOUtils;
-import org.apache.maven.archiva.reporting.database.ReportingDatabase;
+import org.apache.maven.archiva.reporting.database.ArtifactResultsDatabase;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.model.Model;
@@ -44,18 +44,23 @@
     private static final String ROLE_HINT = "invalid-pom";
 
     /**
+     * @plexus.requirement
+     */
+    private ArtifactResultsDatabase database;
+
+    /**
      * @param artifact The pom xml file to be validated, passed as an artifact object.
      * @param reporter The artifact reporter object.
      */
-    public void processArtifact( Artifact artifact, Model model, ReportingDatabase reporter )
+    public void processArtifact( Artifact artifact, Model model )
     {
         ArtifactRepository repository = artifact.getRepository();
 
         if ( !"file".equals( repository.getProtocol() ) )
         {
             // We can't check other types of URLs yet. Need to use Wagon, with an exists() method.
-            throw new UnsupportedOperationException(
-                "Can't process repository '" + repository.getUrl() + "'. Only file based repositories are supported" );
+            throw new UnsupportedOperationException( "Can't process repository '" + repository.getUrl()
+                + "'. Only file based repositories are supported" );
         }
 
         if ( "pom".equals( artifact.getType().toLowerCase() ) )
@@ -64,7 +69,7 @@
 
             if ( !f.exists() )
             {
-                addFailure( reporter, artifact, "pom-missing", "POM not found." );
+                addFailure( artifact, "pom-missing", "POM not found." );
             }
             else
             {
@@ -79,13 +84,12 @@
                 }
                 catch ( XmlPullParserException e )
                 {
-                    addFailure( reporter, artifact, "pom-parse-exception",
+                    addFailure( artifact, "pom-parse-exception",
                                 "The pom xml file is not well-formed. Error while parsing: " + e.getMessage() );
                 }
                 catch ( IOException e )
                 {
-                    addFailure( reporter, artifact, "pom-io-exception",
-                                "Error while reading the pom xml file: " + e.getMessage() );
+                    addFailure( artifact, "pom-io-exception", "Error while reading the pom xml file: " + e.getMessage() );
                 }
                 finally
                 {
@@ -95,9 +99,9 @@
         }
     }
 
-    private static void addFailure( ReportingDatabase reporter, Artifact artifact, String problem, String reason )
+    private void addFailure( Artifact artifact, String problem, String reason )
     {
         // TODO: reason could be an i18n key derived from the processor and the problem ID and the
-        reporter.addFailure( artifact, ROLE_HINT, problem, reason );
+        database.addFailure( artifact, ROLE_HINT, problem, reason );
     }
 }

Modified: maven/archiva/trunk/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/processor/LocationArtifactReportProcessor.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/processor/LocationArtifactReportProcessor.java?view=diff&rev=511053&r1=511052&r2=511053
==============================================================================
--- maven/archiva/trunk/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/processor/LocationArtifactReportProcessor.java (original)
+++ maven/archiva/trunk/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/processor/LocationArtifactReportProcessor.java Fri Feb 23 11:05:21 2007
@@ -20,14 +20,13 @@
  */
 
 import org.apache.commons.io.IOUtils;
-import org.apache.maven.archiva.reporting.database.ReportingDatabase;
+import org.apache.maven.archiva.reporting.database.ArtifactResultsDatabase;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.handler.DefaultArtifactHandler;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.model.Model;
 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
-import org.apache.maven.project.MavenProjectBuilder;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
 import java.io.File;
@@ -57,13 +56,19 @@
     private ArtifactFactory artifactFactory;
 
     // TODO: share with other code with the same
-    private static final Set JAR_FILE_TYPES =
-        new HashSet( Arrays.asList( new String[]{"jar", "war", "par", "ejb", "ear", "rar", "sar"} ) );
+    private static final Set JAR_FILE_TYPES = new HashSet( Arrays.asList( new String[] {
+        "jar",
+        "war",
+        "par",
+        "ejb",
+        "ear",
+        "rar",
+        "sar" } ) );
 
     /**
      * @plexus.requirement
      */
-    private MavenProjectBuilder projectBuilder;
+    private ArtifactResultsDatabase database;
 
     private static final String POM = "pom";
 
@@ -77,15 +82,15 @@
      * location is valid based on the location specified in the pom. Check if the both the location
      * specified in the file system pom and in the pom included in the package is the same.
      */
-    public void processArtifact( Artifact artifact, Model model, ReportingDatabase reporter )
+    public void processArtifact( Artifact artifact, Model model )
     {
         ArtifactRepository repository = artifact.getRepository();
 
         if ( !"file".equals( repository.getProtocol() ) )
         {
             // We can't check other types of URLs yet. Need to use Wagon, with an exists() method.
-            throw new UnsupportedOperationException(
-                "Can't process repository '" + repository.getUrl() + "'. Only file based repositories are supported" );
+            throw new UnsupportedOperationException( "Can't process repository '" + repository.getUrl()
+                + "'. Only file based repositories are supported" );
         }
 
         adjustDistributionArtifactHandler( artifact );
@@ -100,19 +105,16 @@
             {
                 //check if the artifact is located in its proper location based on the info
                 //specified in the model object/pom
-                Artifact modelArtifact = artifactFactory.createArtifactWithClassifier( model.getGroupId(),
-                                                                                       model.getArtifactId(),
-                                                                                       model.getVersion(),
-                                                                                       artifact.getType(),
-                                                                                       artifact.getClassifier() );
+                Artifact modelArtifact = artifactFactory.createArtifactWithClassifier( model.getGroupId(), model
+                    .getArtifactId(), model.getVersion(), artifact.getType(), artifact.getClassifier() );
 
                 adjustDistributionArtifactHandler( modelArtifact );
                 String modelPath = repository.pathOf( modelArtifact );
                 if ( !modelPath.equals( artifactPath ) )
                 {
-                    addFailure( reporter, artifact, "repository-pom-location",
-                                "The artifact is out of place. It does not match the specified location in the repository pom: " +
-                                    modelPath );
+                    addFailure( artifact, "repository-pom-location",
+                                "The artifact is out of place. It does not match the specified location in the repository pom: "
+                                    + modelPath );
                 }
             }
         }
@@ -126,7 +128,7 @@
             {
                 //unpack the artifact (using the groupId, artifactId & version specified in the artifact object itself
                 //check if the pom is included in the package
-                Model extractedModel = readArtifactModel( file, artifact, reporter );
+                Model extractedModel = readArtifactModel( file, artifact );
 
                 if ( extractedModel != null )
                 {
@@ -136,7 +138,7 @@
                                                                                       extractedModel.getPackaging() );
                     if ( !repository.pathOf( extractedArtifact ).equals( artifactPath ) )
                     {
-                        addFailure( reporter, artifact, "packaged-pom-location",
+                        addFailure( artifact, "packaged-pom-location",
                                     "The artifact is out of place. It does not match the specified location in the packaged pom." );
                     }
                 }
@@ -144,15 +146,14 @@
         }
         else
         {
-            addFailure( reporter, artifact, "missing-artifact",
-                        "The artifact file [" + file + "] cannot be found for metadata." );
+            addFailure( artifact, "missing-artifact", "The artifact file [" + file + "] cannot be found for metadata." );
         }
     }
 
-    private static void addFailure( ReportingDatabase reporter, Artifact artifact, String problem, String reason )
+    private void addFailure( Artifact artifact, String problem, String reason )
     {
         // TODO: reason could be an i18n key derived from the processor and the problem ID and the
-        reporter.addFailure( artifact, ROLE_HINT, problem, reason );
+        database.addFailure( artifact, ROLE_HINT, problem, reason );
     }
 
     private static void adjustDistributionArtifactHandler( Artifact artifact )
@@ -168,7 +169,7 @@
         }
     }
 
-    private Model readArtifactModel( File file, Artifact artifact, ReportingDatabase reporter )
+    private Model readArtifactModel( File file, Artifact artifact )
     {
         Model model = null;
 
@@ -178,8 +179,8 @@
             jar = new JarFile( file );
 
             //Get the entry and its input stream.
-            JarEntry entry = jar.getJarEntry(
-                "META-INF/maven/" + artifact.getGroupId() + "/" + artifact.getArtifactId() + "/pom.xml" );
+            JarEntry entry = jar.getJarEntry( "META-INF/maven/" + artifact.getGroupId() + "/"
+                + artifact.getArtifactId() + "/pom.xml" );
 
             // If the entry is not null, extract it.
             if ( entry != null )
@@ -198,11 +199,11 @@
         }
         catch ( IOException e )
         {
-            addWarning( reporter, artifact, "Unable to read artifact to extract model: " + e );
+            addWarning( artifact, "Unable to read artifact to extract model: " + e );
         }
         catch ( XmlPullParserException e )
         {
-            addWarning( reporter, artifact, "Unable to parse extracted model: " + e );
+            addWarning( artifact, "Unable to parse extracted model: " + e );
         }
         finally
         {
@@ -222,10 +223,10 @@
         return model;
     }
 
-    private static void addWarning( ReportingDatabase reporter, Artifact artifact, String reason )
+    private void addWarning( Artifact artifact, String reason )
     {
         // TODO: reason could be an i18n key derived from the processor and the problem ID and the
-        reporter.addWarning( artifact, ROLE_HINT, null, reason );
+        database.addWarning( artifact, ROLE_HINT, null, reason );
     }
 
     private Model readModel( InputStream entryStream )

Modified: maven/archiva/trunk/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/processor/MetadataReportProcessor.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/processor/MetadataReportProcessor.java?view=diff&rev=511053&r1=511052&r2=511053
==============================================================================
--- maven/archiva/trunk/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/processor/MetadataReportProcessor.java (original)
+++ maven/archiva/trunk/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/processor/MetadataReportProcessor.java Fri Feb 23 11:05:21 2007
@@ -19,7 +19,6 @@
  * under the License.
  */
 
-import org.apache.maven.archiva.reporting.database.ReportingDatabase;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
 
@@ -30,5 +29,5 @@
 {
     String ROLE = MetadataReportProcessor.class.getName();
 
-    void processMetadata( RepositoryMetadata metadata, ArtifactRepository repository, ReportingDatabase reporter );
+    void processMetadata( RepositoryMetadata metadata, ArtifactRepository repository );
 }

Modified: maven/archiva/trunk/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/processor/OldArtifactReportProcessor.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/processor/OldArtifactReportProcessor.java?view=diff&rev=511053&r1=511052&r2=511053
==============================================================================
--- maven/archiva/trunk/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/processor/OldArtifactReportProcessor.java (original)
+++ maven/archiva/trunk/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/processor/OldArtifactReportProcessor.java Fri Feb 23 11:05:21 2007
@@ -19,7 +19,7 @@
  * under the License.
  */
 
-import org.apache.maven.archiva.reporting.database.ReportingDatabase;
+import org.apache.maven.archiva.reporting.database.ArtifactResultsDatabase;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.handler.DefaultArtifactHandler;
 import org.apache.maven.artifact.repository.ArtifactRepository;
@@ -44,8 +44,15 @@
      * @plexus.configuration default-value="31536000"
      */
     private int maxAge;
+    
+    /**
+     * TODO: Must create an 'Old Artifact' database.
+     * TODO: Base this off of an artifact table query instead.
+     * @plexus.requirement
+     */
+    private ArtifactResultsDatabase database;
 
-    public void processArtifact( Artifact artifact, Model model, ReportingDatabase reporter )
+    public void processArtifact( Artifact artifact, Model model )
     {
         ArtifactRepository repository = artifact.getRepository();
 
@@ -68,7 +75,7 @@
             if ( System.currentTimeMillis() - file.lastModified() > maxAge * 1000 )
             {
                 // TODO: reason could be an i18n key derived from the processor and the problem ID and the
-                reporter.addNotice( artifact, ROLE_HINT, "old-artifact",
+                database.addNotice( artifact, ROLE_HINT, "old-artifact",
                                     "The artifact is older than the maximum age of " + maxAge + " seconds." );
             }
         }

Modified: maven/archiva/trunk/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/processor/OldSnapshotArtifactReportProcessor.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/processor/OldSnapshotArtifactReportProcessor.java?view=diff&rev=511053&r1=511052&r2=511053
==============================================================================
--- maven/archiva/trunk/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/processor/OldSnapshotArtifactReportProcessor.java (original)
+++ maven/archiva/trunk/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/processor/OldSnapshotArtifactReportProcessor.java Fri Feb 23 11:05:21 2007
@@ -19,7 +19,7 @@
  * under the License.
  */
 
-import org.apache.maven.archiva.reporting.database.ReportingDatabase;
+import org.apache.maven.archiva.reporting.database.ArtifactResultsDatabase;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.handler.DefaultArtifactHandler;
 import org.apache.maven.artifact.repository.ArtifactRepository;
@@ -62,15 +62,22 @@
      */
     private int maxSnapshots;
 
-    public void processArtifact( final Artifact artifact, Model model, ReportingDatabase reporter )
+    /**
+     * TODO: Must create an 'Old Artifact' database.
+     * TODO: Base this off of an artifact table query instead.
+     * @plexus.requirement
+     */
+    private ArtifactResultsDatabase database;
+
+    public void processArtifact( final Artifact artifact, Model model )
     {
         ArtifactRepository repository = artifact.getRepository();
 
         if ( !"file".equals( repository.getProtocol() ) )
         {
             // We can't check other types of URLs yet. Need to use Wagon, with an exists() method.
-            throw new UnsupportedOperationException(
-                "Can't process repository '" + repository.getUrl() + "'. Only file based repositories are supported" );
+            throw new UnsupportedOperationException( "Can't process repository '" + repository.getUrl()
+                + "'. Only file based repositories are supported" );
         }
 
         adjustDistributionArtifactHandler( artifact );
@@ -95,13 +102,14 @@
                     catch ( ParseException e )
                     {
                         throw new IllegalStateException(
-                            "Shouldn't match timestamp pattern and not be able to parse it: " + m.group( 2 ) );
+                                                         "Shouldn't match timestamp pattern and not be able to parse it: "
+                                                             + m.group( 2 ) );
                     }
 
                     if ( System.currentTimeMillis() - timestamp > maxAge * 1000 )
                     {
-                        addNotice( reporter, artifact, "snapshot-expired-time",
-                                   "The artifact is older than the maximum age of " + maxAge + " seconds." );
+                        addNotice( artifact, "snapshot-expired-time", "The artifact is older than the maximum age of "
+                            + maxAge + " seconds." );
                     }
                     else if ( maxSnapshots > 0 )
                     {
@@ -109,12 +117,12 @@
                         {
                             public boolean accept( File file, String string )
                             {
-                                return string.startsWith( artifact.getArtifactId() + "-" ) &&
-                                    string.endsWith( "." + artifact.getArtifactHandler().getExtension() );
+                                return string.startsWith( artifact.getArtifactId() + "-" )
+                                    && string.endsWith( "." + artifact.getArtifactHandler().getExtension() );
                             }
                         } );
 
-                        List/*<Integer>*/ buildNumbers = new ArrayList();
+                        List/*<Integer>*/buildNumbers = new ArrayList();
                         Integer currentBuild = null;
                         for ( Iterator i = Arrays.asList( files ).iterator(); i.hasNext(); )
                         {
@@ -149,7 +157,7 @@
 
                         if ( buildNumbers.contains( currentBuild ) )
                         {
-                            addNotice( reporter, artifact, "snapshot-expired-count",
+                            addNotice( artifact, "snapshot-expired-count",
                                        "The artifact is older than the maximum number of retained snapshot builds." );
                         }
                     }
@@ -162,10 +170,10 @@
         }
     }
 
-    private static void addNotice( ReportingDatabase reporter, Artifact artifact, String problem, String reason )
+    private void addNotice( Artifact artifact, String problem, String reason )
     {
         // TODO: reason could be an i18n key derived from the processor and the problem ID and the
-        reporter.addNotice( artifact, ROLE_HINT, problem, reason );
+        database.addNotice( artifact, ROLE_HINT, problem, reason );
     }
 
     private static void adjustDistributionArtifactHandler( Artifact artifact )

Modified: maven/archiva/trunk/archiva-reports-standard/src/main/mdo/reporting.mdo
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-reports-standard/src/main/mdo/reporting.mdo?view=diff&rev=511053&r1=511052&r2=511053
==============================================================================
--- maven/archiva/trunk/archiva-reports-standard/src/main/mdo/reporting.mdo (original)
+++ maven/archiva/trunk/archiva-reports-standard/src/main/mdo/reporting.mdo Fri Feb 23 11:05:21 2007
@@ -1,3 +1,4 @@
+<?xml version="1.0" ?>
 <!--
   ~ Licensed to the Apache Software Foundation (ASF) under one
   ~ or more contributor license agreements.  See the NOTICE file
@@ -30,7 +31,7 @@
     </default>
   </defaults>
   <classes>
-    <class rootElement="true" xml.tagName="reporting">
+    <class rootElement="true" xml.tagName="reporting" stash.storable="false">
       <name>Reporting</name>
       <version>1.0.0</version>
       <fields>
@@ -50,47 +51,19 @@
             <multiplicity>*</multiplicity>
           </association>
         </field>
-        <field xml.attribute="true">
-          <name>lastModified</name>
-          <version>1.0.0</version>
-          <type>long</type>
-        </field>
-        <field xml.attribute="true">
-          <name>executionTime</name>
-          <version>1.0.0</version>
-          <type>long</type>
-        </field>
       </fields>
     </class>
-    <class>
+    <class stash.storable="true" 
+           jpox.use-identifiers-as-primary-key="true"
+           jpox.identity-type="application"
+           jpox.identity-class="ArtifactResultsKey">
       <name>ArtifactResults</name>
       <version>1.0.0</version>
       <fields>
-        <field>
-          <name>failures</name>
-          <version>1.0.0</version>
-          <association>
-            <type>Result</type>
-            <multiplicity>*</multiplicity>
-          </association>
-        </field>
-        <field>
-          <name>warnings</name>
-          <version>1.0.0</version>
-          <association>
-            <type>Result</type>
-            <multiplicity>*</multiplicity>
-          </association>
-        </field>
-        <field>
-          <name>notices</name>
-          <version>1.0.0</version>
-          <association>
-            <type>Result</type>
-            <multiplicity>*</multiplicity>
-          </association>
-        </field>
-        <field xml.attribute="true">
+        <field xml.attribute="true" 
+               jpox.primary-key="true" 
+               jpox.value-strategy="off" 
+               jpox.persistence-modifier="persistent">
           <name>groupId</name>
           <identity>true</identity>
           <version>1.0.0</version>
@@ -100,7 +73,10 @@
             The group ID of the artifact in the result.
           </description>
         </field>
-        <field xml.attribute="true">
+        <field xml.attribute="true"
+               jpox.primary-key="true" 
+               jpox.value-strategy="off" 
+               jpox.persistence-modifier="persistent">
           <name>artifactId</name>
           <version>1.0.0</version>
           <identity>true</identity>
@@ -110,7 +86,10 @@
             The artifact ID of the artifact in the result.
           </description>
         </field>
-        <field xml.attribute="true">
+        <field xml.attribute="true"
+               jpox.primary-key="true" 
+               jpox.value-strategy="off" 
+               jpox.persistence-modifier="persistent">
           <name>version</name>
           <version>1.0.0</version>
           <identity>true</identity>
@@ -120,7 +99,10 @@
             The version of the artifact in the result.
           </description>
         </field>
-        <field xml.attribute="true">
+        <field xml.attribute="true"
+               jpox.primary-key="true" 
+               jpox.value-strategy="off" 
+               jpox.persistence-modifier="persistent">
           <name>type</name>
           <version>1.0.0</version>
           <type>String</type>
@@ -130,7 +112,11 @@
             The type of the artifact in the result.
           </description>
         </field>
-        <field xml.attribute="true">
+        <field xml.attribute="true"
+               jpox.nullValue="none"
+               jpox.primary-key="true" 
+               jpox.value-strategy="off" 
+               jpox.persistence-modifier="persistent">
           <name>classifier</name>
           <version>1.0.0</version>
           <type>String</type>
@@ -139,16 +125,15 @@
             The classifier of the artifact in the result.
           </description>
         </field>
-      </fields>
-    </class>
-    <class>
-      <name>MetadataResults</name>
-      <version>1.0.0</version>
-      <fields>
         <field>
           <name>failures</name>
           <version>1.0.0</version>
-          <association>
+          <association stash.part="true"
+                       jpox.join="true"
+                       java.init="field"
+                       jpox.dependent="true"
+                       java.generate-break="false"
+                       java.generate-create="false">
             <type>Result</type>
             <multiplicity>*</multiplicity>
           </association>
@@ -156,7 +141,12 @@
         <field>
           <name>warnings</name>
           <version>1.0.0</version>
-          <association>
+          <association stash.part="true"
+                       jpox.join="true"
+                       java.init="field"
+                       jpox.dependent="true"
+                       java.generate-break="false"
+                       java.generate-create="false">
             <type>Result</type>
             <multiplicity>*</multiplicity>
           </association>
@@ -164,12 +154,29 @@
         <field>
           <name>notices</name>
           <version>1.0.0</version>
-          <association>
+          <association stash.part="true"
+                       jpox.join="true"
+                       java.init="field"
+                       jpox.dependent="true"
+                       java.generate-break="false"
+                       java.generate-create="false">
             <type>Result</type>
             <multiplicity>*</multiplicity>
           </association>
         </field>
-        <field xml.attribute="true">
+      </fields>
+    </class>
+    <class stash.storable="true" 
+           jpox.use-identifiers-as-primary-key="true"
+           jpox.identity-type="application"
+           jpox.identity-class="MetadataResultsKey">
+      <name>MetadataResults</name>
+      <version>1.0.0</version>
+      <fields>
+        <field xml.attribute="true"
+               jpox.primary-key="true" 
+               jpox.value-strategy="off" 
+               jpox.persistence-modifier="persistent">
           <name>groupId</name>
           <version>1.0.0</version>
           <type>String</type>
@@ -179,7 +186,11 @@
             The group ID of the metadata in the result.
           </description>
         </field>
-        <field xml.attribute="true">
+        <field xml.attribute="true"
+               jpox.nullValue="none"
+               jpox.primary-key="true" 
+               jpox.value-strategy="off" 
+               jpox.persistence-modifier="persistent">
           <name>artifactId</name>
           <version>1.0.0</version>
           <type>String</type>
@@ -188,7 +199,11 @@
             The artifact ID of the metadata in the result.
           </description>
         </field>
-        <field xml.attribute="true">
+        <field xml.attribute="true"
+               jpox.nullValue="none"
+               jpox.primary-key="true" 
+               jpox.value-strategy="off" 
+               jpox.persistence-modifier="persistent">
           <name>version</name>
           <version>1.0.0</version>
           <type>String</type>
@@ -197,6 +212,45 @@
             The version of the metadata in the result.
           </description>
         </field>
+        <field>
+          <name>failures</name>
+          <version>1.0.0</version>
+          <association stash.part="true"
+                       jpox.join="true"
+                       java.init="field"
+                       jpox.dependent="true"
+                       java.generate-break="false"
+                       java.generate-create="false">
+            <type>Result</type>
+            <multiplicity>*</multiplicity>
+          </association>
+        </field>
+        <field>
+          <name>warnings</name>
+          <version>1.0.0</version>
+          <association stash.part="true"
+                       jpox.join="true"
+                       java.init="field"
+                       jpox.dependent="true"
+                       java.generate-break="false"
+                       java.generate-create="false">
+            <type>Result</type>
+            <multiplicity>*</multiplicity>
+          </association>
+        </field>
+        <field>
+          <name>notices</name>
+          <version>1.0.0</version>
+          <association stash.part="true"
+                       jpox.join="true"
+                       java.init="field"
+                       jpox.dependent="true"
+                       java.generate-break="false"
+                       java.generate-create="false">
+            <type>Result</type>
+            <multiplicity>*</multiplicity>
+          </association>
+        </field>
         <field xml.attribute="true">
           <name>lastModified</name>
           <version>1.0.0</version>
@@ -208,7 +262,7 @@
         </field>
       </fields>
     </class>
-    <class>
+    <class stash.storable="true">
       <name>Result</name>
       <version>1.0.0</version>
       <fields>

Modified: maven/archiva/trunk/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/AbstractRepositoryReportsTestCase.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/AbstractRepositoryReportsTestCase.java?view=diff&rev=511053&r1=511052&r2=511053
==============================================================================
--- maven/archiva/trunk/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/AbstractRepositoryReportsTestCase.java (original)
+++ maven/archiva/trunk/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/AbstractRepositoryReportsTestCase.java Fri Feb 23 11:05:21 2007
@@ -25,8 +25,18 @@
 import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
 import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory;
+import org.codehaus.plexus.jdo.JdoFactory;
+import org.jpox.SchemaTool;
 
 import java.io.File;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.PersistenceManagerFactory;
 
 /**
  *
@@ -50,6 +60,8 @@
     {
         super.setUp();
 
+        setupJdoFactory();
+
         File repositoryDirectory = getTestFile( "src/test/repository" );
 
         factory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
@@ -60,14 +72,57 @@
         artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
     }
 
-    protected Artifact createArtifactFromRepository( File repository, String groupId, String artifactId,
-                                                     String version )
+    protected void setupJdoFactory()
+        throws Exception
+    {
+        DefaultConfigurableJdoFactory jdoFactory = (DefaultConfigurableJdoFactory) lookup( JdoFactory.ROLE, "archiva" );
+
+        jdoFactory.setPersistenceManagerFactoryClass( "org.jpox.PersistenceManagerFactoryImpl" ); //$NON-NLS-1$
+
+        jdoFactory.setDriverName( "org.hsqldb.jdbcDriver" ); //$NON-NLS-1$
+
+        jdoFactory.setUrl( "jdbc:hsqldb:mem:" + getName() ); //$NON-NLS-1$
+
+        jdoFactory.setUserName( "sa" ); //$NON-NLS-1$
+
+        jdoFactory.setPassword( "" ); //$NON-NLS-1$
+
+        jdoFactory.setProperty( "org.jpox.transactionIsolation", "READ_UNCOMMITTED" ); //$NON-NLS-1$ //$NON-NLS-2$
+
+        jdoFactory.setProperty( "org.jpox.poid.transactionIsolation", "READ_UNCOMMITTED" ); //$NON-NLS-1$ //$NON-NLS-2$
+
+        jdoFactory.setProperty( "org.jpox.autoCreateSchema", "true" ); //$NON-NLS-1$ //$NON-NLS-2$
+
+        jdoFactory.setProperty( "javax.jdo.PersistenceManagerFactoryClass", "org.jpox.PersistenceManagerFactoryImpl" );
+
+        Properties properties = jdoFactory.getProperties();
+
+        for ( Iterator it = properties.entrySet().iterator(); it.hasNext(); )
+        {
+            Map.Entry entry = (Map.Entry) it.next();
+
+            System.setProperty( (String) entry.getKey(), (String) entry.getValue() );
+        }
+
+        SchemaTool.createSchemaTables( new URL[] { getClass()
+            .getResource( "/org/apache/maven/archiva/reporting/model/package.jdo" ) }, new URL[] {}, null, false, null ); //$NON-NLS-1$
+
+        PersistenceManagerFactory pmf = jdoFactory.getPersistenceManagerFactory();
+
+        assertNotNull( pmf );
+
+        PersistenceManager pm = pmf.getPersistenceManager();
+
+        pm.close();
+    }
+
+    protected Artifact createArtifactFromRepository( File repository, String groupId, String artifactId, String version )
         throws Exception
     {
         Artifact artifact = artifactFactory.createBuildArtifact( groupId, artifactId, version, "jar" );
 
-        artifact.setRepository(
-            factory.createArtifactRepository( "repository", repository.toURL().toString(), layout, null, null ) );
+        artifact.setRepository( factory.createArtifactRepository( "repository", repository.toURL().toString(), layout,
+                                                                  null, null ) );
 
         artifact.isSnapshot();
 
@@ -90,8 +145,8 @@
     protected Artifact createArtifactWithClassifier( String groupId, String artifactId, String version, String type,
                                                      String classifier )
     {
-        Artifact artifact =
-            artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type, classifier );
+        Artifact artifact = artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type,
+                                                                          classifier );
         artifact.setRepository( repository );
         return artifact;
     }

Modified: maven/archiva/trunk/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/database/ReportingDatabaseTest.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/database/ReportingDatabaseTest.java?view=diff&rev=511053&r1=511052&r2=511053
==============================================================================
--- maven/archiva/trunk/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/database/ReportingDatabaseTest.java (original)
+++ maven/archiva/trunk/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/database/ReportingDatabaseTest.java Fri Feb 23 11:05:21 2007
@@ -19,14 +19,7 @@
  * under the License.
  */
 
-import junit.framework.TestCase;
-import org.apache.maven.archiva.reporting.model.ArtifactResults;
-import org.apache.maven.archiva.reporting.model.MetadataResults;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.DefaultArtifact;
-import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
-import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
-import org.apache.maven.artifact.versioning.VersionRange;
+import org.apache.maven.archiva.reporting.AbstractRepositoryReportsTestCase;
 
 /**
  * Test for {@link ReportingDatabase}.
@@ -35,117 +28,28 @@
  * @version $Id$
  */
 public class ReportingDatabaseTest
-    extends TestCase
+    extends AbstractRepositoryReportsTestCase
 {
-    private Artifact artifact;
-
-    private String processor, problem, reason;
-
-    private ReportingDatabase reportingDatabase;
-
-    private RepositoryMetadata metadata;
+    private ReportingDatabase database;
 
     protected void setUp()
         throws Exception
     {
         super.setUp();
-        artifact = new DefaultArtifact( "group", "artifact", VersionRange.createFromVersion( "1.0" ), "scope", "type",
-                                        "classifier", null );
-        processor = "processor";
-        problem = "problem";
-        reason = "reason";
-        reportingDatabase = new ReportingDatabase( null );
-
-        metadata = new ArtifactRepositoryMetadata( artifact );
-    }
-
-    public void testAddNoticeArtifactStringStringString()
-    {
-        reportingDatabase.addNotice( artifact, processor, problem, reason );
-        ArtifactResults artifactResults = reportingDatabase.getArtifactResults( artifact );
-
-        assertEquals( 1, reportingDatabase.getNumNotices() );
-        assertEquals( 1, artifactResults.getNotices().size() );
-
-        reportingDatabase.addNotice( artifact, processor, problem, reason );
-        artifactResults = reportingDatabase.getArtifactResults( artifact );
-
-        assertEquals( 1, reportingDatabase.getNumNotices() );
-        assertEquals( 1, artifactResults.getNotices().size() );
+        database = (ReportingDatabase) lookup( ReportingDatabase.ROLE );
     }
 
-    public void testAddWarningArtifactStringStringString()
-    {
-        reportingDatabase.addWarning( artifact, processor, problem, reason );
-        ArtifactResults artifactResults = reportingDatabase.getArtifactResults( artifact );
-
-        assertEquals( 1, reportingDatabase.getNumWarnings() );
-        assertEquals( 1, artifactResults.getWarnings().size() );
-
-        reportingDatabase.addWarning( artifact, processor, problem, reason );
-        artifactResults = reportingDatabase.getArtifactResults( artifact );
-
-        assertEquals( 1, reportingDatabase.getNumWarnings() );
-        assertEquals( 1, artifactResults.getWarnings().size() );
-    }
-
-    public void testAddFailureArtifactStringStringString()
-    {
-        reportingDatabase.addFailure( artifact, processor, problem, reason );
-        ArtifactResults artifactResults = reportingDatabase.getArtifactResults( artifact );
-
-        assertEquals( 1, reportingDatabase.getNumFailures() );
-        assertEquals( 1, artifactResults.getFailures().size() );
-
-        reportingDatabase.addFailure( artifact, processor, problem, reason );
-        artifactResults = reportingDatabase.getArtifactResults( artifact );
-
-        assertEquals( 1, reportingDatabase.getNumFailures() );
-        assertEquals( 1, artifactResults.getFailures().size() );
-    }
-
-    public void testAddNoticeRepositoryMetadataStringStringString()
-    {
-        reportingDatabase.addNotice( metadata, processor, problem, reason );
-        MetadataResults metadataResults = reportingDatabase.getMetadataResults( metadata, System.currentTimeMillis() );
-
-        assertEquals( 1, reportingDatabase.getNumNotices() );
-        assertEquals( 1, metadataResults.getNotices().size() );
-
-        reportingDatabase.addNotice( metadata, processor, problem, reason );
-        metadataResults = reportingDatabase.getMetadataResults( metadata, System.currentTimeMillis() );
-
-        assertEquals( 1, reportingDatabase.getNumNotices() );
-        assertEquals( 1, metadataResults.getNotices().size() );
-    }
-
-    public void testAddWarningRepositoryMetadataStringStringString()
+    protected void tearDown()
+        throws Exception
     {
-        reportingDatabase.addWarning( metadata, processor, problem, reason );
-        MetadataResults metadataResults = reportingDatabase.getMetadataResults( metadata, System.currentTimeMillis() );
-
-        assertEquals( 1, reportingDatabase.getNumWarnings() );
-        assertEquals( 1, metadataResults.getWarnings().size() );
-
-        reportingDatabase.addWarning( metadata, processor, problem, reason );
-        metadataResults = reportingDatabase.getMetadataResults( metadata, System.currentTimeMillis() );
-
-        assertEquals( 1, reportingDatabase.getNumWarnings() );
-        assertEquals( 1, metadataResults.getWarnings().size() );
+        release( database );
+        super.tearDown();
     }
 
-    public void testAddFailureRepositoryMetadataStringStringString()
+    public void testLookup()
     {
-        reportingDatabase.addFailure( metadata, processor, problem, reason );
-        MetadataResults metadataResults = reportingDatabase.getMetadataResults( metadata, System.currentTimeMillis() );
-
-        assertEquals( 1, reportingDatabase.getNumFailures() );
-        assertEquals( 1, metadataResults.getFailures().size() );
-
-        reportingDatabase.addFailure( metadata, processor, problem, reason );
-        metadataResults = reportingDatabase.getMetadataResults( metadata, System.currentTimeMillis() );
-
-        assertEquals( 1, reportingDatabase.getNumFailures() );
-        assertEquals( 1, metadataResults.getFailures().size() );
+        assertNotNull( "database should not be null.", database );
+        assertNotNull( "database.artifactDatabase should not be null.", database.getArtifactDatabase() );
+        assertNotNull( "database.metadataDatabase should not be null.", database.getMetadataDatabase() );
     }
 }

Modified: maven/archiva/trunk/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/processor/BadMetadataReportProcessorTest.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/processor/BadMetadataReportProcessorTest.java?view=diff&rev=511053&r1=511052&r2=511053
==============================================================================
--- maven/archiva/trunk/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/processor/BadMetadataReportProcessorTest.java (original)
+++ maven/archiva/trunk/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/processor/BadMetadataReportProcessorTest.java Fri Feb 23 11:05:21 2007
@@ -19,9 +19,9 @@
  * under the License.
  */
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.maven.archiva.reporting.AbstractRepositoryReportsTestCase;
-import org.apache.maven.archiva.reporting.database.ReportingDatabase;
-import org.apache.maven.archiva.reporting.group.ReportGroup;
+import org.apache.maven.archiva.reporting.database.MetadataResultsDatabase;
 import org.apache.maven.archiva.reporting.model.MetadataResults;
 import org.apache.maven.archiva.reporting.model.Result;
 import org.apache.maven.artifact.Artifact;
@@ -36,6 +36,11 @@
 
 import java.util.Iterator;
 
+/**
+ * BadMetadataReportProcessorTest 
+ *
+ * @version $Id$
+ */
 public class BadMetadataReportProcessorTest
     extends AbstractRepositoryReportsTestCase
 {
@@ -43,7 +48,7 @@
 
     private MetadataReportProcessor badMetadataReportProcessor;
 
-    private ReportingDatabase reportingDatabase;
+    private MetadataResultsDatabase database;
 
     protected void setUp()
         throws Exception
@@ -52,12 +57,19 @@
 
         artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
 
-        badMetadataReportProcessor = (MetadataReportProcessor) lookup( MetadataReportProcessor.ROLE, "bad-metadata" );
+        database = (MetadataResultsDatabase) lookup( MetadataResultsDatabase.ROLE );
 
-        ReportGroup reportGroup = (ReportGroup) lookup( ReportGroup.ROLE, "health" );
-        reportingDatabase = new ReportingDatabase( reportGroup );
+        badMetadataReportProcessor = (MetadataReportProcessor) lookup( MetadataReportProcessor.ROLE, "bad-metadata" );
     }
 
+    protected void tearDown()
+        throws Exception
+    {
+        release( artifactFactory );
+        release( badMetadataReportProcessor );
+        super.tearDown();
+    }
+    
     public void testMetadataMissingLastUpdated()
     {
         Artifact artifact = artifactFactory.createBuildArtifact( "groupId", "artifactId", "1.0-alpha-1", "type" );
@@ -68,9 +80,9 @@
 
         RepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact, versioning );
 
-        badMetadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
+        badMetadataReportProcessor.processMetadata( metadata, repository );
 
-        Iterator failures = reportingDatabase.getMetadataIterator();
+        Iterator failures = database.getIterator();
         assertTrue( "check there is a failure", failures.hasNext() );
         MetadataResults results = (MetadataResults) failures.next();
         failures = results.getFailures().iterator();
@@ -87,9 +99,9 @@
 
         RepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact, null );
 
-        badMetadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
+        badMetadataReportProcessor.processMetadata( metadata, repository );
 
-        Iterator failures = reportingDatabase.getMetadataIterator();
+        Iterator failures = database.getIterator();
         assertTrue( "check there is a failure", failures.hasNext() );
         MetadataResults results = (MetadataResults) failures.next();
         failures = results.getFailures().iterator();
@@ -106,41 +118,41 @@
         if ( alpha1First )
         {
             assertEquals( "check reason",
-                          "Artifact version 1.0-alpha-1 found in the repository but missing in the metadata.",
-                          result.getReason() );
+                          "Artifact version 1.0-alpha-1 found in the repository but missing in the metadata.", result
+                              .getReason() );
         }
         else
         {
             assertEquals( "check reason",
-                          "Artifact version 1.0-alpha-2 found in the repository but missing in the metadata.",
-                          result.getReason() );
+                          "Artifact version 1.0-alpha-2 found in the repository but missing in the metadata.", result
+                              .getReason() );
         }
         result = (Result) failures.next();
         if ( !alpha1First )
         {
             assertEquals( "check reason",
-                          "Artifact version 1.0-alpha-1 found in the repository but missing in the metadata.",
-                          result.getReason() );
+                          "Artifact version 1.0-alpha-1 found in the repository but missing in the metadata.", result
+                              .getReason() );
         }
         else
         {
             assertEquals( "check reason",
-                          "Artifact version 1.0-alpha-2 found in the repository but missing in the metadata.",
-                          result.getReason() );
+                          "Artifact version 1.0-alpha-2 found in the repository but missing in the metadata.", result
+                              .getReason() );
         }
         assertFalse( "check no more failures", failures.hasNext() );
     }
 
     public void testSnapshotMetadataMissingVersioning()
     {
-        Artifact artifact =
-            artifactFactory.createBuildArtifact( "groupId", "snapshot-artifact", "1.0-alpha-1-SNAPSHOT", "type" );
+        Artifact artifact = artifactFactory.createBuildArtifact( "groupId", "snapshot-artifact",
+                                                                 "1.0-alpha-1-SNAPSHOT", "type" );
 
         RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact );
 
-        badMetadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
+        badMetadataReportProcessor.processMetadata( metadata, repository );
 
-        Iterator failures = reportingDatabase.getMetadataIterator();
+        Iterator failures = database.getIterator();
         assertTrue( "check there is a failure", failures.hasNext() );
         MetadataResults results = (MetadataResults) failures.next();
         failures = results.getFailures().iterator();
@@ -162,9 +174,9 @@
 
         RepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact, versioning );
 
-        badMetadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
+        badMetadataReportProcessor.processMetadata( metadata, repository );
 
-        Iterator failures = reportingDatabase.getMetadataIterator();
+        Iterator failures = database.getIterator();
         assertFalse( "check there are no failures", failures.hasNext() );
     }
 
@@ -178,9 +190,9 @@
 
         RepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact, versioning );
 
-        badMetadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
+        badMetadataReportProcessor.processMetadata( metadata, repository );
 
-        Iterator failures = reportingDatabase.getMetadataIterator();
+        Iterator failures = database.getIterator();
         assertTrue( "check there is a failure", failures.hasNext() );
         MetadataResults results = (MetadataResults) failures.next();
         failures = results.getFailures().iterator();
@@ -189,8 +201,8 @@
         assertMetadata( metadata, results );
         // TODO: should be more robust
         assertEquals( "check reason",
-                      "Artifact version 1.0-alpha-2 found in the repository but missing in the metadata.",
-                      result.getReason() );
+                      "Artifact version 1.0-alpha-2 found in the repository but missing in the metadata.", result
+                          .getReason() );
         assertFalse( "check no more failures", failures.hasNext() );
     }
 
@@ -206,9 +218,9 @@
 
         RepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact, versioning );
 
-        badMetadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
+        badMetadataReportProcessor.processMetadata( metadata, repository );
 
-        Iterator failures = reportingDatabase.getMetadataIterator();
+        Iterator failures = database.getIterator();
         assertTrue( "check there is a failure", failures.hasNext() );
         MetadataResults results = (MetadataResults) failures.next();
         failures = results.getFailures().iterator();
@@ -217,8 +229,8 @@
         assertMetadata( metadata, results );
         // TODO: should be more robust
         assertEquals( "check reason",
-                      "Artifact version 1.0-alpha-3 is present in metadata but missing in the repository.",
-                      result.getReason() );
+                      "Artifact version 1.0-alpha-3 is present in metadata but missing in the repository.", result
+                          .getReason() );
         assertFalse( "check no more failures", failures.hasNext() );
     }
 
@@ -233,9 +245,9 @@
 
         RepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact, versioning );
 
-        badMetadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
+        badMetadataReportProcessor.processMetadata( metadata, repository );
 
-        Iterator failures = reportingDatabase.getMetadataIterator();
+        Iterator failures = database.getIterator();
         assertTrue( "check there is a failure", failures.hasNext() );
         MetadataResults results = (MetadataResults) failures.next();
         failures = results.getFailures().iterator();
@@ -244,14 +256,14 @@
         assertMetadata( metadata, results );
         // TODO: should be more robust
         assertEquals( "check reason",
-                      "Artifact version 1.0-alpha-3 is present in metadata but missing in the repository.",
-                      result.getReason() );
+                      "Artifact version 1.0-alpha-3 is present in metadata but missing in the repository.", result
+                          .getReason() );
         assertTrue( "check there is a 2nd failure", failures.hasNext() );
         result = (Result) failures.next();
         // TODO: should be more robust
         assertEquals( "check reason",
-                      "Artifact version 1.0-alpha-2 found in the repository but missing in the metadata.",
-                      result.getReason() );
+                      "Artifact version 1.0-alpha-2 found in the repository but missing in the metadata.", result
+                          .getReason() );
         assertFalse( "check no more failures", failures.hasNext() );
     }
 
@@ -261,9 +273,9 @@
         metadata.getMetadata().addPlugin( createMetadataPlugin( "artifactId", "default" ) );
         metadata.getMetadata().addPlugin( createMetadataPlugin( "snapshot-artifact", "default2" ) );
 
-        badMetadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
+        badMetadataReportProcessor.processMetadata( metadata, repository );
 
-        Iterator failures = reportingDatabase.getMetadataIterator();
+        Iterator failures = database.getIterator();
         assertFalse( "check there are no failures", failures.hasNext() );
     }
 
@@ -274,17 +286,16 @@
         metadata.getMetadata().addPlugin( createMetadataPlugin( "snapshot-artifact", "default2" ) );
         metadata.getMetadata().addPlugin( createMetadataPlugin( "missing-plugin", "default3" ) );
 
-        badMetadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
+        badMetadataReportProcessor.processMetadata( metadata, repository );
 
-        Iterator failures = reportingDatabase.getMetadataIterator();
+        Iterator failures = database.getIterator();
         assertTrue( "check there is a failure", failures.hasNext() );
         MetadataResults results = (MetadataResults) failures.next();
         failures = results.getFailures().iterator();
         assertTrue( "check there is a failure", failures.hasNext() );
         Result result = (Result) failures.next();
         // TODO: should be more robust
-        assertEquals( "check reason", "Metadata plugin missing-plugin not found in the repository",
-                      result.getReason() );
+        assertEquals( "check reason", "Metadata plugin missing-plugin not found in the repository", result.getReason() );
         assertFalse( "check no more failures", failures.hasNext() );
     }
 
@@ -293,18 +304,17 @@
         RepositoryMetadata metadata = new GroupRepositoryMetadata( "groupId" );
         metadata.getMetadata().addPlugin( createMetadataPlugin( "artifactId", "default" ) );
 
-        badMetadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
+        badMetadataReportProcessor.processMetadata( metadata, repository );
 
-        Iterator failures = reportingDatabase.getMetadataIterator();
+        Iterator failures = database.getIterator();
         assertTrue( "check there is a failure", failures.hasNext() );
         MetadataResults results = (MetadataResults) failures.next();
         failures = results.getFailures().iterator();
         assertTrue( "check there is a failure", failures.hasNext() );
         Result result = (Result) failures.next();
         // TODO: should be more robust
-        assertEquals( "check reason",
-                      "Plugin snapshot-artifact is present in the repository but " + "missing in the metadata.",
-                      result.getReason() );
+        assertEquals( "check reason", "Plugin snapshot-artifact is present in the repository but "
+            + "missing in the metadata.", result.getReason() );
         assertFalse( "check no more failures", failures.hasNext() );
     }
 
@@ -316,22 +326,22 @@
         metadata.getMetadata().addPlugin( createMetadataPlugin( null, "default3" ) );
         metadata.getMetadata().addPlugin( createMetadataPlugin( "", "default4" ) );
 
-        badMetadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
+        badMetadataReportProcessor.processMetadata( metadata, repository );
 
-        Iterator failures = reportingDatabase.getMetadataIterator();
+        Iterator failures = database.getIterator();
         assertTrue( "check there is a failure", failures.hasNext() );
         MetadataResults results = (MetadataResults) failures.next();
         failures = results.getFailures().iterator();
         assertTrue( "check there is a failure", failures.hasNext() );
         Result result = (Result) failures.next();
         // TODO: should be more robust
-        assertEquals( "check reason", "Missing or empty artifactId in group metadata for plugin default3",
-                      result.getReason() );
+        assertEquals( "check reason", "Missing or empty artifactId in group metadata for plugin default3", result
+            .getReason() );
         assertTrue( "check there is a 2nd failure", failures.hasNext() );
         result = (Result) failures.next();
         // TODO: should be more robust
-        assertEquals( "check reason", "Missing or empty artifactId in group metadata for plugin default4",
-                      result.getReason() );
+        assertEquals( "check reason", "Missing or empty artifactId in group metadata for plugin default4", result
+            .getReason() );
         assertFalse( "check no more failures", failures.hasNext() );
     }
 
@@ -341,9 +351,9 @@
         metadata.getMetadata().addPlugin( createMetadataPlugin( "artifactId", null ) );
         metadata.getMetadata().addPlugin( createMetadataPlugin( "snapshot-artifact", "" ) );
 
-        badMetadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
+        badMetadataReportProcessor.processMetadata( metadata, repository );
 
-        Iterator failures = reportingDatabase.getMetadataIterator();
+        Iterator failures = database.getIterator();
         assertTrue( "check there is a failure", failures.hasNext() );
         MetadataResults results = (MetadataResults) failures.next();
         failures = results.getFailures().iterator();
@@ -354,8 +364,8 @@
         assertTrue( "check there is a 2nd failure", failures.hasNext() );
         result = (Result) failures.next();
         // TODO: should be more robust
-        assertEquals( "check reason", "Missing or empty plugin prefix for artifactId snapshot-artifact.",
-                      result.getReason() );
+        assertEquals( "check reason", "Missing or empty plugin prefix for artifactId snapshot-artifact.", result
+            .getReason() );
         assertFalse( "check no more failures", failures.hasNext() );
     }
 
@@ -365,9 +375,9 @@
         metadata.getMetadata().addPlugin( createMetadataPlugin( "artifactId", "default" ) );
         metadata.getMetadata().addPlugin( createMetadataPlugin( "snapshot-artifact", "default" ) );
 
-        badMetadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
+        badMetadataReportProcessor.processMetadata( metadata, repository );
 
-        Iterator failures = reportingDatabase.getMetadataIterator();
+        Iterator failures = database.getIterator();
         assertTrue( "check there is a failure", failures.hasNext() );
         MetadataResults results = (MetadataResults) failures.next();
         failures = results.getFailures().iterator();
@@ -380,8 +390,8 @@
 
     public void testValidSnapshotMetadata()
     {
-        Artifact artifact =
-            artifactFactory.createBuildArtifact( "groupId", "snapshot-artifact", "1.0-alpha-1-SNAPSHOT", "type" );
+        Artifact artifact = artifactFactory.createBuildArtifact( "groupId", "snapshot-artifact",
+                                                                 "1.0-alpha-1-SNAPSHOT", "type" );
 
         Snapshot snapshot = new Snapshot();
         snapshot.setBuildNumber( 1 );
@@ -389,16 +399,16 @@
 
         RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact, snapshot );
 
-        badMetadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
+        badMetadataReportProcessor.processMetadata( metadata, repository );
 
-        Iterator failures = reportingDatabase.getMetadataIterator();
+        Iterator failures = database.getIterator();
         assertFalse( "check there are no failures", failures.hasNext() );
     }
 
     public void testInvalidSnapshotMetadata()
     {
-        Artifact artifact =
-            artifactFactory.createBuildArtifact( "groupId", "snapshot-artifact", "1.0-alpha-1-SNAPSHOT", "type" );
+        Artifact artifact = artifactFactory.createBuildArtifact( "groupId", "snapshot-artifact",
+                                                                 "1.0-alpha-1-SNAPSHOT", "type" );
 
         Snapshot snapshot = new Snapshot();
         snapshot.setBuildNumber( 2 );
@@ -406,9 +416,9 @@
 
         RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact, snapshot );
 
-        badMetadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
+        badMetadataReportProcessor.processMetadata( metadata, repository );
 
-        Iterator failures = reportingDatabase.getMetadataIterator();
+        Iterator failures = database.getIterator();
         assertTrue( "check there is a failure", failures.hasNext() );
         MetadataResults results = (MetadataResults) failures.next();
         failures = results.getFailures().iterator();
@@ -416,16 +426,21 @@
         Result result = (Result) failures.next();
         assertMetadata( metadata, results );
         // TODO: should be more robust
-        assertEquals( "check reason", "Snapshot artifact 1.0-alpha-1-20050611.202024-2 does not exist.",
-                      result.getReason() );
+        assertEquals( "check reason", "Snapshot artifact 1.0-alpha-1-20050611.202024-2 does not exist.", result
+            .getReason() );
         assertFalse( "check no more failures", failures.hasNext() );
     }
 
     private static void assertMetadata( RepositoryMetadata metadata, MetadataResults results )
     {
-        assertEquals( "check metadata", metadata.getGroupId(), results.getGroupId() );
-        assertEquals( "check metadata", metadata.getArtifactId(), results.getArtifactId() );
-        assertEquals( "check metadata", metadata.getBaseVersion(), results.getVersion() );
+        /* The funky StringUtils.defaultString() is used because of database constraints.
+         * The MetadataResults object has a complex primary key consisting of groupId, artifactId, and version.
+         * This also means that none of those fields may be null.  however, that doesn't eliminate the
+         * ability to have an empty string in place of a null.
+         */
+        assertEquals( "check metadata", StringUtils.defaultString( metadata.getGroupId() ), results.getGroupId() );
+        assertEquals( "check metadata", StringUtils.defaultString( metadata.getArtifactId() ), results.getArtifactId() );
+        assertEquals( "check metadata", StringUtils.defaultString( metadata.getBaseVersion() ), results.getVersion() );
     }
 
     private Plugin createMetadataPlugin( String artifactId, String prefix )

Modified: maven/archiva/trunk/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/processor/DependencyArtifactReportProcessorTest.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/processor/DependencyArtifactReportProcessorTest.java?view=diff&rev=511053&r1=511052&r2=511053
==============================================================================
--- maven/archiva/trunk/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/processor/DependencyArtifactReportProcessorTest.java (original)
+++ maven/archiva/trunk/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/processor/DependencyArtifactReportProcessorTest.java Fri Feb 23 11:05:21 2007
@@ -20,8 +20,7 @@
  */
 
 import org.apache.maven.archiva.reporting.AbstractRepositoryReportsTestCase;
-import org.apache.maven.archiva.reporting.database.ReportingDatabase;
-import org.apache.maven.archiva.reporting.group.ReportGroup;
+import org.apache.maven.archiva.reporting.database.ArtifactResultsDatabase;
 import org.apache.maven.archiva.reporting.model.ArtifactResults;
 import org.apache.maven.archiva.reporting.model.Result;
 import org.apache.maven.artifact.Artifact;
@@ -43,7 +42,7 @@
 
     private static final String VALID_VERSION = "1.0-alpha-1";
 
-    private ReportingDatabase reportingDatabase;
+    private ArtifactResultsDatabase database;
 
     private Model model;
 
@@ -58,27 +57,24 @@
     {
         super.setUp();
         model = new Model();
-        processor = (ArtifactReportProcessor) lookup( ArtifactReportProcessor.ROLE, "dependency" );
-
         artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
-
-        ReportGroup reportGroup = (ReportGroup) lookup( ReportGroup.ROLE, "health" );
-        reportingDatabase = new ReportingDatabase( reportGroup );
+        database = (ArtifactResultsDatabase) lookup( ArtifactResultsDatabase.ROLE );
+        processor = (ArtifactReportProcessor) lookup( ArtifactReportProcessor.ROLE, "dependency" );
     }
 
     public void testArtifactFoundButNoDirectDependencies()
     {
         Artifact artifact = createValidArtifact();
-        processor.processArtifact( artifact, model, reportingDatabase );
-        assertEquals( 0, reportingDatabase.getNumFailures() );
-        assertEquals( 0, reportingDatabase.getNumWarnings() );
-        assertEquals( 0, reportingDatabase.getNumNotices() );
+        processor.processArtifact( artifact, model );
+        assertEquals( 0, database.getNumFailures() );
+        assertEquals( 0, database.getNumWarnings() );
+        assertEquals( 0, database.getNumNotices() );
     }
 
     private Artifact createValidArtifact()
     {
-        Artifact projectArtifact =
-            artifactFactory.createProjectArtifact( VALID_GROUP_ID, VALID_ARTIFACT_ID, VALID_VERSION );
+        Artifact projectArtifact = artifactFactory.createProjectArtifact( VALID_GROUP_ID, VALID_ARTIFACT_ID,
+                                                                          VALID_VERSION );
         projectArtifact.setRepository( repository );
         return projectArtifact;
     }
@@ -87,11 +83,11 @@
     {
         Artifact artifact = artifactFactory.createProjectArtifact( INVALID, INVALID, INVALID );
         artifact.setRepository( repository );
-        processor.processArtifact( artifact, model, reportingDatabase );
-        assertEquals( 1, reportingDatabase.getNumFailures() );
-        assertEquals( 0, reportingDatabase.getNumWarnings() );
-        assertEquals( 0, reportingDatabase.getNumNotices() );
-        Iterator failures = reportingDatabase.getArtifactIterator();
+        processor.processArtifact( artifact, model );
+        assertEquals( 1, database.getNumFailures() );
+        assertEquals( 0, database.getNumWarnings() );
+        assertEquals( 0, database.getNumNotices() );
+        Iterator failures = database.getIterator();
         ArtifactResults results = (ArtifactResults) failures.next();
         assertFalse( failures.hasNext() );
         failures = results.getFailures().iterator();
@@ -106,10 +102,10 @@
         Dependency dependency = createValidDependency();
         model.addDependency( dependency );
 
-        processor.processArtifact( artifact, model, reportingDatabase );
-        assertEquals( 0, reportingDatabase.getNumFailures() );
-        assertEquals( 0, reportingDatabase.getNumWarnings() );
-        assertEquals( 0, reportingDatabase.getNumNotices() );
+        processor.processArtifact( artifact, model );
+        assertEquals( 0, database.getNumFailures() );
+        assertEquals( 0, database.getNumWarnings() );
+        assertEquals( 0, database.getNumNotices() );
     }
 
     private Dependency createValidDependency()
@@ -124,10 +120,10 @@
         Dependency dependency = createValidDependency();
         model.addDependency( dependency );
 
-        processor.processArtifact( artifact, model, reportingDatabase );
-        assertEquals( 0, reportingDatabase.getNumFailures() );
-        assertEquals( 0, reportingDatabase.getNumWarnings() );
-        assertEquals( 0, reportingDatabase.getNumNotices() );
+        processor.processArtifact( artifact, model );
+        assertEquals( 0, database.getNumFailures() );
+        assertEquals( 0, database.getNumWarnings() );
+        assertEquals( 0, database.getNumNotices() );
     }
 
     public void testValidArtifactWithValidMultipleDependencies()
@@ -140,10 +136,10 @@
         model.addDependency( dependency );
 
         Artifact artifact = createValidArtifact();
-        processor.processArtifact( artifact, model, reportingDatabase );
-        assertEquals( 0, reportingDatabase.getNumFailures() );
-        assertEquals( 0, reportingDatabase.getNumWarnings() );
-        assertEquals( 0, reportingDatabase.getNumNotices() );
+        processor.processArtifact( artifact, model );
+        assertEquals( 0, database.getNumFailures() );
+        assertEquals( 0, database.getNumWarnings() );
+        assertEquals( 0, database.getNumNotices() );
     }
 
     public void testValidArtifactWithAnInvalidDependency()
@@ -156,18 +152,17 @@
         model.addDependency( createDependency( INVALID, INVALID, INVALID ) );
 
         Artifact artifact = createValidArtifact();
-        processor.processArtifact( artifact, model, reportingDatabase );
-        assertEquals( 1, reportingDatabase.getNumFailures() );
-        assertEquals( 0, reportingDatabase.getNumWarnings() );
-        assertEquals( 0, reportingDatabase.getNumNotices() );
+        processor.processArtifact( artifact, model );
+        assertEquals( 1, database.getNumFailures() );
+        assertEquals( 0, database.getNumWarnings() );
+        assertEquals( 0, database.getNumNotices() );
 
-        Iterator failures = reportingDatabase.getArtifactIterator();
+        Iterator failures = database.getIterator();
         ArtifactResults results = (ArtifactResults) failures.next();
         assertFalse( failures.hasNext() );
         failures = results.getFailures().iterator();
         Result result = (Result) failures.next();
-        assertEquals( getDependencyNotFoundMessage( createDependency( INVALID, INVALID, INVALID ) ),
-                      result.getReason() );
+        assertEquals( getDependencyNotFoundMessage( createDependency( INVALID, INVALID, INVALID ) ), result.getReason() );
     }
 
     public void testValidArtifactWithInvalidDependencyGroupId()
@@ -177,12 +172,12 @@
         Dependency dependency = createDependency( INVALID, VALID_ARTIFACT_ID, VALID_VERSION );
         model.addDependency( dependency );
 
-        processor.processArtifact( artifact, model, reportingDatabase );
-        assertEquals( 1, reportingDatabase.getNumFailures() );
-        assertEquals( 0, reportingDatabase.getNumWarnings() );
-        assertEquals( 0, reportingDatabase.getNumNotices() );
+        processor.processArtifact( artifact, model );
+        assertEquals( 1, database.getNumFailures() );
+        assertEquals( 0, database.getNumWarnings() );
+        assertEquals( 0, database.getNumNotices() );
 
-        Iterator failures = reportingDatabase.getArtifactIterator();
+        Iterator failures = database.getIterator();
         ArtifactResults results = (ArtifactResults) failures.next();
         assertFalse( failures.hasNext() );
         failures = results.getFailures().iterator();
@@ -206,12 +201,12 @@
         Dependency dependency = createDependency( VALID_GROUP_ID, INVALID, VALID_VERSION );
         model.addDependency( dependency );
 
-        processor.processArtifact( artifact, model, reportingDatabase );
-        assertEquals( 1, reportingDatabase.getNumFailures() );
-        assertEquals( 0, reportingDatabase.getNumWarnings() );
-        assertEquals( 0, reportingDatabase.getNumNotices() );
+        processor.processArtifact( artifact, model );
+        assertEquals( 1, database.getNumFailures() );
+        assertEquals( 0, database.getNumWarnings() );
+        assertEquals( 0, database.getNumNotices() );
 
-        Iterator failures = reportingDatabase.getArtifactIterator();
+        Iterator failures = database.getIterator();
         ArtifactResults results = (ArtifactResults) failures.next();
         assertFalse( failures.hasNext() );
         failures = results.getFailures().iterator();
@@ -226,11 +221,11 @@
         Dependency dependency = createDependency( VALID_GROUP_ID, VALID_ARTIFACT_ID, INVALID );
         model.addDependency( dependency );
 
-        processor.processArtifact( artifact, model, reportingDatabase );
-        assertEquals( 1, reportingDatabase.getNumFailures() );
-        assertEquals( 0, reportingDatabase.getNumWarnings() );
+        processor.processArtifact( artifact, model );
+        assertEquals( 1, database.getNumFailures() );
+        assertEquals( 0, database.getNumWarnings() );
 
-        Iterator failures = reportingDatabase.getArtifactIterator();
+        Iterator failures = database.getIterator();
         ArtifactResults results = (ArtifactResults) failures.next();
         assertFalse( failures.hasNext() );
         failures = results.getFailures().iterator();
@@ -245,12 +240,12 @@
         Dependency dependency = createDependency( VALID_GROUP_ID, VALID_ARTIFACT_ID, "[" );
         model.addDependency( dependency );
 
-        processor.processArtifact( artifact, model, reportingDatabase );
-        assertEquals( 1, reportingDatabase.getNumFailures() );
-        assertEquals( 0, reportingDatabase.getNumWarnings() );
-        assertEquals( 0, reportingDatabase.getNumNotices() );
+        processor.processArtifact( artifact, model );
+        assertEquals( 1, database.getNumFailures() );
+        assertEquals( 0, database.getNumWarnings() );
+        assertEquals( 0, database.getNumNotices() );
 
-        Iterator failures = reportingDatabase.getArtifactIterator();
+        Iterator failures = database.getIterator();
         ArtifactResults results = (ArtifactResults) failures.next();
         assertFalse( failures.hasNext() );
         failures = results.getFailures().iterator();
@@ -265,10 +260,10 @@
         Dependency dependency = createDependency( VALID_GROUP_ID, VALID_ARTIFACT_ID, "[1.0,)" );
         model.addDependency( dependency );
 
-        processor.processArtifact( artifact, model, reportingDatabase );
-        assertEquals( 0, reportingDatabase.getNumFailures() );
-        assertEquals( 0, reportingDatabase.getNumWarnings() );
-        assertEquals( 0, reportingDatabase.getNumNotices() );
+        processor.processArtifact( artifact, model );
+        assertEquals( 0, database.getNumFailures() );
+        assertEquals( 0, database.getNumWarnings() );
+        assertEquals( 0, database.getNumNotices() );
     }
 
     public void testValidArtifactWithMissingDependencyVersion()
@@ -278,12 +273,12 @@
         Dependency dependency = createDependency( VALID_GROUP_ID, VALID_ARTIFACT_ID, null );
         model.addDependency( dependency );
 
-        processor.processArtifact( artifact, model, reportingDatabase );
-        assertEquals( 1, reportingDatabase.getNumFailures() );
-        assertEquals( 0, reportingDatabase.getNumWarnings() );
-        assertEquals( 0, reportingDatabase.getNumNotices() );
+        processor.processArtifact( artifact, model );
+        assertEquals( 1, database.getNumFailures() );
+        assertEquals( 0, database.getNumWarnings() );
+        assertEquals( 0, database.getNumNotices() );
 
-        Iterator failures = reportingDatabase.getArtifactIterator();
+        Iterator failures = database.getIterator();
         ArtifactResults results = (ArtifactResults) failures.next();
         assertFalse( failures.hasNext() );
         failures = results.getFailures().iterator();

Modified: maven/archiva/trunk/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/processor/DuplicateArtifactFileReportProcessorTest.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/processor/DuplicateArtifactFileReportProcessorTest.java?view=diff&rev=511053&r1=511052&r2=511053
==============================================================================
--- maven/archiva/trunk/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/processor/DuplicateArtifactFileReportProcessorTest.java (original)
+++ maven/archiva/trunk/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/processor/DuplicateArtifactFileReportProcessorTest.java Fri Feb 23 11:05:21 2007
@@ -24,8 +24,7 @@
 import org.apache.maven.archiva.indexer.RepositoryArtifactIndexFactory;
 import org.apache.maven.archiva.indexer.record.RepositoryIndexRecordFactory;
 import org.apache.maven.archiva.reporting.AbstractRepositoryReportsTestCase;
-import org.apache.maven.archiva.reporting.database.ReportingDatabase;
-import org.apache.maven.archiva.reporting.group.ReportGroup;
+import org.apache.maven.archiva.reporting.database.ArtifactResultsDatabase;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.model.Model;
@@ -49,7 +48,7 @@
 
     File indexDirectory;
 
-    private ReportingDatabase reportDatabase;
+    private ArtifactResultsDatabase database;
 
     protected void setUp()
         throws Exception
@@ -60,8 +59,11 @@
         FileUtils.deleteDirectory( indexDirectory );
 
         artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
+        
+        database = (ArtifactResultsDatabase) lookup( ArtifactResultsDatabase.ROLE );
+        
         artifact = createArtifact( "groupId", "artifactId", "1.0-alpha-1", "1.0-alpha-1", "jar" );
-        System.out.println( "artifact = " + artifact );
+        
         model = new Model();
 
         RepositoryArtifactIndexFactory factory =
@@ -75,9 +77,6 @@
         index.indexRecords( Collections.singletonList( recordFactory.createRecord( artifact ) ) );
 
         processor = (ArtifactReportProcessor) lookup( ArtifactReportProcessor.ROLE, "duplicate" );
-
-        ReportGroup reportGroup = (ReportGroup) lookup( ReportGroup.ROLE, "health" );
-        reportDatabase = new ReportingDatabase( reportGroup );
     }
 
     public void testNullArtifactFile()
@@ -85,32 +84,32 @@
     {
         artifact.setFile( null );
 
-        processor.processArtifact( artifact, model, reportDatabase );
+        processor.processArtifact( artifact, model );
 
-        assertEquals( "Check no notices", 0, reportDatabase.getNumNotices() );
-        assertEquals( "Check warnings", 1, reportDatabase.getNumWarnings() );
-        assertEquals( "Check no failures", 0, reportDatabase.getNumFailures() );
+        assertEquals( "Check no notices", 0, database.getNumNotices() );
+        assertEquals( "Check warnings", 1, database.getNumWarnings() );
+        assertEquals( "Check no failures", 0, database.getNumFailures() );
     }
 
     public void testSuccessOnAlreadyIndexedArtifact()
         throws Exception
     {
-        processor.processArtifact( artifact, model, reportDatabase );
+        processor.processArtifact( artifact, model );
 
-        assertEquals( "Check no notices", 0, reportDatabase.getNumNotices() );
-        assertEquals( "Check warnings", 0, reportDatabase.getNumWarnings() );
-        assertEquals( "Check no failures", 0, reportDatabase.getNumFailures() );
+        assertEquals( "Check no notices", 0, database.getNumNotices() );
+        assertEquals( "Check warnings", 0, database.getNumWarnings() );
+        assertEquals( "Check no failures", 0, database.getNumFailures() );
     }
 
     public void testSuccessOnDifferentGroupId()
         throws Exception
     {
         artifact.setGroupId( "different.groupId" );
-        processor.processArtifact( artifact, model, reportDatabase );
+        processor.processArtifact( artifact, model );
 
-        assertEquals( "Check no notices", 0, reportDatabase.getNumNotices() );
-        assertEquals( "Check warnings", 0, reportDatabase.getNumWarnings() );
-        assertEquals( "Check no failures", 0, reportDatabase.getNumFailures() );
+        assertEquals( "Check no notices", 0, database.getNumNotices() );
+        assertEquals( "Check warnings", 0, database.getNumWarnings() );
+        assertEquals( "Check no failures", 0, database.getNumFailures() );
     }
 
     public void testSuccessOnNewArtifact()
@@ -118,11 +117,11 @@
     {
         Artifact newArtifact = createArtifact( "groupId", "artifactId", "1.0-alpha-1", "1.0-alpha-1", "pom" );
 
-        processor.processArtifact( newArtifact, model, reportDatabase );
+        processor.processArtifact( newArtifact, model );
 
-        assertEquals( "Check no notices", 0, reportDatabase.getNumNotices() );
-        assertEquals( "Check warnings", 0, reportDatabase.getNumWarnings() );
-        assertEquals( "Check no failures", 0, reportDatabase.getNumFailures() );
+        assertEquals( "Check no notices", 0, database.getNumNotices() );
+        assertEquals( "Check warnings", 0, database.getNumWarnings() );
+        assertEquals( "Check no failures", 0, database.getNumFailures() );
     }
 
     public void testFailure()
@@ -132,11 +131,11 @@
                                              artifact.getVersion(), artifact.getType() );
         duplicate.setFile( artifact.getFile() );
 
-        processor.processArtifact( duplicate, model, reportDatabase );
+        processor.processArtifact( duplicate, model );
 
-        assertEquals( "Check warnings", 0, reportDatabase.getNumWarnings() );
-        assertEquals( "Check no notices", 0, reportDatabase.getNumNotices() );
-        assertEquals( "Check no failures", 1, reportDatabase.getNumFailures() );
+        assertEquals( "Check warnings", 0, database.getNumWarnings() );
+        assertEquals( "Check no notices", 0, database.getNumNotices() );
+        assertEquals( "Check no failures", 1, database.getNumFailures() );
     }
 
     private Artifact createArtifact( String groupId, String artifactId, String baseVersion, String version,



Mime
View raw message