ProcessControllerFactory { public boolean isAttachAPIFound() { if (disableAttachApi) { return false; } boolean found = false; try { final Class<?> virtualMachineClass = Class.forName("com.sun.tools.attach.spi.AttachProvider"); if (virtualMachineClass != null) { Method providersMethod = virtualMachineClass.getMethod("providers"); providersMethod.invoke(virtualMachineClass); found = true; } } catch (ClassNotFoundException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | ServiceConfigurationError ignore) { } return found; } ProcessControllerFactory(); ProcessController createProcessController(final ProcessControllerParameters parameters,
      final int pid); ProcessController createProcessController(final ProcessControllerParameters parameters,
      final File directory, final String pidFileName); boolean isAttachAPIFound(); static final String PROPERTY_DISABLE_ATTACH_API; }
@Test public void isAttachAPIFound_withAttachAPI_returnsTrue() throws Exception { assertThat(factory.isAttachAPIFound()).isTrue(); }
@Test public void isAttachAPIFound_withoutAttachAPI_returnsFalse() throws Exception { System.setProperty(PROPERTY_DISABLE_ATTACH_API, "true"); factory = new ProcessControllerFactory(); assertThat(factory.isAttachAPIFound()).isFalse(); }