Skip to content

Remove dependencies from tests that require additional libraries#729

Merged
peterbae merged 5 commits intomicrosoft:devfrom
peterbae:remove_dependencies
Jun 27, 2018
Merged

Remove dependencies from tests that require additional libraries#729
peterbae merged 5 commits intomicrosoft:devfrom
peterbae:remove_dependencies

Conversation

@peterbae
Copy link
Copy Markdown
Contributor

Remove dependencies from tests that are from outside required libraries.

Replaced:

org.apache.commons.lang3.RandomStringUtils
org.apache.commons.codec.binary.Hex
org.apache.commons.codec.DecoderException;

And replaced with with other methods / java.util functions.

@cheenamalhotra cheenamalhotra added this to the 6.5.4 milestone Jun 26, 2018
@codecov-io
Copy link
Copy Markdown

codecov-io commented Jun 26, 2018

Codecov Report

Merging #729 into dev will decrease coverage by 0.08%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##                dev     #729      +/-   ##
============================================
- Coverage     48.03%   47.95%   -0.09%     
+ Complexity     2631     2629       -2     
============================================
  Files           118      118              
  Lines         26753    26753              
  Branches       4493     4493              
============================================
- Hits          12852    12829      -23     
- Misses        11773    11801      +28     
+ Partials       2128     2123       -5
Flag Coverage Δ Complexity Δ
#JDBC42 47.52% <ø> (+0.06%) 2588 <ø> (+6) ⬆️
#JDBC43 47.8% <ø> (-0.17%) 2618 <ø> (-9)
Impacted Files Coverage Δ Complexity Δ
...om/microsoft/sqlserver/jdbc/ReaderInputStream.java 44.94% <0%> (-2.25%) 16% <0%> (ø)
...in/java/com/microsoft/sqlserver/jdbc/IOBuffer.java 52.8% <0%> (-0.7%) 0% <0%> (ø)
...m/microsoft/sqlserver/jdbc/SQLServerResultSet.java 33.3% <0%> (-0.4%) 247% <0%> (-4%)
...ncurrentlinkedhashmap/ConcurrentLinkedHashMap.java 38.79% <0%> (-0.22%) 43% <0%> (ø)
...om/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java 52.42% <0%> (-0.13%) 239% <0%> (ø)
...rc/main/java/com/microsoft/sqlserver/jdbc/dtv.java 63.36% <0%> (+0.23%) 0% <0%> (ø) ⬇️
...c/main/java/com/microsoft/sqlserver/jdbc/Util.java 61.35% <0%> (+0.43%) 89% <0%> (+1%) ⬆️
...rc/main/java/com/microsoft/sqlserver/jdbc/DDC.java 45.41% <0%> (+1.56%) 108% <0%> (+1%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 09d7967...523fdfe. Read the comment docs.

} else if (this.precision == 1) {
randomNumeric = rnd.nextInt(10);
} else {
randomNumeric = (int) Math.pow(10, this.precision - 1) + rnd.nextInt((int) (9 * Math.pow(10, this.precision - 1)));
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 we save this to a var so we don't have to call Math.pow(10, this.precision - 1) twice?

} else {
randomNumeric = (int) Math.pow(10, this.scale - 1) + rnd.nextInt((int) (9 * Math.pow(10, this.scale - 1)));
}

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.

this is the same as above can we move this out to a method which generates n random digits?

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.

sure!

@@ -474,4 +472,11 @@ boolean passDataAsHex(int colNum) {
return (JDBCType.BINARY == getColumn(colNum).getJdbctype() || JDBCType.VARBINARY == getColumn(colNum).getJdbctype()
|| JDBCType.LONGVARBINARY == getColumn(colNum).getJdbctype());
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 know this didn't get changed, but would be better if we just do getColumn(colNum).getJdbctype() once

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.

cool, done

return new Timestamp(ThreadLocalRandom.current().nextLong(((Timestamp) minvalue).getTime(), ((Timestamp) maxvalue).getTime()));
}

protected int generateRandomInt(int length) {
Copy link
Copy Markdown
Contributor

@lilgreenbird lilgreenbird Jun 27, 2018

Choose a reason for hiding this comment

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

comment header? (applies to other places below)

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.

nah we don't need it

//Example of how this works:
// if length is 3, then we add 100 + random number between 0~899, so that we get a random number between 100~999.
int randomNumeric;
if (length <= 0) {
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.

nitpicking....
we normally do (0 >= blah) etc...

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.

i think that's only for comparing to null (for good reasons)

|| JDBCType.LONGVARBINARY == getColumn(colNum).getJdbctype());
}

private String byteArrayToHex(byte[] a) {
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.

comment header?

@peterbae peterbae merged commit 9b871b8 into microsoft:dev Jun 27, 2018
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.

5 participants