Search in sources :

Example 1 with LeaseUtil

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);
}
Also used : DataSourceRegistry(org.eclipse.dataspaceconnector.spi.transaction.datasource.DataSourceRegistry) LeaseUtil(org.eclipse.dataspaceconnector.sql.lease.LeaseUtil) JdbcDataSource(org.h2.jdbcx.JdbcDataSource) NoopTransactionContext(org.eclipse.dataspaceconnector.spi.transaction.NoopTransactionContext) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with LeaseUtil

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);
}
Also used : DataSourceRegistry(org.eclipse.dataspaceconnector.spi.transaction.datasource.DataSourceRegistry) LeaseUtil(org.eclipse.dataspaceconnector.sql.lease.LeaseUtil) JdbcDataSource(org.h2.jdbcx.JdbcDataSource) TypeManager(org.eclipse.dataspaceconnector.spi.types.TypeManager) NoopTransactionContext(org.eclipse.dataspaceconnector.spi.transaction.NoopTransactionContext) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

NoopTransactionContext (org.eclipse.dataspaceconnector.spi.transaction.NoopTransactionContext)2 DataSourceRegistry (org.eclipse.dataspaceconnector.spi.transaction.datasource.DataSourceRegistry)2 LeaseUtil (org.eclipse.dataspaceconnector.sql.lease.LeaseUtil)2 JdbcDataSource (org.h2.jdbcx.JdbcDataSource)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 TypeManager (org.eclipse.dataspaceconnector.spi.types.TypeManager)1