Search in sources :

Example 1 with JfrRecorderException

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");
    }
}
Also used : JfrRecorderException(com.newrelic.jfr.daemon.JfrRecorderException) MockServiceManager(com.newrelic.agent.MockServiceManager) RPMService(com.newrelic.agent.RPMService) RPMServiceManager(com.newrelic.agent.RPMServiceManager) Java10IncompatibleTest(com.newrelic.test.marker.Java10IncompatibleTest) Test(org.junit.Test) Java7IncompatibleTest(com.newrelic.test.marker.Java7IncompatibleTest) Java9IncompatibleTest(com.newrelic.test.marker.Java9IncompatibleTest)

Aggregations

MockServiceManager (com.newrelic.agent.MockServiceManager)1 RPMService (com.newrelic.agent.RPMService)1 RPMServiceManager (com.newrelic.agent.RPMServiceManager)1 JfrRecorderException (com.newrelic.jfr.daemon.JfrRecorderException)1 Java10IncompatibleTest (com.newrelic.test.marker.Java10IncompatibleTest)1 Java7IncompatibleTest (com.newrelic.test.marker.Java7IncompatibleTest)1 Java9IncompatibleTest (com.newrelic.test.marker.Java9IncompatibleTest)1 Test (org.junit.Test)1