use of org.springframework.integration.file.remote.session.SessionFactory in project spring-integration by spring-projects.
the class SessionFactoryTests method testSameSessionFromThePool.
@Test
public void testSameSessionFromThePool() throws Exception {
SessionFactory sessionFactory = Mockito.mock(SessionFactory.class);
Session session = Mockito.mock(Session.class);
Mockito.when(sessionFactory.getSession()).thenReturn(session);
CachingSessionFactory cachingFactory = new CachingSessionFactory(sessionFactory, 2);
Session s1 = cachingFactory.getSession();
s1.close();
Session s2 = cachingFactory.getSession();
s2.close();
assertEquals(TestUtils.getPropertyValue(s1, "targetSession"), TestUtils.getPropertyValue(s2, "targetSession"));
Mockito.verify(sessionFactory, Mockito.times(2)).getSession();
}
Aggregations