Java 类org.hibernate.connection.UserSuppliedConnectionProvider 实例源码

项目:spring4-understanding    文件:LocalSessionFactoryBeanTests.java   
@Test
public void testLocalSessionFactoryBeanWithValidProperties() throws Exception {
    final Set invocations = new HashSet();
    LocalSessionFactoryBean sfb = new LocalSessionFactoryBean() {
        @Override
        protected SessionFactory newSessionFactory(Configuration config) {
            assertEquals(UserSuppliedConnectionProvider.class.getName(),
                    config.getProperty(Environment.CONNECTION_PROVIDER));
            assertEquals("myValue", config.getProperty("myProperty"));
            invocations.add("newSessionFactory");
            return null;
        }
    };
    Properties prop = new Properties();
    prop.setProperty(Environment.CONNECTION_PROVIDER, UserSuppliedConnectionProvider.class.getName());
    prop.setProperty("myProperty", "myValue");
    sfb.setHibernateProperties(prop);
    sfb.afterPropertiesSet();
    assertTrue(sfb.getConfiguration() != null);
    assertTrue(invocations.contains("newSessionFactory"));
}
项目:class-guard    文件:LocalSessionFactoryBeanTests.java   
@Test
public void testLocalSessionFactoryBeanWithValidProperties() throws Exception {
    final Set invocations = new HashSet();
    LocalSessionFactoryBean sfb = new LocalSessionFactoryBean() {
        @Override
        protected SessionFactory newSessionFactory(Configuration config) {
            assertEquals(UserSuppliedConnectionProvider.class.getName(),
                    config.getProperty(Environment.CONNECTION_PROVIDER));
            assertEquals("myValue", config.getProperty("myProperty"));
            invocations.add("newSessionFactory");
            return null;
        }
    };
    Properties prop = new Properties();
    prop.setProperty(Environment.CONNECTION_PROVIDER, UserSuppliedConnectionProvider.class.getName());
    prop.setProperty("myProperty", "myValue");
    sfb.setHibernateProperties(prop);
    sfb.afterPropertiesSet();
    assertTrue(sfb.getConfiguration() != null);
    assertTrue(invocations.contains("newSessionFactory"));
}