@Test
public void when_session_is_created_and_persisted_but_nonreusable_then_next_creation_should_remove_it_from_list_of_reusable_sessions()
throws Exception {
// having
RemoteWebDriverFactory factory1 = new MockRemoteWebDriverFactory();
RemoteWebDriverFactory factory2 = new MockRemoteWebDriverFactory();
injector.get().inject(factory1);
injector.get().inject(factory2);
when(configuration.getBrowser()).thenReturn("xyz");
when(configuration.isRemoteReusable()).thenReturn(true);
when(configuration.getCapabilities()).thenReturn(desiredCapabilities);
when(configuration.getRemoteAddress()).thenReturn(hubUrl);
// when
fire(new BeforeSuite());
// creates new session
RemoteWebDriver webdriver1 = factory1.createInstance(configuration);
// persists session into store
factory1.destroyInstance(webdriver1);
// makes driver non-reusable
webdriver1.quit();
// new suite
fire(new BeforeSuite());
// pulls non-reusable session from store, so creates new session
RemoteWebDriver webdriver2 = factory2.createInstance(configuration);
// quit newly created session
factory2.destroyInstance(webdriver2);
webdriver2.quit();
// persists available sessions (none should be available)
// persistEvent.fire(new PersistReusedSessionsEvent());
// new suite