From 8133a2c491d5d59c35af8a7d55dba506ade3c8fa Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Fri, 18 Jan 2013 15:40:58 +0100 Subject: SONAR-4069 Refactoring of Task extension * @RequiresProject is no more in API * Simplify TaskModule --- .../batch/bootstrap/AbstractTaskModuleTest.java | 65 ---------------------- .../org/sonar/batch/bootstrap/TaskModuleTest.java | 65 ++++++++++++++++++++++ 2 files changed, 65 insertions(+), 65 deletions(-) delete mode 100644 sonar-batch/src/test/java/org/sonar/batch/bootstrap/AbstractTaskModuleTest.java create mode 100644 sonar-batch/src/test/java/org/sonar/batch/bootstrap/TaskModuleTest.java (limited to 'sonar-batch/src/test/java/org/sonar') diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/AbstractTaskModuleTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/AbstractTaskModuleTest.java deleted file mode 100644 index 4963c9cd0c8..00000000000 --- a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/AbstractTaskModuleTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2012 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.batch.bootstrap; - -import org.junit.Test; -import org.sonar.api.platform.ComponentContainer; -import org.sonar.api.task.TaskDefinition; - -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - -public class AbstractTaskModuleTest { - @Test - public void should_register_task_extensions_when_project_present() { - final ExtensionInstaller extensionInstaller = mock(ExtensionInstaller.class); - Module bootstrapModule = new Module() { - @Override - protected void configure() { - // used to install project extensions - container.addSingleton(extensionInstaller); - } - }; - bootstrapModule.init(); - ProjectTaskModule module = new ProjectTaskModule(TaskDefinition.create()); - bootstrapModule.installChild(module); - - verify(extensionInstaller).installTaskExtensions(any(ComponentContainer.class), eq(true)); - } - - @Test - public void should_register_task_extensions_when_no_project() { - final ExtensionInstaller extensionInstaller = mock(ExtensionInstaller.class); - Module bootstrapModule = new Module() { - @Override - protected void configure() { - // used to install project extensions - container.addSingleton(extensionInstaller); - } - }; - bootstrapModule.init(); - ProjectLessTaskModule module = new ProjectLessTaskModule(TaskDefinition.create()); - bootstrapModule.installChild(module); - - verify(extensionInstaller).installTaskExtensions(any(ComponentContainer.class), eq(false)); - } -} diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/TaskModuleTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/TaskModuleTest.java new file mode 100644 index 00000000000..e5b7f49b035 --- /dev/null +++ b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/TaskModuleTest.java @@ -0,0 +1,65 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2012 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * Sonar is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.batch.bootstrap; + +import org.junit.Test; +import org.sonar.api.platform.ComponentContainer; +import org.sonar.api.task.TaskDefinition; + +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + +public class TaskModuleTest { + @Test + public void should_register_task_extensions_when_project_present() { + final ExtensionInstaller extensionInstaller = mock(ExtensionInstaller.class); + Module bootstrapModule = new Module() { + @Override + protected void configure() { + // used to install project extensions + container.addSingleton(extensionInstaller); + } + }; + bootstrapModule.init(); + TaskModule module = new TaskModule(TaskDefinition.create(), true); + bootstrapModule.installChild(module); + + verify(extensionInstaller).installTaskExtensions(any(ComponentContainer.class), eq(true)); + } + + @Test + public void should_register_task_extensions_when_no_project() { + final ExtensionInstaller extensionInstaller = mock(ExtensionInstaller.class); + Module bootstrapModule = new Module() { + @Override + protected void configure() { + // used to install project extensions + container.addSingleton(extensionInstaller); + } + }; + bootstrapModule.init(); + TaskModule module = new TaskModule(TaskDefinition.create(), false); + bootstrapModule.installChild(module); + + verify(extensionInstaller).installTaskExtensions(any(ComponentContainer.class), eq(false)); + } +} -- cgit v1.2.3