use of com.newrelic.jfr.daemon.JfrRecorderException in project newrelic-java-agent by newrelic.
the class JfrServiceTest method jfrLoopDoesStart.
@Test
public void jfrLoopDoesStart() {
JfrService jfrService = new JfrService(jfrConfig, agentConfig);
JfrService spyJfr = spy(jfrService);
when(spyJfr.coreApisExist()).thenReturn(true);
when(spyJfr.isEnabled()).thenReturn(true);
MockServiceManager manager = new MockServiceManager();
ServiceFactory.setServiceManager(manager);
RPMServiceManager mockRPMServiceManager = manager.getRPMServiceManager();
RPMService mockRPMService = mock(RPMService.class);
when(mockRPMServiceManager.getRPMService()).thenReturn(mockRPMService);
when(mockRPMService.getEntityGuid()).thenReturn("test_guid");
spyJfr.doStart();
try {
// The timeout wait is necessary because jfr loop is being executed on async thread.
verify(spyJfr, timeout(100)).startJfrLoop();
spyJfr.doStop();
} catch (JfrRecorderException e) {
fail("Should not have thrown any exception");
}
}
Aggregations