You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ep...@apache.org on 2005/12/02 07:41:44 UTC

svn commit: r351613 - in /maven/repository-manager/trunk/maven-repository-reports-standard/src: main/java/org/apache/maven/repository/reporting/ main/java/org/apache/maven/repository/reporting/reports/ test/java/org/apache/maven/repository/reporting/

Author: epunzalan
Date: Thu Dec  1 22:41:24 2005
New Revision: 351613

URL: http://svn.apache.org/viewcvs?rev=351613&view=rev
Log:
PR: MRM-51
Submitted by: John Tolentino

Mock Objects and additional class files

Added:
    maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/
    maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/Failure.java   (with props)
    maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/ReportError.java   (with props)
    maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/ReportResult.java   (with props)
    maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/Success.java   (with props)
    maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/Warning.java   (with props)
    maven/repository-manager/trunk/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/MockArtifactReportProcessor.java   (with props)
    maven/repository-manager/trunk/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/MockRepositoryQueryLayer.java   (with props)
    maven/repository-manager/trunk/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/ReportCondition.java   (with props)
Modified:
    maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DefaultArtifactReporter.java

Modified: maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DefaultArtifactReporter.java
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DefaultArtifactReporter.java?rev=351613&r1=351612&r2=351613&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DefaultArtifactReporter.java (original)
+++ maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DefaultArtifactReporter.java Thu Dec  1 22:41:24 2005
@@ -18,12 +18,26 @@
 
 import org.apache.maven.artifact.Artifact;
 
