// TODO selenium
}
- /**
- * This is currently a limitation of Ruby on Rails stack.
- */
@Test
public void basic_authentication_does_not_support_utf8_passwords() {
String login = LOGIN;
return new Object[] {
ResourceTypes.class,
DefaultResourceTypes.get(),
- Periods.class, // used by JRuby and EvaluationResultTextConverterImpl
+ Periods.class,
// quality profile
ActiveRuleIndexer.class,
+++ /dev/null
-# This file must contain only ISO 8859-1 characters
-# see http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Properties.html#load(java.io.InputStream)
-#
-# To use an environment variable, use the following syntax : ${env:NAME_OF_ENV_VARIABLE}
-# For example:
-# sonar.jdbc.url= ${env:SONAR_JDBC_URL}
-#
-#
-# See also the file conf/wrapper.conf for JVM advanced settings
-
-
-
-#--------------------------------------------------------------------------------------------------
-# DATABASE
-#
-# IMPORTANT: the embedded H2 database is used by default. It is recommended for tests only.
-# Please use a production-ready database. Supported databases are MySQL, Oracle, PostgreSQL
-# and Microsoft SQLServer.
-
-# Permissions to create tables, indices and triggers must be granted to JDBC user.
-# The schema must be created first.
-sonar.jdbc.username=sonar
-sonar.jdbc.password=sonar
-
-#----- Embedded database H2
-# Note: it does not accept connections from remote hosts, so the
-# SonarQube server and the maven plugin must be executed on the same host.
-
-# Comment the following line to deactivate the default embedded database.
-sonar.jdbc.url=jdbc:h2:tcp://localhost:9092/sonar
-
-# directory containing H2 database files. By default it's the /data directory in the SonarQube installation.
-#sonar.embeddedDatabase.dataDir=
-# H2 embedded database server listening port, defaults to 9092
-#sonar.embeddedDatabase.port=9092
-
-
-#----- MySQL 5.x
-# Comment the embedded database and uncomment the following line to use MySQL
-#sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true
-
-
-#----- Oracle 10g/11g
-# To connect to Oracle database:
-#
-# - It's recommended to use the latest version of the JDBC driver (ojdbc6.jar).
-# Download it in http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html
-# - Copy the driver to the directory extensions/jdbc-driver/oracle/
-# - If you need to set the schema, please refer to http://jira.sonarsource.com/browse/SONAR-5000
-# - Comment the embedded database and uncomment the following line:
-#sonar.jdbc.url=jdbc:oracle:thin:@localhost/XE
-
-
-#----- PostgreSQL 8.x/9.x
-# Comment the embedded database and uncomment the following property to use PostgreSQL.
-# If you don't use the schema named "public", please refer to http://jira.sonarsource.com/browse/SONAR-5000
-#sonar.jdbc.url=jdbc:postgresql://localhost/sonar
-
-
-#----- Microsoft SQLServer
-# The Jtds open source driver is available in extensions/jdbc-driver/mssql. More details on http://jtds.sourceforge.net
-#sonar.jdbc.url=jdbc:jtds:sqlserver://localhost/sonar;SelectMethod=Cursor
-
-
-#----- Connection pool settings
-sonar.jdbc.maxActive=20
-sonar.jdbc.maxIdle=5
-sonar.jdbc.minIdle=2
-sonar.jdbc.maxWait=5000
-sonar.jdbc.minEvictableIdleTimeMillis=600000
-sonar.jdbc.timeBetweenEvictionRunsMillis=30000
-
-
-
-#--------------------------------------------------------------------------------------------------
-# WEB SERVER
-
-# Binding IP address. For servers with more than one IP address, this property specifies which
-# address will be used for listening on the specified ports.
-# By default, ports will be used on all IP addresses associated with the server.
-#sonar.web.host=0.0.0.0
-
-# Web context. When set, it must start with forward slash (for example /sonarqube).
-# The default value is root context (empty value).
-#sonar.web.context=
-
-# TCP port for incoming HTTP connections. Disabled when value is -1.
-#sonar.web.port=9000
-
-# The maximum number of connections that the server will accept and process at any given time.
-# When this number has been reached, the server will not accept any more connections until
-# the number of connections falls below this value. The operating system may still accept connections
-# based on the sonar.web.connections.acceptCount property. The default value is 50 for each
-# enabled connector.
-#sonar.web.http.maxThreads=50
-
-# The minimum number of threads always kept running. The default value is 5 for each
-# enabled connector.
-#sonar.web.http.minThreads=5
-
-# The maximum queue length for incoming connection requests when all possible request processing
-# threads are in use. Any requests received when the queue is full will be refused.
-# The default value is 25 for each enabled connector.
-#sonar.web.http.acceptCount=25
-
-# Access logs are generated in the file logs/access.log. This file is rolled over when it's 5Mb.
-# An archive of 3 files is kept in the same directory.
-# Access logs are enabled by default.
-#sonar.web.accessLogs.enable=true
-
-#--------------------------------------------------------------------------------------------------
-# UPDATE CENTER
-
-# The Update Center requires an internet connection to request https://update.sonarsource.org
-# It is enabled by default.
-#sonar.updatecenter.activate=true
-
-# HTTP proxy (default none)
-#http.proxyHost=
-#http.proxyPort=
-
-# NT domain name if NTLM proxy is used
-#http.auth.ntlm.domain=
-
-# SOCKS proxy (default none)
-#socksProxyHost=
-#socksProxyPort=
-
-# proxy authentication. The 2 following properties are used for HTTP and SOCKS proxies.
-#http.proxyUser=
-#http.proxyPassword=
-
-
-#--------------------------------------------------------------------------------------------------
-# NOTIFICATIONS
-
-# Delay in seconds between processing of notification queue. Default is 60.
-#sonar.notifications.delay=60
-
-
-
-#--------------------------------------------------------------------------------------------------
-# DEVELOPMENT MODE
-# Only for debugging
-
-# Set to true to apply Ruby on Rails code changes on the fly
-#sonar.rails.dev=false
*/
public static final String ENABLE_STOP_COMMAND = "sonar.enableStopCommand";
- public static final String WEB_ENFORCED_JVM_ARGS = "-Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djruby.management.enabled=false " +
- // jruby is slow with java 8: https://jira.sonarsource.com/browse/SONAR-6115
- "-Djruby.compile.invokedynamic=false";
+ public static final String WEB_ENFORCED_JVM_ARGS = "-Djava.awt.headless=true -Dfile.encoding=UTF-8";
public static final String CE_ENFORCED_JVM_ARGS = "-Djava.awt.headless=true -Dfile.encoding=UTF-8";
+++ /dev/null
-# This file must contain only ISO 8859-1 characters
-# see http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Properties.html#load(java.io.InputStream)
-#
-# To use an environment variable, use the following syntax : ${env:NAME_OF_ENV_VARIABLE}
-# For example:
-# sonar.jdbc.url= ${env:SONAR_JDBC_URL}
-#
-#
-# See also the file conf/wrapper.conf for JVM advanced settings
-
-
-
-#--------------------------------------------------------------------------------------------------
-# DATABASE
-#
-# IMPORTANT: the embedded H2 database is used by default. It is recommended for tests only.
-# Please use a production-ready database. Supported databases are MySQL, Oracle, PostgreSQL
-# and Microsoft SQLServer.
-
-# Permissions to create tables, indices and triggers must be granted to JDBC user.
-# The schema must be created first.
-sonar.jdbc.username=sonar
-sonar.jdbc.password=sonar
-
-#----- Embedded database H2
-# Note: it does not accept connections from remote hosts, so the
-# SonarQube server and the maven plugin must be executed on the same host.
-
-# Comment the following line to deactivate the default embedded database.
-sonar.jdbc.url=jdbc:h2:tcp://localhost:9092/sonar
-
-# directory containing H2 database files. By default it's the /data directory in the SonarQube installation.
-#sonar.embeddedDatabase.dataDir=
-# H2 embedded database server listening port, defaults to 9092
-#sonar.embeddedDatabase.port=9092
-
-
-#----- MySQL 5.x
-# Comment the embedded database and uncomment the following line to use MySQL
-#sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true
-
-
-#----- Oracle 10g/11g
-# To connect to Oracle database:
-#
-# - It's recommended to use the latest version of the JDBC driver (ojdbc6.jar).
-# Download it in http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html
-# - Copy the driver to the directory extensions/jdbc-driver/oracle/
-# - If you need to set the schema, please refer to http://jira.sonarsource.com/browse/SONAR-5000
-# - Comment the embedded database and uncomment the following line:
-#sonar.jdbc.url=jdbc:oracle:thin:@localhost/XE
-
-
-#----- PostgreSQL 8.x/9.x
-# Comment the embedded database and uncomment the following property to use PostgreSQL.
-# If you don't use the schema named "public", please refer to http://jira.sonarsource.com/browse/SONAR-5000
-#sonar.jdbc.url=jdbc:postgresql://localhost/sonar
-
-
-#----- Microsoft SQLServer
-# The Jtds open source driver is available in extensions/jdbc-driver/mssql. More details on http://jtds.sourceforge.net
-#sonar.jdbc.url=jdbc:jtds:sqlserver://localhost/sonar;SelectMethod=Cursor
-
-
-#----- Connection pool settings
-sonar.jdbc.maxActive=20
-sonar.jdbc.maxIdle=5
-sonar.jdbc.minIdle=2
-sonar.jdbc.maxWait=5000
-sonar.jdbc.minEvictableIdleTimeMillis=600000
-sonar.jdbc.timeBetweenEvictionRunsMillis=30000
-
-
-
-#--------------------------------------------------------------------------------------------------
-# WEB SERVER
-
-# Binding IP address. For servers with more than one IP address, this property specifies which
-# address will be used for listening on the specified ports.
-# By default, ports will be used on all IP addresses associated with the server.
-#sonar.web.host=0.0.0.0
-
-# Web context. When set, it must start with forward slash (for example /sonarqube).
-# The default value is root context (empty value).
-#sonar.web.context=
-
-# TCP port for incoming HTTP connections. Disabled when value is -1.
-#sonar.web.port=9000
-
-# The maximum number of connections that the server will accept and process at any given time.
-# When this number has been reached, the server will not accept any more connections until
-# the number of connections falls below this value. The operating system may still accept connections
-# based on the sonar.web.connections.acceptCount property. The default value is 50 for each
-# enabled connector.
-#sonar.web.http.maxThreads=50
-
-# The minimum number of threads always kept running. The default value is 5 for each
-# enabled connector.
-#sonar.web.http.minThreads=5
-
-# The maximum queue length for incoming connection requests when all possible request processing
-# threads are in use. Any requests received when the queue is full will be refused.
-# The default value is 25 for each enabled connector.
-#sonar.web.http.acceptCount=25
-
-# Access logs are generated in the file logs/access.log. This file is rolled over when it's 5Mb.
-# An archive of 3 files is kept in the same directory.
-# Access logs are enabled by default.
-#sonar.web.accessLogs.enable=true
-
-#--------------------------------------------------------------------------------------------------
-# UPDATE CENTER
-
-# The Update Center requires an internet connection to request https://update.sonarsource.org
-# It is enabled by default.
-#sonar.updatecenter.activate=true
-
-# HTTP proxy (default none)
-#http.proxyHost=
-#http.proxyPort=
-
-# NT domain name if NTLM proxy is used
-#http.auth.ntlm.domain=
-
-# SOCKS proxy (default none)
-#socksProxyHost=
-#socksProxyPort=
-
-# proxy authentication. The 2 following properties are used for HTTP and SOCKS proxies.
-#http.proxyUser=
-#http.proxyPassword=
-
-
-#--------------------------------------------------------------------------------------------------
-# NOTIFICATIONS
-
-# Delay in seconds between processing of notification queue. Default is 60.
-#sonar.notifications.delay=60
-
-
-
-#--------------------------------------------------------------------------------------------------
-# DEVELOPMENT MODE
-# Only for debugging
-
-# Set to true to apply Ruby on Rails code changes on the fly
-#sonar.rails.dev=false
void start() {
// '%2F' (slash /) and '%5C' (backslash \) are permitted as path delimiters in URLs
- // See Ruby on Rails url_for
System.setProperty("org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH", "true");
System.setProperty("org.apache.catalina.startup.EXIT_ON_INIT_FAILURE", "true");
import java.io.IOException;
import java.util.Map;
import javax.servlet.ServletException;
-import org.apache.catalina.Context;
import org.apache.catalina.core.StandardContext;
import org.apache.catalina.startup.Tomcat;
import org.apache.commons.io.FileUtils;
*/
public class TomcatContexts {
- private static final String JRUBY_MAX_RUNTIMES = "jruby.max.runtimes";
- private static final String RAILS_ENV = "rails.env";
public static final String PROPERTY_CONTEXT = "sonar.web.context";
public static final String WEB_DEPLOY_PATH_RELATIVE_TO_DATA_DIR = "web/deploy";
addStaticDir(tomcat, getContextPath(props) + "/deploy", new File(props.nonNullValueAsFile(ProcessProperties.PATH_DATA), WEB_DEPLOY_PATH_RELATIVE_TO_DATA_DIR));
StandardContext webapp = addContext(tomcat, getContextPath(props), webappDir(props));
- configureRails(props, webapp);
for (Map.Entry<Object, Object> entry : props.rawProperties().entrySet()) {
String key = entry.getKey().toString();
webapp.addParameter(key, entry.getValue().toString());
}
}
- static void configureRails(Props props, Context context) {
- // sonar.dev is kept for backward-compatibility
- if (props.valueAsBoolean("sonar.dev", false)) {
- props.set("sonar.web.dev", "true");
- }
- if (props.valueAsBoolean("sonar.web.dev", false)) {
- context.addParameter(RAILS_ENV, "development");
- context.addParameter(JRUBY_MAX_RUNTIMES, "3");
- Loggers.get(TomcatContexts.class).warn("WEB DEVELOPMENT MODE IS ENABLED - DO NOT USE FOR PRODUCTION USAGE");
- } else {
- context.addParameter(RAILS_ENV, "production");
- context.addParameter(JRUBY_MAX_RUNTIMES, "1");
- }
- }
-
static File webappDir(Props props) {
String devDir = props.value("sonar.web.dev.sources");
File dir;
import org.sonar.api.utils.ValidationMessages;
/**
- * Used through ruby code <pre>Internal.debt</pre>
* Also used by SQALE plugin.
*/
public class DebtModelService implements DebtModel {
}
/**
- * Send test email. This method called from Ruby.
+ * Send test email.
*
* @throws EmailException when unable to send
*/
import java.util.Collection;
import java.util.List;
import java.util.Properties;
-import javax.annotation.CheckForNull;
import javax.servlet.ServletContext;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
return INSTANCE;
}
- /**
- * Used by ruby code
- */
- @CheckForNull
- public static <T> T component(Class<T> type) {
- if (INSTANCE.started) {
- return INSTANCE.getContainer().getComponentByType(type);
- }
- return null;
- }
-
public void init(Properties properties, ServletContext servletContext) {
this.properties = properties;
this.servletContext = servletContext;
event.getServletContext().setAttribute(STARTED_ATTRIBUTE, Boolean.TRUE);
} catch (Throwable t) {
- // Tomcat 7 "limitations":
- // - server does not stop if webapp fails at startup
- // - the second listener for jruby on rails is started even if this listener fails. It generates
- // unexpected errors
+ // Tomcat 7 "limitations": server does not stop if webapp fails at startup
stopQuietly();
throw Throwables.propagate(t);
}
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
-import java.io.StringWriter;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
exporter.exportProfile(wrap(profile), writer);
}
- /**
- * Only for ruby on rails
- */
- public String export(String profileKey, String tool) {
- StringWriter writer = new StringWriter();
- export(profileKey, tool, writer);
- return writer.toString();
- }
-
private RulesProfile wrap(QualityProfileDto profile) {
DbSession dbSession = dbClient.openSession(false);
RulesProfile target = new RulesProfile(profile.getName(), profile.getLanguage());
*/
package org.sonar.server.qualityprofile;
-import java.io.StringWriter;
import java.io.Writer;
import java.util.List;
import javax.annotation.CheckForNull;
backuper.backup(profileKey, writer);
}
- /**
- * @deprecated used only by Ruby on Rails. Use {@link #backup(String, java.io.Writer)}
- */
- @Deprecated
- public String backup(String profileKey) {
- StringWriter output = new StringWriter();
- backup(profileKey, output);
- return output.toString();
- }
-
/**
* Used in /api/profiles and in /profiles/export
*/
import com.google.common.base.Throwables;
import com.google.common.collect.Lists;
-import java.io.File;
-import java.io.IOException;
import java.net.URL;
import java.net.URLDecoder;
import java.util.Collection;
import java.util.Enumeration;
-import java.util.function.Function;
import java.util.function.Predicate;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import javax.annotation.Nullable;
-import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.CharEncoding;
import org.apache.commons.lang.StringUtils;
import org.sonar.api.utils.log.Loggers;
// only static methods
}
- public static File copyResources(ClassLoader classLoader, String rootPath, File toDir, Function<String, String> relocationFunction) {
- Collection<String> relativePaths = listFiles(classLoader, rootPath);
- for (String relativePath : relativePaths) {
- URL resource = classLoader.getResource(relativePath);
- String filename = relocationFunction.apply(relativePath);
- File toFile = new File(toDir, filename);
- try {
- FileUtils.copyURLToFile(resource, toFile);
- } catch (IOException e) {
- throw new IllegalStateException("Fail to extract " + relativePath + " to " + toFile.getAbsolutePath(), e);
- }
- }
-
- return toDir;
- }
-
/**
* Finds files within a given directory and its subdirectories
*
// Path of the root directory
// Examples :
- // org/sonar/sqale/index.txt -> rootDirectory is org/sonar/sqale
- // org/sonar/sqale/ -> rootDirectory is org/sonar/sqale
- // org/sonar/sqale -> rootDirectory is org/sonar/sqale
+ // org/sonar/sqale/index.txt -> rootDirectory is org/sonar/sqale
+ // org/sonar/sqale/ -> rootDirectory is org/sonar/sqale
+ // org/sonar/sqale -> rootDirectory is org/sonar/sqale
String rootDirectory = rootPath;
if (StringUtils.substringAfterLast(rootPath, "/").indexOf('.') >= 0) {
rootDirectory = StringUtils.substringBeforeLast(rootPath, "/");
}
- //strip out only the JAR file
+ // strip out only the JAR file
jarPath = root.getPath().substring(5, root.getPath().indexOf('!'));
jar = new JarFile(URLDecoder.decode(jarPath, CharEncoding.UTF_8));
Enumeration<JarEntry> entries = jar.entries();
"java.vm.specification.version": "1.7",
"java.vm.vendor": "Oracle Corporation",
"java.vm.version": "24.71-b01",
- "jruby.compile.invokedynamic": "false",
- "jruby.management.enabled": "false",
"line.separator": "\n",
"org.apache.catalina.startup.EXIT_ON_INIT_FAILURE": "true",
"org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH": "true",
2016.11.17 16:26:33 INFO app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /Users/me/sonarqube-6.2/temp
2016.11.17 16:26:33 INFO app[][o.s.p.m.JavaProcessLauncher] Launch process[es]: /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/bin/java -Djava.awt.headless=true -Xmx1G -Xms256m -Xss256k -Djna.nosys=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -Djava.io.tmpdir=/Users/me/sonarqube-6.2/temp -javaagent:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/management-agent.jar -cp ./lib/common/*:./lib/search/* org.sonar.search.SearchServer /Users/me/sonarqube-6.2/temp/sq-process607963922619414430properties
2016.11.17 16:26:39 INFO app[][o.s.p.m.Monitor] Process[es] is up
-2016.11.17 16:26:39 INFO app[][o.s.p.m.JavaProcessLauncher] Launch process[web]: /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/bin/java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djruby.management.enabled=false -Djruby.compile.invokedynamic=false -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Djava.io.tmpdir=/Users/me/sonarqube-6.2/temp -javaagent:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/management-agent.jar -cp ./lib/common/*:./lib/server/*:/Users/me/sonarqube-6.2/lib/jdbc/h2/h2-1.3.176.jar org.sonar.server.app.WebServer /Users/me/sonarqube-6.2/temp/sq-process8504251823484440932properties
+2016.11.17 16:26:39 INFO app[][o.s.p.m.JavaProcessLauncher] Launch process[web]: /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/bin/java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Djava.io.tmpdir=/Users/me/sonarqube-6.2/temp -javaagent:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/management-agent.jar -cp ./lib/common/*:./lib/server/*:/Users/me/sonarqube-6.2/lib/jdbc/h2/h2-1.3.176.jar org.sonar.server.app.WebServer /Users/me/sonarqube-6.2/temp/sq-process8504251823484440932properties
2016.11.17 16:26:59 INFO app[][o.s.p.m.Monitor] Process[web] is up
2016.11.17 16:26:59 INFO app[][o.s.p.m.JavaProcessLauncher] Launch process[ce]: /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/bin/java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Djava.io.tmpdir=/Users/me/sonarqube-6.2/temp -javaagent:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/management-agent.jar -cp ./lib/common/*:./lib/server/*:./lib/ce/*:/Users/me/sonarqube-6.2/lib/jdbc/h2/h2-1.3.176.jar org.sonar.ce.app.CeServer /Users/me/sonarqube-6.2/temp/sq-process6754313832695376518properties
2016.11.17 16:27:04 INFO app[][o.s.p.m.Monitor] Process[ce] is up
+++ /dev/null
-# this script defines a method which calls the class method "clear_cache" of the Metric class defined
-# in /server/sonar-web/src/main/webapp/WEB-INF/app/models/metric.rb
-
-# this essentially makes UT work, must be a file that actually exists in production
-require 'database_version'
-
-class RbCallInvalidateMetricCache
- include Java::org.sonar.server.ruby.CallInvalidateMetricCache
- def call_invalidate
- Metric.clear_cache
- end
-end
-RbCallInvalidateMetricCache.new
+++ /dev/null
-# this script defines a method which calls the class method "load_java_web_services" of the Bootstrap class
-# definedin /server/sonar-web/src/main/webapp/WEB-INF/config/environment.rb
-
-# this essentially makes UT work, must be a file that actually exists in production
-require 'database_version'
-
-class RbCallLoadJavaWebServices
- include Java::org.sonar.server.ruby.CallLoadJavaWebServices
- def call_load_java_web_services
- Bootstrap.load_java_web_services
- end
-end
-RbCallLoadJavaWebServices.new
import java.io.File;
import java.io.IOException;
import java.util.Properties;
-import org.apache.catalina.Context;
import org.apache.catalina.core.StandardContext;
import org.apache.catalina.startup.Tomcat;
import org.apache.commons.io.FileUtils;
verify(context).addParameter("foo", "bar");
}
- @Test
- public void configure_rails_dev_mode() {
- props.setProperty("sonar.web.dev", "true");
- Context context = mock(Context.class);
-
- underTest.configureRails(new Props(props), context);
-
- verify(context).addParameter("jruby.max.runtimes", "3");
- verify(context).addParameter("rails.env", "development");
- }
-
- @Test
- public void configure_rails_production_mode() {
- props.setProperty("sonar.web.dev", "false");
- Context context = mock(Context.class);
-
- underTest.configureRails(new Props(props), context);
-
- verify(context).addParameter("jruby.max.runtimes", "1");
- verify(context).addParameter("rails.env", "production");
- }
-
@Test
public void create_dir_and_configure_static_directory() throws Exception {
File dir = temp.newFolder();
*/
package org.sonar.server.platform;
-import java.io.File;
-import java.io.IOException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Collection;
-import java.util.function.Function;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.FilenameUtils;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
import org.sonar.server.util.ClassLoaderUtils;
import static org.apache.commons.lang.StringUtils.endsWith;
private ClassLoader classLoader;
- @Rule
- public TemporaryFolder temp = new TemporaryFolder();
-
@Before
public void prepareClassLoader() {
// This JAR file has the three following files :
"org/sonar/sqale/app/README.md");
}
- @Test
- public void copyRubyRailsApp() throws IOException {
- File toDir = temp.newFolder("dest");
- ClassLoaderUtils.copyResources(classLoader, "org/sonar/sqale", toDir, Function.identity());
-
- assertThat(FileUtils.listFiles(toDir, null, true)).hasSize(2);
- assertThat(new File(toDir, "org/sonar/sqale/app/copyright.txt")).exists();
- assertThat(new File(toDir, "org/sonar/sqale/app/README.md")).exists();
- }
-
- @Test
- public void copyRubyRailsApp_relocate_files() throws IOException {
- File toDir = temp.newFolder("dest");
- ClassLoaderUtils.copyResources(classLoader, "org/sonar/sqale", toDir, path -> "foo/" + FilenameUtils.getName(path));
-
- assertThat(FileUtils.listFiles(toDir, null, true)).hasSize(2);
- assertThat(new File(toDir, "foo/copyright.txt")).exists();
- assertThat(new File(toDir, "foo/README.md")).exists();
- }
}
import org.sonar.db.qualityprofile.ActiveRuleDto;
import org.sonar.db.qualityprofile.QualityProfileDto;
import org.sonar.server.exceptions.BadRequestException;
-import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.qualityprofile.index.ActiveRuleIndexer;
import org.sonar.server.rule.index.RuleIndex;
import org.sonar.server.rule.index.RuleQuery;
assertThat(exporters.mimeType("standard")).isEqualTo("text/plain");
}
- @Test
- public void export() {
- QualityProfileDto profile = tester.get(QProfileLoader.class).getByLangAndName("xoo", "P1");
- assertThat(exporters.export(profile.getKey(), "xootool")).isEqualTo("xoo -> P1 -> 1");
- assertThat(exporters.export(profile.getKey(), "standard")).isEqualTo("standard -> P1 -> 1");
- }
-
- @Test
- public void fail_if_missing_exporter() {
- QualityProfileDto profile = tester.get(QProfileLoader.class).getByLangAndName("xoo", "P1");
- try {
- exporters.export(profile.getKey(), "unknown");
- fail();
- } catch (NotFoundException e) {
- assertThat(e).hasMessage("Unknown quality profile exporter: unknown");
- }
- }
-
- @Test
- public void fail_if_missing_profile() {
- try {
- exporters.export("unknown", "xootool");
- fail();
- } catch (NotFoundException e) {
- assertThat(e).hasMessage("Unknown Quality profile: unknown");
- }
- }
-
@Test
public void profile_importers_for_language() {
assertThat(exporters.findProfileImportersForLanguage("xoo")).hasSize(3);
+++ /dev/null
-# a dummy class Bootstrap that "mocks" the Bootstrap class of the platform by defining a class method called load_java_web_services
-# unit test only makes sure the wrapping and method forwarding provided by JRuby works so providing an empty method is enough as
-# it would otherwise raise an exception
-class Bootstrap
-
- def self.load_java_web_services
-
- end
-
-end
-
-class Metric
-
- def self.clear_cache
-
- end
-
-end
result.setProperty(StringUtils.removeStart(key, SONAR_JDBC), (String) entry.getValue());
}
}
-
- // This property is required by the Ruby Oracle enhanced adapter.
- // It directly uses the Connection implementation provided by the Oracle driver
- result.setProperty("accessToUnderlyingConnectionAllowed", "true");
return result;
}
package org.sonar.db.schemamigration;
/**
- * Maps the table SCHEMA_MIGRATIONS that is fed by Ruby on Rails Migrations
+ * Maps the table SCHEMA_MIGRATIONS
* @since 3.0
*/
public class SchemaMigrationDto {
import static java.util.Arrays.asList;
/**
- * Defines a web service. Note that contrary to the deprecated {@link org.sonar.api.web.Webservice}
- * the ws is fully implemented in Java and does not require any Ruby on Rails code.
+ * Defines a web service.
* <br>
* <br>
* The classes implementing this extension point must be declared by {@link org.sonar.api.Plugin}.
public interface Footer {
/**
- * Static HTML (no Ruby on Rails)
+ * Static HTML
*/
String getHtml();
}
// ES + TOMCAT
@Test
public void server_startup_and_shutdown() throws Exception {
- String defaultWebJavaOptions = "-Xmx768m -XX:+HeapDumpOnOutOfMemoryError -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djruby.management.enabled=false";
+ String defaultWebJavaOptions = "-Xmx768m -XX:+HeapDumpOnOutOfMemoryError -Djava.awt.headless=true -Dfile.encoding=UTF-8";
Orchestrator orchestrator = Orchestrator.builderEnv()
.setOrchestratorProperty("javaVersion", "LATEST_RELEASE")
.addPlugin("java")
connection.connect();
assertThat(connection.getResponseCode()).as("Fail to load " + path).isEqualTo(HttpURLConnection.HTTP_OK);
- // Error HTML pages generated by Ruby on Rails
String content = IOUtils.toString(connection.getInputStream());
assertThat(content).as("Fail to load " + path).doesNotContain("something went wrong");
assertThat(content).as("Fail to load " + path).doesNotContain("The page you were looking for doesn't exist");