From 0d57ce7853c35d7b6c502bd4b1c3284dafc41371 Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Sun, 11 Sep 2011 18:39:27 +0200 Subject: [PATCH] SONAR-2603 provide a dedicated page to generate server id --- .../resources/org/sonar/l10n/core.properties | 15 +++-- .../java/org/sonar/batch/ServerMetadata.java | 4 +- .../java/org/sonar/api/CoreProperties.java | 6 +- .../java/org/sonar/api/platform/Server.java | 2 +- .../org/sonar/server/platform/Platform.java | 2 +- ...yGenerator.java => ServerIdGenerator.java} | 26 ++++---- .../org/sonar/server/platform/ServerImpl.java | 6 +- .../java/org/sonar/server/ui/JRubyFacade.java | 11 ++-- ... => server_id_configuration_controller.rb} | 37 +++++++----- .../app/controllers/settings_controller.rb | 2 +- .../server_id_configuration/index.html.erb | 60 +++++++++++++++++++ .../server_key_configuration/index.html.erb | 58 ------------------ ...orTest.java => ServerIdGeneratorTest.java} | 34 +++++------ .../sonar/server/platform/ServerImplTest.java | 8 +-- .../platform/ServerLifecycleNotifierTest.java | 2 +- .../startup/ServerMetadataPersisterTest.java | 2 +- ...xml => shouldLoadServerIdFromDatabase.xml} | 2 +- 17 files changed, 144 insertions(+), 133 deletions(-) rename sonar-server/src/main/java/org/sonar/server/platform/{ServerKeyGenerator.java => ServerIdGenerator.java} (80%) rename sonar-server/src/main/webapp/WEB-INF/app/controllers/{server_key_configuration_controller.rb => server_id_configuration_controller.rb} (56%) create mode 100644 sonar-server/src/main/webapp/WEB-INF/app/views/server_id_configuration/index.html.erb delete mode 100644 sonar-server/src/main/webapp/WEB-INF/app/views/server_key_configuration/index.html.erb rename sonar-server/src/test/java/org/sonar/server/platform/{ServerKeyGeneratorTest.java => ServerIdGeneratorTest.java} (61%) rename sonar-server/src/test/resources/org/sonar/server/platform/ServerImplTest/{shouldLoadServerKeyFromDatabase.xml => shouldLoadServerIdFromDatabase.xml} (54%) diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties index 3d9927c5a69..148bcf9b14c 100644 --- a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties @@ -434,7 +434,7 @@ property.category.differentialViews=Differential Views property.category.codeCoverage=Code Coverage property.category.duplications=Duplications property.category.localization=Localization -property.category.server_key=Server Key +property.category.server_id=Server ID #------------------------------------------------------------------------------ @@ -766,9 +766,16 @@ email_configuration.test.email_was_sent_to_x=Email was sent to {0} # SERVER KEY CONFIGURATION # #------------------------------------------------------------------------------ -server_key_configuration.page=Server Key -server_key_configuration.generate_button=Generate Key -server_key_configuration.generating_button=Generating Key... +server_id_configuration.page=Server ID +server_id_configuration.generate_button=Generate ID +server_id_configuration.generating_button=Generating ID... +server_id_configuration.bad_key=The ID is not valid anymore. Please check the organisation and the IP address. +server_id_configuration.information=The Server ID is a unique identifier of this Sonar instance. It is used for example to obtain a license key for the SonarSource's commercial plugins. Two fields have to be provided to generate the ID : organisation name and one of the IP addresses of the machine that hosts this server. +server_id_configuration.organisation.title=Organisation +server_id_configuration.organisation.desc=Name of the organisation +server_id_configuration.ip.title=Fixed IP Address +server_id_configuration.ip.desc=A server ID is linked to the IP address of the hosting machine that runs Sonar. If the server IP address was to changed, the server ID will have to be regenerated. The valid addresses are : +server_id_configuration.generation_error=Organisation and/or IP address are not valid. #------------------------------------------------------------------------------ diff --git a/sonar-batch/src/main/java/org/sonar/batch/ServerMetadata.java b/sonar-batch/src/main/java/org/sonar/batch/ServerMetadata.java index 6415c9e01e1..97dae9df62f 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/ServerMetadata.java +++ b/sonar-batch/src/main/java/org/sonar/batch/ServerMetadata.java @@ -63,7 +63,7 @@ public class ServerMetadata extends Server { } @Override - public String getKey() { - return conf.getString(CoreProperties.SERVER_KEY); + public String getPermanentServerId() { + return conf.getString(CoreProperties.PERMANENT_SERVER_ID); } } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java index df3a8584548..958e01870d3 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java @@ -240,15 +240,15 @@ public interface CoreProperties { /** * @since 2.11 */ - String ORGANIZATION = "sonar.organization"; + String ORGANISATION = "sonar.organisation"; /** * @since 2.11 */ - String SERVER_KEY = "sonar.server_key"; + String PERMANENT_SERVER_ID = "sonar.server_id"; /** * @since 2.11 */ - String SERVER_KEY_IP_ADDRESS = "sonar.server_key.ip_address"; + String SERVER_ID_IP_ADDRESS = "sonar.server_id.ip_address"; } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/platform/Server.java b/sonar-plugin-api/src/main/java/org/sonar/api/platform/Server.java index f5043073dbb..195671febe5 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/platform/Server.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/platform/Server.java @@ -44,5 +44,5 @@ public abstract class Server implements BatchComponent, ServerComponent { /** * @since 2.10 */ - public abstract String getKey(); + public abstract String getPermanentServerId(); } 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 7eb85ce851a..c733a991588 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 @@ -144,7 +144,7 @@ public final class Platform { coreContainer.as(Characteristics.CACHE).addComponent(UpdateCenterClient.class); coreContainer.as(Characteristics.CACHE).addComponent(UpdateCenterMatrixFactory.class); coreContainer.as(Characteristics.CACHE).addComponent(PluginDownloader.class); - coreContainer.as(Characteristics.CACHE).addComponent(ServerKeyGenerator.class); + coreContainer.as(Characteristics.CACHE).addComponent(ServerIdGenerator.class); coreContainer.as(Characteristics.CACHE).addComponent(ServerImpl.class); coreContainer.as(Characteristics.NO_CACHE).addComponent(FilterExecutor.class); coreContainer.as(Characteristics.NO_CACHE).addAdapter(new DatabaseSessionProvider()); diff --git a/sonar-server/src/main/java/org/sonar/server/platform/ServerKeyGenerator.java b/sonar-server/src/main/java/org/sonar/server/platform/ServerIdGenerator.java similarity index 80% rename from sonar-server/src/main/java/org/sonar/server/platform/ServerKeyGenerator.java rename to sonar-server/src/main/java/org/sonar/server/platform/ServerIdGenerator.java index 0a29e0eb876..3577effe7e6 100644 --- a/sonar-server/src/main/java/org/sonar/server/platform/ServerKeyGenerator.java +++ b/sonar-server/src/main/java/org/sonar/server/platform/ServerIdGenerator.java @@ -35,7 +35,7 @@ import java.util.List; /** * @since 2.11 */ -public class ServerKeyGenerator { +public class ServerIdGenerator { /** * Increment this version each time the algorithm is changed. Do not exceed 9. @@ -46,23 +46,23 @@ public class ServerKeyGenerator { private final boolean acceptPrivateAddress; - public ServerKeyGenerator() { + public ServerIdGenerator() { this(false); } - ServerKeyGenerator(boolean acceptPrivateAddress) { + ServerIdGenerator(boolean acceptPrivateAddress) { this.acceptPrivateAddress = acceptPrivateAddress; } - public String generate(String organization, String ipAddress) { - String key = null; - if (StringUtils.isNotBlank(organization) && StringUtils.isNotBlank(ipAddress)) { + public String generate(String organisation, String ipAddress) { + String id = null; + if (StringUtils.isNotBlank(organisation) && StringUtils.isNotBlank(ipAddress)) { InetAddress inetAddress = toValidAddress(ipAddress); if (inetAddress != null) { - key = toKey(organization, inetAddress); + id = toId(organisation, inetAddress); } } - return key; + return id; } boolean isFixed(InetAddress address) { @@ -72,13 +72,13 @@ public class ServerKeyGenerator { return acceptPrivateAddress || (!address.isLoopbackAddress() && !address.isLinkLocalAddress()); } - String toKey(String organization, InetAddress address) { - String key = new StringBuilder().append(organization).append("-").append(address.getHostAddress()).toString(); + String toId(String organisation, InetAddress address) { + String id = new StringBuilder().append(organisation).append("-").append(address.getHostAddress()).toString(); try { - return VERSION + DigestUtils.shaHex(key.getBytes("UTF-8")).substring(0, CHECKSUM_SIZE); + return VERSION + DigestUtils.shaHex(id.getBytes("UTF-8")).substring(0, CHECKSUM_SIZE); } catch (UnsupportedEncodingException e) { - throw new IllegalArgumentException("Organization is not UTF-8 encoded: " + organization, e); + throw new IllegalArgumentException("Organisation is not UTF-8 encoded: " + organisation, e); } } @@ -112,7 +112,7 @@ public class ServerKeyGenerator { } } } catch (SocketException e) { - LoggerFactory.getLogger(ServerKeyGenerator.class).error("Fail to browse network interfaces", e); + LoggerFactory.getLogger(ServerIdGenerator.class).error("Fail to browse network interfaces", e); } return result; } diff --git a/sonar-server/src/main/java/org/sonar/server/platform/ServerImpl.java b/sonar-server/src/main/java/org/sonar/server/platform/ServerImpl.java index f030202c85d..abd659627fc 100644 --- a/sonar-server/src/main/java/org/sonar/server/platform/ServerImpl.java +++ b/sonar-server/src/main/java/org/sonar/server/platform/ServerImpl.java @@ -66,10 +66,10 @@ public final class ServerImpl extends Server { } } - public String getKey() { + public String getPermanentServerId() { DatabaseSession session = dbSessionFactory.getSession(); - Property serverKey = session.getSingleResult(Property.class, "key", CoreProperties.SERVER_KEY); - return (serverKey!= null ? serverKey.getValue() : null); + Property serverId = session.getSingleResult(Property.class, "key", CoreProperties.PERMANENT_SERVER_ID); + return (serverId!= null ? serverId.getValue() : null); } public String getId() { diff --git a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java index 297f1b23413..bb8d0d3b99b 100644 --- a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java +++ b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java @@ -44,7 +44,7 @@ import org.sonar.server.filters.FilterExecutor; import org.sonar.server.filters.FilterResult; import org.sonar.server.notifications.reviews.ReviewsNotificationManager; import org.sonar.server.platform.Platform; -import org.sonar.server.platform.ServerKeyGenerator; +import org.sonar.server.platform.ServerIdGenerator; import org.sonar.server.plugins.*; import org.sonar.server.rules.ProfilesConsole; import org.sonar.server.rules.RulesConsole; @@ -52,7 +52,6 @@ import org.sonar.updatecenter.common.Version; import java.net.InetAddress; import java.sql.Connection; -import java.sql.SQLException; import java.util.Collection; import java.util.List; import java.util.Set; @@ -276,12 +275,12 @@ public final class JRubyFacade { return getContainer().getComponent(Configuration.class).getString(key, null); } - public List getValidInetAddressesForServerKey() { - return getContainer().getComponent(ServerKeyGenerator.class).getAvailableAddresses(); + public List getValidInetAddressesForServerId() { + return getContainer().getComponent(ServerIdGenerator.class).getAvailableAddresses(); } - public String generateServerKey(String organization, String ipAddress) { - return getContainer().getComponent(ServerKeyGenerator.class).generate(organization, ipAddress); + public String generateServerId(String organisation, String ipAddress) { + return getContainer().getComponent(ServerIdGenerator.class).generate(organisation, ipAddress); } public Connection getConnection() { diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/server_key_configuration_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/server_id_configuration_controller.rb similarity index 56% rename from sonar-server/src/main/webapp/WEB-INF/app/controllers/server_key_configuration_controller.rb rename to sonar-server/src/main/webapp/WEB-INF/app/controllers/server_id_configuration_controller.rb index 8e2e59fd3e1..9f77056ad06 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/server_key_configuration_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/server_id_configuration_controller.rb @@ -17,37 +17,42 @@ # License along with Sonar; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 # -class ServerKeyConfigurationController < ApplicationController +class ServerIdConfigurationController < ApplicationController SECTION=Navigation::SECTION_CONFIGURATION - PROPERTY_SERVER_KEY = 'sonar.server_key' - PROPERTY_IP_ADDRESS = 'sonar.server_key.ip_address' - PROPERTY_ORGANIZATION = 'sonar.organization' + PROPERTY_SERVER_ID = 'sonar.server_id' + PROPERTY_IP_ADDRESS = 'sonar.server_id.ip_address' + PROPERTY_ORGANISATION = 'sonar.organisation' before_filter :admin_required - verify :method => :post, :only => [:save], :redirect_to => {:action => :index} + verify :method => :post, :only => [:generate], :redirect_to => {:action => :index} def index - @server_key = Property.value(PROPERTY_SERVER_KEY) - @organization = Property.value(PROPERTY_ORGANIZATION) + @server_id = Property.value(PROPERTY_SERVER_ID) + @organisation = Property.value(PROPERTY_ORGANISATION) @address = Property.value(PROPERTY_IP_ADDRESS) - @valid_addresses = java_facade.getValidInetAddressesForServerKey() + @valid_addresses = java_facade.getValidInetAddressesForServerId() + @bad_id = false + if @server_id.present? + id = java_facade.generateServerId(@organisation, @address) + @bad_id = (@server_id != id) + end params[:layout]='false' end - def save - organization = params[:organization] - Property.set(PROPERTY_ORGANIZATION, organization) + def generate + organisation = params[:organisation] + Property.set(PROPERTY_ORGANISATION, organisation) ip_address=params[:address] Property.set(PROPERTY_IP_ADDRESS, ip_address) - key = java_facade.generate_server_key(organization, ip_address) - if key - Property.set(PROPERTY_SERVER_KEY, key) + id = java_facade.generateServerId(organisation, ip_address) + if id + Property.set(PROPERTY_SERVER_ID, id) else - Property.clear(PROPERTY_SERVER_KEY) - flash[:error] = 'Please set valid organization and IP address' + Property.clear(PROPERTY_SERVER_ID) + flash[:error] = Api::Utils.message('server_id_configuration.generation_error') end redirect_to :action => 'index' diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb index 8a052d24953..d3d27285c9e 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb @@ -21,7 +21,7 @@ class SettingsController < ApplicationController SECTION=Navigation::SECTION_CONFIGURATION - SPECIAL_CATEGORIES=['email', 'server_key'] + SPECIAL_CATEGORIES=['email', 'server_id'] verify :method => :post, :only => ['update'], :redirect_to => {:action => :index} diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/server_id_configuration/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/server_id_configuration/index.html.erb new file mode 100644 index 00000000000..b5c39c8ac28 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/server_id_configuration/index.html.erb @@ -0,0 +1,60 @@ +

