]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1025] make sure listeners work in delete artifact action
authorBrett Porter <brett@apache.org>
Fri, 16 Oct 2009 13:26:47 +0000 (13:26 +0000)
committerBrett Porter <brett@apache.org>
Fri, 16 Oct 2009 13:26:47 +0000 (13:26 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@825884 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/DeleteArtifactAction.java
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/DeleteArtifactActionTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoryProblemDAOStub.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/DeleteArtifactActionTest.xml [new file with mode: 0644]

index e70e9d29d729e83b6bd7f5907910597b4a50d1e3..de5dc2d4d4789cd1358b533f9118294cf0cfc8b2 100644 (file)
@@ -120,7 +120,7 @@ public class DeleteArtifactAction
      */
     private DatabaseConsumers databaseConsumers;
 
-    /** @plexus.requirement */
+    /** @plexus.requirement role="org.apache.maven.archiva.repository.events.RepositoryListener" */
     private List<RepositoryListener> listeners;
 
     private ChecksumAlgorithm[] algorithms = new ChecksumAlgorithm[] { ChecksumAlgorithm.SHA1, ChecksumAlgorithm.MD5 };
@@ -410,4 +410,9 @@ public class DeleteArtifactAction
         }
         return Collections.emptyList();
     }
+
+    public List<RepositoryListener> getListeners()
+    {
+        return listeners;
+    }
 }
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/DeleteArtifactActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/DeleteArtifactActionTest.java
new file mode 100644 (file)
index 0000000..4544670
--- /dev/null
@@ -0,0 +1,36 @@
+package org.apache.maven.archiva.web.action;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 com.opensymphony.xwork2.Action;
+import org.codehaus.plexus.spring.PlexusInSpringTestCase;
+
+public class DeleteArtifactActionTest
+    extends PlexusInSpringTestCase
+{
+    public void testGetListeners()
+        throws Exception
+    {
+        DeleteArtifactAction action = (DeleteArtifactAction) lookup( Action.class.getName(), "deleteArtifactAction" );
+        assertNotNull( action );
+        assertNotNull( action.getListeners() );
+        assertFalse( action.getListeners().isEmpty() );
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoryProblemDAOStub.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoryProblemDAOStub.java
new file mode 100644 (file)
index 0000000..8203c0d
--- /dev/null
@@ -0,0 +1,55 @@
+package org.apache.maven.archiva.web.action.admin.repositories;
+
+import java.util.List;
+
+import org.apache.maven.archiva.database.ArchivaDatabaseException;
+import org.apache.maven.archiva.database.Constraint;
+import org.apache.maven.archiva.database.ObjectNotFoundException;
+import org.apache.maven.archiva.database.RepositoryProblemDAO;
+import org.apache.maven.archiva.model.RepositoryProblem;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+/**
+ * Stub class for Archiva DAO to avoid having to set up a database for tests.
+ *
+ * @todo a mock would be better, but that won't play nicely with Plexus injection.
+ */
+public class RepositoryProblemDAOStub
+    implements RepositoryProblemDAO
+{
+    public List<RepositoryProblem> queryRepositoryProblems( Constraint constraint )
+        throws ObjectNotFoundException, ArchivaDatabaseException
+    {
+        throw new UnsupportedOperationException( "not implemented for stub" );
+    }
+
+    public RepositoryProblem saveRepositoryProblem( RepositoryProblem problem )
+        throws ArchivaDatabaseException
+    {
+        throw new UnsupportedOperationException( "not implemented for stub" );
+    }
+
+    public void deleteRepositoryProblem( RepositoryProblem problem )
+        throws ArchivaDatabaseException
+    {
+        throw new UnsupportedOperationException( "not implemented for stub" );
+    }
+}
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/DeleteArtifactActionTest.xml b/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/DeleteArtifactActionTest.xml
new file mode 100644 (file)
index 0000000..e2ebee5
--- /dev/null
@@ -0,0 +1,54 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you 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.
+  -->
+
+<plexus>
+  <components>
+    <component>
+      <role>org.apache.maven.archiva.database.ArchivaDAO</role>
+      <role-hint>jdo</role-hint>
+      <implementation>org.apache.maven.archiva.web.action.admin.repositories.ArchivaDAOStub</implementation>
+      <requirements>
+        <requirement>
+          <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
+          <field-name>configuration</field-name>
+        </requirement>
+      </requirements>
+    </component>
+    <component>
+      <role>org.apache.maven.archiva.database.RepositoryProblemDAO</role>
+      <role-hint>jdo</role-hint>
+      <implementation>org.apache.maven.archiva.web.action.admin.repositories.RepositoryProblemDAOStub</implementation>
+    </component>
+    <component>
+      <role>org.apache.maven.archiva.database.ProjectModelDAO</role>
+      <role-hint>jdo</role-hint>
+      <implementation>org.apache.maven.archiva.web.action.admin.repositories.ProjectModelDAOStub</implementation>
+    </component>
+    <component>
+      <role>org.apache.maven.archiva.database.ArtifactDAO</role>
+      <role-hint>jdo</role-hint>
+      <implementation>org.apache.maven.archiva.web.action.admin.repositories.ArtifactDAOStub</implementation>
+    </component>
+    <component>
+      <role>org.apache.maven.archiva.security.UserRepositories</role>
+      <role-hint>default</role-hint>
+      <implementation>org.apache.maven.archiva.security.UserRepositoriesStub</implementation>
+    </component>
+  </components>
+</plexus>