@Test public void testStartupSuccess() { runner.startup(); Mockito.verify(instance).startup(); }
@Override public void startup() { if (obtainInstanceLock(InstanceLockState.STARTUP)) { try { if (instance == null) { try { configuration.load(); instance = activityWrapper.newInstance(); activityLog = liveActivityRuntime.getActivityLog(installedActivity, configuration, activityFilesystem); liveActivityRuntime.initializeActivityInstance(installedActivity, activityFilesystem, instance, configuration, activityLog, activityWrapper.newExecutionContext()); instance.startup(); if (!instance.getActivityStatus().getState().isRunning()) { instance = null; } } catch (Throwable e) { setActivityStatusUnprotected(new ActivityStatus(ActivityState.STARTUP_FAILURE, null, e)); if (instance != null) { try { instance.handleStartupFailure(); } catch (Throwable e1) { liveActivityRuntime.getSpaceEnvironment().getLog() .error("Error cleaning up activity which could not start", e1); } instance = null; } } if (instance == null) { cleanupResources(); } } else { liveActivityRuntime.getSpaceEnvironment().getLog() .warn(String.format("Attempt to start activity %s that is already started", uuid)); } } finally { releaseInstanceLock(); } } }
StandardLiveActivityRunner implements LiveActivityRunner { @Override public void startup() { if (obtainInstanceLock(InstanceLockState.STARTUP)) { try { if (instance == null) { try { configuration.load(); instance = activityWrapper.newInstance(); activityLog = liveActivityRuntime.getActivityLog(installedActivity, configuration, activityFilesystem); liveActivityRuntime.initializeActivityInstance(installedActivity, activityFilesystem, instance, configuration, activityLog, activityWrapper.newExecutionContext()); instance.startup(); if (!instance.getActivityStatus().getState().isRunning()) { instance = null; } } catch (Throwable e) { setActivityStatusUnprotected(new ActivityStatus(ActivityState.STARTUP_FAILURE, null, e)); if (instance != null) { try { instance.handleStartupFailure(); } catch (Throwable e1) { liveActivityRuntime.getSpaceEnvironment().getLog() .error("Error cleaning up activity which could not start", e1); } instance = null; } } if (instance == null) { cleanupResources(); } } else { liveActivityRuntime.getSpaceEnvironment().getLog() .warn(String.format("Attempt to start activity %s that is already started", uuid)); } } finally { releaseInstanceLock(); } } } }
StandardLiveActivityRunner implements LiveActivityRunner { @Override public void startup() { if (obtainInstanceLock(InstanceLockState.STARTUP)) { try { if (instance == null) { try { configuration.load(); instance = activityWrapper.newInstance(); activityLog = liveActivityRuntime.getActivityLog(installedActivity, configuration, activityFilesystem); liveActivityRuntime.initializeActivityInstance(installedActivity, activityFilesystem, instance, configuration, activityLog, activityWrapper.newExecutionContext()); instance.startup(); if (!instance.getActivityStatus().getState().isRunning()) { instance = null; } } catch (Throwable e) { setActivityStatusUnprotected(new ActivityStatus(ActivityState.STARTUP_FAILURE, null, e)); if (instance != null) { try { instance.handleStartupFailure(); } catch (Throwable e1) { liveActivityRuntime.getSpaceEnvironment().getLog() .error("Error cleaning up activity which could not start", e1); } instance = null; } } if (instance == null) { cleanupResources(); } } else { liveActivityRuntime.getSpaceEnvironment().getLog() .warn(String.format("Attempt to start activity %s that is already started", uuid)); } } finally { releaseInstanceLock(); } } } StandardLiveActivityRunner(InstalledLiveActivity installedActivity, ActivityWrapper activityWrapper,
      InternalLiveActivityFilesystem activityFilesystem, LiveActivityConfiguration configuration,
      LiveActivityRunnerListener liveActivityRunnerListener, LiveActivityRuntime liveActivityRuntime); }
