assertNoCacheInBrowser(response);
}
- @Test
- public void verify_headers_of_ruby_ws() throws Exception {
- Response response = call(orchestrator.getServer().getUrl() + "/api/projects/index");
-
- verifySecurityHeaders(response);
- verifyContentType(response, "application/json;charset=utf-8");
- assertNoCacheInBrowser(response);
- }
-
@Test
public void verify_headers_of_images() throws Exception {
Response response = call(orchestrator.getServer().getUrl() + "/images/logo.svg");
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
-import org.sonar.api.component.Component;
-import org.sonar.api.component.RubyComponentService;
import org.sonar.api.resources.Qualifiers;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import static org.sonar.server.component.NewComponent.newComponentBuilder;
-public class DefaultRubyComponentService implements RubyComponentService {
+/**
+ * Used in GOV
+ */
+public class DefaultRubyComponentService {
private final DbClient dbClient;
private final ComponentService componentService;
this.defaultOrganizationProvider = defaultOrganizationProvider;
}
- @Override
- @CheckForNull
- public Component findByKey(String key) {
- try (DbSession dbSession = dbClient.openSession(false)) {
- return dbClient.componentDao().selectByKey(dbSession, key).orNull();
- }
- }
-
// Used in GOV
@CheckForNull
public Long createComponent(String key, String name, String qualifier) {
- return createComponent(key, null, name, qualifier);
- }
-
- // Used in rails
- @CheckForNull
- public Long createComponent(String key, @Nullable String branch, String name, @Nullable String qualifier) {
try (DbSession dbSession = dbClient.openSession(false)) {
- return createComponent(dbSession, key, branch, name, qualifier);
+ return createComponent(dbSession, key, null, name, qualifier);
}
}
import org.sonar.db.measure.custom.CustomMeasureDto;
import org.sonar.db.metric.MetricDto;
import org.sonar.server.exceptions.BadRequestException;
-import org.sonar.server.ruby.RubyBridge;
import org.sonar.server.user.UserSession;
import static org.sonar.server.util.MetricKeyValidator.checkMetricKeyFormat;
private final DbClient dbClient;
private final UserSession userSession;
- private final RubyBridge rubyBridge;
- public CreateAction(DbClient dbClient, UserSession userSession, RubyBridge rubyBridge) {
+ public CreateAction(DbClient dbClient, UserSession userSession) {
this.dbClient = dbClient;
this.userSession = userSession;
- this.rubyBridge = rubyBridge;
}
@Override
JsonWriter json = response.newJsonWriter();
writeMetric(json, metricInDb);
json.close();
- rubyBridge.metricCache().invalidate();
} finally {
MyBatis.closeQuietly(dbSession);
}
import org.sonar.db.DbSession;
import org.sonar.db.MyBatis;
import org.sonar.db.metric.MetricDto;
-import org.sonar.server.ruby.RubyBridge;
import org.sonar.server.user.UserSession;
import static com.google.common.base.Preconditions.checkArgument;
private final DbClient dbClient;
private final UserSession userSession;
- private final RubyBridge rubyBridge;
- public DeleteAction(DbClient dbClient, UserSession userSession, RubyBridge rubyBridge) {
+ public DeleteAction(DbClient dbClient, UserSession userSession) {
this.dbClient = dbClient;
this.userSession = userSession;
- this.rubyBridge = rubyBridge;
}
@Override
}
response.noContent();
- rubyBridge.metricCache().invalidate();
}
private List<Integer> loadIds(DbSession dbSession, Request request) {
import org.sonar.db.measure.custom.CustomMeasureDto;
import org.sonar.db.metric.MetricDto;
import org.sonar.server.exceptions.BadRequestException;
-import org.sonar.server.ruby.RubyBridge;
import org.sonar.server.user.UserSession;
import org.sonar.server.util.MetricKeyValidator;
private final DbClient dbClient;
private final UserSession userSession;
- private final RubyBridge rubyBridge;
- public UpdateAction(DbClient dbClient, UserSession userSession, RubyBridge rubyBridge) {
+ public UpdateAction(DbClient dbClient, UserSession userSession) {
this.dbClient = dbClient;
this.userSession = userSession;
- this.rubyBridge = rubyBridge;
}
@Override
JsonWriter json = response.newJsonWriter();
writeMetric(json, metricInDb);
json.close();
- rubyBridge.metricCache().invalidate();
} finally {
MyBatis.closeQuietly(dbSession);
}
import org.sonar.server.platform.Platform;
import org.sonar.server.platform.db.migration.engine.MigrationEngine;
import org.sonar.server.platform.db.migration.step.MigrationStepExecutionException;
-import org.sonar.server.ruby.RubyBridge;
import static org.sonar.server.platform.db.migration.DatabaseMigrationState.Status;
* ExecutorService implements threads management.
*/
private final DatabaseMigrationExecutorService executorService;
- private final RubyBridge rubyBridge;
private final MigrationEngine migrationEngine;
private final Platform platform;
private final MutableDatabaseMigrationState migrationState;
private final AtomicBoolean running = new AtomicBoolean(false);
public DatabaseMigrationImpl(DatabaseMigrationExecutorService executorService, MutableDatabaseMigrationState migrationState,
- RubyBridge rubyBridge, MigrationEngine migrationEngine, Platform platform) {
+ MigrationEngine migrationEngine, Platform platform) {
this.executorService = executorService;
this.migrationState = migrationState;
- this.rubyBridge = rubyBridge;
this.migrationEngine = migrationEngine;
this.platform = platform;
}
profiler.startInfo("Starting DB Migration and container restart");
doUpgradeDb();
doRestartContainer();
- doRecreateWebRoutes();
migrationState.setStatus(Status.SUCCEEDED);
profiler.stopInfo("DB Migration and container restart: success");
} catch (MigrationStepExecutionException e) {
profiler.stopTrace("Container restarted successfully");
}
- private void doRecreateWebRoutes() {
- Profiler profiler = Profiler.createIfTrace(LOGGER);
- profiler.startTrace("Recreating web routes");
- rubyBridge.railsRoutes().recreate();
- profiler.startTrace("Routes recreated successfully");
- }
-
}
import org.sonar.server.platform.cluster.ClusterProperties;
import org.sonar.server.platform.db.EmbeddedDatabaseFactory;
import org.sonar.server.qualityprofile.index.ActiveRuleIndex;
-import org.sonar.server.ruby.PlatformRackBridge;
import org.sonar.server.rule.index.RuleIndex;
import org.sonar.server.search.EsSearchModule;
import org.sonar.server.setting.ThreadLocalSettings;
new TempFolderProvider(),
System2.INSTANCE,
- // rack bridges
- PlatformRackBridge.class,
-
// user session
ThreadLocalUserSession.class,
import org.sonar.server.platform.db.migration.history.MigrationHistoryTable;
import org.sonar.server.platform.db.migration.history.MigrationHistoryTableImpl;
import org.sonar.server.platform.db.migration.version.DatabaseVersion;
-import org.sonar.server.platform.web.RailsAppsDeployer;
import org.sonar.server.plugins.InstalledPluginReferentialFactory;
import org.sonar.server.plugins.ServerPluginJarExploder;
import org.sonar.server.plugins.ServerPluginRepository;
import org.sonar.server.plugins.WebServerExtensionInstaller;
-import org.sonar.server.ruby.PlatformRubyBridge;
-import org.sonar.server.ui.JRubyI18n;
public class PlatformLevel2 extends PlatformLevel {
public PlatformLevel2(PlatformLevel parent) {
new StartupMetadataProvider(),
DefaultServerUpgradeStatus.class,
Durations.class,
- JRubyI18n.class,
-
- // depends on Ruby
- PlatformRubyBridge.class,
// plugins
ServerPluginRepository.class,
WebServerExtensionInstaller.class,
// depends on plugins
- RailsAppsDeployer.class,
DefaultI18n.class,
RuleI18nManager.class);
import org.sonar.server.test.ws.CoveredFilesAction;
import org.sonar.server.test.ws.TestsWs;
import org.sonar.server.text.MacroInterpreter;
+import org.sonar.server.ui.DeprecatedViews;
import org.sonar.server.ui.PageDecorations;
import org.sonar.server.ui.PageRepository;
-import org.sonar.server.ui.DeprecatedViews;
import org.sonar.server.ui.ws.NavigationWsModule;
import org.sonar.server.updatecenter.UpdateCenterModule;
import org.sonar.server.user.DefaultUserFinder;
-import org.sonar.server.user.DefaultUserService;
import org.sonar.server.user.DeprecatedUserFinder;
import org.sonar.server.user.NewUserNotifier;
import org.sonar.server.user.SecurityRealmFactory;
DeprecatedUserFinder.class,
NewUserNotifier.class,
DefaultUserFinder.class,
- DefaultUserService.class,
UserIndexDefinition.class,
UserIndexer.class,
UserIndex.class,
+++ /dev/null
-/*
- * 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.
- */
-package org.sonar.server.platform.web;
-
-import com.google.common.annotations.VisibleForTesting;
-import java.io.File;
-import java.io.IOException;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang.StringUtils;
-import org.picocontainer.Startable;
-import org.sonar.api.Plugin;
-import org.sonar.api.utils.log.Logger;
-import org.sonar.api.utils.log.Loggers;
-import org.sonar.core.platform.PluginInfo;
-import org.sonar.core.platform.PluginRepository;
-import org.sonar.server.platform.ServerFileSystem;
-import org.sonar.server.util.ClassLoaderUtils;
-
-/**
- * Ruby on Rails requires the files to be on filesystem but not in Java classpath (JAR). This component extracts
- * all the needed files from plugins and copy them to $SONAR_HOME/temp
- *
- * @since 3.0
- */
-public class RailsAppsDeployer implements Startable {
-
- private static final Logger LOG = Loggers.get(RailsAppsDeployer.class);
- private static final String ROR_PATH = "org/sonar/ror/";
-
- private final ServerFileSystem fs;
- private final PluginRepository pluginRepository;
-
- public RailsAppsDeployer(ServerFileSystem fs, PluginRepository pluginRepository) {
- this.fs = fs;
- this.pluginRepository = pluginRepository;
- }
-
- @Override
- public void start() {
- LOG.info("Deploying Ruby on Rails applications");
- File appsDir = prepareRailsDirectory();
-
- for (PluginInfo pluginInfo : pluginRepository.getPluginInfos()) {
- String pluginKey = pluginInfo.getKey();
- Plugin plugin = pluginRepository.getPluginInstance(pluginKey);
- try {
- deployRailsApp(appsDir, pluginKey, plugin.getClass().getClassLoader());
- } catch (Exception e) {
- throw new IllegalStateException(String.format("Fail to deploy Ruby on Rails application of plugin [%s]", pluginKey), e);
- }
- }
- }
-
- @Override
- public void stop() {
- // do nothing
- }
-
- @VisibleForTesting
- File prepareRailsDirectory() {
- File appsDir = new File(fs.getTempDir(), "ror");
- prepareDir(appsDir);
- return appsDir;
- }
-
- @VisibleForTesting
- static void deployRailsApp(File appsDir, final String pluginKey, ClassLoader appClassLoader) {
- if (hasRailsApp(pluginKey, appClassLoader)) {
- LOG.info("Deploying app: " + pluginKey);
- File appDir = new File(appsDir, pluginKey);
- ClassLoaderUtils.copyResources(appClassLoader, pathToRubyInitFile(pluginKey), appDir, relativePath ->
- // Relocate the deployed files :
- // relativePath format is: org/sonar/ror/sqale/app/controllers/foo_controller.rb
- // app path is: org/sonar/ror/sqale
- // -> deployed file is app/controllers/foo_controller.rb
- StringUtils.substringAfter(relativePath, pluginKey + "/")
- );
- }
- }
-
- private static String pathToRubyInitFile(String pluginKey) {
- return ROR_PATH + pluginKey + "/init.rb";
- }
-
- @VisibleForTesting
- static boolean hasRailsApp(String pluginKey, ClassLoader classLoader) {
- return classLoader.getResource(pathToRubyInitFile(pluginKey)) != null;
- }
-
- private void prepareDir(File appsDir) {
- if (appsDir.exists() && appsDir.isDirectory()) {
- try {
- org.sonar.core.util.FileUtils.deleteDirectory(appsDir);
- } catch (IOException e) {
- throw new IllegalStateException("Fail to delete temp directory: " + appsDir, e);
- }
- }
- try {
- FileUtils.forceMkdir(appsDir);
- } catch (IOException e) {
- throw new IllegalStateException("Fail to create temp directory: " + appsDir, e);
- }
- }
-}
+++ /dev/null
-/*
- * 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.
- */
-package org.sonar.server.platform.web;
-
-import com.google.common.base.Throwables;
-import javax.servlet.ServletContextEvent;
-import org.jruby.rack.RackApplicationFactory;
-import org.jruby.rack.rails.RailsServletContextListener;
-import org.jruby.rack.servlet.ServletRackContext;
-
-/**
- * Overriding {@link RailsServletContextListener} allows to disable initialization of Ruby on Rails
- * environment when Java components fail to start.
- * See https://jira.sonarsource.com/browse/SONAR-6740
- */
-public class RubyRailsContextListener extends RailsServletContextListener {
-
- @Override
- public void contextInitialized(ServletContextEvent event) {
- if (event.getServletContext().getAttribute(PlatformServletContextListener.STARTED_ATTRIBUTE) != null) {
- super.contextInitialized(event);
- }
- }
-
- // Always stop server when an error is raised during startup.
- // By default Rack only logs an error (see org.jruby.rack.RackServletContextListener#handleInitializationException()).
- // Rack propagates exceptions if the properties jruby.rack.exception or jruby.rack.error are set to true.
- // Unfortunately we didn't succeed in defining these properties, so the method is overridden here.
- // Initial need: SONAR-6171
- @Override
- protected void handleInitializationException(Exception e, RackApplicationFactory factory, ServletRackContext rackContext) {
- throw Throwables.propagate(e);
- }
-}
+++ /dev/null
-/*
- * 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.
- */
-package org.sonar.server.ruby;
-
-public interface CallInvalidateMetricCache {
- void callInvalidate();
-}
+++ /dev/null
-/*
- * 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.
- */
-package org.sonar.server.ruby;
-
-/**
- * Interface which must be a top-level public class to be used by the Ruby engine but that hides name of the Ruby
- * method in the Ruby script from the rest of the platform (only {@link RubyRailsRoutes} is known to the platform).
- */
-public interface CallLoadJavaWebServices {
- /**
- * Java method that calls the call_upgrade_and_start method defined in the {@code call_load_java_web_services.rb} script.
- */
- void callLoadJavaWebServices();
-}
+++ /dev/null
-/*
- * 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.
- */
-package org.sonar.server.ruby;
-
-import org.jruby.Ruby;
-import org.jruby.rack.RackApplicationFactory;
-
-import javax.servlet.ServletContext;
-import javax.servlet.ServletContextEvent;
-
-/**
- * Implementation of {@link RackBridge} which get access to the Rack object through the {@link ServletContext}.
- */
-public class PlatformRackBridge implements RackBridge {
- public static final String RACK_FACTORY_ATTR_KEY = "rack.factory";
- private final ServletContext servletContext;
-
- public PlatformRackBridge(ServletContext servletContext) {
- this.servletContext = servletContext;
- }
-
- /**
- * From {@link org.jruby.rack.RackServletContextListener#contextInitialized(ServletContextEvent)} implementation, we
- * know that the {@link RackApplicationFactory} is stored in the {@link ServletContext} under the attribute key
- * {@link #RACK_FACTORY_ATTR_KEY}.
- *
- * @return a {@link Ruby} object representing the runtime environment of the RoR application of the platform.
- *
- * @throws RuntimeException if the {@link RackApplicationFactory} can not be retrieved
- */
- @Override
- public Ruby getRubyRuntime() {
- Object attribute = servletContext.getAttribute(RACK_FACTORY_ATTR_KEY);
- if (!(attribute instanceof RackApplicationFactory)) {
- throw new RuntimeException("Can not retrieve the RackApplicationFactory from ServletContext. " +
- "Ruby runtime can not be retrieved");
- }
-
- RackApplicationFactory rackApplicationFactory = (RackApplicationFactory) attribute;
- return rackApplicationFactory.getApplication().getRuntime();
- }
-}
+++ /dev/null
-/*
- * 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.
- */
-package org.sonar.server.ruby;
-
-import java.io.IOException;
-import java.io.InputStream;
-import javax.annotation.Nullable;
-import org.jruby.Ruby;
-import org.jruby.RubyNil;
-import org.jruby.embed.InvokeFailedException;
-import org.jruby.javasupport.JavaEmbedUtils;
-import org.jruby.javasupport.JavaUtil;
-import org.jruby.runtime.builtin.IRubyObject;
-
-public class PlatformRubyBridge implements RubyBridge {
- private static final String CALL_LOAD_JAVA_WEB_SERVICES_RB_FILENAME = "call_load_java_web_services.rb";
- private static final String CALL_INVALIDATE_METRIC_CACHE_RB_FILENAME = "call_invalidate_metric_cache.rb";
-
- private final RackBridge rackBridge;
-
- public PlatformRubyBridge(RackBridge rackBridge) {
- this.rackBridge = rackBridge;
- }
-
- @Override
- public RubyRailsRoutes railsRoutes() {
- CallLoadJavaWebServices callLoadJavaWebServices = parseMethodScriptToInterface(
- CALL_LOAD_JAVA_WEB_SERVICES_RB_FILENAME, CallLoadJavaWebServices.class
- );
-
- return callLoadJavaWebServices::callLoadJavaWebServices;
- }
-
- @Override
- public RubyMetricCache metricCache() {
- CallInvalidateMetricCache callInvalidateMetricCache = parseMethodScriptToInterface(
- CALL_INVALIDATE_METRIC_CACHE_RB_FILENAME, CallInvalidateMetricCache.class
- );
-
- return callInvalidateMetricCache::callInvalidate;
- }
-
- /**
- * Parses a Ruby script that defines a single method and returns an instance of the specified interface type as a
- * wrapper to this Ruby method.
- */
- private <T> T parseMethodScriptToInterface(String fileName, Class<T> clazz) {
- try (InputStream in = getClass().getResourceAsStream(fileName)) {
- Ruby rubyRuntime = rackBridge.getRubyRuntime();
- JavaEmbedUtils.EvalUnit evalUnit = JavaEmbedUtils.newRuntimeAdapter().parse(rubyRuntime, in, fileName, 0);
- IRubyObject rubyObject = evalUnit.run();
- Object receiver = JavaEmbedUtils.rubyToJava(rubyObject);
- T wrapper = getInstance(rubyRuntime, receiver, clazz);
- return wrapper;
- } catch (IOException e) {
- throw new RuntimeException("Failed to load script " + fileName, e);
- }
- }
-
- /**
- * Fork of method {@link org.jruby.embed.internal.EmbedRubyInterfaceAdapterImpl#getInstance(Object, Class)}
- */
- @SuppressWarnings("unchecked")
- public <T> T getInstance(Ruby runtime, @Nullable Object receiver, @Nullable Class<T> clazz) {
- if (clazz == null || !clazz.isInterface()) {
- return null;
- }
- Object o;
- if (receiver == null || receiver instanceof RubyNil) {
- o = JavaEmbedUtils.rubyToJava(runtime, runtime.getTopSelf(), clazz);
- } else if (receiver instanceof IRubyObject) {
- o = JavaEmbedUtils.rubyToJava(runtime, (IRubyObject) receiver, clazz);
- } else {
- IRubyObject rubyReceiver = JavaUtil.convertJavaToRuby(runtime, receiver);
- o = JavaEmbedUtils.rubyToJava(runtime, rubyReceiver, clazz);
- }
- String name = clazz.getName();
- try {
- Class<T> c = (Class<T>) Class.forName(name, true, o.getClass().getClassLoader());
- return c.cast(o);
- } catch (ClassNotFoundException e) {
- throw new InvokeFailedException(e);
- }
- }
-
-}
+++ /dev/null
-/*
- * 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.
- */
-package org.sonar.server.ruby;
-
-import org.jruby.Ruby;
-
-/**
- * Acts as a bridge between the Java application of the platform and the Rack application.
- */
-public interface RackBridge {
- /**
- * Provides access to {@link Ruby} runtime instance created by the Rack application.
- * @return
- */
- Ruby getRubyRuntime();
-}
+++ /dev/null
-/*
- * 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.
- */
-package org.sonar.server.ruby;
-
-/**
- * This component acts as a bridge between a Ruby runtime and Java. Each method it defines creates a wrapping
- * Java object which an underlying Ruby implementation.
- */
-public interface RubyBridge {
-
- /**
- * Returns a class that allows calling the (re)creation of web routes in Rails.
- *
- * @return a {@link RubyRailsRoutes}
- */
- RubyRailsRoutes railsRoutes();
-
- RubyMetricCache metricCache();
-}
+++ /dev/null
-/*
- * 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.
- */
-package org.sonar.server.ruby;
-
-@FunctionalInterface
-public interface RubyMetricCache {
- void invalidate();
-}
+++ /dev/null
-/*
- * 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.
- */
-package org.sonar.server.ruby;
-
-@FunctionalInterface
-public interface RubyRailsRoutes {
- /**
- * Triggers the (re)creation of web route in Ruby On Rails.
- * <strong>This is not thread safe!</strong>
- */
- void recreate();
-}
+++ /dev/null
-/*
- * 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.
- */
-@ParametersAreNonnullByDefault
-package org.sonar.server.ruby;
-
-import javax.annotation.ParametersAreNonnullByDefault;
+++ /dev/null
-/*
- * 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.
- */
-package org.sonar.server.ui;
-
-import java.sql.Connection;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import java.util.Optional;
-import javax.annotation.Nullable;
-import org.sonar.api.Plugin;
-import org.sonar.api.config.PropertyDefinitions;
-import org.sonar.api.config.Settings;
-import org.sonar.api.resources.Language;
-import org.sonar.api.resources.ResourceType;
-import org.sonar.api.resources.ResourceTypes;
-import org.sonar.api.utils.log.Loggers;
-import org.sonar.api.web.RubyRailsWebservice;
-import org.sonar.core.platform.ComponentContainer;
-import org.sonar.core.platform.PluginInfo;
-import org.sonar.core.platform.PluginRepository;
-import org.sonar.core.timemachine.Periods;
-import org.sonar.db.Database;
-import org.sonar.db.DbClient;
-import org.sonar.db.DbSession;
-import org.sonar.db.property.PropertiesDao;
-import org.sonar.db.property.PropertyDto;
-import org.sonar.process.ProcessProperties;
-import org.sonar.server.component.ComponentCleanerService;
-import org.sonar.server.platform.PersistentSettings;
-import org.sonar.server.platform.Platform;
-import org.sonar.server.platform.db.migration.DatabaseMigrationState;
-import org.sonar.server.platform.db.migration.version.DatabaseVersion;
-import org.sonar.server.platform.ws.UpgradesAction;
-
-import static com.google.common.collect.Lists.newArrayList;
-import static org.sonar.server.platform.db.migration.DatabaseMigrationState.Status;
-
-public final class JRubyFacade {
-
- private static final JRubyFacade SINGLETON = new JRubyFacade();
-
- public static JRubyFacade getInstance() {
- return SINGLETON;
- }
-
- <T> T get(Class<T> componentType) {
- return getContainer().getComponentByType(componentType);
- }
-
- public Collection<ResourceType> getResourceTypes() {
- return get(ResourceTypes.class).getAllOrdered();
- }
-
- public ResourceType getResourceType(String qualifier) {
- return get(ResourceTypes.class).get(qualifier);
- }
-
- public List<String> getQualifiersWithProperty(final String propertyKey) {
- List<String> qualifiers = newArrayList();
- for (ResourceType type : getResourceTypes()) {
- if (type.getBooleanProperty(propertyKey) == Boolean.TRUE) {
- qualifiers.add(type.getQualifier());
- }
- }
- return qualifiers;
- }
-
- public Collection<String> getResourceLeavesQualifiers(String qualifier) {
- return get(ResourceTypes.class).getLeavesQualifiers(qualifier);
- }
-
- public Collection<String> getResourceChildrenQualifiers(String qualifier) {
- return get(ResourceTypes.class).getChildrenQualifiers(qualifier);
- }
-
- // PLUGINS ------------------------------------------------------------------
- public PropertyDefinitions getPropertyDefinitions() {
- return get(PropertyDefinitions.class);
- }
-
- /**
- * Used for WS api/updatecenter/installed_plugins, to be replaced by api/plugins/installed.
- */
- public Collection<PluginInfo> getPluginInfos() {
- return get(PluginRepository.class).getPluginInfos();
- }
-
- public Collection<RubyRailsWebservice> getRubyRailsWebservices() {
- return getContainer().getComponentsByType(RubyRailsWebservice.class);
- }
-
- public Collection<Language> getLanguages() {
- return getContainer().getComponentsByType(Language.class);
- }
-
- public Database getDatabase() {
- return get(Database.class);
- }
-
- public boolean isDbUptodate() {
- return getContainer().getComponentByType(DatabaseVersion.class).getStatus() == DatabaseVersion.Status.UP_TO_DATE;
- }
-
- /* PROFILES CONSOLE : RULES AND METRIC THRESHOLDS */
-
- public void saveProperty(String key, @Nullable Long componentId, @Nullable Long userId, @Nullable String value) {
- if (componentId == null && userId == null) {
- get(PersistentSettings.class).saveProperty(key, value);
- } else {
- DbClient dbClient = get(DbClient.class);
- PropertiesDao propertiesDao = dbClient.propertiesDao();
-
- try (DbSession dbSession = dbClient.openSession(false)) {
- if (value == null) {
- propertiesDao.delete(dbSession, new PropertyDto().setKey(key).setResourceId(componentId).setUserId(userId));
- } else {
- propertiesDao.saveProperty(dbSession, new PropertyDto().setKey(key).setResourceId(componentId).setUserId(userId).setValue(value));
- }
- dbSession.commit();
- }
- }
- }
-
- public String getConfigurationValue(String key) {
- return get(Settings.class).getString(key);
- }
-
- public Connection getConnection() {
- try {
- return get(Database.class).getDataSource().getConnection();
- } catch (Exception e) {
- /* activerecord does not correctly manage exceptions when connection can not be opened. */
- return null;
- }
- }
-
- public Object getComponentByClassname(String pluginKey, String className) {
- Plugin plugin = get(PluginRepository.class).getPluginInstance(pluginKey);
- try {
- Class componentClass = plugin.getClass().getClassLoader().loadClass(className);
- return get(componentClass);
- } catch (ClassNotFoundException e) {
- throw new IllegalStateException(String.format("Class [%s] not found in plugin [%s]", className, pluginKey), e);
- }
- }
-
- private JRubyI18n getJRubyI18n() {
- return get(JRubyI18n.class);
- }
-
- public String getMessage(String rubyLocale, String key, String defaultValue, Object... parameters) {
- return getJRubyI18n().message(rubyLocale, key, defaultValue, parameters);
- }
-
- /*
- * /!\ Used by Views
- */
- public void deleteResourceTree(String projectKey) {
- try {
- get(ComponentCleanerService.class).delete(projectKey);
- } catch (RuntimeException e) {
- Loggers.get(JRubyFacade.class).error("Fail to delete resource with key: " + projectKey, e);
- throw e;
- }
- }
-
- public void logError(String message) {
- Loggers.get(getClass()).error(message);
- }
-
- public String getServerHome() {
- return get(Settings.class).getString(ProcessProperties.PATH_HOME);
- }
-
- public ComponentContainer getContainer() {
- return Platform.getInstance().getContainer();
- }
-
- public String getPeriodLabel(int periodIndex) {
- return get(Periods.class).label(periodIndex);
- }
-
- public String getPeriodLabel(String mode, String param, Date date) {
- return get(Periods.class).label(mode, param, date);
- }
-
- public String getPeriodLabel(String mode, String param, String date) {
- return get(Periods.class).label(mode, param, date);
- }
-
- public String getPeriodAbbreviation(int periodIndex) {
- return get(Periods.class).abbreviation(periodIndex);
- }
-
- /**
- * Checks whether the SQ instance is up and running (ie. not in safemode and with an up-to-date database).
- * <p>
- * This method duplicates most of the logic code written in {@link UpgradesAction}
- * class. There is no need to refactor code to avoid this duplication since this method is only used by RoR code
- * which will soon be replaced by pure JS code based on the {@link UpgradesAction}
- * WebService.
- * </p>
- */
- public boolean isSonarAccessAllowed() {
- ComponentContainer container = Platform.getInstance().getContainer();
- DatabaseMigrationState databaseMigrationState = container.getComponentByType(DatabaseMigrationState.class);
- Status migrationStatus = databaseMigrationState.getStatus();
- if (migrationStatus == Status.RUNNING || migrationStatus == Status.FAILED) {
- return false;
- }
- if (migrationStatus == Status.SUCCEEDED) {
- return true;
- }
-
- DatabaseVersion databaseVersion = container.getComponentByType(DatabaseVersion.class);
- Optional<Long> currentVersion = databaseVersion.getVersion();
- if (!currentVersion.isPresent()) {
- throw new IllegalStateException("Version can not be retrieved from Database. Database is either blank or corrupted");
- }
- DatabaseVersion.Status status = databaseVersion.getStatus();
- if (status == DatabaseVersion.Status.UP_TO_DATE || status == DatabaseVersion.Status.REQUIRES_DOWNGRADE) {
- return true;
- }
-
- Database database = container.getComponentByType(Database.class);
- return !database.getDialect().supportsMigration();
- }
-
-}
+++ /dev/null
-/*
- * 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.
- */
-package org.sonar.server.ui;
-
-import com.google.common.collect.Maps;
-import java.util.Date;
-import java.util.Locale;
-import java.util.Map;
-import javax.annotation.Nullable;
-import org.apache.commons.lang.StringUtils;
-import org.sonar.api.server.ServerSide;
-import org.sonar.api.i18n.I18n;
-import org.sonar.api.utils.Duration;
-import org.sonar.api.utils.Durations;
-import org.sonar.server.user.UserSession;
-
-/**
- * Used through ruby code <pre>Internal.i18n</pre>
- *
- * Bridge between JRuby webapp and Java I18n component
- */
-@ServerSide
-public class JRubyI18n {
-
- private final I18n i18n;
- private final Durations durations;
- private final UserSession userSession;
- private Map<String, Locale> localesByRubyKey = Maps.newHashMap();
-
- public JRubyI18n(I18n i18n, Durations durations, UserSession userSession) {
- this.i18n = i18n;
- this.durations = durations;
- this.userSession = userSession;
- }
-
- Locale getLocale(String rubyKey) {
- Locale locale = localesByRubyKey.get(rubyKey);
- if (locale == null) {
- locale = toLocale(rubyKey);
- localesByRubyKey.put(rubyKey, locale);
- }
- return locale;
- }
-
- Map<String, Locale> getLocalesByRubyKey() {
- return localesByRubyKey;
- }
-
- public static Locale toLocale(@Nullable String rubyKey) {
- Locale locale;
- if (rubyKey == null) {
- locale = Locale.ENGLISH;
- } else {
- String[] fields = StringUtils.split(rubyKey, "-");
- if (fields.length == 1) {
- locale = new Locale(fields[0]);
- } else {
- locale = new Locale(fields[0], fields[1]);
- }
- }
- return locale;
- }
-
- public String message(String rubyLocale, String key, String defaultValue, Object... parameters) {
- return StringUtils.defaultString(i18n.message(getLocale(rubyLocale), key, defaultValue, parameters), key);
- }
-
- public String ageFromNow(Date date) {
- return i18n.ageFromNow(userSession.locale(), date);
- }
-
- public String formatDuration(Duration duration, String format) {
- return durations.format(userSession.locale(), duration, Durations.DurationFormat.valueOf(format));
- }
-
- public String formatLongDuration(long duration, String format) {
- return formatDuration(Duration.create(duration), format);
- }
-
- public String formatDateTime(Date date) {
- return i18n.formatDateTime(userSession.locale(), date);
- }
-
-}
+++ /dev/null
-/*
- * 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.
- */
-package org.sonar.server.user;
-
-import java.util.List;
-import java.util.Map;
-import javax.annotation.CheckForNull;
-import org.sonar.api.user.RubyUserService;
-import org.sonar.api.user.User;
-import org.sonar.api.user.UserFinder;
-import org.sonar.api.user.UserQuery;
-import org.sonar.server.util.RubyUtils;
-
-public class DefaultUserService implements RubyUserService {
-
- private final UserFinder finder;
-
- public DefaultUserService(UserFinder finder) {
- this.finder = finder;
- }
-
- @Override
- @CheckForNull
- public User findByLogin(String login) {
- return finder.findByLogin(login);
- }
-
- @Override
- public List<User> find(Map<String, Object> params) {
- UserQuery query = parseQuery(params);
- return finder.find(query);
- }
-
- private static UserQuery parseQuery(Map<String, Object> params) {
- UserQuery.Builder builder = UserQuery.builder();
- if (RubyUtils.toBoolean(params.get("includeDeactivated")) == Boolean.TRUE) {
- builder.includeDeactivated();
- }
- builder.logins(RubyUtils.toStrings(params.get("logins")));
- builder.searchText((String) params.get("s"));
- return builder.build();
- }
-}
import org.sonar.db.metric.MetricTesting;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.ServerException;
-import org.sonar.server.ruby.RubyBridge;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.WsTester;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
-import static org.mockito.Mockito.mock;
import static org.sonar.server.metric.ws.CreateAction.PARAM_DESCRIPTION;
import static org.sonar.server.metric.ws.CreateAction.PARAM_DOMAIN;
import static org.sonar.server.metric.ws.CreateAction.PARAM_KEY;
import static org.sonar.server.metric.ws.CreateAction.PARAM_NAME;
import static org.sonar.server.metric.ws.CreateAction.PARAM_TYPE;
-
public class CreateActionTest {
private static final String DEFAULT_KEY = "custom-metric-key";
@Before
public void setUp() {
- ws = new WsTester(new MetricsWs(new CreateAction(dbClient, userSessionRule, mock(RubyBridge.class, RETURNS_DEEP_STUBS))));
+ ws = new WsTester(new MetricsWs(new CreateAction(dbClient, userSessionRule)));
userSessionRule.login("login").setGlobalPermissions(GlobalPermissions.SYSTEM_ADMIN);
}
import org.sonar.db.metric.MetricDao;
import org.sonar.db.metric.MetricDto;
import org.sonar.server.exceptions.ForbiddenException;
-import org.sonar.server.ruby.RubyBridge;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.WsTester;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
-import static org.mockito.Mockito.mock;
import static org.sonar.db.metric.MetricTesting.newMetricDto;
-
public class DeleteActionTest {
@Rule
@Before
public void setUp() {
userSessionRule.login("login").setGlobalPermissions(GlobalPermissions.SYSTEM_ADMIN);
- ws = new WsTester(new MetricsWs(new DeleteAction(dbClient, userSessionRule, mock(RubyBridge.class, RETURNS_DEEP_STUBS))));
+ ws = new WsTester(new MetricsWs(new DeleteAction(dbClient, userSessionRule)));
metricDao = dbClient.metricDao();
}
import org.junit.Test;
import org.sonar.api.server.ws.WebService;
import org.sonar.db.DbClient;
-import org.sonar.server.ruby.RubyBridge;
import org.sonar.server.user.UserSession;
import org.sonar.server.ws.WsTester;
public void setUp() {
DbClient dbClient = mock(DbClient.class);
UserSession userSession = mock(UserSession.class);
- RubyBridge rubyBridge = mock(RubyBridge.class);
ws = new WsTester(new MetricsWs(
new SearchAction(dbClient),
- new CreateAction(dbClient, userSession, rubyBridge),
- new UpdateAction(dbClient, userSession, rubyBridge),
- new DeleteAction(dbClient, userSession, rubyBridge),
+ new CreateAction(dbClient, userSession),
+ new UpdateAction(dbClient, userSession),
+ new DeleteAction(dbClient, userSession),
new TypesAction(),
- new DomainsAction(dbClient)
- ));
-
+ new DomainsAction(dbClient)));
}
@Test
import org.sonar.db.metric.MetricDto;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.ServerException;
-import org.sonar.server.ruby.RubyBridge;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.WsTester;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
-import static org.mockito.Mockito.mock;
import static org.sonar.db.measure.custom.CustomMeasureTesting.newCustomMeasureDto;
import static org.sonar.server.metric.ws.UpdateAction.PARAM_DESCRIPTION;
import static org.sonar.server.metric.ws.UpdateAction.PARAM_DOMAIN;
import static org.sonar.server.metric.ws.UpdateAction.PARAM_NAME;
import static org.sonar.server.metric.ws.UpdateAction.PARAM_TYPE;
-
public class UpdateActionTest {
private static final String DEFAULT_KEY = "custom-metric-key";
@Before
public void setUp() {
- ws = new WsTester(new MetricsWs(new UpdateAction(dbClient, userSessionRule, mock(RubyBridge.class, RETURNS_DEEP_STUBS))));
+ ws = new WsTester(new MetricsWs(new UpdateAction(dbClient, userSessionRule)));
userSessionRule.login("login").setGlobalPermissions(GlobalPermissions.SYSTEM_ADMIN);
}
import org.junit.Test;
import org.sonar.server.platform.Platform;
import org.sonar.server.platform.db.migration.engine.MigrationEngine;
-import org.sonar.server.ruby.RubyBridge;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
}
};
private MutableDatabaseMigrationState migrationState = mock(MutableDatabaseMigrationState.class);
- private RubyBridge rubyBridge = mock(RubyBridge.class);
private Platform platform = mock(Platform.class);
private MigrationEngine migrationEngine = mock(MigrationEngine.class);
- private DatabaseMigrationImpl underTest = new DatabaseMigrationImpl(executorService, migrationState, rubyBridge, migrationEngine, platform);
+ private DatabaseMigrationImpl underTest = new DatabaseMigrationImpl(executorService, migrationState, migrationEngine, platform);
@Test
public void testName() throws Exception {
import org.junit.Test;
import org.sonar.server.platform.Platform;
import org.sonar.server.platform.db.migration.engine.MigrationEngine;
-import org.sonar.server.ruby.RubyBridge;
-import org.sonar.server.ruby.RubyRailsRoutes;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
public class DatabaseMigrationImplConcurrentAccessTest {
}
};
private MutableDatabaseMigrationState migrationState = mock(MutableDatabaseMigrationState.class);
- private RubyBridge rubyBridge = mock(RubyBridge.class);
private Platform platform = mock(Platform.class);
- private RubyRailsRoutes railsRoutes = mock(RubyRailsRoutes.class);
- private DatabaseMigrationImpl underTest = new DatabaseMigrationImpl(executorService, migrationState, rubyBridge, incrementingMigrationEngine, platform);
+ private DatabaseMigrationImpl underTest = new DatabaseMigrationImpl(executorService, migrationState, incrementingMigrationEngine, platform);
@After
public void tearDown() {
@Test
public void two_concurrent_calls_to_startit_call_migration_engine_only_once() throws Exception {
- when(rubyBridge.railsRoutes()).thenReturn(railsRoutes);
-
pool.submit(new CallStartit());
pool.submit(new CallStartit());
import org.mockito.InOrder;
import org.sonar.server.platform.Platform;
import org.sonar.server.platform.db.migration.engine.MigrationEngine;
-import org.sonar.server.ruby.RubyBridge;
-import org.sonar.server.ruby.RubyRailsRoutes;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
/**
* Unit test for DatabaseMigrationImpl which does not test any of its concurrency management and asynchronous execution code.
}
};
private MutableDatabaseMigrationState migrationState = new DatabaseMigrationStateImpl();
- private RubyBridge rubyBridge = mock(RubyBridge.class);
- private RubyRailsRoutes rubyRailsRoutes = mock(RubyRailsRoutes.class);
private Platform platform = mock(Platform.class);
private MigrationEngine migrationEngine = mock(MigrationEngine.class);
- private InOrder inOrder = inOrder(rubyBridge, rubyRailsRoutes, platform, migrationEngine);
+ private InOrder inOrder = inOrder(platform, migrationEngine);
- private DatabaseMigrationImpl underTest = new DatabaseMigrationImpl(executorService, migrationState, rubyBridge, migrationEngine, platform);
+ private DatabaseMigrationImpl underTest = new DatabaseMigrationImpl(executorService, migrationState, migrationEngine, platform);
@Test
public void startit_calls_MigrationEngine_execute() {
- when(rubyBridge.railsRoutes()).thenReturn(rubyRailsRoutes);
-
underTest.startIt();
inOrder.verify(migrationEngine).execute();
inOrder.verify(platform).doStart();
- inOrder.verify(rubyBridge).railsRoutes();
- inOrder.verify(rubyRailsRoutes).recreate();
inOrder.verifyNoMoreInteractions();
}
@Test
public void status_is_SUCCEEDED_and_failure_is_null_when_trigger_runs_without_an_exception() {
- when(rubyBridge.railsRoutes()).thenReturn(rubyRailsRoutes);
-
underTest.startIt();
assertThat(migrationState.getStatus()).isEqualTo(DatabaseMigrationState.Status.SUCCEEDED);
private void mockMigrationThrowsError() {
doThrow(AN_ERROR).when(migrationEngine).execute();
- when(rubyBridge.railsRoutes()).thenReturn(rubyRailsRoutes);
}
private void mockMigrationDoesNothing() {
doNothing().when(migrationEngine).execute();
- when(rubyBridge.railsRoutes()).thenReturn(rubyRailsRoutes);
}
}
+++ /dev/null
-/*
- * 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.
- */
-package org.sonar.server.platform.web;
-
-import java.io.File;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.Collections;
-import org.apache.commons.io.FileUtils;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.sonar.core.platform.PluginRepository;
-import org.sonar.server.platform.ServerFileSystem;
-
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class RailsAppsDeployerTest {
-
- @Rule
- public TemporaryFolder temp = new TemporaryFolder();
-
- @Test
- public void hasRubyRailsApp() throws Exception {
- ClassLoader classLoader = new URLClassLoader(new URL[]{
- getClass().getResource("/org/sonar/server/platform/web/RailsAppsDeployerTest/FakeRubyRailsApp.jar").toURI().toURL()}, null);
-
- assertTrue(RailsAppsDeployer.hasRailsApp("fake", classLoader));
- assertFalse(RailsAppsDeployer.hasRailsApp("other", classLoader));
- }
-
- @Test
- public void deployRubyRailsApp() throws Exception {
- File tempDir = this.temp.getRoot();
- ClassLoader classLoader = new URLClassLoader(new URL[]{
- getClass().getResource("/org/sonar/server/platform/web/RailsAppsDeployerTest/FakeRubyRailsApp.jar").toURI().toURL()}, null);
-
- RailsAppsDeployer.deployRailsApp(tempDir, "fake", classLoader);
-
- File appDir = new File(tempDir, "fake");
- assertThat(appDir.isDirectory(), is(true));
- assertThat(appDir.exists(), is(true));
- assertThat(FileUtils.listFiles(appDir, null, true).size(), is(3));
- assertThat(new File(appDir, "init.rb").exists(), is(true));
- assertThat(new File(appDir, "app/controllers/fake_controller.rb").exists(), is(true));
- assertThat(new File(appDir, "app/views/fake/index.html.erb").exists(), is(true));
- }
-
- @Test
- public void deployRubyRailsApps_no_apps() {
- ServerFileSystem fileSystem = mock(ServerFileSystem.class);
- File tempDir = this.temp.getRoot();
- when(fileSystem.getTempDir()).thenReturn(tempDir);
-
- PluginRepository pluginRepository = mock(PluginRepository.class);
- when(pluginRepository.getPluginInfos()).thenReturn(Collections.emptyList());
- new RailsAppsDeployer(fileSystem, pluginRepository).start();
-
- File appDir = new File(tempDir, "ror");
- assertThat(appDir.isDirectory(), is(true));
- assertThat(appDir.exists(), is(true));
- assertThat(FileUtils.listFiles(appDir, null, true).size(), is(0));
- }
-
- @Test
- public void prepareRubyRailsRootDirectory() throws Exception {
- ServerFileSystem fileSystem = mock(ServerFileSystem.class);
- File tempDir = this.temp.getRoot();
- when(fileSystem.getTempDir()).thenReturn(tempDir);
-
- File dir = new RailsAppsDeployer(fileSystem, mock(PluginRepository.class)).prepareRailsDirectory();
-
- assertThat(dir.isDirectory(), is(true));
- assertThat(dir.exists(), is(true));
- assertThat(dir.getCanonicalPath(), is(new File(tempDir, "ror").getCanonicalPath()));
- }
-
- @Test
- public void prepareRubyRailsRootDirectory_delete_existing_dir() throws Exception {
- ServerFileSystem fileSystem = mock(ServerFileSystem.class);
- File tempDir = this.temp.getRoot();
- when(fileSystem.getTempDir()).thenReturn(tempDir);
-
- File file = new File(tempDir, "ror/foo/bar.txt");
- FileUtils.writeStringToFile(file, "foooo");
-
- File dir = new RailsAppsDeployer(fileSystem, mock(PluginRepository.class)).prepareRailsDirectory();
-
- assertThat(dir.isDirectory(), is(true));
- assertThat(dir.exists(), is(true));
- assertThat(dir.getCanonicalPath(), is(new File(tempDir, "ror").getCanonicalPath()));
- assertThat(FileUtils.listFiles(new File(tempDir, "ror"), null, true).size(), is(0));
- }
-}
+++ /dev/null
-/*
- * 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.
- */
-package org.sonar.server.platform.web;
-
-import java.io.IOException;
-import javax.servlet.ServletContextEvent;
-import org.jruby.rack.RackApplicationFactory;
-import org.jruby.rack.servlet.ServletRackContext;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.mockito.Mockito;
-import org.sonar.server.platform.web.PlatformServletContextListener;
-import org.sonar.server.platform.web.RubyRailsContextListener;
-
-import static java.lang.Boolean.TRUE;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class RubyRailsContextListenerTest {
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- ServletContextEvent event = mock(ServletContextEvent.class, Mockito.RETURNS_DEEP_STUBS);
- RubyRailsContextListener underTest = new RubyRailsContextListener();
-
- @Test
- public void do_not_initialize_rails_if_error_during_startup() {
- when(event.getServletContext().getAttribute(PlatformServletContextListener.STARTED_ATTRIBUTE)).thenReturn(null);
-
- underTest.contextInitialized(event);
-
- verify(event.getServletContext(), never()).setAttribute(anyString(), anyObject());
- }
-
- @Test
- public void initialize_rails_if_no_errors_during_startup() {
- when(event.getServletContext().getAttribute(PlatformServletContextListener.STARTED_ATTRIBUTE)).thenReturn(TRUE);
- underTest.contextInitialized(event);
- // Ruby environment is started
- // See RailsServletContextListener -> RackServletContextListener
- verify(event.getServletContext()).setAttribute(eq("rack.factory"), anyObject());
- }
-
- @Test
- public void always_propagates_initialization_errors() {
- expectedException.expect(RuntimeException.class);
-
- underTest.handleInitializationException(new IOException(), mock(RackApplicationFactory.class), mock(ServletRackContext.class));
- }
-}
+++ /dev/null
-/*
- * 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.
- */
-package org.sonar.server.ruby;
-
-import org.jruby.rack.RackApplication;
-import org.jruby.rack.RackApplicationFactory;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-import javax.servlet.ServletContext;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class PlatformRackBridgeTest {
- @Mock
- private ServletContext servletContext;
- @Mock
- private RackApplicationFactory rackApplicationFactory;
- @Mock
- private RackApplication rackApplication;
-
- @InjectMocks
- PlatformRackBridge underTest;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test(expected = RuntimeException.class)
- public void getRubyRuntime_throws_RE_when_RackApplicationFactory_is_not_in_ServletContext() {
- underTest.getRubyRuntime();
- }
-
- @Test
- public void getRubyRuntime_returns_Ruby_instance_from_rack_application() {
- when(servletContext.getAttribute("rack.factory")).thenReturn(rackApplicationFactory);
- when(rackApplicationFactory.getApplication()).thenReturn(rackApplication);
-
- // since Ruby object can not be mocked and creating a Ruby instance is costly, we only make sure rackApplication#getRuntime method is
- // called and that we get null (as rackApplication#getRuntime() returns null)
- assertThat(underTest.getRubyRuntime()).isNull();
- verify(rackApplication).getRuntime();
- }
-}
+++ /dev/null
-/*
- * 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.
- */
-package org.sonar.server.ruby;
-
-import com.google.common.collect.ImmutableList;
-import java.io.File;
-import java.net.URISyntaxException;
-import java.net.URL;
-import org.jruby.embed.LocalContextScope;
-import org.jruby.embed.ScriptingContainer;
-import org.jruby.exceptions.RaiseException;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class PlatformRubyBridgeTest {
- private static ScriptingContainer container = setupScriptingContainer();
-
- private RackBridge rackBridge = mock(RackBridge.class);
- private PlatformRubyBridge underTest;
-
- @Before
- public void setUp() {
- when(rackBridge.getRubyRuntime()).thenReturn(container.getProvider().getRuntime());
- underTest = new PlatformRubyBridge(rackBridge);
- }
-
- /**
- * Creates a Ruby runtime which loading path includes the test resource directory where our Ruby test DatabaseVersion
- * is defined.
- */
- private static ScriptingContainer setupScriptingContainer() {
- try {
- ScriptingContainer container = new ScriptingContainer(LocalContextScope.THREADSAFE);
- URL resource = PlatformRubyBridge.class.getResource("database_version.rb");
- String dirPath = new File(resource.toURI()).getParentFile().getPath();
- container.setLoadPaths(ImmutableList.of(dirPath));
-
- return container;
- } catch (URISyntaxException e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * unit test only makes sure the wrapping and method forwarding provided by JRuby works so building the
- * RubyRailsRoutes object and calling its trigger method is enough as it would otherwise raise an exception
- */
- @Test
- public void testRailsRoutes() {
- try {
- underTest.railsRoutes().recreate();
- } catch (RaiseException e) {
- e.printStackTrace();
- throw new RuntimeException("Loading error with container loadPath " + container.getLoadPaths(), e);
- }
- }
-
- /**
- * unit test only makes sure the wrapping and method forwarding provided by JRuby works so building the
- * RubyRailsRoutes object and calling its trigger method is enough as it would otherwise raise an exception
- */
- @Test
- public void testInvalidateCache() {
- try {
- underTest.metricCache().invalidate();
- } catch (RaiseException e) {
- e.printStackTrace();
- throw new RuntimeException("Loading error with container loadPath " + container.getLoadPaths(), e);
- }
- }
-
-}
+++ /dev/null
-/*
- * 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.
- */
-package org.sonar.server.ui;
-
-import java.util.Date;
-import java.util.Locale;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.sonar.api.i18n.I18n;
-import org.sonar.api.utils.Duration;
-import org.sonar.api.utils.Durations;
-import org.sonar.server.tester.UserSessionRule;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.verify;
-
-@RunWith(MockitoJUnitRunner.class)
-public class JRubyI18nTest {
- @Rule
- public UserSessionRule userSessionRule = UserSessionRule.standalone();
-
- @Mock
- I18n i18n;
-
- @Mock
- Durations durations;
-
- JRubyI18n jRubyI18n;
-
-
- @Before
- public void setUp() {
- jRubyI18n = new JRubyI18n(i18n, durations, userSessionRule);
- }
-
- @Test
- public void convert_locales() {
- assertThat(JRubyI18n.toLocale("fr")).isEqualTo(Locale.FRENCH);
- assertThat(JRubyI18n.toLocale("fr-CH")).isEqualTo(new Locale("fr", "CH"));
- }
-
- @Test
- public void cache_locales() {
- assertThat(jRubyI18n.getLocalesByRubyKey()).isEmpty();
-
- jRubyI18n.getLocale("fr");
-
- assertThat(jRubyI18n.getLocalesByRubyKey()).hasSize(1);
- assertThat(jRubyI18n.getLocalesByRubyKey().get("fr")).isNotNull();
- }
-
- @Test
- public void default_locale_should_be_english() {
- assertThat(JRubyI18n.toLocale(null)).isEqualTo(Locale.ENGLISH);
- }
-
- @Test
- public void message() {
- jRubyI18n.message("en", "my.key", "default");
- verify(i18n).message(any(Locale.class), eq("my.key"), eq("default"));
- }
-
- @Test
- public void age_from_now() {
- Date date = new Date();
- jRubyI18n.ageFromNow(date);
- verify(i18n).ageFromNow(any(Locale.class), eq(date));
- }
-
- @Test
- public void format_work_duration() {
- jRubyI18n.formatDuration(Duration.create(10L), "SHORT");
- verify(durations).format(any(Locale.class), eq(Duration.create(10L)), eq(Durations.DurationFormat.SHORT));
- }
-
- @Test
- public void format_long_work_duration() {
- jRubyI18n.formatLongDuration(10L, "SHORT");
- verify(durations).format(any(Locale.class), eq(Duration.create(10L)), eq(Durations.DurationFormat.SHORT));
- }
-
- @Test
- public void format_date_time() {
- Date date = new Date();
- jRubyI18n.formatDateTime(date);
- verify(i18n).formatDateTime(any(Locale.class), eq(date));
- }
-
-}
+++ /dev/null
-/*
- * 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.
- */
-package org.sonar.server.user;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.mockito.ArgumentMatcher;
-import org.sonar.api.user.UserFinder;
-import org.sonar.api.user.UserQuery;
-
-import static org.mockito.Matchers.argThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-public class DefaultUserServiceTest {
-
- private UserFinder finder = mock(UserFinder.class);
- private DefaultUserService service = new DefaultUserService(finder);
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- @Test
- public void parse_query() {
- service.find(ImmutableMap.of(
- "logins", "simon,loic",
- "includeDeactivated", "true",
- "s", "sim"));
-
- verify(finder, times(1)).find(argThat(new ArgumentMatcher<UserQuery>() {
- @Override
- public boolean matches(Object o) {
- UserQuery query = (UserQuery) o;
- return query.includeDeactivated() &&
- query.logins().contains("simon") && query.logins().contains("loic") && query.logins().size() == 2 &&
- query.searchText().equals("sim");
- }
- }));
- }
-
- @Test
- public void test_empty_query() throws Exception {
- service.find(Maps.newHashMap());
-
- verify(finder, times(1)).find(argThat(new ArgumentMatcher<UserQuery>() {
- @Override
- public boolean matches(Object o) {
- UserQuery query = (UserQuery) o;
- return !query.includeDeactivated() && query.logins() == null && query.searchText() == null;
- }
- }));
- }
-}
+++ /dev/null
-/*
- * 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.
- */
-package org.sonar.api.component;
-
-import javax.annotation.CheckForNull;
-import org.sonar.api.server.ServerSide;
-
-/**
- * @since 3.6
- * @deprecated in 6.0
- */
-@ServerSide
-@Deprecated
-public interface RubyComponentService {
-
- @CheckForNull
- Component findByKey(String key);
-
-}
+++ /dev/null
-/*
- * 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.
- */
-package org.sonar.api.user;
-
-import org.sonar.api.server.ServerSide;
-
-import javax.annotation.CheckForNull;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @since 3.6
- */
-@ServerSide
-public interface RubyUserService {
-
- @CheckForNull
- User findByLogin(String login);
-
- /**
- * Search for users
- * <br>
- * Optional parameters are:
- * <ul>
- * <li><code>s</code> to match all the logins or names containing this search query</li>
- * <li><code>logins</code>, as an array of strings (['simon', 'julien']) or a comma-separated list of logins ('simon,julien')</li>
- * <li><code>includeDeactivated</code> as a boolean. By Default deactivated users are excluded from query.</li>
- * </ul>
- */
- List<User> find(Map<String, Object> params);
-}