diff options
Diffstat (limited to 'it/it-plugins/ui-extensions-plugin')
18 files changed, 324 insertions, 0 deletions
diff --git a/it/it-plugins/ui-extensions-plugin/pom.xml b/it/it-plugins/ui-extensions-plugin/pom.xml new file mode 100644 index 00000000000..aa8439349b4 --- /dev/null +++ b/it/it-plugins/ui-extensions-plugin/pom.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.sonarsource.sonarqube</groupId> + <artifactId>it-plugins</artifactId> + <version>5.5-SNAPSHOT</version> + </parent> + + <artifactId>ui-extensions-plugin</artifactId> + <version>1.0-SNAPSHOT</version> + <packaging>sonar-plugin</packaging> + <name>SonarQube Integration Tests :: Plugins :: UI extensions</name> + <description>Main plugin for UT extensions tests</description> + + <dependencies> + <dependency> + <groupId>org.sonarsource.sonarqube</groupId> + <artifactId>sonar-plugin-api</artifactId> + <version>${apiVersion}</version> + <scope>provided</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId> + <artifactId>sonar-packaging-maven-plugin</artifactId> + <version>1.15</version> + <extensions>true</extensions> + <configuration> + <pluginClass>UiExtensionsPlugin</pluginClass> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/it/it-plugins/ui-extensions-plugin/src/main/java/FakePageDecorations.java b/it/it-plugins/ui-extensions-plugin/src/main/java/FakePageDecorations.java new file mode 100644 index 00000000000..bc05bb2288b --- /dev/null +++ b/it/it-plugins/ui-extensions-plugin/src/main/java/FakePageDecorations.java @@ -0,0 +1,28 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program 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. + * + * This program 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import org.sonar.api.web.PageDecoration; + +public class FakePageDecorations extends PageDecoration { + + @Override + protected String getTemplatePath() { + return "/fake_page_decoration.html.erb"; + } +} diff --git a/it/it-plugins/ui-extensions-plugin/src/main/java/ResourceConfigurationPage.java b/it/it-plugins/ui-extensions-plugin/src/main/java/ResourceConfigurationPage.java new file mode 100644 index 00000000000..b804359642d --- /dev/null +++ b/it/it-plugins/ui-extensions-plugin/src/main/java/ResourceConfigurationPage.java @@ -0,0 +1,39 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program 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. + * + * This program 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import org.sonar.api.resources.Qualifiers; +import org.sonar.api.web.NavigationSection; +import org.sonar.api.web.Page; +import org.sonar.api.web.ResourceQualifier; +import org.sonar.api.web.UserRole; + +@NavigationSection(NavigationSection.RESOURCE_CONFIGURATION) +@UserRole(UserRole.ADMIN) +@ResourceQualifier({Qualifiers.PROJECT}) +public class ResourceConfigurationPage implements Page { + + public String getId() { + return "/resource_configuration_sample"; + } + + public String getTitle() { + return "Resource Configuration"; + } + +} diff --git a/it/it-plugins/ui-extensions-plugin/src/main/java/RubyApiGlobalPage.java b/it/it-plugins/ui-extensions-plugin/src/main/java/RubyApiGlobalPage.java new file mode 100644 index 00000000000..37c3ae6e180 --- /dev/null +++ b/it/it-plugins/ui-extensions-plugin/src/main/java/RubyApiGlobalPage.java @@ -0,0 +1,40 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program 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. + * + * This program 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import org.sonar.api.web.AbstractRubyTemplate; +import org.sonar.api.web.NavigationSection; +import org.sonar.api.web.RubyRailsPage; + +@NavigationSection({NavigationSection.HOME}) +public class RubyApiGlobalPage extends AbstractRubyTemplate implements RubyRailsPage { + + public String getId() { + return getClass().getName(); + } + + public String getTitle() { + return "Ruby API Global Page"; + } + + @Override + public String getTemplatePath() { + return "/ruby-api-global-page.erb"; + } + +} diff --git a/it/it-plugins/ui-extensions-plugin/src/main/java/RubyApiProjectPage.java b/it/it-plugins/ui-extensions-plugin/src/main/java/RubyApiProjectPage.java new file mode 100644 index 00000000000..c868215ba11 --- /dev/null +++ b/it/it-plugins/ui-extensions-plugin/src/main/java/RubyApiProjectPage.java @@ -0,0 +1,42 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program 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. + * + * This program 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import org.sonar.api.web.AbstractRubyTemplate; +import org.sonar.api.web.NavigationSection; +import org.sonar.api.web.RubyRailsPage; +import org.sonar.api.web.UserRole; + +@NavigationSection({NavigationSection.RESOURCE}) +@UserRole(UserRole.USER) +public class RubyApiProjectPage extends AbstractRubyTemplate implements RubyRailsPage { + + public String getId() { + return getClass().getName(); + } + + public String getTitle() { + return "Ruby API Project Page"; + } + + @Override + public String getTemplatePath() { + return "/ruby-api-project-page.erb"; + } + +} diff --git a/it/it-plugins/ui-extensions-plugin/src/main/java/UiExtensionsPlugin.java b/it/it-plugins/ui-extensions-plugin/src/main/java/UiExtensionsPlugin.java new file mode 100644 index 00000000000..e75149eb32d --- /dev/null +++ b/it/it-plugins/ui-extensions-plugin/src/main/java/UiExtensionsPlugin.java @@ -0,0 +1,34 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program 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. + * + * This program 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import java.util.Arrays; +import java.util.List; +import org.sonar.api.SonarPlugin; + +public class UiExtensionsPlugin extends SonarPlugin { + public List getExtensions() { + return Arrays.asList( + FakePageDecorations.class, + RubyApiGlobalPage.class, + RubyApiProjectPage.class, + ResourceConfigurationPage.class + ); + } +} diff --git a/it/it-plugins/ui-extensions-plugin/src/main/resources/fake_page_decoration.html.erb b/it/it-plugins/ui-extensions-plugin/src/main/resources/fake_page_decoration.html.erb new file mode 100644 index 00000000000..e888224f7b2 --- /dev/null +++ b/it/it-plugins/ui-extensions-plugin/src/main/resources/fake_page_decoration.html.erb @@ -0,0 +1,22 @@ +<% content_for :script do %> + <script> + function fakeFooter() { + $j('#fake-footer').html("Footer generated by plugin"); + } + </script> +<% end %> + + + +<% content_for :header do %> + <div id="fake-header">Header generated by plugin</div> +<% end %> + + + +<% content_for :footer do %> + <div id="fake-footer"></div> + <script> + fakeFooter(); + </script> +<% end %> diff --git a/it/it-plugins/ui-extensions-plugin/src/main/resources/org/sonar/ror/uiextensionsplugin/app/controllers/fake_app_controller.rb b/it/it-plugins/ui-extensions-plugin/src/main/resources/org/sonar/ror/uiextensionsplugin/app/controllers/fake_app_controller.rb new file mode 100644 index 00000000000..6442fac5140 --- /dev/null +++ b/it/it-plugins/ui-extensions-plugin/src/main/resources/org/sonar/ror/uiextensionsplugin/app/controllers/fake_app_controller.rb @@ -0,0 +1,10 @@ +class FakeAppController < ApplicationController + SECTION=Navigation::SECTION_HOME + def index + @title = 'Fake application' + end + + def advanced + render :partial => 'fake_app/advanced', :locals => {:properties => Property.find(:all)} + end +end diff --git a/it/it-plugins/ui-extensions-plugin/src/main/resources/org/sonar/ror/uiextensionsplugin/app/controllers/resource_configuration_sample_controller.rb b/it/it-plugins/ui-extensions-plugin/src/main/resources/org/sonar/ror/uiextensionsplugin/app/controllers/resource_configuration_sample_controller.rb new file mode 100644 index 00000000000..9d735a0e551 --- /dev/null +++ b/it/it-plugins/ui-extensions-plugin/src/main/resources/org/sonar/ror/uiextensionsplugin/app/controllers/resource_configuration_sample_controller.rb @@ -0,0 +1,9 @@ +class ResourceConfigurationSampleController < ApplicationController + + SECTION=Navigation::SECTION_RESOURCE + + def index + init_resource_for_role(:user, :resource) if params[:resource] + end + +end diff --git a/it/it-plugins/ui-extensions-plugin/src/main/resources/org/sonar/ror/uiextensionsplugin/app/helpers/fake_app_helper.rb b/it/it-plugins/ui-extensions-plugin/src/main/resources/org/sonar/ror/uiextensionsplugin/app/helpers/fake_app_helper.rb new file mode 100644 index 00000000000..dbe0021b17a --- /dev/null +++ b/it/it-plugins/ui-extensions-plugin/src/main/resources/org/sonar/ror/uiextensionsplugin/app/helpers/fake_app_helper.rb @@ -0,0 +1,5 @@ +module FakeAppHelper + def call_helper + 'message generated by helper' + end +end diff --git a/it/it-plugins/ui-extensions-plugin/src/main/resources/org/sonar/ror/uiextensionsplugin/app/views/fake_app/_advanced.html.erb b/it/it-plugins/ui-extensions-plugin/src/main/resources/org/sonar/ror/uiextensionsplugin/app/views/fake_app/_advanced.html.erb new file mode 100644 index 00000000000..082cd4c8728 --- /dev/null +++ b/it/it-plugins/ui-extensions-plugin/src/main/resources/org/sonar/ror/uiextensionsplugin/app/views/fake_app/_advanced.html.erb @@ -0,0 +1,9 @@ +<div id="fake-div"> + +<p>This page requests database and use RoR partial</p> + +<% unless properties.empty? %> + <p>Database connection OK</p> +<% end %> + +</div>
\ No newline at end of file diff --git a/it/it-plugins/ui-extensions-plugin/src/main/resources/org/sonar/ror/uiextensionsplugin/app/views/fake_app/index.html.erb b/it/it-plugins/ui-extensions-plugin/src/main/resources/org/sonar/ror/uiextensionsplugin/app/views/fake_app/index.html.erb new file mode 100644 index 00000000000..3686424c668 --- /dev/null +++ b/it/it-plugins/ui-extensions-plugin/src/main/resources/org/sonar/ror/uiextensionsplugin/app/views/fake_app/index.html.erb @@ -0,0 +1,2 @@ +<span id="fake-app"><%= @title -%></span> +<span id="helper-test"><%= call_helper -%></span> diff --git a/it/it-plugins/ui-extensions-plugin/src/main/resources/org/sonar/ror/uiextensionsplugin/app/views/resource_configuration_sample/index.html.erb b/it/it-plugins/ui-extensions-plugin/src/main/resources/org/sonar/ror/uiextensionsplugin/app/views/resource_configuration_sample/index.html.erb new file mode 100644 index 00000000000..b2b22ef23c7 --- /dev/null +++ b/it/it-plugins/ui-extensions-plugin/src/main/resources/org/sonar/ror/uiextensionsplugin/app/views/resource_configuration_sample/index.html.erb @@ -0,0 +1,2 @@ +<div>Hello <%= @resource.key %> ! </div> + diff --git a/it/it-plugins/ui-extensions-plugin/src/main/resources/org/sonar/ror/uiextensionsplugin/init.rb b/it/it-plugins/ui-extensions-plugin/src/main/resources/org/sonar/ror/uiextensionsplugin/init.rb new file mode 100644 index 00000000000..65006bed958 --- /dev/null +++ b/it/it-plugins/ui-extensions-plugin/src/main/resources/org/sonar/ror/uiextensionsplugin/init.rb @@ -0,0 +1 @@ +# initialization script
\ No newline at end of file diff --git a/it/it-plugins/ui-extensions-plugin/src/main/resources/ruby-api-global-page.erb b/it/it-plugins/ui-extensions-plugin/src/main/resources/ruby-api-global-page.erb new file mode 100644 index 00000000000..40aea8687f9 --- /dev/null +++ b/it/it-plugins/ui-extensions-plugin/src/main/resources/ruby-api-global-page.erb @@ -0,0 +1,33 @@ +<h1>Ruby API Global Page</h1> + +<% success=true %> + +<% if logged_in? %> + <h2>User Properties</h2> + <ul id="user_properties"> + <% + current_user.set_property({:prop_key => 'foo', :text_value => 'bar'}) + test=current_user.property_value('foo')=='bar' + success&=test + %> + <li>create: <%= 'OK' if test -%></li> + + <% + current_user.delete_property('foo') + test=current_user.property('foo').nil? + success&=test + %> + <li>delete: <%= 'OK' if test -%></li> + + <% + current_user.set_property({:prop_key => 'foo', :text_value => 'bar'}) + current_user.set_property({:prop_key => 'foo', :text_value => 'newbar'}) + test=current_user.property_value('foo')=='newbar' + success&=test + %> + <li>update: <%= 'OK' if test -%></li> + </ul> +<% end %> + +<br/> +<p>Result: <span id="ruby-api-result"><%= success ? 'OK' : 'FAIL' %></span></p> diff --git a/it/it-plugins/ui-extensions-plugin/src/main/resources/ruby-api-project.page.rb b/it/it-plugins/ui-extensions-plugin/src/main/resources/ruby-api-project.page.rb new file mode 100644 index 00000000000..7cbc55a983d --- /dev/null +++ b/it/it-plugins/ui-extensions-plugin/src/main/resources/ruby-api-project.page.rb @@ -0,0 +1,3 @@ +<h1>Ruby API Project</h1> + +<p>Project name is: <span id="ruby-api-project"><%= @project.name -%></span></p> diff --git a/it/it-plugins/ui-extensions-plugin/src/main/resources/static/cute.jpg b/it/it-plugins/ui-extensions-plugin/src/main/resources/static/cute.jpg Binary files differnew file mode 100644 index 00000000000..20f59bc1c42 --- /dev/null +++ b/it/it-plugins/ui-extensions-plugin/src/main/resources/static/cute.jpg diff --git a/it/it-plugins/ui-extensions-plugin/src/main/resources/static/file.html b/it/it-plugins/ui-extensions-plugin/src/main/resources/static/file.html new file mode 100644 index 00000000000..6b0300e5f19 --- /dev/null +++ b/it/it-plugins/ui-extensions-plugin/src/main/resources/static/file.html @@ -0,0 +1,6 @@ +<html> + <body> + Text from static resource + <img id="cute-image" src="cute.jpg"/> + </body> +</html> |