Yevgeny Zaspitsky has uploaded a new change for review. Change subject: core: test that verifies DAO classes being annotated with Singleton ......................................................................
core: test that verifies DAO classes being annotated with Singleton The new test verifies that all DAO concrete classes being annotated with @Singleton. Change-Id: I8057dfce430cb3ce6a35181479b8999b4a1fe264 Signed-off-by: Yevgeny Zaspitsky <yzasp...@redhat.com> --- M backend/manager/modules/dal/pom.xml A backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/DaoCdiIntegrationTest.java 2 files changed, 46 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/72/39572/1 diff --git a/backend/manager/modules/dal/pom.xml b/backend/manager/modules/dal/pom.xml index 98a363e..44889c95 100644 --- a/backend/manager/modules/dal/pom.xml +++ b/backend/manager/modules/dal/pom.xml @@ -15,6 +15,12 @@ </properties> <dependencies> <dependency> + <groupId>org.reflections</groupId> + <artifactId>reflections</artifactId> + <version>0.9.9-RC1</version> + <scope>test</scope> + </dependency> + <dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> <version>${commons-collections}</version> diff --git a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/DaoCdiIntegrationTest.java b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/DaoCdiIntegrationTest.java new file mode 100644 index 0000000..be6a343 --- /dev/null +++ b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/DaoCdiIntegrationTest.java @@ -0,0 +1,40 @@ +package org.ovirt.engine.core.dao; + +import java.lang.reflect.Modifier; +import java.util.Collections; +import java.util.Set; + +import javax.inject.Singleton; + +import org.junit.BeforeClass; +import org.junit.Test; +import org.reflections.Reflections; + +import static org.junit.Assert.assertTrue; + +public class DaoCdiIntegrationTest { + + private static Set<Class<? extends DAO>> daos; + + @BeforeClass + public static void setUp() throws Exception { + final Reflections reflections = new Reflections("org.ovirt.engine"); + + daos = Collections.unmodifiableSet(reflections.getSubTypesOf(DAO.class)); + } + + @Test + public void testSingletonDaoAnnotation() { + + for (Class<? extends DAO> dao : daos) { + if (isConcreteClass(dao)) { + assertTrue("A concrete DAO class has to be annotated with @Singleton: " + dao.getCanonicalName(), + dao.isAnnotationPresent(Singleton.class)); + } + } + } + + private boolean isConcreteClass(Class<? extends DAO> clazz) { + return !(clazz.isInterface() || Modifier.isAbstract(clazz.getModifiers())); + } +} -- To view, visit https://gerrit.ovirt.org/39572 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8057dfce430cb3ce6a35181479b8999b4a1fe264 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Yevgeny Zaspitsky <yzasp...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches