Search in sources :

Example 1 with TableMetaCache

use of io.seata.rm.datasource.sql.struct.TableMetaCache in project seata by seata.

the class OracleTableMetaCacheTest method getTableMetaTest.

@Test
public void getTableMetaTest() throws SQLException {
    MockDriver mockDriver = new MockDriver(columnMetas, indexMetas, pkMetas);
    DruidDataSource dataSource = new DruidDataSource();
    dataSource.setUrl("jdbc:mock:xxx");
    dataSource.setDriver(mockDriver);
    DataSourceProxy proxy = new DataSourceProxy(dataSource);
    TableMetaCache tableMetaCache = TableMetaCacheFactory.getTableMetaCache(JdbcConstants.ORACLE);
    TableMeta tableMeta = tableMetaCache.getTableMeta(proxy.getPlainConnection(), "t.ot1", proxy.getResourceId());
    Assertions.assertNotNull(tableMeta);
    tableMeta = tableMetaCache.getTableMeta(proxy.getPlainConnection(), "t.\"ot1\"", proxy.getResourceId());
    Assertions.assertNotNull(tableMeta);
}
Also used : MockDriver(io.seata.rm.datasource.mock.MockDriver) DataSourceProxy(io.seata.rm.datasource.DataSourceProxy) TableMetaCache(io.seata.rm.datasource.sql.struct.TableMetaCache) TableMeta(io.seata.rm.datasource.sql.struct.TableMeta) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) Test(org.junit.jupiter.api.Test)

Example 2 with TableMetaCache

use of io.seata.rm.datasource.sql.struct.TableMetaCache in project seata by seata.

the class PostgresqlTableMetaCacheTest method getTableMetaTest.

@Test
public void getTableMetaTest() throws SQLException {
    MockDriver mockDriver = new MockDriver(columnMetas, indexMetas, pkMetas);
    DruidDataSource dataSource = new DruidDataSource();
    dataSource.setUrl("jdbc:mock:xxx");
    dataSource.setDriver(mockDriver);
    DataSourceProxy proxy = new DataSourceProxy(dataSource);
    TableMetaCache tableMetaCache = TableMetaCacheFactory.getTableMetaCache(JdbcConstants.POSTGRESQL);
    TableMeta tableMeta = tableMetaCache.getTableMeta(proxy.getPlainConnection(), "pt1", proxy.getResourceId());
    Assertions.assertNotNull(tableMeta);
    tableMeta = tableMetaCache.getTableMeta(proxy.getPlainConnection(), "t.pt1", proxy.getResourceId());
    Assertions.assertNotNull(tableMeta);
    tableMeta = tableMetaCache.getTableMeta(proxy.getPlainConnection(), "t.\"pt1\"", proxy.getResourceId());
    Assertions.assertNotNull(tableMeta);
}
Also used : MockDriver(io.seata.rm.datasource.mock.MockDriver) DataSourceProxy(io.seata.rm.datasource.DataSourceProxy) TableMetaCache(io.seata.rm.datasource.sql.struct.TableMetaCache) TableMeta(io.seata.rm.datasource.sql.struct.TableMeta) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) Test(org.junit.jupiter.api.Test)

Example 3 with TableMetaCache

use of io.seata.rm.datasource.sql.struct.TableMetaCache in project seata by seata.

the class MysqlTableMetaCacheTest method testTableMeta.

@Test
public void testTableMeta() {
    TableMetaCache tableMetaCache = getTableMetaCache();
    Assertions.assertNotNull(tableMetaCache);
    Assertions.assertThrows(IllegalArgumentException.class, () -> {
        tableMetaCache.getTableMeta(null, null, null);
    });
}
Also used : TableMetaCache(io.seata.rm.datasource.sql.struct.TableMetaCache) Test(org.junit.jupiter.api.Test)

Aggregations

TableMetaCache (io.seata.rm.datasource.sql.struct.TableMetaCache)3 Test (org.junit.jupiter.api.Test)3 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)2 DataSourceProxy (io.seata.rm.datasource.DataSourceProxy)2 MockDriver (io.seata.rm.datasource.mock.MockDriver)2 TableMeta (io.seata.rm.datasource.sql.struct.TableMeta)2