use of io.seata.rm.datasource.mock.MockDataSource in project seata by seata.
the class DataSourceProxyTest method test_constructor.
@Test
public void test_constructor() {
DataSource dataSource = new MockDataSource();
DataSourceProxy dataSourceProxy = new DataSourceProxy(dataSource);
Assertions.assertEquals(dataSourceProxy.getTargetDataSource(), dataSource);
DataSourceProxy dataSourceProxy2 = new DataSourceProxy(dataSourceProxy);
Assertions.assertEquals(dataSourceProxy2.getTargetDataSource(), dataSource);
}
use of io.seata.rm.datasource.mock.MockDataSource in project seata by seata.
the class MySQLInsertExecutorTest method init.
@BeforeEach
public void init() throws SQLException {
ConnectionProxy connectionProxy = mock(ConnectionProxy.class);
when(connectionProxy.getDbType()).thenReturn(JdbcConstants.MYSQL);
DataSourceProxy dataSourceProxy = new DataSourceProxy(new MockDataSource());
when(connectionProxy.getDataSourceProxy()).thenReturn(dataSourceProxy);
statementProxy = mock(PreparedStatementProxy.class);
when(statementProxy.getConnectionProxy()).thenReturn(connectionProxy);
when(statementProxy.getTargetStatement()).thenReturn(statementProxy);
MockResultSet resultSet = new MockResultSet(statementProxy);
resultSet.mockResultSet(Arrays.asList("Variable_name", "Value"), new Object[][] { { "auto_increment_increment", "1" } });
when(statementProxy.getTargetStatement().executeQuery("SHOW VARIABLES LIKE 'auto_increment_increment'")).thenReturn(resultSet);
StatementCallback statementCallback = mock(StatementCallback.class);
sqlInsertRecognizer = mock(SQLInsertRecognizer.class);
tableMeta = mock(TableMeta.class);
insertExecutor = Mockito.spy(new MySQLInsertExecutor(statementProxy, statementCallback, sqlInsertRecognizer));
pkIndexMap = new HashMap<String, Integer>() {
{
put(ID_COLUMN, pkIndex);
}
};
}
use of io.seata.rm.datasource.mock.MockDataSource in project seata by seata.
the class DataSourceProxyXATest method test_constructor.
@Test
public void test_constructor() {
DataSource dataSource = new MockDataSource();
DataSourceProxyXA dataSourceProxy = new DataSourceProxyXA(dataSource);
Assertions.assertEquals(dataSourceProxy.getTargetDataSource(), dataSource);
DataSourceProxyXA dataSourceProxy2 = new DataSourceProxyXA(dataSourceProxy);
Assertions.assertEquals(dataSourceProxy2.getTargetDataSource(), dataSource);
}
Aggregations