summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sonar-core/src/main/java/org/sonar/core/technicaldebt/DefaultTechnicalDebtManager.java1
-rw-r--r--sonar-core/src/main/java/org/sonar/core/technicaldebt/db/CharacteristicDao.java5
-rw-r--r--sonar-core/src/main/java/org/sonar/core/technicaldebt/db/CharacteristicMapper.java2
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/api/resources/ProjectUtils.java (renamed from sonar-plugin-api/src/main/java/org/sonar/api/resources/ProjectUtils.java)7
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/charts/ChartParameters.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/charts/package-info.java (renamed from sonar-server/src/main/java/org/sonar/server/group/package-info.java)4
-rw-r--r--sonar-server/src/main/java/org/sonar/server/charts/ChartFactory.java4
-rw-r--r--sonar-server/src/main/java/org/sonar/server/charts/package-info.java23
-rw-r--r--sonar-server/src/main/java/org/sonar/server/es/ESIndex.java27
-rw-r--r--sonar-server/src/main/java/org/sonar/server/exceptions/package-info.java25
-rw-r--r--sonar-server/src/main/java/org/sonar/server/issue/IssueChangelogFormatter.java12
-rw-r--r--sonar-server/src/main/java/org/sonar/server/issue/ws/IssueShowWsHandler.java11
-rw-r--r--sonar-server/src/main/java/org/sonar/server/platform/Platform.java23
-rw-r--r--sonar-server/src/main/java/org/sonar/server/plugins/MimeTypes.java11
-rw-r--r--sonar-server/src/main/java/org/sonar/server/startup/CleanPreviewAnalysisCache.java (renamed from sonar-server/src/main/java/org/sonar/server/startup/CleanDryRunCache.java)17
-rw-r--r--sonar-server/src/main/java/org/sonar/server/startup/ServerMetadataPersister.java9
-rw-r--r--sonar-server/src/main/java/org/sonar/server/technicaldebt/DebtFormatter.java (renamed from sonar-server/src/main/java/org/sonar/server/technicaldebt/TechnicalDebtFormatter.java)4
-rw-r--r--sonar-server/src/main/java/org/sonar/server/technicaldebt/DebtService.java (renamed from sonar-server/src/main/java/org/sonar/server/technicaldebt/InternalRubyTechnicalDebtService.java)14
-rw-r--r--sonar-server/src/main/java/org/sonar/server/user/CompatibilityRealm.java (renamed from sonar-server/src/main/java/org/sonar/server/ui/CompatibilityRealm.java)2
-rw-r--r--sonar-server/src/main/java/org/sonar/server/user/DatabaseSessionFilter.java (renamed from sonar-server/src/main/java/org/sonar/server/ui/DatabaseSessionFilter.java)4
-rw-r--r--sonar-server/src/main/java/org/sonar/server/user/GroupMembershipFinder.java (renamed from sonar-server/src/main/java/org/sonar/server/group/GroupMembershipFinder.java)26
-rw-r--r--sonar-server/src/main/java/org/sonar/server/user/GroupMembershipService.java (renamed from sonar-server/src/main/java/org/sonar/server/group/InternalGroupMembershipService.java)8
-rw-r--r--sonar-server/src/main/java/org/sonar/server/user/SecurityRealmFactory.java (renamed from sonar-server/src/main/java/org/sonar/server/ui/SecurityRealmFactory.java)2
-rw-r--r--sonar-server/src/main/java/org/sonar/server/ws/ServletResponse.java5
-rw-r--r--sonar-server/src/main/java/org/sonar/server/ws/WebServiceEngine.java3
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/internal.rb4
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/server.rb85
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/lib/need_authentication.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/web.xml2
-rw-r--r--sonar-server/src/test/java/org/sonar/server/db/EmbeddedDatabaseFactoryTest.java12
-rw-r--r--sonar-server/src/test/java/org/sonar/server/issue/IssueChangelogFormatterTest.java70
-rw-r--r--sonar-server/src/test/java/org/sonar/server/issue/ws/IssueShowWsHandlerTest.java8
-rw-r--r--sonar-server/src/test/java/org/sonar/server/startup/CleanPreviewAnalysisCacheTest.java (renamed from sonar-server/src/main/java/org/sonar/server/group/GroupMembershipQueryResult.java)32
-rw-r--r--sonar-server/src/test/java/org/sonar/server/startup/ServerMetadataPersisterTest.java16
-rw-r--r--sonar-server/src/test/java/org/sonar/server/technicaldebt/DebtFormatterTest.java (renamed from sonar-server/src/test/java/org/sonar/server/technicaldebt/TechnicalDebtFormatterTest.java)25
-rw-r--r--sonar-server/src/test/java/org/sonar/server/technicaldebt/DebtServiceTest.java (renamed from sonar-server/src/test/java/org/sonar/server/technicaldebt/InternalRubyTechnicalDebtServiceTest.java)27
-rw-r--r--sonar-server/src/test/java/org/sonar/server/user/CompatibilityRealmTest.java (renamed from sonar-server/src/test/java/org/sonar/server/ui/CompatibilityRealmTest.java)2
-rw-r--r--sonar-server/src/test/java/org/sonar/server/user/GroupMembershipFinderTest.java (renamed from sonar-server/src/test/java/org/sonar/server/group/GroupMembershipFinderTest.java)27
-rw-r--r--sonar-server/src/test/java/org/sonar/server/user/GroupMembershipServiceTest.java (renamed from sonar-server/src/test/java/org/sonar/server/group/InternalGroupMembershipServiceTest.java)26
-rw-r--r--sonar-server/src/test/java/org/sonar/server/user/SecurityRealmFactoryTest.java (renamed from sonar-server/src/test/java/org/sonar/server/ui/SecurityRealmFactoryTest.java)34
-rw-r--r--sonar-server/src/test/java/org/sonar/server/ws/WebServiceEngineTest.java3
-rw-r--r--sonar-server/src/test/resources/org/sonar/server/user/GroupMembershipServiceTest/shared.xml (renamed from sonar-server/src/test/resources/org/sonar/server/group/InternalGroupMembershipServiceTest/shared.xml)4
42 files changed, 328 insertions, 302 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/technicaldebt/DefaultTechnicalDebtManager.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/DefaultTechnicalDebtManager.java
index b417216bca3..86913704cf3 100644
--- a/sonar-core/src/main/java/org/sonar/core/technicaldebt/DefaultTechnicalDebtManager.java
+++ b/sonar-core/src/main/java/org/sonar/core/technicaldebt/DefaultTechnicalDebtManager.java
@@ -31,7 +31,6 @@ import org.sonar.core.technicaldebt.db.CharacteristicDto;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
-
import java.util.List;
import static com.google.common.collect.Lists.newArrayList;
diff --git a/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/CharacteristicDao.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/CharacteristicDao.java
index fbac58d237c..c94f61d580b 100644
--- a/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/CharacteristicDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/CharacteristicDao.java
@@ -26,10 +26,9 @@ import org.sonar.api.ServerComponent;
import org.sonar.core.persistence.MyBatis;
import javax.annotation.CheckForNull;
-
import java.util.List;
-public class CharacteristicDao implements BatchComponent, ServerComponent {
+public class CharacteristicDao implements BatchComponent, ServerComponent {
private final MyBatis mybatis;
@@ -75,7 +74,7 @@ public class CharacteristicDao implements BatchComponent, ServerComponent {
}
@CheckForNull
- public CharacteristicDto selectById(Integer id) {
+ public CharacteristicDto selectById(int id) {
SqlSession session = mybatis.openSession();
CharacteristicMapper mapper = session.getMapper(CharacteristicMapper.class);
try {
diff --git a/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/CharacteristicMapper.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/CharacteristicMapper.java
index be972668908..78b0e2b17c9 100644
--- a/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/CharacteristicMapper.java
+++ b/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/CharacteristicMapper.java
@@ -30,7 +30,7 @@ public interface CharacteristicMapper {
CharacteristicDto selectByKey(String key);
- CharacteristicDto selectById(Integer id);
+ CharacteristicDto selectById(int id);
CharacteristicDto selectByRuleId(Integer ruleId);
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/ProjectUtils.java b/sonar-deprecated/src/main/java/org/sonar/api/resources/ProjectUtils.java
index fc75e6bab18..7540d7ddb2f 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/ProjectUtils.java
+++ b/sonar-deprecated/src/main/java/org/sonar/api/resources/ProjectUtils.java
@@ -26,11 +26,10 @@ import java.util.Collection;
import java.util.List;
/**
- * TODO Actually this class incorrectly named, because provides information not about project, but about Java project.
- * And seems that only core plugins use this class.
- *
* @since 1.10
+ * @deprecated see method comments
*/
+@Deprecated
public final class ProjectUtils {
private ProjectUtils() {
@@ -57,7 +56,9 @@ public final class ProjectUtils {
/**
* @since 2.7
+ * @deprecated in 4.2. Replaced by org.sonar.api.resources.InputFileUtils#toFiles()
*/
+ @Deprecated
public static List<java.io.File> toIoFiles(Collection<InputFile> inputFiles) {
List<java.io.File> files = Lists.newArrayList();
for (InputFile inputFile : inputFiles) {
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/charts/ChartParameters.java b/sonar-plugin-api/src/main/java/org/sonar/api/charts/ChartParameters.java
index 71019742ef2..0b299dbd426 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/charts/ChartParameters.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/charts/ChartParameters.java
@@ -49,7 +49,7 @@ public class ChartParameters {
public static final int DEFAULT_HEIGHT = 200;
- private Map<String, String> params;
+ private final Map<String, String> params;
/**
* Creates a ChartParameter based on a list of parameters
diff --git a/sonar-server/src/main/java/org/sonar/server/group/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/charts/package-info.java
index e27d33915b0..9d4eff6d281 100644
--- a/sonar-server/src/main/java/org/sonar/server/group/package-info.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/charts/package-info.java
@@ -17,9 +17,7 @@
* 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.group;
+package org.sonar.api.charts;
import javax.annotation.ParametersAreNonnullByDefault;
-
diff --git a/sonar-server/src/main/java/org/sonar/server/charts/ChartFactory.java b/sonar-server/src/main/java/org/sonar/server/charts/ChartFactory.java
index 202b035dd88..87ac84d93ca 100644
--- a/sonar-server/src/main/java/org/sonar/server/charts/ChartFactory.java
+++ b/sonar-server/src/main/java/org/sonar/server/charts/ChartFactory.java
@@ -25,11 +25,12 @@ import org.slf4j.LoggerFactory;
import org.sonar.api.ServerComponent;
import org.sonar.api.charts.Chart;
+import javax.annotation.CheckForNull;
import java.util.Map;
public final class ChartFactory implements ServerComponent {
private static final Logger LOG = LoggerFactory.getLogger(ChartFactory.class);
- private Map<String, Chart> chartsByKey = Maps.newHashMap();
+ private final Map<String, Chart> chartsByKey = Maps.newHashMap();
public ChartFactory(Chart[] charts) {
@@ -47,6 +48,7 @@ public final class ChartFactory implements ServerComponent {
// DO NOT SUPPRESS : used by picocontainer if no charts
}
+ @CheckForNull
public Chart getChart(String key) {
return chartsByKey.get(key);
}
diff --git a/sonar-server/src/main/java/org/sonar/server/charts/package-info.java b/sonar-server/src/main/java/org/sonar/server/charts/package-info.java
new file mode 100644
index 00000000000..4991802e1fa
--- /dev/null
+++ b/sonar-server/src/main/java/org/sonar/server/charts/package-info.java
@@ -0,0 +1,23 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2013 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube 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.
+ *
+ * SonarQube 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.charts;
+
+import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-server/src/main/java/org/sonar/server/es/ESIndex.java b/sonar-server/src/main/java/org/sonar/server/es/ESIndex.java
index 28edb3483a0..32e2872f8e7 100644
--- a/sonar-server/src/main/java/org/sonar/server/es/ESIndex.java
+++ b/sonar-server/src/main/java/org/sonar/server/es/ESIndex.java
@@ -60,27 +60,26 @@ public class ESIndex implements Startable {
private static final String BULK_EXECUTE_FAILED = "Execution of bulk operation failed";
private static final String BULK_INTERRUPTED = "Interrupted during bulk operation";
-
private static final String PROFILE_DOMAIN = "es";
private static final Logger LOG = LoggerFactory.getLogger(ESIndex.class);
- private ESNode searchNode;
+ private final ESNode node;
+ private final Profiling profiling;
private Client client;
- private Profiling profiling;
- public ESIndex(ESNode searchNode, Profiling profiling) {
- this.searchNode = searchNode;
+ public ESIndex(ESNode node, Profiling profiling) {
+ this.node = node;
this.profiling = profiling;
}
@Override
public void start() {
- this.client = searchNode.client();
+ this.client = node.client();
}
@Override
public void stop() {
- if(client != null) {
+ if (client != null) {
client.close();
}
}
@@ -120,7 +119,7 @@ public class ESIndex implements Startable {
public void bulkIndex(String index, String type, String[] ids, BytesStream[] sources) {
BulkRequestBuilder builder = new BulkRequestBuilder(client);
- for (int i=0; i<ids.length; i++) {
+ for (int i = 0; i < ids.length; i++) {
builder.add(client.prepareIndex(index, type, ids[i]).setSource(sources[i].bytes()));
}
StopWatch watch = createWatch();
@@ -133,7 +132,7 @@ public class ESIndex implements Startable {
public void bulkIndex(String index, String type, String[] ids, BytesStream[] sources, String[] parentIds) {
BulkRequestBuilder builder = new BulkRequestBuilder(client);
- for (int i=0; i<ids.length; i++) {
+ for (int i = 0; i < ids.length; i++) {
builder.add(client.prepareIndex(index, type, ids[i]).setParent(parentIds[i]).setSource(sources[i].bytes()));
}
StopWatch watch = createWatch();
@@ -151,7 +150,7 @@ public class ESIndex implements Startable {
throw new IllegalArgumentException("Could not load unexisting file at " + resourcePath);
}
addMapping(index, type, IOUtils.toString(resource));
- } catch(IOException ioException) {
+ } catch (IOException ioException) {
throw new IllegalArgumentException("Problem loading file at " + resourcePath, ioException);
}
}
@@ -160,7 +159,7 @@ public class ESIndex implements Startable {
IndicesAdminClient indices = client.admin().indices();
StopWatch watch = createWatch();
try {
- if (! indices.exists(indices.prepareExists(index).request()).get().isExists()) {
+ if (!indices.exists(indices.prepareExists(index).request()).get().isExists()) {
indices.prepareCreate(index)
.execute().actionGet();
}
@@ -173,7 +172,7 @@ public class ESIndex implements Startable {
watch = createWatch();
try {
indices.putMapping(Requests.putMappingRequest(index).type(type).source(mapping)).actionGet();
- } catch(ElasticSearchParseException parseException) {
+ } catch (ElasticSearchParseException parseException) {
throw new IllegalArgumentException("Invalid mapping file", parseException);
} finally {
watch.stop("put mapping on index '%s' for type '%s'", index, type);
@@ -248,7 +247,7 @@ public class ESIndex implements Startable {
private String builderToString(SearchRequestBuilder builder) {
try {
return builder.internalBuilder().toXContent(XContentFactory.jsonBuilder(), ToXContent.EMPTY_PARAMS)
- .humanReadable(false).string();
+ .humanReadable(false).string();
} catch (IOException ioException) {
LOG.warn("Could not serialize request: " + builder.internalBuilder().toString(), ioException);
return "<IOException in serialize>";
@@ -273,7 +272,7 @@ public class ESIndex implements Startable {
BulkResponse bulkResponse = client.bulk(builder.setRefresh(true).request()).get();
if (bulkResponse.hasFailures()) {
for (BulkItemResponse bulkItemResponse : bulkResponse.getItems()) {
- if(bulkItemResponse.isFailed()) {
+ if (bulkItemResponse.isFailed()) {
throw new IllegalStateException("Bulk operation partially executed: " + bulkItemResponse.getFailure().getMessage());
}
}
diff --git a/sonar-server/src/main/java/org/sonar/server/exceptions/package-info.java b/sonar-server/src/main/java/org/sonar/server/exceptions/package-info.java
new file mode 100644
index 00000000000..643797f7e8c
--- /dev/null
+++ b/sonar-server/src/main/java/org/sonar/server/exceptions/package-info.java
@@ -0,0 +1,25 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2013 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube 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.
+ *
+ * SonarQube 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.exceptions;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
diff --git a/sonar-server/src/main/java/org/sonar/server/issue/IssueChangelogFormatter.java b/sonar-server/src/main/java/org/sonar/server/issue/IssueChangelogFormatter.java
index 037ba13280c..56d38affc15 100644
--- a/sonar-server/src/main/java/org/sonar/server/issue/IssueChangelogFormatter.java
+++ b/sonar-server/src/main/java/org/sonar/server/issue/IssueChangelogFormatter.java
@@ -24,7 +24,7 @@ import org.sonar.api.issue.internal.FieldDiffs;
import org.sonar.api.issue.internal.WorkDayDuration;
import org.sonar.core.i18n.DefaultI18n;
import org.sonar.core.issue.IssueUpdater;
-import org.sonar.server.technicaldebt.TechnicalDebtFormatter;
+import org.sonar.server.technicaldebt.DebtFormatter;
import java.io.Serializable;
import java.util.List;
@@ -38,11 +38,11 @@ public class IssueChangelogFormatter implements ServerComponent {
private static final String ISSUE_CHANGELOG_FIELD = "issue.changelog.field.";
private final DefaultI18n defaultI18n;
- private final TechnicalDebtFormatter technicalDebtFormatter;
+ private final DebtFormatter debtFormatter;
- public IssueChangelogFormatter(DefaultI18n defaultI18n, TechnicalDebtFormatter technicalDebtFormatter) {
+ public IssueChangelogFormatter(DefaultI18n defaultI18n, DebtFormatter debtFormatter) {
this.defaultI18n = defaultI18n;
- this.technicalDebtFormatter = technicalDebtFormatter;
+ this.debtFormatter = debtFormatter;
}
public List<String> format(Locale locale, FieldDiffs diffs) {
@@ -74,10 +74,10 @@ public class IssueChangelogFormatter implements ServerComponent {
String oldValueString = oldValue != null && !"".equals(oldValue) ? oldValue.toString() : null;
if (IssueUpdater.TECHNICAL_DEBT.equals(key)) {
if (newValueString != null) {
- newValueString = technicalDebtFormatter.format(locale, WorkDayDuration.fromLong(Long.parseLong(newValueString)));
+ newValueString = debtFormatter.format(locale, WorkDayDuration.fromLong(Long.parseLong(newValueString)));
}
if (oldValueString != null) {
- oldValueString = technicalDebtFormatter.format(locale, WorkDayDuration.fromLong(Long.parseLong(oldValueString)));
+ oldValueString = debtFormatter.format(locale, WorkDayDuration.fromLong(Long.parseLong(oldValueString)));
}
}
return new IssueChangelogDiffFormat(oldValueString, newValueString);
diff --git a/sonar-server/src/main/java/org/sonar/server/issue/ws/IssueShowWsHandler.java b/sonar-server/src/main/java/org/sonar/server/issue/ws/IssueShowWsHandler.java
index ff0a494ba4b..46e1c997b70 100644
--- a/sonar-server/src/main/java/org/sonar/server/issue/ws/IssueShowWsHandler.java
+++ b/sonar-server/src/main/java/org/sonar/server/issue/ws/IssueShowWsHandler.java
@@ -42,12 +42,11 @@ import org.sonar.server.issue.ActionService;
import org.sonar.server.issue.IssueChangelog;
import org.sonar.server.issue.IssueChangelogService;
import org.sonar.server.issue.IssueService;
-import org.sonar.server.technicaldebt.TechnicalDebtFormatter;
+import org.sonar.server.technicaldebt.DebtFormatter;
import org.sonar.server.user.UserSession;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
-
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@@ -60,17 +59,17 @@ public class IssueShowWsHandler implements RequestHandler {
private final IssueService issueService;
private final IssueChangelogService issueChangelogService;
private final ActionService actionService;
- private final TechnicalDebtFormatter technicalDebtFormatter;
+ private final DebtFormatter debtFormatter;
private final DefaultTechnicalDebtManager technicalDebtManager;
private final I18n i18n;
public IssueShowWsHandler(IssueFinder issueFinder, IssueService issueService, IssueChangelogService issueChangelogService, ActionService actionService,
- TechnicalDebtFormatter technicalDebtFormatter, DefaultTechnicalDebtManager technicalDebtManager, I18n i18n) {
+ DebtFormatter debtFormatter, DefaultTechnicalDebtManager technicalDebtManager, I18n i18n) {
this.issueFinder = issueFinder;
this.issueService = issueService;
this.issueChangelogService = issueChangelogService;
this.actionService = actionService;
- this.technicalDebtFormatter = technicalDebtFormatter;
+ this.debtFormatter = debtFormatter;
this.technicalDebtManager = technicalDebtManager;
this.i18n = i18n;
}
@@ -122,7 +121,7 @@ public class IssueShowWsHandler implements RequestHandler {
.prop("severity", issue.severity())
.prop("author", issue.authorLogin())
.prop("actionPlan", actionPlanKey)
- .prop("debt", technicalDebt != null ? technicalDebtFormatter.format(UserSession.get().locale(), technicalDebt) : null)
+ .prop("debt", technicalDebt != null ? debtFormatter.format(UserSession.get().locale(), technicalDebt) : null)
.prop("actionPlanName", actionPlanKey != null ? result.actionPlan(issue).name() : null)
.prop("creationDate", DateUtils.formatDateTime(issue.creationDate()))
.prop("fCreationDate", formatDate(issue.creationDate()))
diff --git a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java
index 597ec30f409..513be22291e 100644
--- a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java
+++ b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java
@@ -74,15 +74,12 @@ import org.sonar.jpa.session.ThreadLocalDatabaseSessionFactory;
import org.sonar.server.charts.ChartFactory;
import org.sonar.server.component.DefaultComponentFinder;
import org.sonar.server.component.DefaultRubyComponentService;
-import org.sonar.server.qualityprofile.ProfilesManager;
import org.sonar.server.db.EmbeddedDatabaseFactory;
import org.sonar.server.db.migrations.DatabaseMigration;
import org.sonar.server.db.migrations.DatabaseMigrations;
import org.sonar.server.db.migrations.DatabaseMigrator;
import org.sonar.server.es.ESIndex;
import org.sonar.server.es.ESNode;
-import org.sonar.server.group.GroupMembershipFinder;
-import org.sonar.server.group.InternalGroupMembershipService;
import org.sonar.server.issue.*;
import org.sonar.server.issue.filter.IssueFilterService;
import org.sonar.server.issue.filter.IssueFilterWs;
@@ -104,13 +101,15 @@ import org.sonar.server.source.SourceService;
import org.sonar.server.source.ws.SourcesShowWsHandler;
import org.sonar.server.source.ws.SourcesWs;
import org.sonar.server.startup.*;
-import org.sonar.server.technicaldebt.InternalRubyTechnicalDebtService;
-import org.sonar.server.technicaldebt.TechnicalDebtFormatter;
+import org.sonar.server.technicaldebt.DebtFormatter;
+import org.sonar.server.technicaldebt.DebtService;
import org.sonar.server.text.MacroInterpreter;
import org.sonar.server.text.RubyTextService;
-import org.sonar.server.ui.*;
-import org.sonar.server.user.DefaultUserService;
-import org.sonar.server.user.NewUserNotifier;
+import org.sonar.server.ui.JRubyI18n;
+import org.sonar.server.ui.JRubyProfiling;
+import org.sonar.server.ui.PageDecorations;
+import org.sonar.server.ui.Views;
+import org.sonar.server.user.*;
import org.sonar.server.util.*;
import org.sonar.server.ws.ListingWs;
import org.sonar.server.ws.WebServiceEngine;
@@ -299,7 +298,7 @@ public final class Platform {
servicesContainer.addSingleton(DefaultUserService.class);
// groups
- servicesContainer.addSingleton(InternalGroupMembershipService.class);
+ servicesContainer.addSingleton(GroupMembershipService.class);
servicesContainer.addSingleton(GroupMembershipFinder.class);
// permissions
@@ -362,12 +361,12 @@ public final class Platform {
servicesContainer.addSingleton(RuleTagsWs.class);
// technical debt
- servicesContainer.addSingleton(InternalRubyTechnicalDebtService.class);
+ servicesContainer.addSingleton(DebtService.class);
servicesContainer.addSingleton(TechnicalDebtModelSynchronizer.class);
servicesContainer.addSingleton(TechnicalDebtModelRepository.class);
servicesContainer.addSingleton(TechnicalDebtXMLImporter.class);
servicesContainer.addSingleton(TechnicalDebtConverter.class);
- servicesContainer.addSingleton(TechnicalDebtFormatter.class);
+ servicesContainer.addSingleton(DebtFormatter.class);
servicesContainer.addSingleton(DefaultTechnicalDebtManager.class);
// source
@@ -426,7 +425,7 @@ public final class Platform {
startupContainer.addSingleton(RenameDeprecatedPropertyKeys.class);
startupContainer.addSingleton(LogServerId.class);
startupContainer.addSingleton(RegisterServletFilters.class);
- startupContainer.addSingleton(CleanDryRunCache.class);
+ startupContainer.addSingleton(CleanPreviewAnalysisCache.class);
startupContainer.startComponents();
startupContainer.getComponentByType(ServerLifecycleNotifier.class).notifyStart();
diff --git a/sonar-server/src/main/java/org/sonar/server/plugins/MimeTypes.java b/sonar-server/src/main/java/org/sonar/server/plugins/MimeTypes.java
index e1cffe96c99..7ad624f820a 100644
--- a/sonar-server/src/main/java/org/sonar/server/plugins/MimeTypes.java
+++ b/sonar-server/src/main/java/org/sonar/server/plugins/MimeTypes.java
@@ -31,10 +31,15 @@ import java.util.Map;
*/
public final class MimeTypes {
private MimeTypes() {
+ // only static methods
}
+ public static final String JSON = "application/json";
+ public static final String XML = "application/xml";
+ public static final String DEFAULT = "application/octet-stream";
+
private static final Map<String, String> MAP = new ImmutableMap.Builder<String, String>()
- .put("json", "application/json")
+ .put("json", JSON)
.put("zip", "application/zip")
.put("tgz", "application/tgz")
.put("ps", "application/postscript")
@@ -43,7 +48,7 @@ public final class MimeTypes {
.put("xls", "application/vnd.ms-excel")
.put("ppt", "application/vnd.ms-powerpoint")
.put("tar", "application/x-tar")
- .put("xml", "application/xml")
+ .put("xml", XML)
.put("dtd", "application/xml-dtd")
.put("xslt", "application/xslt+xml")
.put("bmp", "image/bmp")
@@ -63,8 +68,6 @@ public final class MimeTypes {
.put("tsv", "text/tab-separated-values")
.build();
- public static final String DEFAULT = "application/octet-stream";
-
public static String getByFilename(String filename) {
String extension = FilenameUtils.getExtension(filename);
String mime = null;
diff --git a/sonar-server/src/main/java/org/sonar/server/startup/CleanDryRunCache.java b/sonar-server/src/main/java/org/sonar/server/startup/CleanPreviewAnalysisCache.java
index d70003ecf7f..e386cde515e 100644
--- a/sonar-server/src/main/java/org/sonar/server/startup/CleanDryRunCache.java
+++ b/sonar-server/src/main/java/org/sonar/server/startup/CleanPreviewAnalysisCache.java
@@ -19,20 +19,27 @@
*/
package org.sonar.server.startup;
+import org.picocontainer.Startable;
import org.sonar.core.preview.PreviewCache;
/**
* @since 4.0
*/
-public class CleanDryRunCache {
+public class CleanPreviewAnalysisCache implements Startable {
- private PreviewCache dryRunCache;
+ private final PreviewCache cache;
- public CleanDryRunCache(PreviewCache dryRunCache) {
- this.dryRunCache = dryRunCache;
+ public CleanPreviewAnalysisCache(PreviewCache cache) {
+ this.cache = cache;
}
+ @Override
public void start() {
- dryRunCache.cleanAll();
+ cache.cleanAll();
+ }
+
+ @Override
+ public void stop() {
+ // nothing
}
}
diff --git a/sonar-server/src/main/java/org/sonar/server/startup/ServerMetadataPersister.java b/sonar-server/src/main/java/org/sonar/server/startup/ServerMetadataPersister.java
index 6ef13983f50..231a3c8e05e 100644
--- a/sonar-server/src/main/java/org/sonar/server/startup/ServerMetadataPersister.java
+++ b/sonar-server/src/main/java/org/sonar/server/startup/ServerMetadataPersister.java
@@ -20,6 +20,7 @@
package org.sonar.server.startup;
import com.google.common.collect.ImmutableMap;
+import org.picocontainer.Startable;
import org.slf4j.LoggerFactory;
import org.sonar.api.CoreProperties;
import org.sonar.api.platform.Server;
@@ -27,7 +28,7 @@ import org.sonar.server.platform.PersistentSettings;
import java.text.SimpleDateFormat;
-public final class ServerMetadataPersister {
+public final class ServerMetadataPersister implements Startable {
private final Server server;
private final PersistentSettings persistentSettings;
@@ -37,6 +38,7 @@ public final class ServerMetadataPersister {
this.persistentSettings = persistentSettings;
}
+ @Override
public void start() {
LoggerFactory.getLogger(getClass()).debug("Persisting server metadata");
persistentSettings.saveProperties(ImmutableMap.of(
@@ -44,4 +46,9 @@ public final class ServerMetadataPersister {
CoreProperties.SERVER_VERSION, server.getVersion(),
CoreProperties.SERVER_STARTTIME, new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(server.getStartedAt())));
}
+
+ @Override
+ public void stop() {
+ // nothing
+ }
}
diff --git a/sonar-server/src/main/java/org/sonar/server/technicaldebt/TechnicalDebtFormatter.java b/sonar-server/src/main/java/org/sonar/server/technicaldebt/DebtFormatter.java
index 6c77f0d2889..5a44a0f432e 100644
--- a/sonar-server/src/main/java/org/sonar/server/technicaldebt/TechnicalDebtFormatter.java
+++ b/sonar-server/src/main/java/org/sonar/server/technicaldebt/DebtFormatter.java
@@ -26,11 +26,11 @@ import org.sonar.core.i18n.DefaultI18n;
import java.util.Locale;
-public class TechnicalDebtFormatter implements ServerComponent {
+public class DebtFormatter implements ServerComponent {
private final DefaultI18n defaultI18n;
- public TechnicalDebtFormatter(DefaultI18n defaultI18n) {
+ public DebtFormatter(DefaultI18n defaultI18n) {
this.defaultI18n = defaultI18n;
}
diff --git a/sonar-server/src/main/java/org/sonar/server/technicaldebt/InternalRubyTechnicalDebtService.java b/sonar-server/src/main/java/org/sonar/server/technicaldebt/DebtService.java
index 6d8774403c6..464214c03e3 100644
--- a/sonar-server/src/main/java/org/sonar/server/technicaldebt/InternalRubyTechnicalDebtService.java
+++ b/sonar-server/src/main/java/org/sonar/server/technicaldebt/DebtService.java
@@ -27,20 +27,21 @@ import org.sonar.api.technicaldebt.server.Characteristic;
import org.sonar.core.technicaldebt.DefaultTechnicalDebtManager;
import org.sonar.server.user.UserSession;
+import javax.annotation.CheckForNull;
import java.util.List;
-public class InternalRubyTechnicalDebtService implements ServerComponent {
+public class DebtService implements ServerComponent {
- private final TechnicalDebtFormatter technicalDebtFormatter;
+ private final DebtFormatter debtFormatter;
private final DefaultTechnicalDebtManager finder;
- public InternalRubyTechnicalDebtService(TechnicalDebtFormatter technicalDebtFormatter, DefaultTechnicalDebtManager finder) {
- this.technicalDebtFormatter = technicalDebtFormatter;
+ public DebtService(DebtFormatter debtFormatter, DefaultTechnicalDebtManager finder) {
+ this.debtFormatter = debtFormatter;
this.finder = finder;
}
public String format(WorkDayDuration technicalDebt) {
- return technicalDebtFormatter.format(UserSession.get().locale(), technicalDebt);
+ return debtFormatter.format(UserSession.get().locale(), technicalDebt);
}
public WorkDayDuration toTechnicalDebt(String technicalDebtInLong) {
@@ -55,7 +56,8 @@ public class InternalRubyTechnicalDebtService implements ServerComponent {
return finder.findRequirementByRule(rule);
}
- public Characteristic findCharacteristic(Integer id) {
+ @CheckForNull
+ public Characteristic findCharacteristic(int id) {
return finder.findCharacteristicById(id);
}
diff --git a/sonar-server/src/main/java/org/sonar/server/ui/CompatibilityRealm.java b/sonar-server/src/main/java/org/sonar/server/user/CompatibilityRealm.java
index 73d85bf0152..e56ea977a37 100644
--- a/sonar-server/src/main/java/org/sonar/server/ui/CompatibilityRealm.java
+++ b/sonar-server/src/main/java/org/sonar/server/user/CompatibilityRealm.java
@@ -17,7 +17,7 @@
* 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;
+package org.sonar.server.user;
import org.sonar.api.security.LoginPasswordAuthenticator;
import org.sonar.api.security.SecurityRealm;
diff --git a/sonar-server/src/main/java/org/sonar/server/ui/DatabaseSessionFilter.java b/sonar-server/src/main/java/org/sonar/server/user/DatabaseSessionFilter.java
index f6f0893834f..83b43ffe818 100644
--- a/sonar-server/src/main/java/org/sonar/server/ui/DatabaseSessionFilter.java
+++ b/sonar-server/src/main/java/org/sonar/server/user/DatabaseSessionFilter.java
@@ -17,13 +17,13 @@
* 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;
+package org.sonar.server.user;
import org.sonar.jpa.session.DatabaseSessionFactory;
import org.sonar.server.platform.Platform;
-import java.io.IOException;
import javax.servlet.*;
+import java.io.IOException;
public class DatabaseSessionFilter implements Filter {
@Override
diff --git a/sonar-server/src/main/java/org/sonar/server/group/GroupMembershipFinder.java b/sonar-server/src/main/java/org/sonar/server/user/GroupMembershipFinder.java
index 07c3d48f5fe..1aaca4e79cb 100644
--- a/sonar-server/src/main/java/org/sonar/server/group/GroupMembershipFinder.java
+++ b/sonar-server/src/main/java/org/sonar/server/user/GroupMembershipFinder.java
@@ -18,7 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.server.group;
+package org.sonar.server.user;
import org.sonar.api.ServerComponent;
import org.sonar.core.user.*;
@@ -30,6 +30,24 @@ import static com.google.common.collect.Lists.newArrayList;
public class GroupMembershipFinder implements ServerComponent {
+ public static class Membership {
+ private List<GroupMembership> groups;
+ private boolean hasMoreResults;
+
+ private Membership(List<GroupMembership> groups, boolean hasMoreResults) {
+ this.groups = groups;
+ this.hasMoreResults = hasMoreResults;
+ }
+
+ public List<GroupMembership> groups() {
+ return groups;
+ }
+
+ public boolean hasMoreResults() {
+ return hasMoreResults;
+ }
+ }
+
private final UserDao userDao;
private final GroupMembershipDao groupMembershipDao;
@@ -38,7 +56,7 @@ public class GroupMembershipFinder implements ServerComponent {
this.groupMembershipDao = groupMembershipDao;
}
- public GroupMembershipQueryResult find(GroupMembershipQuery query) {
+ public Membership find(GroupMembershipQuery query) {
Long userId = userId(query.login());
int pageSize = query.pageSize();
int pageIndex = query.pageIndex();
@@ -53,13 +71,13 @@ public class GroupMembershipFinder implements ServerComponent {
// Removed last entry as it's only need to know if there more results or not
dtos.remove(dtos.size() - 1);
}
- return new GroupMembershipQueryResult(toGroupMembership(dtos), hasMoreResults);
+ return new Membership(toGroupMembership(dtos), hasMoreResults);
}
private Long userId(String login) {
UserDto userDto = userDao.selectActiveUserByLogin(login);
if (userDto == null) {
- throw new NotFoundException("User '"+ login +"' does not exists.");
+ throw new NotFoundException("User '" + login + "' does not exists.");
}
return userDto.getId();
}
diff --git a/sonar-server/src/main/java/org/sonar/server/group/InternalGroupMembershipService.java b/sonar-server/src/main/java/org/sonar/server/user/GroupMembershipService.java
index 1746f8d91f5..ec32e47249f 100644
--- a/sonar-server/src/main/java/org/sonar/server/group/InternalGroupMembershipService.java
+++ b/sonar-server/src/main/java/org/sonar/server/user/GroupMembershipService.java
@@ -18,7 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.server.group;
+package org.sonar.server.user;
import org.sonar.api.ServerComponent;
import org.sonar.core.user.GroupMembershipQuery;
@@ -29,18 +29,18 @@ import java.util.Map;
/**
* Used by ruby code <pre>Internal.group_membership</pre>
*/
-public class InternalGroupMembershipService implements ServerComponent {
+public class GroupMembershipService implements ServerComponent {
private static final String SELECTED_MEMBERSHIP = "selected";
private static final String DESELECTED_MEMBERSHIP = "deselected";
private final GroupMembershipFinder finder;
- public InternalGroupMembershipService(GroupMembershipFinder finder) {
+ public GroupMembershipService(GroupMembershipFinder finder) {
this.finder = finder;
}
- public GroupMembershipQueryResult find(Map<String, Object> params) {
+ public GroupMembershipFinder.Membership find(Map<String, Object> params) {
return finder.find(parseQuery(params));
}
diff --git a/sonar-server/src/main/java/org/sonar/server/ui/SecurityRealmFactory.java b/sonar-server/src/main/java/org/sonar/server/user/SecurityRealmFactory.java
index f3baa373da5..7b048cdcb4d 100644
--- a/sonar-server/src/main/java/org/sonar/server/ui/SecurityRealmFactory.java
+++ b/sonar-server/src/main/java/org/sonar/server/user/SecurityRealmFactory.java
@@ -17,7 +17,7 @@
* 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;
+package org.sonar.server.user;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
diff --git a/sonar-server/src/main/java/org/sonar/server/ws/ServletResponse.java b/sonar-server/src/main/java/org/sonar/server/ws/ServletResponse.java
index d884d0753a7..a30d890caf0 100644
--- a/sonar-server/src/main/java/org/sonar/server/ws/ServletResponse.java
+++ b/sonar-server/src/main/java/org/sonar/server/ws/ServletResponse.java
@@ -22,6 +22,7 @@ package org.sonar.server.ws;
import org.sonar.api.server.ws.Response;
import org.sonar.api.utils.text.JsonWriter;
import org.sonar.api.utils.text.XmlWriter;
+import org.sonar.server.plugins.MimeTypes;
import javax.annotation.CheckForNull;
import java.io.ByteArrayOutputStream;
@@ -75,13 +76,13 @@ public class ServletResponse implements Response {
@Override
public JsonWriter newJsonWriter() {
- stream.setMediaType("application/json");
+ stream.setMediaType(MimeTypes.JSON);
return JsonWriter.of(new OutputStreamWriter(stream.output()));
}
@Override
public XmlWriter newXmlWriter() {
- stream.setMediaType("application/xml");
+ stream.setMediaType(MimeTypes.XML);
return XmlWriter.of(new OutputStreamWriter(stream.output()));
}
diff --git a/sonar-server/src/main/java/org/sonar/server/ws/WebServiceEngine.java b/sonar-server/src/main/java/org/sonar/server/ws/WebServiceEngine.java
index 760d8b74f7c..e8f19b7c03e 100644
--- a/sonar-server/src/main/java/org/sonar/server/ws/WebServiceEngine.java
+++ b/sonar-server/src/main/java/org/sonar/server/ws/WebServiceEngine.java
@@ -27,6 +27,7 @@ import org.sonar.api.server.ws.WebService;
import org.sonar.api.utils.text.JsonWriter;
import org.sonar.server.exceptions.BadRequestException;
import org.sonar.server.exceptions.ServerException;
+import org.sonar.server.plugins.MimeTypes;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStreamWriter;
@@ -110,7 +111,7 @@ public class WebServiceEngine implements ServerComponent, Startable {
ServletResponse.ServletStream stream = response.stream();
stream.reset();
stream.setStatus(status);
- stream.setMediaType("application/json");
+ stream.setMediaType(MimeTypes.JSON);
JsonWriter json = JsonWriter.of(new OutputStreamWriter(stream.output()));
try {
json.beginObject();
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/internal.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/internal.rb
index 4c56be7800d..b169243bb19 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/internal.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/internal.rb
@@ -55,7 +55,7 @@ class Internal
end
def self.technical_debt
- component(Java::OrgSonarServerTechnicaldebt::InternalRubyTechnicalDebtService.java_class)
+ component(Java::OrgSonarServerTechnicaldebt::DebtService.java_class)
end
def self.profiling
@@ -63,7 +63,7 @@ class Internal
end
def self.group_membership
- component(Java::OrgSonarServerGroup::InternalGroupMembershipService.java_class)
+ component(Java::OrgSonarServerUser::GroupMembershipService.java_class)
end
def self.quality_profiles
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/server.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/server.rb
index a1acde9f0ce..b95ef772adb 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/server.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/server.rb
@@ -25,60 +25,60 @@ class Server
def system_info
system_info=[]
- add_property(system_info, 'System date') {java.util.Date.new()}
- add_property(system_info, 'JVM Vendor') {java.lang.management.ManagementFactory.getRuntimeMXBean().getVmVendor()}
- add_property(system_info, 'JVM Name') {java.lang.management.ManagementFactory.getRuntimeMXBean().getVmName()}
- add_property(system_info, 'JVM Version') {java.lang.management.ManagementFactory.getRuntimeMXBean().getVmVersion() }
- add_property(system_info, 'Java Version') {java_property('java.runtime.version') }
- add_property(system_info, 'Java Home') {java_property('java.home')}
- add_property(system_info, 'JIT Compiler') {java_property('java.compiler')}
- add_property(system_info, 'Application Server Container') {$servlet_context.getServerInfo() }
- add_property(system_info, 'User Name') {java_property('user.name')}
- add_property(system_info, 'User TimeZone') {java_property('user.timezone')}
- add_property(system_info, 'OS') {"#{java_property('os.name')} / #{java_property('os.arch')} / #{java_property('os.version')}"}
- add_property(system_info, 'Processors') {java.lang.Runtime.getRuntime().availableProcessors()}
- add_property(system_info, 'System Classpath') {java.lang.management.ManagementFactory.getRuntimeMXBean().getClassPath()}
- add_property(system_info, 'Boot Classpath') {java.lang.management.ManagementFactory.getRuntimeMXBean().getBootClassPath() }
- add_property(system_info, 'Library Path') {java.lang.management.ManagementFactory.getRuntimeMXBean().getLibraryPath() }
+ add_property(system_info, 'System date') { java.util.Date.new() }
+ add_property(system_info, 'JVM Vendor') { java.lang.management.ManagementFactory.getRuntimeMXBean().getVmVendor() }
+ add_property(system_info, 'JVM Name') { java.lang.management.ManagementFactory.getRuntimeMXBean().getVmName() }
+ add_property(system_info, 'JVM Version') { java.lang.management.ManagementFactory.getRuntimeMXBean().getVmVersion() }
+ add_property(system_info, 'Java Version') { java_property('java.runtime.version') }
+ add_property(system_info, 'Java Home') { java_property('java.home') }
+ add_property(system_info, 'JIT Compiler') { java_property('java.compiler') }
+ add_property(system_info, 'Application Server Container') { $servlet_context.getServerInfo() }
+ add_property(system_info, 'User Name') { java_property('user.name') }
+ add_property(system_info, 'User TimeZone') { java_property('user.timezone') }
+ add_property(system_info, 'OS') { "#{java_property('os.name')} / #{java_property('os.arch')} / #{java_property('os.version')}" }
+ add_property(system_info, 'Processors') { java.lang.Runtime.getRuntime().availableProcessors() }
+ add_property(system_info, 'System Classpath') { java.lang.management.ManagementFactory.getRuntimeMXBean().getClassPath() }
+ add_property(system_info, 'Boot Classpath') { java.lang.management.ManagementFactory.getRuntimeMXBean().getBootClassPath() }
+ add_property(system_info, 'Library Path') { java.lang.management.ManagementFactory.getRuntimeMXBean().getLibraryPath() }
system_info
end
def system_statistics
system_statistics=[]
- add_property(system_statistics, 'Total Memory') {"#{java.lang.Runtime.getRuntime().totalMemory() / 1000000} MB"}
- add_property(system_statistics, 'Free Memory') {"#{java.lang.Runtime.getRuntime().freeMemory() / 1000000} MB"}
- add_property(system_statistics, 'Max Memory') {"#{java.lang.Runtime.getRuntime().maxMemory() / 1000000} MB"}
- add_property(system_statistics, 'Heap') {"#{java.lang.management.ManagementFactory.getMemoryMXBean().getHeapMemoryUsage()}"}
- add_property(system_statistics, 'Non Heap') {"#{java.lang.management.ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage()}"}
- add_property(system_statistics, 'System Load Average (last minute)') {system_load_average()}
- add_property(system_statistics, 'Loaded Classes (currently/total/unloaded)') {"#{java.lang.management.ManagementFactory.getClassLoadingMXBean().getLoadedClassCount()} / #{java.lang.management.ManagementFactory.getClassLoadingMXBean().getTotalLoadedClassCount()} / #{java.lang.management.ManagementFactory.getClassLoadingMXBean().getUnloadedClassCount()}"}
- add_property(system_statistics, 'Start Time') {"#{format_date(java.util.Date.new(java.lang.management.ManagementFactory.getRuntimeMXBean().getStartTime()))}"}
- add_property(system_statistics, 'Threads (total/peak/daemon)') {"#{java.lang.management.ManagementFactory.getThreadMXBean().getThreadCount()} / #{java.lang.management.ManagementFactory.getThreadMXBean().getPeakThreadCount()} / #{java.lang.management.ManagementFactory.getThreadMXBean().getDaemonThreadCount() }" }
+ add_property(system_statistics, 'Total Memory') { "#{java.lang.Runtime.getRuntime().totalMemory() / 1000000} MB" }
+ add_property(system_statistics, 'Free Memory') { "#{java.lang.Runtime.getRuntime().freeMemory() / 1000000} MB" }
+ add_property(system_statistics, 'Max Memory') { "#{java.lang.Runtime.getRuntime().maxMemory() / 1000000} MB" }
+ add_property(system_statistics, 'Heap') { "#{java.lang.management.ManagementFactory.getMemoryMXBean().getHeapMemoryUsage()}" }
+ add_property(system_statistics, 'Non Heap') { "#{java.lang.management.ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage()}" }
+ add_property(system_statistics, 'System Load Average (last minute)') { system_load_average() }
+ add_property(system_statistics, 'Loaded Classes (currently/total/unloaded)') { "#{java.lang.management.ManagementFactory.getClassLoadingMXBean().getLoadedClassCount()} / #{java.lang.management.ManagementFactory.getClassLoadingMXBean().getTotalLoadedClassCount()} / #{java.lang.management.ManagementFactory.getClassLoadingMXBean().getUnloadedClassCount()}" }
+ add_property(system_statistics, 'Start Time') { "#{format_date(java.util.Date.new(java.lang.management.ManagementFactory.getRuntimeMXBean().getStartTime()))}" }
+ add_property(system_statistics, 'Threads (total/peak/daemon)') { "#{java.lang.management.ManagementFactory.getThreadMXBean().getThreadCount()} / #{java.lang.management.ManagementFactory.getThreadMXBean().getPeakThreadCount()} / #{java.lang.management.ManagementFactory.getThreadMXBean().getDaemonThreadCount() }" }
system_statistics
end
def sonar_info
sonar_info=[]
- add_property(sonar_info, 'Server ID') {sonar_property(ServerIdConfigurationController::PROPERTY_SERVER_ID)}
- add_property(sonar_info, 'Version') {org.sonar.server.platform.Platform.getServer().getVersion()}
- add_property(sonar_info, 'Started at') {org.sonar.server.platform.Platform.getServer().getStartedAt()}
- add_property(sonar_info, 'Database') {"#{jdbc_metadata. getDatabaseProductName()} #{jdbc_metadata. getDatabaseProductVersion()}"}
- add_property(sonar_info, 'Database URL') {sonar_property('sonar.jdbc.url')}
- add_property(sonar_info, 'Database Login') {sonar_property('sonar.jdbc.username')}
- add_property(sonar_info, 'Database Driver') {"#{jdbc_metadata.getDriverName()} #{jdbc_metadata.getDriverVersion()}"}
- add_property(sonar_info, 'Database Driver Class') {sonar_property('sonar.jdbc.driverClassName')}
- add_property(sonar_info, 'Database Dialect (Hibernate)') {"#{Java::OrgSonarServerUi::JRubyFacade.getInstance().getDatabase().getDialect().getId()} (#{Java::OrgSonarServerUi::JRubyFacade.getInstance().getDatabase().getDialect().getHibernateDialectClass().getName()})"}
- add_property(sonar_info, 'External User Authentication') {realm_name}
- add_property(sonar_info, 'Automatic User Creation') {sonar_property(org.sonar.api.CoreProperties.CORE_AUTHENTICATOR_CREATE_USERS)}
- add_property(sonar_info, 'Allow Users to Sign Up') {sonar_property(org.sonar.api.CoreProperties.CORE_ALLOW_USERS_TO_SIGNUP_PROPERTY)}
- add_property(sonar_info, 'Force Authentication') {sonar_property(org.sonar.api.CoreProperties.CORE_FORCE_AUTHENTICATION_PROPERTY)}
+ add_property(sonar_info, 'Server ID') { sonar_property(ServerIdConfigurationController::PROPERTY_SERVER_ID) }
+ add_property(sonar_info, 'Version') { org.sonar.server.platform.Platform.getServer().getVersion() }
+ add_property(sonar_info, 'Started at') { org.sonar.server.platform.Platform.getServer().getStartedAt() }
+ add_property(sonar_info, 'Database') { "#{jdbc_metadata.getDatabaseProductName()} #{jdbc_metadata.getDatabaseProductVersion()}" }
+ add_property(sonar_info, 'Database URL') { sonar_property('sonar.jdbc.url') }
+ add_property(sonar_info, 'Database Login') { sonar_property('sonar.jdbc.username') }
+ add_property(sonar_info, 'Database Driver') { "#{jdbc_metadata.getDriverName()} #{jdbc_metadata.getDriverVersion()}" }
+ add_property(sonar_info, 'Database Driver Class') { sonar_property('sonar.jdbc.driverClassName') }
+ add_property(sonar_info, 'Database Dialect (Hibernate)') { "#{Java::OrgSonarServerUi::JRubyFacade.getInstance().getDatabase().getDialect().getId()} (#{Java::OrgSonarServerUi::JRubyFacade.getInstance().getDatabase().getDialect().getHibernateDialectClass().getName()})" }
+ add_property(sonar_info, 'External User Authentication') { realm_name }
+ add_property(sonar_info, 'Automatic User Creation') { sonar_property(org.sonar.api.CoreProperties.CORE_AUTHENTICATOR_CREATE_USERS) }
+ add_property(sonar_info, 'Allow Users to Sign Up') { sonar_property(org.sonar.api.CoreProperties.CORE_ALLOW_USERS_TO_SIGNUP_PROPERTY) }
+ add_property(sonar_info, 'Force Authentication') { sonar_property(org.sonar.api.CoreProperties.CORE_FORCE_AUTHENTICATION_PROPERTY) }
sonar_info
end
def sonar_plugins
sonar_plugins=[]
- Java::OrgSonarServerUi::JRubyFacade.getInstance().getPluginsMetadata().select{|plugin| !plugin.isCore()}.sort.each do |plugin|
- add_property(sonar_plugins, plugin.getName()) {plugin.getVersion()}
+ Java::OrgSonarServerUi::JRubyFacade.getInstance().getPluginsMetadata().select { |plugin| !plugin.isCore() }.sort.each do |plugin|
+ add_property(sonar_plugins, plugin.getName()) { plugin.getVersion() }
end
sonar_plugins
end
@@ -87,13 +87,12 @@ class Server
system_properties=[]
keys=java.lang.System.getProperties().keySet().sort
keys.each do |key|
- add_property(system_properties, key) {java.lang.System.getProperty(key)}
+ add_property(system_properties, key) { java.lang.System.getProperty(key) }
end
system_properties
end
-
private
def java_property(key)
@@ -112,7 +111,7 @@ class Server
end
def format_double(d)
- (d * 10).to_i / 10.0
+ (d * 10).to_i / 10.0
end
def format_date(date)
@@ -124,7 +123,7 @@ class Server
end
def realm_name
- realm_factory = Api::Utils.java_facade.getCoreComponentByClassname('org.sonar.server.ui.SecurityRealmFactory')
+ realm_factory = Api::Utils.java_facade.getCoreComponentByClassname('org.sonar.server.user.SecurityRealmFactory')
if realm_factory && realm_factory.getRealm()
realm_factory.getRealm().getName()
else
diff --git a/sonar-server/src/main/webapp/WEB-INF/lib/need_authentication.rb b/sonar-server/src/main/webapp/WEB-INF/lib/need_authentication.rb
index 9daae83263c..4e3cfa3b114 100644
--- a/sonar-server/src/main/webapp/WEB-INF/lib/need_authentication.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/lib/need_authentication.rb
@@ -186,7 +186,7 @@ class RealmFactory
def self.realm
if @@realm.nil?
- realm_factory = Api::Utils.java_facade.getCoreComponentByClassname('org.sonar.server.ui.SecurityRealmFactory')
+ realm_factory = Api::Utils.java_facade.getCoreComponentByClassname('org.sonar.server.user.SecurityRealmFactory')
if realm_factory
component = realm_factory.getRealm()
@@realm = component ? PluginRealm.new(component) : DefaultRealm.new
diff --git a/sonar-server/src/main/webapp/WEB-INF/web.xml b/sonar-server/src/main/webapp/WEB-INF/web.xml
index 6f130d298c4..26b0dc019b4 100644
--- a/sonar-server/src/main/webapp/WEB-INF/web.xml
+++ b/sonar-server/src/main/webapp/WEB-INF/web.xml
@@ -37,7 +37,7 @@
</filter>
<filter>
<filter-name>DatabaseSessionFilter</filter-name>
- <filter-class>org.sonar.server.ui.DatabaseSessionFilter</filter-class>
+ <filter-class>org.sonar.server.user.DatabaseSessionFilter</filter-class>
</filter>
<filter>
<filter-name>UserSessionFilter</filter-name>
diff --git a/sonar-server/src/test/java/org/sonar/server/db/EmbeddedDatabaseFactoryTest.java b/sonar-server/src/test/java/org/sonar/server/db/EmbeddedDatabaseFactoryTest.java
index 79ed485350d..ed43851aea6 100644
--- a/sonar-server/src/test/java/org/sonar/server/db/EmbeddedDatabaseFactoryTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/db/EmbeddedDatabaseFactoryTest.java
@@ -20,23 +20,15 @@
package org.sonar.server.db;
-import org.junit.Before;
import org.junit.Test;
import org.sonar.api.config.Settings;
import org.sonar.api.database.DatabaseProperties;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.*;
public class EmbeddedDatabaseFactoryTest {
- private Settings settings;
-
- @Before
- public void initSettings() {
- settings = new Settings();
- }
+ Settings settings = new Settings();
@Test
public void should_start_and_stop_tcp_h2_database() throws Exception {
diff --git a/sonar-server/src/test/java/org/sonar/server/issue/IssueChangelogFormatterTest.java b/sonar-server/src/test/java/org/sonar/server/issue/IssueChangelogFormatterTest.java
index c214dac11a1..ff90a7cc425 100644
--- a/sonar-server/src/test/java/org/sonar/server/issue/IssueChangelogFormatterTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/issue/IssueChangelogFormatterTest.java
@@ -27,7 +27,7 @@ import org.mockito.runners.MockitoJUnitRunner;
import org.sonar.api.issue.internal.FieldDiffs;
import org.sonar.api.issue.internal.WorkDayDuration;
import org.sonar.core.i18n.DefaultI18n;
-import org.sonar.server.technicaldebt.TechnicalDebtFormatter;
+import org.sonar.server.technicaldebt.DebtFormatter;
import java.util.List;
import java.util.Locale;
@@ -41,26 +41,26 @@ public class IssueChangelogFormatterTest {
private static final Locale DEFAULT_LOCALE = Locale.getDefault();
@Mock
- private DefaultI18n defaultI18n;
+ private DefaultI18n i18n;
@Mock
- private TechnicalDebtFormatter technicalDebtFormatter;
+ private DebtFormatter debtFormatter;
private IssueChangelogFormatter formatter;
@Before
- public void before(){
- formatter = new IssueChangelogFormatter(defaultI18n, technicalDebtFormatter);
+ public void before() {
+ formatter = new IssueChangelogFormatter(i18n, debtFormatter);
}
@Test
- public void format_field_diffs_with_new_and_old_value(){
+ public void format_field_diffs_with_new_and_old_value() {
FieldDiffs diffs = new FieldDiffs();
diffs.setDiff("severity", "BLOCKER", "INFO");
- when(defaultI18n.message(DEFAULT_LOCALE, "issue.changelog.field.severity", null)).thenReturn("Severity");
- when(defaultI18n.message(DEFAULT_LOCALE, "issue.changelog.changed_to", null, "Severity", "INFO")).thenReturn("Severity changed to INFO");
- when(defaultI18n.message(DEFAULT_LOCALE, "issue.changelog.was", null, "BLOCKER")).thenReturn("was BLOCKER");
+ when(i18n.message(DEFAULT_LOCALE, "issue.changelog.field.severity", null)).thenReturn("Severity");
+ when(i18n.message(DEFAULT_LOCALE, "issue.changelog.changed_to", null, "Severity", "INFO")).thenReturn("Severity changed to INFO");
+ when(i18n.message(DEFAULT_LOCALE, "issue.changelog.was", null, "BLOCKER")).thenReturn("was BLOCKER");
List<String> result = formatter.format(DEFAULT_LOCALE, diffs);
assertThat(result).hasSize(1);
@@ -69,12 +69,12 @@ public class IssueChangelogFormatterTest {
}
@Test
- public void format_field_diffs_with_only_new_value(){
+ public void format_field_diffs_with_only_new_value() {
FieldDiffs diffs = new FieldDiffs();
diffs.setDiff("severity", null, "INFO");
- when(defaultI18n.message(DEFAULT_LOCALE, "issue.changelog.field.severity", null)).thenReturn("Severity");
- when(defaultI18n.message(DEFAULT_LOCALE, "issue.changelog.changed_to", null, "Severity", "INFO")).thenReturn("Severity changed to INFO");
+ when(i18n.message(DEFAULT_LOCALE, "issue.changelog.field.severity", null)).thenReturn("Severity");
+ when(i18n.message(DEFAULT_LOCALE, "issue.changelog.changed_to", null, "Severity", "INFO")).thenReturn("Severity changed to INFO");
List<String> result = formatter.format(DEFAULT_LOCALE, diffs);
assertThat(result).hasSize(1);
@@ -83,13 +83,13 @@ public class IssueChangelogFormatterTest {
}
@Test
- public void format_field_diffs_with_only_old_value(){
+ public void format_field_diffs_with_only_old_value() {
FieldDiffs diffs = new FieldDiffs();
diffs.setDiff("severity", "BLOCKER", null);
- when(defaultI18n.message(DEFAULT_LOCALE, "issue.changelog.field.severity", null)).thenReturn("Severity");
- when(defaultI18n.message(DEFAULT_LOCALE, "issue.changelog.removed", null, "Severity")).thenReturn("Severity removed");
- when(defaultI18n.message(DEFAULT_LOCALE, "issue.changelog.was", null, "BLOCKER")).thenReturn("was BLOCKER");
+ when(i18n.message(DEFAULT_LOCALE, "issue.changelog.field.severity", null)).thenReturn("Severity");
+ when(i18n.message(DEFAULT_LOCALE, "issue.changelog.removed", null, "Severity")).thenReturn("Severity removed");
+ when(i18n.message(DEFAULT_LOCALE, "issue.changelog.was", null, "BLOCKER")).thenReturn("was BLOCKER");
List<String> result = formatter.format(DEFAULT_LOCALE, diffs);
assertThat(result).hasSize(1);
@@ -98,12 +98,12 @@ public class IssueChangelogFormatterTest {
}
@Test
- public void format_field_diffs_without_value(){
+ public void format_field_diffs_without_value() {
FieldDiffs diffs = new FieldDiffs();
diffs.setDiff("severity", null, null);
- when(defaultI18n.message(DEFAULT_LOCALE, "issue.changelog.field.severity", null)).thenReturn("Severity");
- when(defaultI18n.message(DEFAULT_LOCALE, "issue.changelog.removed", null, "Severity")).thenReturn("Severity removed");
+ when(i18n.message(DEFAULT_LOCALE, "issue.changelog.field.severity", null)).thenReturn("Severity");
+ when(i18n.message(DEFAULT_LOCALE, "issue.changelog.removed", null, "Severity")).thenReturn("Severity removed");
List<String> result = formatter.format(DEFAULT_LOCALE, diffs);
assertThat(result).hasSize(1);
@@ -112,12 +112,12 @@ public class IssueChangelogFormatterTest {
}
@Test
- public void format_field_diffs_with_empty_old_value(){
+ public void format_field_diffs_with_empty_old_value() {
FieldDiffs diffs = new FieldDiffs();
diffs.setDiff("severity", "", null);
- when(defaultI18n.message(DEFAULT_LOCALE, "issue.changelog.field.severity", null)).thenReturn("Severity");
- when(defaultI18n.message(DEFAULT_LOCALE, "issue.changelog.removed", null, "Severity")).thenReturn("Severity removed");
+ when(i18n.message(DEFAULT_LOCALE, "issue.changelog.field.severity", null)).thenReturn("Severity");
+ when(i18n.message(DEFAULT_LOCALE, "issue.changelog.removed", null, "Severity")).thenReturn("Severity removed");
List<String> result = formatter.format(DEFAULT_LOCALE, diffs);
assertThat(result).hasSize(1);
@@ -126,16 +126,16 @@ public class IssueChangelogFormatterTest {
}
@Test
- public void format_technical_debt_with_old_and_new_value(){
+ public void format_technical_debt_with_old_and_new_value() {
FieldDiffs diffs = new FieldDiffs();
diffs.setDiff("technicalDebt", "500", "10000");
- when(technicalDebtFormatter.format(DEFAULT_LOCALE, WorkDayDuration.of(0, 5, 0))).thenReturn("5 hours");
- when(technicalDebtFormatter.format(DEFAULT_LOCALE, WorkDayDuration.of(0, 0, 1))).thenReturn("1 days");
+ when(debtFormatter.format(DEFAULT_LOCALE, WorkDayDuration.of(0, 5, 0))).thenReturn("5 hours");
+ when(debtFormatter.format(DEFAULT_LOCALE, WorkDayDuration.of(0, 0, 1))).thenReturn("1 days");
- when(defaultI18n.message(DEFAULT_LOCALE, "issue.changelog.field.technicalDebt", null)).thenReturn("Technical Debt");
- when(defaultI18n.message(DEFAULT_LOCALE, "issue.changelog.changed_to", null, "Technical Debt", "1 days")).thenReturn("Technical Debt changed to 1 days");
- when(defaultI18n.message(DEFAULT_LOCALE, "issue.changelog.was", null, "5 hours")).thenReturn("was 5 hours");
+ when(i18n.message(DEFAULT_LOCALE, "issue.changelog.field.technicalDebt", null)).thenReturn("Technical Debt");
+ when(i18n.message(DEFAULT_LOCALE, "issue.changelog.changed_to", null, "Technical Debt", "1 days")).thenReturn("Technical Debt changed to 1 days");
+ when(i18n.message(DEFAULT_LOCALE, "issue.changelog.was", null, "5 hours")).thenReturn("was 5 hours");
List<String> result = formatter.format(DEFAULT_LOCALE, diffs);
assertThat(result).hasSize(1);
@@ -144,14 +144,14 @@ public class IssueChangelogFormatterTest {
}
@Test
- public void format_technical_debt_with_new_value_only(){
+ public void format_technical_debt_with_new_value_only() {
FieldDiffs diffs = new FieldDiffs();
diffs.setDiff("technicalDebt", null, "10000");
- when(technicalDebtFormatter.format(DEFAULT_LOCALE, WorkDayDuration.of(0, 0, 1))).thenReturn("1 days");
+ when(debtFormatter.format(DEFAULT_LOCALE, WorkDayDuration.of(0, 0, 1))).thenReturn("1 days");
- when(defaultI18n.message(DEFAULT_LOCALE, "issue.changelog.field.technicalDebt", null)).thenReturn("Technical Debt");
- when(defaultI18n.message(DEFAULT_LOCALE, "issue.changelog.changed_to", null, "Technical Debt", "1 days")).thenReturn("Technical Debt changed to 1 days");
+ when(i18n.message(DEFAULT_LOCALE, "issue.changelog.field.technicalDebt", null)).thenReturn("Technical Debt");
+ when(i18n.message(DEFAULT_LOCALE, "issue.changelog.changed_to", null, "Technical Debt", "1 days")).thenReturn("Technical Debt changed to 1 days");
List<String> result = formatter.format(DEFAULT_LOCALE, diffs);
assertThat(result).hasSize(1);
@@ -160,12 +160,12 @@ public class IssueChangelogFormatterTest {
}
@Test
- public void format_technical_debt_without_value(){
+ public void format_technical_debt_without_value() {
FieldDiffs diffs = new FieldDiffs();
diffs.setDiff("technicalDebt", null, null);
- when(defaultI18n.message(DEFAULT_LOCALE, "issue.changelog.field.technicalDebt", null)).thenReturn("Technical Debt");
- when(defaultI18n.message(DEFAULT_LOCALE, "issue.changelog.removed", null, "Technical Debt")).thenReturn("Technical Debt removed");
+ when(i18n.message(DEFAULT_LOCALE, "issue.changelog.field.technicalDebt", null)).thenReturn("Technical Debt");
+ when(i18n.message(DEFAULT_LOCALE, "issue.changelog.removed", null, "Technical Debt")).thenReturn("Technical Debt removed");
List<String> result = formatter.format(DEFAULT_LOCALE, diffs);
assertThat(result).hasSize(1);
diff --git a/sonar-server/src/test/java/org/sonar/server/issue/ws/IssueShowWsHandlerTest.java b/sonar-server/src/test/java/org/sonar/server/issue/ws/IssueShowWsHandlerTest.java
index f123ae99f8a..c8337a87279 100644
--- a/sonar-server/src/test/java/org/sonar/server/issue/ws/IssueShowWsHandlerTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/issue/ws/IssueShowWsHandlerTest.java
@@ -53,7 +53,7 @@ import org.sonar.server.issue.ActionService;
import org.sonar.server.issue.IssueChangelog;
import org.sonar.server.issue.IssueChangelogService;
import org.sonar.server.issue.IssueService;
-import org.sonar.server.technicaldebt.TechnicalDebtFormatter;
+import org.sonar.server.technicaldebt.DebtFormatter;
import org.sonar.server.user.MockUserSession;
import org.sonar.server.user.UserSession;
@@ -84,7 +84,7 @@ public class IssueShowWsHandlerTest {
ActionService actionService;
@Mock
- TechnicalDebtFormatter technicalDebtFormatter;
+ DebtFormatter debtFormatter;
@Mock
DefaultTechnicalDebtManager technicalDebtManager;
@@ -113,7 +113,7 @@ public class IssueShowWsHandlerTest {
when(i18n.message(any(Locale.class), eq("created"), eq((String) null))).thenReturn("Created");
- tester = new WsTester(new IssuesWs(new IssueShowWsHandler(issueFinder, issueService, issueChangelogService, actionService, technicalDebtFormatter, technicalDebtManager, i18n)));
+ tester = new WsTester(new IssuesWs(new IssueShowWsHandler(issueFinder, issueService, issueChangelogService, actionService, debtFormatter, technicalDebtManager, i18n)));
}
@Test
@@ -214,7 +214,7 @@ public class IssueShowWsHandlerTest {
.setTechnicalDebt(technicalDebt);
issues.add(issue);
- when(technicalDebtFormatter.format(any(Locale.class), eq(technicalDebt))).thenReturn("2 hours 1 minutes");
+ when(debtFormatter.format(any(Locale.class), eq(technicalDebt))).thenReturn("2 hours 1 minutes");
MockUserSession.set();
WsTester.TestRequest request = tester.newRequest("show").setParam("key", issue.key());
diff --git a/sonar-server/src/main/java/org/sonar/server/group/GroupMembershipQueryResult.java b/sonar-server/src/test/java/org/sonar/server/startup/CleanPreviewAnalysisCacheTest.java
index 647f0a28774..2ae9b5b020a 100644
--- a/sonar-server/src/main/java/org/sonar/server/group/GroupMembershipQueryResult.java
+++ b/sonar-server/src/test/java/org/sonar/server/startup/CleanPreviewAnalysisCacheTest.java
@@ -17,28 +17,22 @@
* 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.group;
+package org.sonar.server.startup;
-import org.sonar.core.user.GroupMembership;
+import org.junit.Test;
+import org.sonar.core.preview.PreviewCache;
-import java.util.List;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
-public class GroupMembershipQueryResult {
+public class CleanPreviewAnalysisCacheTest {
+ @Test
+ public void clean_cache_on_startup() throws Exception {
+ PreviewCache cache = mock(PreviewCache.class);
+ CleanPreviewAnalysisCache cleaner = new CleanPreviewAnalysisCache(cache);
- private List<GroupMembership> groups;
- private boolean hasMoreResults;
-
- public GroupMembershipQueryResult(List<GroupMembership> groups, boolean hasMoreResults) {
- this.groups = groups;
- this.hasMoreResults = hasMoreResults;
- }
-
- public List<GroupMembership> groups() {
- return groups;
+ cleaner.start();
+ verify(cache).cleanAll();
+ cleaner.stop();
}
-
- public boolean hasMoreResults() {
- return hasMoreResults;
- }
-
}
diff --git a/sonar-server/src/test/java/org/sonar/server/startup/ServerMetadataPersisterTest.java b/sonar-server/src/test/java/org/sonar/server/startup/ServerMetadataPersisterTest.java
index 9ddeeaae9e0..f5c8bf13c92 100644
--- a/sonar-server/src/test/java/org/sonar/server/startup/ServerMetadataPersisterTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/startup/ServerMetadataPersisterTest.java
@@ -32,14 +32,12 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.*;
public class ServerMetadataPersisterTest {
- private TimeZone initialTimeZone;
- private PersistentSettings persistentSettings;
+ TimeZone initialTimeZone;
+ PersistentSettings persistentSettings;
@Before
public void fixTimeZone() {
@@ -65,9 +63,11 @@ public class ServerMetadataPersisterTest {
persister.start();
verify(persistentSettings).saveProperties(ImmutableMap.of(
- CoreProperties.SERVER_ID, "123",
- CoreProperties.SERVER_VERSION, "3.2",
- CoreProperties.SERVER_STARTTIME, "2010-05-18T17:59:00+0000"));
+ CoreProperties.SERVER_ID, "123",
+ CoreProperties.SERVER_VERSION, "3.2",
+ CoreProperties.SERVER_STARTTIME, "2010-05-18T17:59:00+0000"));
+
+ persister.stop();
}
}
diff --git a/sonar-server/src/test/java/org/sonar/server/technicaldebt/TechnicalDebtFormatterTest.java b/sonar-server/src/test/java/org/sonar/server/technicaldebt/DebtFormatterTest.java
index 0de635bfcd1..f7249fb21b5 100644
--- a/sonar-server/src/test/java/org/sonar/server/technicaldebt/TechnicalDebtFormatterTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/technicaldebt/DebtFormatterTest.java
@@ -20,39 +20,28 @@
package org.sonar.server.technicaldebt;
-import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
import org.sonar.api.issue.internal.WorkDayDuration;
import org.sonar.core.i18n.DefaultI18n;
import java.util.Locale;
import static org.fest.assertions.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
-public class TechnicalDebtFormatterTest {
+public class DebtFormatterTest {
private static final Locale DEFAULT_LOCALE = Locale.getDefault();
- @Mock
- private DefaultI18n defaultI18n;
-
- private TechnicalDebtFormatter formatter;
-
- @Before
- public void before() {
- formatter = new TechnicalDebtFormatter(defaultI18n);
- }
+ DefaultI18n i18n = mock(DefaultI18n.class);
+ DebtFormatter formatter = new DebtFormatter(i18n);
@Test
public void format() {
- when(defaultI18n.message(DEFAULT_LOCALE, "issue.technical_debt.x_days", null, 5)).thenReturn("5 days");
- when(defaultI18n.message(DEFAULT_LOCALE, "issue.technical_debt.x_hours", null, 2)).thenReturn("2 hours");
- when(defaultI18n.message(DEFAULT_LOCALE, "issue.technical_debt.x_minutes", null, 1)).thenReturn("1 minutes");
+ when(i18n.message(DEFAULT_LOCALE, "issue.technical_debt.x_days", null, 5)).thenReturn("5 days");
+ when(i18n.message(DEFAULT_LOCALE, "issue.technical_debt.x_hours", null, 2)).thenReturn("2 hours");
+ when(i18n.message(DEFAULT_LOCALE, "issue.technical_debt.x_minutes", null, 1)).thenReturn("1 minutes");
assertThat(formatter.format(DEFAULT_LOCALE, WorkDayDuration.of(0, 0, 5))).isEqualTo("5 days");
assertThat(formatter.format(DEFAULT_LOCALE, WorkDayDuration.of(0, 2, 0))).isEqualTo("2 hours");
diff --git a/sonar-server/src/test/java/org/sonar/server/technicaldebt/InternalRubyTechnicalDebtServiceTest.java b/sonar-server/src/test/java/org/sonar/server/technicaldebt/DebtServiceTest.java
index f3f836a312b..b0a1cd61cb2 100644
--- a/sonar-server/src/test/java/org/sonar/server/technicaldebt/InternalRubyTechnicalDebtServiceTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/technicaldebt/DebtServiceTest.java
@@ -19,11 +19,7 @@
*/
package org.sonar.server.technicaldebt;
-import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
import org.sonar.api.issue.internal.WorkDayDuration;
import org.sonar.api.rules.Rule;
import org.sonar.api.technicaldebt.server.Characteristic;
@@ -37,30 +33,19 @@ import static com.google.common.collect.Lists.newArrayList;
import static org.fest.assertions.Assertions.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.*;
-@RunWith(MockitoJUnitRunner.class)
-public class InternalRubyTechnicalDebtServiceTest {
+public class DebtServiceTest {
- @Mock
- TechnicalDebtFormatter technicalDebtFormatter;
-
- @Mock
- DefaultTechnicalDebtManager finder;
-
- private InternalRubyTechnicalDebtService service;
-
- @Before
- public void before() {
- service = new InternalRubyTechnicalDebtService(technicalDebtFormatter, finder);
- }
+ DebtFormatter debtFormatter = mock(DebtFormatter.class);
+ DefaultTechnicalDebtManager finder = mock(DefaultTechnicalDebtManager.class);
+ DebtService service = new DebtService(debtFormatter, finder);
@Test
public void format() {
WorkDayDuration technicalDebt = WorkDayDuration.of(5, 0, 0);
service.format(technicalDebt);
- verify(technicalDebtFormatter).format(any(Locale.class), eq(technicalDebt));
+ verify(debtFormatter).format(any(Locale.class), eq(technicalDebt));
}
@Test
diff --git a/sonar-server/src/test/java/org/sonar/server/ui/CompatibilityRealmTest.java b/sonar-server/src/test/java/org/sonar/server/user/CompatibilityRealmTest.java
index 3b68e4c24d8..ee47aeaedda 100644
--- a/sonar-server/src/test/java/org/sonar/server/ui/CompatibilityRealmTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/user/CompatibilityRealmTest.java
@@ -17,7 +17,7 @@
* 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;
+package org.sonar.server.user;
import org.junit.Test;
import org.sonar.api.security.LoginPasswordAuthenticator;
diff --git a/sonar-server/src/test/java/org/sonar/server/group/GroupMembershipFinderTest.java b/sonar-server/src/test/java/org/sonar/server/user/GroupMembershipFinderTest.java
index 874d9f11957..2b4eff37486 100644
--- a/sonar-server/src/test/java/org/sonar/server/group/GroupMembershipFinderTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/user/GroupMembershipFinderTest.java
@@ -18,31 +18,24 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.server.group;
+package org.sonar.server.user;
import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
import org.sonar.core.user.*;
import static com.google.common.collect.Lists.newArrayList;
import static org.fest.assertions.Assertions.assertThat;
-import static org.mockito.Matchers.*;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.anyLong;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.*;
-@RunWith(MockitoJUnitRunner.class)
public class GroupMembershipFinderTest {
- @Mock
- UserDao userDao;
-
- @Mock
- GroupMembershipDao groupMembershipDao;
-
+ UserDao userDao = mock(UserDao.class);
+ GroupMembershipDao groupMembershipDao = mock(GroupMembershipDao.class);
GroupMembershipFinder finder;
@Before
@@ -58,7 +51,7 @@ public class GroupMembershipFinderTest {
newArrayList(new GroupMembershipDto().setId(1L).setName("users").setUserId(100L))
);
- GroupMembershipQueryResult result = finder.find(query);
+ GroupMembershipFinder.Membership result = finder.find(query);
assertThat(result.groups()).hasSize(1);
assertThat(result.hasMoreResults()).isFalse();
@@ -89,7 +82,7 @@ public class GroupMembershipFinderTest {
new GroupMembershipDto().setId(2L).setName("group2"),
new GroupMembershipDto().setId(3L).setName("group3"))
);
- GroupMembershipQueryResult result = finder.find(query);
+ GroupMembershipFinder.Membership result = finder.find(query);
ArgumentCaptor<Integer> argumentOffset = ArgumentCaptor.forClass(Integer.class);
ArgumentCaptor<Integer> argumentLimit = ArgumentCaptor.forClass(Integer.class);
@@ -109,7 +102,7 @@ public class GroupMembershipFinderTest {
new GroupMembershipDto().setId(3L).setName("group3"),
new GroupMembershipDto().setId(4L).setName("group4"))
);
- GroupMembershipQueryResult result = finder.find(query);
+ GroupMembershipFinder.Membership result = finder.find(query);
ArgumentCaptor<Integer> argumentOffset = ArgumentCaptor.forClass(Integer.class);
ArgumentCaptor<Integer> argumentLimit = ArgumentCaptor.forClass(Integer.class);
diff --git a/sonar-server/src/test/java/org/sonar/server/group/InternalGroupMembershipServiceTest.java b/sonar-server/src/test/java/org/sonar/server/user/GroupMembershipServiceTest.java
index aa687691be5..ff99af0f694 100644
--- a/sonar-server/src/test/java/org/sonar/server/group/InternalGroupMembershipServiceTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/user/GroupMembershipServiceTest.java
@@ -18,7 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.server.group;
+package org.sonar.server.user;
import com.google.common.collect.ImmutableMap;
import org.junit.Before;
@@ -37,23 +37,23 @@ import static org.fest.assertions.Fail.fail;
/**
* Use BbUnit tests because there's no IT on this feature for the moment
*/
-public class InternalGroupMembershipServiceTest extends AbstractDaoTestCase {
+public class GroupMembershipServiceTest extends AbstractDaoTestCase {
- private InternalGroupMembershipService service;
+ GroupMembershipService service;
@Before
public void before() throws Exception {
- GroupMembershipDao groupMembershipDao = new GroupMembershipDao(getMyBatis());
+ GroupMembershipDao membershipDao = new GroupMembershipDao(getMyBatis());
UserDao userDao = new UserDao(getMyBatis());
- GroupMembershipFinder finder = new GroupMembershipFinder(userDao, groupMembershipDao);
- service = new InternalGroupMembershipService(finder);
+ GroupMembershipFinder finder = new GroupMembershipFinder(userDao, membershipDao);
+ service = new GroupMembershipService(finder);
}
@Test
public void find_all_member_groups() {
setupData("shared");
- GroupMembershipQueryResult queryResult = service.find(ImmutableMap.<String, Object>of(
+ GroupMembershipFinder.Membership queryResult = service.find(ImmutableMap.<String, Object>of(
"user", "user1",
"selected", "all"));
List<GroupMembership> result = queryResult.groups();
@@ -67,7 +67,7 @@ public class InternalGroupMembershipServiceTest extends AbstractDaoTestCase {
public void find_all_member_groups_when_no_selected_parameter() {
setupData("shared");
- GroupMembershipQueryResult queryResult = service.find(ImmutableMap.<String, Object>of(
+ GroupMembershipFinder.Membership queryResult = service.find(ImmutableMap.<String, Object>of(
"user", "user1"));
List<GroupMembership> result = queryResult.groups();
assertThat(result).hasSize(3);
@@ -80,7 +80,7 @@ public class InternalGroupMembershipServiceTest extends AbstractDaoTestCase {
public void find_member_groups() {
setupData("shared");
- GroupMembershipQueryResult queryResult = service.find(ImmutableMap.<String, Object>of(
+ GroupMembershipFinder.Membership queryResult = service.find(ImmutableMap.<String, Object>of(
"user", "user1",
"selected", "selected"));
List<GroupMembership> result = queryResult.groups();
@@ -92,7 +92,7 @@ public class InternalGroupMembershipServiceTest extends AbstractDaoTestCase {
public void find_not_member_groups() {
setupData("shared");
- GroupMembershipQueryResult queryResult = service.find(ImmutableMap.<String, Object>of(
+ GroupMembershipFinder.Membership queryResult = service.find(ImmutableMap.<String, Object>of(
"user", "user1",
"selected", "deselected"));
List<GroupMembership> result = queryResult.groups();
@@ -105,7 +105,7 @@ public class InternalGroupMembershipServiceTest extends AbstractDaoTestCase {
public void find_with_paging_with_more_results() {
setupData("shared");
- GroupMembershipQueryResult queryResult = service.find(ImmutableMap.<String, Object>of(
+ GroupMembershipFinder.Membership queryResult = service.find(ImmutableMap.<String, Object>of(
"user", "user1",
"selected", "all",
"page", 1,
@@ -120,7 +120,7 @@ public class InternalGroupMembershipServiceTest extends AbstractDaoTestCase {
public void find_with_paging_with_no_more_results() {
setupData("shared");
- GroupMembershipQueryResult queryResult = service.find(ImmutableMap.<String, Object>of(
+ GroupMembershipFinder.Membership queryResult = service.find(ImmutableMap.<String, Object>of(
"user", "user1",
"selected", "all",
"page", 3,
@@ -149,7 +149,7 @@ public class InternalGroupMembershipServiceTest extends AbstractDaoTestCase {
public void find_matched_groups_name() {
setupData("shared");
- GroupMembershipQueryResult queryResult = service.find(ImmutableMap.<String, Object>of(
+ GroupMembershipFinder.Membership queryResult = service.find(ImmutableMap.<String, Object>of(
"user", "user1",
"selected", "all",
"query", "user"));
diff --git a/sonar-server/src/test/java/org/sonar/server/ui/SecurityRealmFactoryTest.java b/sonar-server/src/test/java/org/sonar/server/user/SecurityRealmFactoryTest.java
index c2e134f9d5c..70bd0be1b7f 100644
--- a/sonar-server/src/test/java/org/sonar/server/ui/SecurityRealmFactoryTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/user/SecurityRealmFactoryTest.java
@@ -17,9 +17,8 @@
* 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;
+package org.sonar.server.user;
-import org.junit.Before;
import org.junit.Test;
import org.sonar.api.CoreProperties;
import org.sonar.api.config.Settings;
@@ -27,23 +26,14 @@ import org.sonar.api.security.LoginPasswordAuthenticator;
import org.sonar.api.security.SecurityRealm;
import org.sonar.api.utils.SonarException;
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.nullValue;
-import static org.junit.Assert.assertThat;
+import static org.fest.assertions.Assertions.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
public class SecurityRealmFactoryTest {
- private Settings settings;
-
- @Before
- public void setUp() {
- settings = new Settings();
- }
+ Settings settings = new Settings();
/**
* Typical usage.
@@ -55,7 +45,7 @@ public class SecurityRealmFactoryTest {
SecurityRealmFactory factory = new SecurityRealmFactory(settings, new SecurityRealm[]{realm});
factory.start();
- assertThat(factory.getRealm(), is(realm));
+ assertThat(factory.getRealm()).isSameAs(realm);
verify(realm).init();
}
@@ -63,7 +53,7 @@ public class SecurityRealmFactoryTest {
public void do_not_fail_if_no_realms() {
SecurityRealmFactory factory = new SecurityRealmFactory(settings);
factory.start();
- assertThat(factory.getRealm(), nullValue());
+ assertThat(factory.getRealm()).isNull();
}
@Test
@@ -74,7 +64,7 @@ public class SecurityRealmFactoryTest {
new SecurityRealmFactory(settings);
fail();
} catch (SonarException e) {
- assertThat(e.getMessage(), containsString("Realm 'Fake' not found."));
+ assertThat(e.getMessage()).contains("Realm 'Fake' not found.");
}
}
@@ -85,7 +75,7 @@ public class SecurityRealmFactoryTest {
SecurityRealmFactory factory = new SecurityRealmFactory(settings, new LoginPasswordAuthenticator[]{authenticator});
SecurityRealm realm = factory.getRealm();
- assertThat(realm, instanceOf(CompatibilityRealm.class));
+ assertThat(realm).isInstanceOf(CompatibilityRealm.class);
}
@Test
@@ -96,8 +86,8 @@ public class SecurityRealmFactoryTest {
settings.setProperty(CoreProperties.CORE_AUTHENTICATOR_CLASS, FakeAuthenticator.class.getName());
SecurityRealmFactory factory = new SecurityRealmFactory(settings, new SecurityRealm[]{realm},
- new LoginPasswordAuthenticator[]{authenticator});
- assertThat(factory.getRealm(), is(realm));
+ new LoginPasswordAuthenticator[]{authenticator});
+ assertThat(factory.getRealm()).isSameAs(realm);
}
@Test
@@ -108,7 +98,7 @@ public class SecurityRealmFactoryTest {
new SecurityRealmFactory(settings);
fail();
} catch (SonarException e) {
- assertThat(e.getMessage(), containsString("Authenticator 'Fake' not found."));
+ assertThat(e.getMessage()).contains("Authenticator 'Fake' not found.");
}
}
@@ -131,8 +121,8 @@ public class SecurityRealmFactoryTest {
new SecurityRealmFactory(settings, new SecurityRealm[]{realm}).start();
fail();
} catch (SonarException e) {
- assertThat(e.getCause(), instanceOf(IllegalStateException.class));
- assertThat(e.getMessage(), containsString("Security realm fails to start"));
+ assertThat(e.getCause()).isInstanceOf(IllegalStateException.class);
+ assertThat(e.getMessage()).contains("Security realm fails to start");
}
}
diff --git a/sonar-server/src/test/java/org/sonar/server/ws/WebServiceEngineTest.java b/sonar-server/src/test/java/org/sonar/server/ws/WebServiceEngineTest.java
index 0ca4143ddea..f17386c287f 100644
--- a/sonar-server/src/test/java/org/sonar/server/ws/WebServiceEngineTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/ws/WebServiceEngineTest.java
@@ -30,6 +30,7 @@ import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
import org.sonar.api.utils.text.JsonWriter;
import org.sonar.api.utils.text.XmlWriter;
+import org.sonar.server.plugins.MimeTypes;
import javax.annotation.CheckForNull;
@@ -187,7 +188,7 @@ public class WebServiceEngineTest {
assertThat(response.stream().outputAsString()).isEqualTo("{\"errors\":[{\"msg\":\"Unexpected\"}]}");
assertThat(response.stream().httpStatus()).isEqualTo(500);
- assertThat(response.stream().mediaType()).isEqualTo("application/json");
+ assertThat(response.stream().mediaType()).isEqualTo(MimeTypes.JSON);
}
static class SystemWebService implements WebService {
diff --git a/sonar-server/src/test/resources/org/sonar/server/group/InternalGroupMembershipServiceTest/shared.xml b/sonar-server/src/test/resources/org/sonar/server/user/GroupMembershipServiceTest/shared.xml
index 166defff5f2..018a2be408c 100644
--- a/sonar-server/src/test/resources/org/sonar/server/group/InternalGroupMembershipServiceTest/shared.xml
+++ b/sonar-server/src/test/resources/org/sonar/server/user/GroupMembershipServiceTest/shared.xml
@@ -1,8 +1,8 @@
<dataset>
<groups id="100" name="sonar-administrators"/>
- <groups id="101" name="sonar-users" />
- <groups id="102" name="sonar-reviewers" />
+ <groups id="101" name="sonar-users"/>
+ <groups id="102" name="sonar-reviewers"/>
<!-- user 1 is in users group -->
<groups_users user_id="200" group_id="101"/>