Add test for improved messages

This commit is contained in:
jean-philippe bempel 2020-04-06 12:19:20 +02:00
parent 343a77d619
commit ce26d0532e
1 changed files with 14 additions and 5 deletions

View File

@ -1,5 +1,6 @@
package com.datadog.profiling.controller;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.condition.JRE.JAVA_8;
@ -19,10 +20,18 @@ public class ControllerFactoryTest {
@Test
@EnabledOnJre({JAVA_8})
public void testCreateControllerJava8() {
assertThrows(
UnsupportedEnvironmentException.class,
() -> {
ControllerFactory.createController(config);
});
System.out.println("Java Version: " + System.getProperty("java.version") + " " + System.getProperty("java.vendor"));
UnsupportedEnvironmentException unsupportedEnvironmentException = assertThrows(
UnsupportedEnvironmentException.class,
() -> {
ControllerFactory.createController(config);
});
System.out.println(unsupportedEnvironmentException.getMessage());
System.out.println(System.getProperty("java.vendor"));
String expected = "The JFR controller could not find a supported JFR API, use OpenJDK 11+ or Azul zulu version 1.8.0_212+";
if ("Azul Systems, Inc.".equals(System.getProperty("java.vendor"))) {
expected = "The JFR controller could not find a supported JFR API, use Azul zulu version 1.8.0_212+";
}
assertEquals(expected, unsupportedEnvironmentException.getMessage());
}
}