Search in sources :

Example 1 with ISQLServerDataSource

use of com.microsoft.sqlserver.jdbc.ISQLServerDataSource in project mssql-jdbc by Microsoft.

the class NativeMSSQLDataSourceTest method testInterfaceWrapping.

@Test
public void testInterfaceWrapping() throws ClassNotFoundException, SQLException {
    SQLServerDataSource ds = new SQLServerDataSource();
    assertEquals(true, ds.isWrapperFor(Class.forName("com.microsoft.sqlserver.jdbc.ISQLServerDataSource")));
    assertEquals(true, ds.isWrapperFor(Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDataSource")));
    assertEquals(true, ds.isWrapperFor(Class.forName("javax.sql.CommonDataSource")));
    ISQLServerDataSource ids = (ISQLServerDataSource) (ds.unwrap(Class.forName("com.microsoft.sqlserver.jdbc.ISQLServerDataSource")));
    ids.setApplicationName("AppName");
    SQLServerConnectionPoolDataSource poolDS = new SQLServerConnectionPoolDataSource();
    assertEquals(true, poolDS.isWrapperFor(Class.forName("com.microsoft.sqlserver.jdbc.ISQLServerDataSource")));
    assertEquals(true, poolDS.isWrapperFor(Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDataSource")));
    assertEquals(true, poolDS.isWrapperFor(Class.forName("com.microsoft.sqlserver.jdbc.SQLServerConnectionPoolDataSource")));
    assertEquals(true, poolDS.isWrapperFor(Class.forName("javax.sql.CommonDataSource")));
    ISQLServerDataSource ids2 = (ISQLServerDataSource) (poolDS.unwrap(Class.forName("com.microsoft.sqlserver.jdbc.ISQLServerDataSource")));
    ids2.setApplicationName("AppName");
    SQLServerXADataSource xaDS = new SQLServerXADataSource();
    assertEquals(true, xaDS.isWrapperFor(Class.forName("com.microsoft.sqlserver.jdbc.ISQLServerDataSource")));
    assertEquals(true, xaDS.isWrapperFor(Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDataSource")));
    assertEquals(true, xaDS.isWrapperFor(Class.forName("com.microsoft.sqlserver.jdbc.SQLServerConnectionPoolDataSource")));
    assertEquals(true, xaDS.isWrapperFor(Class.forName("com.microsoft.sqlserver.jdbc.SQLServerXADataSource")));
    assertEquals(true, xaDS.isWrapperFor(Class.forName("javax.sql.CommonDataSource")));
    ISQLServerDataSource ids3 = (ISQLServerDataSource) (xaDS.unwrap(Class.forName("com.microsoft.sqlserver.jdbc.ISQLServerDataSource")));
    ids3.setApplicationName("AppName");
}
Also used : SQLServerConnectionPoolDataSource(com.microsoft.sqlserver.jdbc.SQLServerConnectionPoolDataSource) ISQLServerDataSource(com.microsoft.sqlserver.jdbc.ISQLServerDataSource) SQLServerDataSource(com.microsoft.sqlserver.jdbc.SQLServerDataSource) ISQLServerDataSource(com.microsoft.sqlserver.jdbc.ISQLServerDataSource) SQLServerXADataSource(com.microsoft.sqlserver.jdbc.SQLServerXADataSource) Test(org.junit.jupiter.api.Test) AbstractTest(com.microsoft.sqlserver.testframework.AbstractTest)

Aggregations

ISQLServerDataSource (com.microsoft.sqlserver.jdbc.ISQLServerDataSource)1 SQLServerConnectionPoolDataSource (com.microsoft.sqlserver.jdbc.SQLServerConnectionPoolDataSource)1 SQLServerDataSource (com.microsoft.sqlserver.jdbc.SQLServerDataSource)1 SQLServerXADataSource (com.microsoft.sqlserver.jdbc.SQLServerXADataSource)1 AbstractTest (com.microsoft.sqlserver.testframework.AbstractTest)1 Test (org.junit.jupiter.api.Test)1