SqlDbConfiguration { public DataSource createDataSource() { final String driverClass = (String) dbConfig.get("javax.persistence.jdbc.driver"); final String connectionUrl = (String) dbConfig.get("javax.persistence.jdbc.url"); final String username = (String) dbConfig.get("javax.persistence.jdbc.user"); final String password = (String) dbConfig.get("javax.persistence.jdbc.password"); final BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName(driverClass); ds.setUsername(username); ds.setPassword(password); ds.setUrl(connectionUrl); ds.setMinIdle(1); ds.setMaxIdle(2); return ds; } SqlDbConfiguration(final PersistenceUnitDescriptor descriptor); static boolean isSupported(final PersistenceUnitDescriptor descriptor); DataSource createDataSource();  }
@Test public void testCreateDataSource() { when(descriptor.getProperties()).thenReturn(ImmutableMap.<String, Object>builder() .put("javax.persistence.jdbc.driver", "some.Driver") .put("javax.persistence.jdbc.url", "some: .put("javax.persistence.jdbc.user", "someUser") .put("javax.persistence.jdbc.password", "somePassword") .build()); SqlDbConfiguration config = new SqlDbConfiguration(descriptor); BasicDataSource dataSource = (BasicDataSource) config.createDataSource(); assertNotNull(dataSource); assertThat(dataSource.getDriverClassName(),equalTo("some.Driver")); assertThat(dataSource.getUrl(),equalTo("some: assertThat(dataSource.getUsername(),equalTo("someUser")); assertThat(dataSource.getPassword(),equalTo("somePassword")); assertThat(dataSource.getMinIdle(),equalTo(1)); assertThat(dataSource.getMaxIdle(),equalTo(2)); }