Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection test #95

Merged
merged 15 commits into from
Jan 6, 2017
Merged

Connection test #95

merged 15 commits into from
Jan 6, 2017

Conversation

xiangyushawn
Copy link
Contributor

No description provided.

public void testNativeMSSQLDataSource() throws SQLException {
SQLServerXADataSource ds = new SQLServerXADataSource();
ds.setLastUpdateCount(true);
assertTrue(true == ds.getLastUpdateCount());
Copy link
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
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
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
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
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
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
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
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
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.

2 participants