/** * here is the place to be used in test case and within this callable flashback will use the scene specified by sceneConf. * * @param sceneConf the scene config, will be loaded into flashback. * @param callable to call after the scene changed in flashback. * @param <T> return type of the callable. * @return return callable result. * @throws Exception */ protected <T> T withScene(SceneConfiguration sceneConf, Callable<T> callable) throws Exception { try { Scene scene = SceneFactory.create(sceneConf); _flashbackRunner.setScene(scene); return (T) callable.call(); } finally { _flashbackRunner.setScene(_defaultScene); } }
/** * here is the place to be used in test case and within this runnable flashback will use the scene according to the sceneConf. * * @param sceneConf the scene config, will be loaded into flashback. * @param runnable to call after the scene loaded. */ protected void withScene(SceneConfiguration sceneConf, Runnable runnable) { try { Scene scene = SceneFactory.create(sceneConf); _flashbackRunner.setScene(scene); runnable.run(); } catch (IOException e) { Assert.fail(e.getMessage()); } finally { _flashbackRunner.setScene(_defaultScene); } }
private void determineDefaultSettings() throws IOException { // if default scenePath hasn't been set, need to figure it out // from either your java default resource folder or home dir. if (_defaultScenePath == null) { _defaultScenePath = HOME_DIR; URL flashbackScene = getClass().getResource(FLASHBACK_SCENE_DIR); if (flashbackScene != null) { _defaultScenePath = flashbackScene.getPath(); } } // if default sceneName is set, it must exist (because by default is PLAYBACK mode) // and we will try to load it. if (_defaultSceneName != null) { SceneConfiguration sceneConfiguration = new SceneConfiguration(_defaultScenePath, _defaultSceneMode, _defaultSceneName); _defaultScene = SceneFactory.create(sceneConfiguration); } // after determined the default Scene&MatchRule for this test class, set them. _flashbackRunner.setScene(_defaultScene); _flashbackRunner.setMatchRule(_defaultMatchRule); }
@Action(name = "changeScene") public void changeScene(@ActionParam("sceneName") String sceneName) { validate(); SceneConfiguration sceneConfiguration = new SceneConfiguration(_scenePath, _currSceneMode, sceneName); try { _flashbackRunner.setScene(SceneFactory.create(sceneConfiguration)); } catch (IOException e) { throw new RestLiServiceException(HttpStatus.S_500_INTERNAL_SERVER_ERROR, e); } }