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

Remove dependencies from tests that require additional libraries #729

Merged
merged 5 commits into from Jun 27, 2018

Conversation

5 participants
@peterbae
Member

peterbae commented Jun 26, 2018

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

@cheenamalhotra cheenamalhotra added this to Under Peer Review in MSSQL JDBC Jun 26, 2018

@codecov-io

This comment has been minimized.

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)));

This comment has been minimized.

@lilgreenbird

lilgreenbird Jun 27, 2018

Member

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)));
}

This comment has been minimized.

@lilgreenbird

lilgreenbird Jun 27, 2018

Member

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

This comment has been minimized.

@peterbae
@@ -474,4 +472,11 @@ boolean passDataAsHex(int colNum) {
return (JDBCType.BINARY == getColumn(colNum).getJdbctype() || JDBCType.VARBINARY == getColumn(colNum).getJdbctype()
|| JDBCType.LONGVARBINARY == getColumn(colNum).getJdbctype());

This comment has been minimized.

@lilgreenbird

lilgreenbird Jun 27, 2018

Member

I know this didn't get changed, but would be better if we just do getColumn(colNum).getJdbctype() once

This comment has been minimized.

@peterbae

peterbae Jun 27, 2018

Member

cool, done

@@ -41,4 +42,22 @@ public SqlDateTime() {
public Object createdata() {
return new Timestamp(ThreadLocalRandom.current().nextLong(((Timestamp) minvalue).getTime(), ((Timestamp) maxvalue).getTime()));
}
protected int generateRandomInt(int length) {

This comment has been minimized.

@lilgreenbird

lilgreenbird Jun 27, 2018

Member

comment header? (applies to other places below)

This comment has been minimized.

@peterbae

peterbae Jun 27, 2018

Member

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) {

This comment has been minimized.

@lilgreenbird

lilgreenbird Jun 27, 2018

Member

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

This comment has been minimized.

@peterbae

peterbae Jun 27, 2018

Member

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

@@ -474,4 +472,11 @@ boolean passDataAsHex(int colNum) {
return (JDBCType.BINARY == getColumn(colNum).getJdbctype() || JDBCType.VARBINARY == getColumn(colNum).getJdbctype()
|| JDBCType.LONGVARBINARY == getColumn(colNum).getJdbctype());
}
private String byteArrayToHex(byte[] a) {

This comment has been minimized.

@lilgreenbird

lilgreenbird Jun 27, 2018

Member

comment header?

@ulvii

ulvii approved these changes Jun 27, 2018

@peterbae peterbae merged commit 9b871b8 into Microsoft:dev Jun 27, 2018

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
license/cla All CLA requirements met.
Details

MSSQL JDBC automation moved this from Under Peer Review to Closed/Merged PRs Jun 27, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment