Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

JvmPropertiesSectionTest.java 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2023 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. package org.sonar.process.systeminfo;
  21. import java.util.ArrayList;
  22. import java.util.Collections;
  23. import java.util.List;
  24. import org.junit.Test;
  25. import org.sonar.process.systeminfo.protobuf.ProtobufSystemInfo;
  26. import static org.assertj.core.api.Assertions.assertThat;
  27. public class JvmPropertiesSectionTest {
  28. private JvmPropertiesSection underTest = new JvmPropertiesSection("Web JVM Properties");
  29. @Test
  30. public void name_is_not_empty() {
  31. assertThat(underTest.toProtobuf().getName()).isEqualTo("Web JVM Properties");
  32. }
  33. @Test
  34. public void system_properties_are_returned_in_alphabetical_order() {
  35. ProtobufSystemInfo.Section section = underTest.toProtobuf();
  36. List<String> keys = section.getAttributesList()
  37. .stream()
  38. .map(ProtobufSystemInfo.Attribute::getKey)
  39. .toList();
  40. assertThat(keys).contains("java.vm.vendor", "os.name");
  41. List<String> sortedKeys = new ArrayList<>(keys);
  42. Collections.sort(sortedKeys);
  43. assertThat(sortedKeys).isEqualTo(keys);
  44. }
  45. }