StandardLiveActivityRunner implements LiveActivityRunner { @Override public void startup() { if (obtainInstanceLock(InstanceLockState.STARTUP)) { try { if (instance == null) { try { configuration.load(); instance = activityWrapper.newInstance(); activityLog = liveActivityRuntime.getActivityLog(installedActivity, configuration, activityFilesystem); liveActivityRuntime.initializeActivityInstance(installedActivity, activityFilesystem, instance, configuration, activityLog, activityWrapper.newExecutionContext()); instance.startup(); if (!instance.getActivityStatus().getState().isRunning()) { instance = null; } } catch (Throwable e) { setActivityStatusUnprotected(new ActivityStatus(ActivityState.STARTUP_FAILURE, null, e)); if (instance != null) { try { instance.handleStartupFailure(); } catch (Throwable e1) { liveActivityRuntime.getSpaceEnvironment().getLog() .error("Error cleaning up activity which could not start", e1); } instance = null; } } if (instance == null) { cleanupResources(); } } else { liveActivityRuntime.getSpaceEnvironment().getLog() .warn(String.format("Attempt to start activity %s that is already started", uuid)); } } finally { releaseInstanceLock(); } } } StandardLiveActivityRunner(InstalledLiveActivity installedActivity, ActivityWrapper activityWrapper,
      InternalLiveActivityFilesystem activityFilesystem, LiveActivityConfiguration configuration,
      LiveActivityRunnerListener liveActivityRunnerListener, LiveActivityRuntime liveActivityRuntime); @Override String getUuid(); @Override void updateConfiguration(Map<String, String> update); @Override void startup(); @Override void shutdown(); @Override void activate(); @Override void deactivate(); @Override ActivityStatus sampleActivityStatus(); @Override ActivityStatus getCachedActivityStatus(); @Override Activity getInstance(); @VisibleForTesting void setCachedActivityStatus(ActivityStatus cachedActivityStatus); @Override void setActivityStatus(ActivityStatus status); @Override String getDisplayName(); @Override @VisibleForTesting ActivityWrapper getActivityWrapper(); @Override void markStale(); @Override boolean isStale(); }
StandardLiveActivityRunner implements LiveActivityRunner { @Override public void startup() { if (obtainInstanceLock(InstanceLockState.STARTUP)) { try { if (instance == null) { try { configuration.load(); instance = activityWrapper.newInstance(); activityLog = liveActivityRuntime.getActivityLog(installedActivity, configuration, activityFilesystem); liveActivityRuntime.initializeActivityInstance(installedActivity, activityFilesystem, instance, configuration, activityLog, activityWrapper.newExecutionContext()); instance.startup(); if (!instance.getActivityStatus().getState().isRunning()) { instance = null; } } catch (Throwable e) { setActivityStatusUnprotected(new ActivityStatus(ActivityState.STARTUP_FAILURE, null, e)); if (instance != null) { try { instance.handleStartupFailure(); } catch (Throwable e1) { liveActivityRuntime.getSpaceEnvironment().getLog() .error("Error cleaning up activity which could not start", e1); } instance = null; } } if (instance == null) { cleanupResources(); } } else { liveActivityRuntime.getSpaceEnvironment().getLog() .warn(String.format("Attempt to start activity %s that is already started", uuid)); } } finally { releaseInstanceLock(); } } } StandardLiveActivityRunner(InstalledLiveActivity installedActivity, ActivityWrapper activityWrapper,
      InternalLiveActivityFilesystem activityFilesystem, LiveActivityConfiguration configuration,
      LiveActivityRunnerListener liveActivityRunnerListener, LiveActivityRuntime liveActivityRuntime); @Override String getUuid(); @Override void updateConfiguration(Map<String, String> update); @Override void startup(); @Override void shutdown(); @Override void activate(); @Override void deactivate(); @Override ActivityStatus sampleActivityStatus(); @Override ActivityStatus getCachedActivityStatus(); @Override Activity getInstance(); @VisibleForTesting void setCachedActivityStatus(ActivityStatus cachedActivityStatus); @Override void setActivityStatus(ActivityStatus status); @Override String getDisplayName(); @Override @VisibleForTesting ActivityWrapper getActivityWrapper(); @Override void markStale(); @Override boolean isStale();  }