<%= message('server_id_configuration.page') -%>

+ +<% if @server_id %> +

+ <%= @server_id -%> + <% if @bad_id %> + <%= message('server_id_configuration.bad_id') -%> + <% end %> +

+
+<% end %> + +

+ <%= message('server_id_configuration.information') -%> +

+ +<% form_tag :action => 'generate' do %> + + + + + + + + + + + + + + + + + + + +
+ <%= submit_tag message('server_id_configuration.generate_button'), :disable_with => message('server_id_configuration.generating_button') %> +
+

<%= message('server_id_configuration.organisation.title') -%>

+ +

<%= message('server_id_configuration.organisation.desc') -%>

+ +

+ +

+
+

<%= message('server_id_configuration.ip.title') -%>

+ +

<%= message('server_id_configuration.ip.desc') -%>

+
    + <% @valid_addresses.each_with_index do |ip_address, index| %> +
  • <%= ip_address.getHostAddress() -%>
  • + <% end %> +
+

+ +

+
+<% end %> \ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/server_key_configuration/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/server_key_configuration/index.html.erb deleted file mode 100644 index cf7db6f87c5..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/server_key_configuration/index.html.erb +++ /dev/null @@ -1,58 +0,0 @@ -

<%= message('server_key_configuration.page') -%>

- -<% if @server_key %> -

