use of org.eclipse.dataspaceconnector.sql.lease.LeaseUtil in project DataSpaceConnector by eclipse-dataspaceconnector.
the class SqlTransferProcessStoreTest method setUp.
@BeforeEach
void setUp() throws SQLException, IOException {
var transactionContext = new NoopTransactionContext();
dataSourceRegistry = mock(DataSourceRegistry.class);
var jdbcDataSource = new JdbcDataSource();
jdbcDataSource.setURL("jdbc:h2:mem:");
// do not actually close
connection = spy(jdbcDataSource.getConnection());
doNothing().when(connection).close();
var datasourceMock = mock(DataSource.class);
when(datasourceMock.getConnection()).thenReturn(connection);
when(dataSourceRegistry.resolve(DATASOURCE_NAME)).thenReturn(datasourceMock);
var statements = new PostgresStatements();
store = new SqlTransferProcessStore(dataSourceRegistry, DATASOURCE_NAME, transactionContext, new ObjectMapper(), statements, CONNECTOR_NAME);
var schema = Files.readString(Paths.get("./docs/schema.sql"));
transactionContext.execute(() -> SqlQueryExecutor.executeQuery(connection, schema));
leaseUtil = new LeaseUtil(transactionContext, this::getConnection, statements);
}
use of org.eclipse.dataspaceconnector.sql.lease.LeaseUtil in project DataSpaceConnector by eclipse-dataspaceconnector.
the class SqlContractNegotiationStoreTest method setUp.
@BeforeEach
void setUp() throws SQLException, IOException {
var txManager = new NoopTransactionContext();
dataSourceRegistry = mock(DataSourceRegistry.class);
var jdbcDataSource = new JdbcDataSource();
jdbcDataSource.setURL("jdbc:h2:mem:");
// do not actually close
connection = spy(jdbcDataSource.getConnection());
doNothing().when(connection).close();
var datasourceMock = mock(DataSource.class);
when(datasourceMock.getConnection()).thenReturn(connection);
when(dataSourceRegistry.resolve(DATASOURCE_NAME)).thenReturn(datasourceMock);
var statements = new PostgresStatements();
TypeManager manager = new TypeManager();
manager.registerTypes(PolicyRegistrationTypes.TYPES.toArray(Class<?>[]::new));
store = new SqlContractNegotiationStore(dataSourceRegistry, DATASOURCE_NAME, txManager, manager, statements, CONNECTOR_NAME);
var schema = Files.readString(Paths.get("./docs/schema.sql"));
txManager.execute(() -> SqlQueryExecutor.executeQuery(connection, schema));
leaseUtil = new LeaseUtil(txManager, this::getConnection, statements);
}
Aggregations