use of applications.SleepingApplication in project oracle-bedrock by coherence-community.
the class JacocoProfileTest method shouldEstablishJaCoCoProfileUsingASystemProperty.
/**
* Ensure we can configure and establish a {@link JacocoProfile} using a System Property
*/
@Test
public void shouldEstablishJaCoCoProfileUsingASystemProperty() throws Exception {
// define the JaCoCo destination file pattern
String jacocoDestinationFileName = "jacoco-${bedrock.runtime.id}.exec";
// create a temp file name for JaCoCo to output the code coverage report to
File destinationFile = new File(System.getProperty("java.io.tmpdir"), jacocoDestinationFileName);
// define the JaCoCo profile as a System Property
System.getProperties().setProperty("bedrock.profile.jacoco", "destfile=" + destinationFile);
// build and start the SleepingApplication
LocalPlatform platform = LocalPlatform.get();
File telemetricsFile;
try (JavaApplication application = platform.launch(JavaApplication.class, ClassName.of(SleepingApplication.class), IPv4Preferred.yes())) {
ExpressionEvaluator evaluator = new ExpressionEvaluator(application.getOptions());
// create a File representing the JaCoCo telemetrics file
telemetricsFile = new File(System.getProperty("java.io.tmpdir"), evaluator.evaluate(jacocoDestinationFileName, String.class));
} finally {
System.getProperties().remove("bedrock.profile.jacoco");
}
// assert that JaCoCo created the telemetrics file (and thus the agent ran)
assertThat(telemetricsFile.exists(), is(true));
// assert that the telemetrics file contains something
assertThat(telemetricsFile.length(), is(greaterThan(0L)));
}
use of applications.SleepingApplication in project oracle-bedrock by coherence-community.
the class JacocoProfileTest method shouldEstablishJaCoCoProfileUsingAnOption.
/**
* Ensure we can configure and establish a {@link JacocoProfile} as an {@link Option}.
*/
@Test
public void shouldEstablishJaCoCoProfileUsingAnOption() throws Exception {
// define the JaCoCo destination file pattern
String jacocoDestinationFileName = "jacoco-${bedrock.runtime.id}.exec";
// create a temp file name for JaCoCo to output the code coverage report to
File destinationFile = new File(System.getProperty("java.io.tmpdir"), jacocoDestinationFileName);
// define the JaCoCo profile
JacocoProfile profile = JacocoProfile.enabled("destfile=" + destinationFile);
// build and start the SleepingApplication
LocalPlatform platform = LocalPlatform.get();
File telemetricsFile;
try (JavaApplication application = platform.launch(JavaApplication.class, ClassName.of(SleepingApplication.class), IPv4Preferred.yes(), profile)) {
ExpressionEvaluator evaluator = new ExpressionEvaluator(application.getOptions());
// create a File representing the JaCoCo telemetrics file
telemetricsFile = new File(System.getProperty("java.io.tmpdir"), evaluator.evaluate(jacocoDestinationFileName, String.class));
}
// assert that JaCoCo created the telemetrics file (and thus the agent ran)
assertThat(telemetricsFile.exists(), is(true));
// assert that the telemetrics file contains something
assertThat(telemetricsFile.length(), is(greaterThan(0L)));
}
Aggregations