Server Key: <%= @server_key -%>

-<% else %> -<% end %> -

- Speech sur l'utilité de la clé.... -

- -<% form_tag :action => :save do %> - - - - - - - - <% if @server_key %> - - - - <% end %> - - - - - - - - - - - - -
- Changing configuration can disable your SonarSource commercial licenses. You'll have to renew them. -
- <%= submit_tag message('server_key_configuration.generate_button'), :disable_with => message('server_key_configuration.generating_button') %> -
-

Organization

-

The organization is ....

-

- -

-
-

Fixed IP Address

-

The IP address is .... Choose one of the following:

-
    - <% @valid_addresses.each_with_index do |ip_address, index| %> -
  • <%= ip_address.getHostAddress() -%>
  • - <% end %> -
-

- -

-
-<% end %> \ No newline at end of file diff --git a/sonar-server/src/test/java/org/sonar/server/platform/ServerKeyGeneratorTest.java b/sonar-server/src/test/java/org/sonar/server/platform/ServerIdGeneratorTest.java similarity index 61% rename from sonar-server/src/test/java/org/sonar/server/platform/ServerKeyGeneratorTest.java rename to sonar-server/src/test/java/org/sonar/server/platform/ServerIdGeneratorTest.java index f23abdc18c9..73677bec163 100644 --- a/sonar-server/src/test/java/org/sonar/server/platform/ServerKeyGeneratorTest.java +++ b/sonar-server/src/test/java/org/sonar/server/platform/ServerIdGeneratorTest.java @@ -30,7 +30,7 @@ import java.net.UnknownHostException; import static org.hamcrest.text.StringStartsWith.startsWith; import static org.junit.Assert.assertThat; -public class ServerKeyGeneratorTest { +public class ServerIdGeneratorTest { private static InetAddress localhost; @@ -40,31 +40,31 @@ public class ServerKeyGeneratorTest { } @Test - public void keyShouldHaveTenCharacters() { - String key = new ServerKeyGenerator().toKey("SonarSource", localhost); - assertThat(key.length(), Is.is(10)); // first character is version + 9 characters for checksum - assertThat(StringUtils.isBlank(key), Is.is(false)); + public void idShouldHaveTenCharacters() { + String id = new ServerIdGenerator().toId("SonarSource", localhost); + assertThat(id.length(), Is.is(10)); // first character is version + 9 characters for checksum + assertThat(StringUtils.isBlank(id), Is.is(false)); } @Test - public void keyShouldStartWithVersion() { - String key = new ServerKeyGenerator().toKey("SonarSource", localhost); - assertThat(key, startsWith(ServerKeyGenerator.VERSION)); + public void idShouldStartWithVersion() { + String id = new ServerIdGenerator().toId("SonarSource", localhost); + assertThat(id, startsWith(ServerIdGenerator.VERSION)); } @Test public void loopbackAddressesShouldNotBeAccepted() throws UnknownHostException { - assertThat(new ServerKeyGenerator().isFixed(InetAddress.getByName("127.0.0.1")), Is.is(false)); + assertThat(new ServerIdGenerator().isFixed(InetAddress.getByName("127.0.0.1")), Is.is(false)); } @Test public void publicAddressesNotBeAccepted() throws UnknownHostException { - assertThat(new ServerKeyGenerator().isFixed(InetAddress.getByName("sonarsource.com")), Is.is(true)); + assertThat(new ServerIdGenerator().isFixed(InetAddress.getByName("sonarsource.com")), Is.is(true)); } @Test - public void keyShouldBeUniquePerOrganization() { - ServerKeyGenerator generator = new ServerKeyGenerator(true); + public void idShouldBeUniquePerOrganisation() { + ServerIdGenerator generator = new ServerIdGenerator(true); String k1 = generator.generate("Corp One", "127.0.0.1"); String k2 = generator.generate("Corp Two", "127.0.0.1"); @@ -72,11 +72,11 @@ public class ServerKeyGeneratorTest { } @Test - public void keyShouldBeReproducible() { - ServerKeyGenerator generator = new ServerKeyGenerator(true); - String k1 = generator.generate("SonarSource", "127.0.0.1"); - String k2 = generator.generate("SonarSource", "127.0.0.1"); - assertThat(StringUtils.equals(k1, k2), Is.is(true)); + public void idShouldBeReproducible() { + ServerIdGenerator generator = new ServerIdGenerator(true); + String i1 = generator.generate("SonarSource", "127.0.0.1"); + String i2 = generator.generate("SonarSource", "127.0.0.1"); + assertThat(StringUtils.equals(i1, i2), Is.is(true)); } } diff --git a/sonar-server/src/test/java/org/sonar/server/platform/ServerImplTest.java b/sonar-server/src/test/java/org/sonar/server/platform/ServerImplTest.java index 835d53de9b8..145970608c5 100644 --- a/sonar-server/src/test/java/org/sonar/server/platform/ServerImplTest.java +++ b/sonar-server/src/test/java/org/sonar/server/platform/ServerImplTest.java @@ -27,8 +27,6 @@ import java.io.IOException; import java.util.Date; import static org.junit.Assert.*; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; public class ServerImplTest extends AbstractDbUnitTestCase { @@ -68,12 +66,12 @@ public class ServerImplTest extends AbstractDbUnitTestCase { } @Test - public void shouldLoadServerKeyFromDatabase() { - setupData("shouldLoadServerKeyFromDatabase"); + public void shouldLoadServerIdFromDatabase() { + setupData("shouldLoadServerIdFromDatabase"); ServerImpl server = new ServerImpl(getSessionFactory(), new Date()); server.start(); - assertThat(server.getKey(), Is.is("abcde")); + assertThat(server.getPermanentServerId(), Is.is("abcde")); } } diff --git a/sonar-server/src/test/java/org/sonar/server/platform/ServerLifecycleNotifierTest.java b/sonar-server/src/test/java/org/sonar/server/platform/ServerLifecycleNotifierTest.java index 851164b38de..efa3a4adae1 100644 --- a/sonar-server/src/test/java/org/sonar/server/platform/ServerLifecycleNotifierTest.java +++ b/sonar-server/src/test/java/org/sonar/server/platform/ServerLifecycleNotifierTest.java @@ -100,7 +100,7 @@ class FakeServer extends Server { return null; } - public String getKey() { + public String getPermanentServerId() { return null; } } 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 51b0cf38baf..4a22f851b6d 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 @@ -79,7 +79,7 @@ public class ServerMetadataPersisterTest extends AbstractDbUnitTestCase { private Server newServer() throws ParseException { Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm").parse("2010-05-18 17:59"); Server server = mock(Server.class); - when(server.getKey()).thenReturn("1abcdef"); + when(server.getPermanentServerId()).thenReturn("1abcdef"); when(server.getId()).thenReturn("123"); when(server.getVersion()).thenReturn("2.2"); when(server.getStartedAt()).thenReturn(date); diff --git a/sonar-server/src/test/resources/org/sonar/server/platform/ServerImplTest/shouldLoadServerKeyFromDatabase.xml b/sonar-server/src/test/resources/org/sonar/server/platform/ServerImplTest/shouldLoadServerIdFromDatabase.xml similarity index 54% rename from sonar-server/src/test/resources/org/sonar/server/platform/ServerImplTest/shouldLoadServerKeyFromDatabase.xml rename to sonar-server/src/test/resources/org/sonar/server/platform/ServerImplTest/shouldLoadServerIdFromDatabase.xml index 0ca33b1e732..6e0919bd266 100644 --- a/sonar-server/src/test/resources/org/sonar/server/platform/ServerImplTest/shouldLoadServerKeyFromDatabase.xml +++ b/sonar-server/src/test/resources/org/sonar/server/platform/ServerImplTest/shouldLoadServerIdFromDatabase.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file -- 2.39.5