SessionFactoryImpl implements SessionFactory { @Override public NetworkSession newInstance( SessionConfig sessionConfig ) { BookmarkHolder bookmarkHolder = new DefaultBookmarkHolder( InternalBookmark.from( sessionConfig.bookmarks() ) ); return createSession( connectionProvider, retryLogic, parseDatabaseName( sessionConfig ), sessionConfig.defaultAccessMode(), bookmarkHolder, parseFetchSize( sessionConfig ), logging ); } SessionFactoryImpl( ConnectionProvider connectionProvider, RetryLogic retryLogic, Config config ); @Override NetworkSession newInstance( SessionConfig sessionConfig ); @Override CompletionStage<Void> verifyConnectivity(); @Override CompletionStage<Void> close(); @Override CompletionStage<Boolean> supportsMultiDb(); ConnectionProvider getConnectionProvider();  }
@Test void createsNetworkSessions() { Config config = Config.builder().withLogging( DEV_NULL_LOGGING ).build(); SessionFactory factory = newSessionFactory( config ); NetworkSession readSession = factory.newInstance( builder().withDefaultAccessMode( AccessMode.READ ).build() ); assertThat( readSession, instanceOf( NetworkSession.class ) ); NetworkSession writeSession = factory.newInstance( builder().withDefaultAccessMode( AccessMode.WRITE ).build() ); assertThat( writeSession, instanceOf( NetworkSession.class ) ); }
@Test void createsLeakLoggingNetworkSessions() { Config config = Config.builder().withLogging( DEV_NULL_LOGGING ).withLeakedSessionsLogging().build(); SessionFactory factory = newSessionFactory( config ); NetworkSession readSession = factory.newInstance( builder().withDefaultAccessMode( AccessMode.READ ).build() ); assertThat( readSession, instanceOf( LeakLoggingNetworkSession.class ) ); NetworkSession writeSession = factory.newInstance( builder().withDefaultAccessMode( AccessMode.WRITE ).build() ); assertThat( writeSession, instanceOf( LeakLoggingNetworkSession.class ) ); }