+import java.util.List;
+import java.util.ArrayList;
+
 /**
  * @author <a href="mailto:jtolentino@mergere.com">John Tolentino</a>
  */
 public class DefaultArtifactReporter
     implements ArtifactReporter
 {
+    private List success;
+    private List warnings;
+    private List failures;
+
+
+    public DefaultArtifactReporter()
+    {
+        success = new ArrayList();
+        warnings = new ArrayList();
+        failures = new ArrayList();
+    }
 
     public void addFailure( Artifact artifact, String reason )
     {

Added: maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/Failure.java
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/Failure.java?rev=351613&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/Failure.java (added)
+++ maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/Failure.java Thu Dec  1 22:41:24 2005
@@ -0,0 +1,32 @@
+package org.apache.maven.repository.reporting.reports;
+
+import org.apache.maven.artifact.Artifact;
+
+/*
+ * 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.
+ */
+
+/**
+ * @author <a href="mailto:jtolentino@mergere.com">John Tolentino</a>
+ */
+public class Failure
+    extends ReportError
+{
+    public Failure( Artifact artifact, String reason )
+    {
+        super( artifact, reason );
+    }
+}

Propchange: maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/Failure.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/Failure.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/ReportError.java
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/ReportError.java?rev=351613&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/ReportError.java (added)
+++ maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/ReportError.java Thu Dec  1 22:41:24 2005
@@ -0,0 +1,44 @@
+package org.apache.maven.repository.reporting.reports;
+
+import org.apache.maven.artifact.Artifact;
+
+/*
+ * 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.
+ */
+
+/**
+ * @author <a href="mailto:jtolentino@mergere.com">John Tolentino</a>
+ */
+public class ReportError
+    extends ReportResult
+{
+    String reason = "";
+
+    public ReportError( Artifact artifact, String reason )
+    {
+        super( artifact );
+        this.reason = reason;
+    }
+
+    public String getReason()
+    {
+        return reason;
+    }
+
+    public void setReason( String reason )
+    {
+        this.reason = reason;
+    }
+}

Propchange: maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/ReportError.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/ReportError.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/ReportResult.java
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/ReportResult.java?rev=351613&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/ReportResult.java (added)
+++ maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/ReportResult.java Thu Dec  1 22:41:24 2005
@@ -0,0 +1,42 @@
+package org.apache.maven.repository.reporting.reports;
+
+import org.apache.maven.artifact.Artifact;
+
+/*
+ * 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.
+ */
+
+/**
+ * @author <a href="mailto:jtolentino@mergere.com">John Tolentino</a>
+ */
+public class ReportResult
+{
+    private Artifact artifact;
+
+    public ReportResult( Artifact artifact )
+    {
+        this.artifact = artifact;
+    }
+
+    public Artifact getArtifact()
+    {
+        return artifact;
+    }
+
+    public void setArtifact( Artifact artifact )
+    {
+        this.artifact = artifact;
+    }
+}

Propchange: maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/ReportResult.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/ReportResult.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/Success.java
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/Success.java?rev=351613&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/Success.java (added)
+++ maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/Success.java Thu Dec  1 22:41:24 2005
@@ -0,0 +1,33 @@
+package org.apache.maven.repository.reporting.reports;
+
+import org.apache.maven.repository.reporting.reports.ReportResult;
+import org.apache.maven.artifact.Artifact;
+
+/*
+ * 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.
+ */
+
+/**
+ * @author <a href="mailto:jtolentino@mergere.com">John Tolentino</a>
+ */
+public class Success
+    extends ReportResult
+{
+    public Success( Artifact artifact )
+    {
+        super( artifact );
+    }
+}

Propchange: maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/Success.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/Success.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/Warning.java
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/Warning.java?rev=351613&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/Warning.java (added)
+++ maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/Warning.java Thu Dec  1 22:41:24 2005
@@ -0,0 +1,33 @@
+package org.apache.maven.repository.reporting.reports;
+
+import org.apache.maven.repository.reporting.reports.ReportError;
+import org.apache.maven.artifact.Artifact;
+
+/*
+ * 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.
+ */
+
+/**
+ * @author <a href="mailto:jtolentino@mergere.com">John Tolentino</a>
+ */
+public class Warning
+    extends ReportError
+{
+    public Warning( Artifact artifact, String reason )
+    {
+        super( artifact, reason );
+    }
+}

Propchange: maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/Warning.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/Warning.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/repository-manager/trunk/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/MockArtifactReportProcessor.java
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/MockArtifactReportProcessor.java?rev=351613&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/MockArtifactReportProcessor.java (added)
+++ maven/repository-manager/trunk/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/MockArtifactReportProcessor.java Thu Dec  1 22:41:24 2005
@@ -0,0 +1,76 @@
+package org.apache.maven.repository.reporting;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.Model;
+
+import java.util.List;
+import java.util.Iterator;
+import java.util.ArrayList;
+
+/*
+ * 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.
+ */
+
+/**
+ * @author <a href="mailto:jtolentino@mergere.com">John Tolentino</a>
+ */
+public class MockArtifactReportProcessor
+    implements ArtifactReportProcessor
+{
+    private List reportConditions;
+    private Iterator iterator;
+
+    public MockArtifactReportProcessor()
+    {
+        reportConditions = new ArrayList();
+    }
+
+    public void processArtifact( Model model, Artifact artifact, ArtifactReporter reporter )
+    {
+        if ( iterator == null || !iterator.hasNext() ) // not initialized or reached end of the list. start again
+        {
+            iterator = reportConditions.iterator();
+        }
+        if ( ! reportConditions.isEmpty() )
+        {
+            ReportCondition reportCondition = (ReportCondition) iterator.next();
+            switch( reportCondition.getResult() )
+            {
+                case ReportCondition.SUCCESS :
+                    {
+                        reporter.addSuccess( reportCondition.getArtifact() );
+                    }
+                case ReportCondition.WARNING :
+                    {
+                        reporter.addWarning( reportCondition.getArtifact(), reportCondition.getReason() );
+                    }
+                case ReportCondition.FAILURE :
+                    {
+                        reporter.addFailure( reportCondition.getArtifact(), reportCondition.getReason() );
+                    }
+            }
+        }
+    }
+
+    public void addReturnValue( int result, Artifact artifact, String reason )
+    {
+        reportConditions.add( new ReportCondition( result, artifact, reason ) );
+    }
+
+    public void clearList()
+    {
+        reportConditions.clear();
+    }
+}

Propchange: maven/repository-manager/trunk/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/MockArtifactReportProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/repository-manager/trunk/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/MockArtifactReportProcessor.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/repository-manager/trunk/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/MockRepositoryQueryLayer.java
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/MockRepositoryQueryLayer.java?rev=351613&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/MockRepositoryQueryLayer.java (added)
+++ maven/repository-manager/trunk/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/MockRepositoryQueryLayer.java Thu Dec  1 22:41:24 2005
@@ -0,0 +1,64 @@
+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.apache.maven.artifact.Artifact;
+
+import java.util.List;
+import java.util.Iterator;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:jtolentino@mergere.com">John Tolentino</a>
+ */
+public class MockRepositoryQueryLayer
+    implements RepositoryQueryLayer
+{
+    private List queryConditions;
+    private Iterator iterator;
+
+    public MockRepositoryQueryLayer()
+    {
+        queryConditions = new ArrayList();
+    }
+
+    public boolean containsArtifact( Artifact artifact )
+    {
+        if ( iterator == null || !iterator.hasNext() ) // not initialized or reached end of the list. start again
+        {
+            iterator = queryConditions.iterator();
+        }
+        if ( queryConditions.isEmpty() )
+        {
+            return false;
+        }
+        else
+        {
+            return ( (Boolean) iterator.next() ).booleanValue();
+        }
+    }
+
+    public void addReturnValue( boolean queryCondition )
+    {
+        queryConditions.add( new Boolean( queryCondition ) );
+    }
+
+    public void clearList()
+    {
+        queryConditions.clear();
+    }
+}

Propchange: maven/repository-manager/trunk/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/MockRepositoryQueryLayer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/repository-manager/trunk/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/MockRepositoryQueryLayer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/repository-manager/trunk/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/ReportCondition.java
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/ReportCondition.java?rev=351613&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/ReportCondition.java (added)
+++ maven/repository-manager/trunk/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/ReportCondition.java Thu Dec  1 22:41:24 2005
@@ -0,0 +1,70 @@
+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.apache.maven.artifact.Artifact;
+
+/**
+ * @author <a href="mailto:jtolentino@mergere.com">John Tolentino</a>
+ */
+public class ReportCondition
+{
+    public final static int SUCCESS = 0;
+    public final static int FAILURE = -1;
+    public final static int WARNING = 1;
+
+    private int result;
+    private Artifact artifact;
+    private String reason;
+
+    public ReportCondition( int result, Artifact artifact, String reason )
+    {
+        this.result = result;
+        this.artifact = artifact;
+        this.reason = reason;
+    }
+
+    public int getResult()
+    {
+        return result;
+    }
+
+    public void setResult( int result )
+    {
+        this.result = result;
+    }
+
+    public Artifact getArtifact()
+    {
+        return artifact;
+    }
+
+    public void setArtifact( Artifact artifact )
+    {
+        this.artifact = artifact;
+    }
+
+    public String getReason()
+    {
+        return reason;
+    }
+
+    public void setReason( String reason )
+    {
+        this.reason = reason;
+    }
+}

Propchange: maven/repository-manager/trunk/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/ReportCondition.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/repository-manager/trunk/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/ReportCondition.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"