Skip to content

Commit

Permalink
Merge pull request #148 from baztian/fix-mockito-incompat
Browse files Browse the repository at this point in the history
Upgrade mockito to work around JPype incompatibilities
  • Loading branch information
baztian committed Jun 4, 2020
2 parents dc8dc67 + 5449ca8 commit 53012d5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions mockdriver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<dependencies>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<artifactId>mockito-core</artifactId>
<version>3.3.3</version>
<!-- non-test scope on purpose -->
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public final void mockExceptionOnExecute(String className, String exceptionMessa
PreparedStatement mockPreparedStatement = Mockito.mock(PreparedStatement.class);
Throwable exception = createException(className, exceptionMessage);
Mockito.when(mockPreparedStatement.execute()).thenThrow(exception);
Mockito.when(this.prepareStatement(Mockito.anyString())).thenReturn(mockPreparedStatement);
Mockito.when(this.prepareStatement(Mockito.any())).thenReturn(mockPreparedStatement);
}

public final void mockBigDecimalResult(long value, int scale) throws SQLException {
Expand All @@ -73,7 +73,7 @@ public final void mockBigDecimalResult(long value, int scale) throws SQLExceptio
BigDecimal columnValue = BigDecimal.valueOf(value, scale);
Mockito.when(mockResultSet.getObject(1)).thenReturn(columnValue);
Mockito.when(mockMetaData.getColumnType(1)).thenReturn(Types.DECIMAL);
Mockito.when(this.prepareStatement(Mockito.anyString())).thenReturn(mockPreparedStatement);
Mockito.when(this.prepareStatement(Mockito.any())).thenReturn(mockPreparedStatement);
}

public final void mockDoubleDecimalResult(double value) throws SQLException {
Expand All @@ -89,7 +89,7 @@ public final void mockDoubleDecimalResult(double value) throws SQLException {
Double columnValue = Double.valueOf(value);
Mockito.when(mockResultSet.getObject(1)).thenReturn(value);
Mockito.when(mockMetaData.getColumnType(1)).thenReturn(Types.DECIMAL);
Mockito.when(this.prepareStatement(Mockito.anyString())).thenReturn(mockPreparedStatement);
Mockito.when(this.prepareStatement(Mockito.any())).thenReturn(mockPreparedStatement);
}

public final void mockDateResult(int year, int month, int day) throws SQLException {
Expand All @@ -109,7 +109,7 @@ public final void mockDateResult(int year, int month, int day) throws SQLExcepti
Date ancientDate = new Date(cal.getTime().getTime());
Mockito.when(mockResultSet.getDate(1)).thenReturn(ancientDate);
Mockito.when(mockMetaData.getColumnType(1)).thenReturn(Types.DATE);
Mockito.when(this.prepareStatement(Mockito.anyString())).thenReturn(mockPreparedStatement);
Mockito.when(this.prepareStatement(Mockito.any())).thenReturn(mockPreparedStatement);
}

public final void mockType(String sqlTypesName) throws SQLException {
Expand All @@ -123,7 +123,7 @@ public final void mockType(String sqlTypesName) throws SQLException {
Mockito.when(mockMetaData.getColumnCount()).thenReturn(1);
int sqlTypeCode = extractTypeCodeForName(sqlTypesName);
Mockito.when(mockMetaData.getColumnType(1)).thenReturn(sqlTypeCode);
Mockito.when(this.prepareStatement(Mockito.anyString())).thenReturn(mockPreparedStatement);
Mockito.when(this.prepareStatement(Mockito.any())).thenReturn(mockPreparedStatement);
}

public final ResultSet verifyResultSet() {
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ deps =
py35-newjpype: JPype1==0.7.5
py36-newjpype: JPype1==0.7.5
py27-newjpype: JPype1==0.7.0
jip==0.9.14
jip==0.9.15
coverage==4.5.4
commands =
python --version
Expand Down

0 comments on commit 53012d5

Please sign in to comment.