From: Brett Porter Date: Fri, 16 Oct 2009 13:26:47 +0000 (+0000) Subject: [MRM-1025] make sure listeners work in delete artifact action X-Git-Tag: archiva-1.4-M1~1017^2~185 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=116d2d2387bc42262cd48c5c902cd1989c98f466;p=archiva.git [MRM-1025] make sure listeners work in delete artifact action git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@825884 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/DeleteArtifactAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/DeleteArtifactAction.java index e70e9d29d..de5dc2d4d 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/DeleteArtifactAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/DeleteArtifactAction.java @@ -120,7 +120,7 @@ public class DeleteArtifactAction */ private DatabaseConsumers databaseConsumers; - /** @plexus.requirement */ + /** @plexus.requirement role="org.apache.maven.archiva.repository.events.RepositoryListener" */ private List listeners; private ChecksumAlgorithm[] algorithms = new ChecksumAlgorithm[] { ChecksumAlgorithm.SHA1, ChecksumAlgorithm.MD5 }; @@ -410,4 +410,9 @@ public class DeleteArtifactAction } return Collections.emptyList(); } + + public List 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 index 000000000..45446707b --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/DeleteArtifactActionTest.java @@ -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 index 000000000..8203c0d3d --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoryProblemDAOStub.java @@ -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 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 index 000000000..e2ebee50c --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/DeleteArtifactActionTest.xml @@ -0,0 +1,54 @@ + + + + + + org.apache.maven.archiva.database.ArchivaDAO + jdo + org.apache.maven.archiva.web.action.admin.repositories.ArchivaDAOStub + + + org.apache.maven.archiva.configuration.ArchivaConfiguration + configuration + + + + + org.apache.maven.archiva.database.RepositoryProblemDAO + jdo + org.apache.maven.archiva.web.action.admin.repositories.RepositoryProblemDAOStub + + + org.apache.maven.archiva.database.ProjectModelDAO + jdo + org.apache.maven.archiva.web.action.admin.repositories.ProjectModelDAOStub + + + org.apache.maven.archiva.database.ArtifactDAO + jdo + org.apache.maven.archiva.web.action.admin.repositories.ArtifactDAOStub + + + org.apache.maven.archiva.security.UserRepositories + default + org.apache.maven.archiva.security.UserRepositoriesStub + + +