Skip to content

Connection test#95

Merged
xiangyushawn merged 15 commits intomicrosoft:devfrom
xiangyushawn:connection-test
Jan 6, 2017
Merged

Connection test#95
xiangyushawn merged 15 commits intomicrosoft:devfrom
xiangyushawn:connection-test

Conversation

@xiangyushawn
Copy link
Copy Markdown
Contributor

No description provided.

public void testNativeMSSQLDataSource() throws SQLException {
SQLServerXADataSource ds = new SQLServerXADataSource();
ds.setLastUpdateCount(true);
assertTrue(true == ds.getLastUpdateCount());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertTrue(ds.getLastUpdateCount()); will suffice the purpose.

No need to compare true == ds.getLastUpdateCount());

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Copy Markdown
Contributor

@v-nisidh v-nisidh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed.

.unwrap(Class.forName("com.microsoft.sqlserver.jdbc.ISQLServerDataSource")));
ids.setApplicationName("AppName");
} catch (UnsupportedOperationException e) {
assertEquals("This operation is not supported.", e.getMessage());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some java docs related to which Unsupported Operation you are expecting in this unit test case?

public class PoolingTest extends AbstractTest {
@Test
public void testPooling() throws SQLException {
if (!DBConnection.isSqlAzure(DriverManager.getConnection(connectionString))) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use assumeTrue(DBConnection.isSqlAzure(DriverManager.getConnection(connectionString)),"Skipping / Aborting testcase as this is not Azure Env");

No need to use if condition. In assumeTrue(...) if given condition results true then JUnit runner executes further lines else it will abort running test case.

This will give us indications about how many test case gets skipped.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

rs.next();
int engineEdition = rs.getInt(1);
rs.close();
if (engineEdition == ENGINE_EDITION_FOR_SQL_AZURE) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: Although code is right, as per standard can you use constant on left side?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Connection con = ds.getConnection();

//drop function
String sqlDropFunction = "if exists (select * from dbo.sysobjects where id = object_id(N'[dbo]." + functionName + "')" + "and xtype in (N'FN', N'IF', N'TF'))"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this sql query for Drop Function is generic and should be reusable.

@xiangyushawn xiangyushawn merged commit 1f45849 into microsoft:dev Jan 6, 2017
@xiangyushawn xiangyushawn deleted the connection-test branch January 6, 2017 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants