final List<String> tables = embeddedDB.getAllTables(); final Connection connection = embeddedDB.getDataSource().getConnection(); try { for (final String table : tables) {
@Override @BeforeMethod(groups = "slow") public void beforeMethod() throws Exception { if (hasFailed()) { return; } super.beforeMethod(); final KillBillJdbcRealm realm = new KillBillJdbcRealm(helper.getDataSource(), securityConfig); securityManager = new DefaultSecurityManager(realm); SecurityUtils.setSecurityManager(securityManager); }
protected Connection getConnection() throws SQLException, IOException { return getDataSource().getConnection(); }
@Override public DataSource getDataSource() throws IOException { if (!started.get()) { throw new IOException("H2 is not running"); } return super.getDataSource(); }
public void stop() throws IOException { final DataSource dataSource = getDataSource(); if (dataSource instanceof HikariDataSource) { ((HikariDataSource) dataSource).shutdown(); } }
final List<String> tables = embeddedDB.getAllTables(); final Connection connection = embeddedDB.getDataSource().getConnection(); try { for (final String table : tables) {
private DataSource buildDataSource() { switch(config.getConnectionPoolingType()) { case C3P0: loadDriver(); return new C3P0DataSourceBuilder().buildDataSource(); case HIKARICP: if (dataSourceClassName != null) { loadDriver(); } return new HikariDataSourceBuilder().buildDataSource(); case NONE: if (embeddedDB != null) { try { embeddedDB.initialize(); embeddedDB.start(); return embeddedDB.getDataSource(); } catch (final IOException e) { throw new RuntimeException(e); } catch (final SQLException e) { throw new RuntimeException(e); } } default: break; } throw new IllegalArgumentException("DataSource " + config.getConnectionPoolingType() + " unsupported"); }
@Override @BeforeMethod(groups = "slow") public void beforeMethod() throws Exception { if (hasFailed()) { return; } super.beforeMethod(); final KillBillJdbcRealm realm = new KillBillJdbcRealm(helper.getDataSource(), securityConfig); securityManager = new DefaultSecurityManager(realm); SecurityUtils.setSecurityManager(securityManager); }
@Override @BeforeClass(groups = "slow") public void setUpBeforeClass() throws Exception { super.setUpBeforeClass(); this.dao = new TestPluginPaymentDao(embeddedDB.getDataSource()); final Clock clock = new DefaultClock(); final UUID tenantId = UUID.randomUUID(); context = Mockito.mock(CallContext.class); Mockito.when(context.getTenantId()).thenReturn(tenantId); account = TestUtils.buildAccount(Currency.JPY, "JP"); final OSGIKillbillAPI killbillApi = TestUtils.buildOSGIKillbillAPI(account); final Payment payment = TestUtils.buildPayment(account.getId(), account.getPaymentMethodId(), account.getCurrency(), killbillApi); final OSGIKillbillLogService logService = TestUtils.buildLogService(); final OSGIConfigPropertiesService configPropertiesService = Mockito.mock(OSGIConfigPropertiesService.class); api = new TestPaymentPluginApi(killbillApi, configPropertiesService, logService, clock, dao); TestUtils.updateOSGIKillbillAPI(killbillApi, api); }
dbi = new DBI(embeddedDB.getDataSource()); InTransaction.setupDBI(dbi); dbi.setTransactionHandler(new NotificationTransactionHandler(databaseTransactionNotificationApi));