Skip to content

Commit bf5598d

Browse files
committed
Polishing tests for compatibility with mockito 3.3.x
1 parent 8ce13ac commit bf5598d

9 files changed

+43
-97
lines changed

src/test/java/org/apache/ibatis/type/BooleanTypeHandlerTest.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2009-2019 the original author or authors.
2+
* Copyright 2009-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,10 +36,8 @@ public void shouldSetParameter() throws Exception {
3636
@Override
3737
@Test
3838
public void shouldGetResultFromResultSetByName() throws Exception {
39-
when(rs.getBoolean("column")).thenReturn(true);
39+
when(rs.getBoolean("column")).thenReturn(true, false);
4040
assertEquals(true, TYPE_HANDLER.getResult(rs, "column"));
41-
42-
when(rs.getBoolean("column")).thenReturn(false);
4341
assertEquals(false, TYPE_HANDLER.getResult(rs, "column"));
4442
}
4543

@@ -54,10 +52,8 @@ public void shouldGetResultNullFromResultSetByName() throws Exception {
5452
@Override
5553
@Test
5654
public void shouldGetResultFromResultSetByPosition() throws Exception {
57-
when(rs.getBoolean(1)).thenReturn(true);
55+
when(rs.getBoolean(1)).thenReturn(true, false);
5856
assertEquals(true, TYPE_HANDLER.getResult(rs, 1));
59-
60-
when(rs.getBoolean(1)).thenReturn(false);
6157
assertEquals(false, TYPE_HANDLER.getResult(rs, 1));
6258
}
6359

@@ -72,10 +68,8 @@ public void shouldGetResultNullFromResultSetByPosition() throws Exception {
7268
@Override
7369
@Test
7470
public void shouldGetResultFromCallableStatement() throws Exception {
75-
when(cs.getBoolean(1)).thenReturn(true);
71+
when(cs.getBoolean(1)).thenReturn(true, false);
7672
assertEquals(true, TYPE_HANDLER.getResult(cs, 1));
77-
78-
when(cs.getBoolean(1)).thenReturn(false);
7973
assertEquals(false, TYPE_HANDLER.getResult(cs, 1));
8074
}
8175

@@ -86,4 +80,4 @@ public void shouldGetResultNullFromCallableStatement() throws Exception {
8680
assertNull(TYPE_HANDLER.getResult(cs, 1));
8781
}
8882

89-
}
83+
}

src/test/java/org/apache/ibatis/type/ByteTypeHandlerTest.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2009-2019 the original author or authors.
2+
* Copyright 2009-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,10 +36,8 @@ public void shouldSetParameter() throws Exception {
3636
@Override
3737
@Test
3838
public void shouldGetResultFromResultSetByName() throws Exception {
39-
when(rs.getByte("column")).thenReturn((byte) 100);
39+
when(rs.getByte("column")).thenReturn((byte) 100, (byte) 0);
4040
assertEquals(Byte.valueOf((byte) 100), TYPE_HANDLER.getResult(rs, "column"));
41-
42-
when(rs.getByte("column")).thenReturn((byte) 0);
4341
assertEquals(Byte.valueOf((byte) 0), TYPE_HANDLER.getResult(rs, "column"));
4442
}
4543

@@ -54,10 +52,8 @@ public void shouldGetResultNullFromResultSetByName() throws Exception {
5452
@Override
5553
@Test
5654
public void shouldGetResultFromResultSetByPosition() throws Exception {
57-
when(rs.getByte(1)).thenReturn((byte) 100);
55+
when(rs.getByte(1)).thenReturn((byte) 100, (byte) 0);
5856
assertEquals(Byte.valueOf((byte) 100), TYPE_HANDLER.getResult(rs, 1));
59-
60-
when(rs.getByte(1)).thenReturn((byte) 0);
6157
assertEquals(Byte.valueOf((byte) 0), TYPE_HANDLER.getResult(rs, 1));
6258
}
6359

@@ -72,10 +68,8 @@ public void shouldGetResultNullFromResultSetByPosition() throws Exception {
7268
@Override
7369
@Test
7470
public void shouldGetResultFromCallableStatement() throws Exception {
75-
when(cs.getByte(1)).thenReturn((byte) 100);
71+
when(cs.getByte(1)).thenReturn((byte) 100, (byte) 0);
7672
assertEquals(Byte.valueOf((byte) 100), TYPE_HANDLER.getResult(cs, 1));
77-
78-
when(cs.getByte(1)).thenReturn((byte) 0);
7973
assertEquals(Byte.valueOf((byte) 0), TYPE_HANDLER.getResult(cs, 1));
8074
}
8175

@@ -87,4 +81,4 @@ public void shouldGetResultNullFromCallableStatement() throws Exception {
8781
assertNull(TYPE_HANDLER.getResult(cs, 1));
8882
}
8983

90-
}
84+
}

src/test/java/org/apache/ibatis/type/DoubleTypeHandlerTest.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2009-2019 the original author or authors.
2+
* Copyright 2009-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,10 +36,8 @@ public void shouldSetParameter() throws Exception {
3636
@Override
3737
@Test
3838
public void shouldGetResultFromResultSetByName() throws Exception {
39-
when(rs.getDouble("column")).thenReturn(100d);
39+
when(rs.getDouble("column")).thenReturn(100d, 0d);
4040
assertEquals(Double.valueOf(100d), TYPE_HANDLER.getResult(rs, "column"));
41-
42-
when(rs.getDouble("column")).thenReturn(0d);
4341
assertEquals(Double.valueOf(0d), TYPE_HANDLER.getResult(rs, "column"));
4442
}
4543

@@ -54,10 +52,8 @@ public void shouldGetResultNullFromResultSetByName() throws Exception {
5452
@Override
5553
@Test
5654
public void shouldGetResultFromResultSetByPosition() throws Exception {
57-
when(rs.getDouble(1)).thenReturn(100d);
55+
when(rs.getDouble(1)).thenReturn(100d, 0d);
5856
assertEquals(Double.valueOf(100d), TYPE_HANDLER.getResult(rs, 1));
59-
60-
when(rs.getDouble(1)).thenReturn(0d);
6157
assertEquals(Double.valueOf(0d), TYPE_HANDLER.getResult(rs, 1));
6258
}
6359

@@ -72,10 +68,8 @@ public void shouldGetResultNullFromResultSetByPosition() throws Exception {
7268
@Override
7369
@Test
7470
public void shouldGetResultFromCallableStatement() throws Exception {
75-
when(cs.getDouble(1)).thenReturn(100d);
71+
when(cs.getDouble(1)).thenReturn(100d, 0d);
7672
assertEquals(Double.valueOf(100d), TYPE_HANDLER.getResult(cs, 1));
77-
78-
when(cs.getDouble(1)).thenReturn(0d);
7973
assertEquals(Double.valueOf(0d), TYPE_HANDLER.getResult(cs, 1));
8074
}
8175

@@ -87,4 +81,4 @@ public void shouldGetResultNullFromCallableStatement() throws Exception {
8781
assertNull(TYPE_HANDLER.getResult(cs, 1));
8882
}
8983

90-
}
84+
}

src/test/java/org/apache/ibatis/type/FloatTypeHandlerTest.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2009-2019 the original author or authors.
2+
* Copyright 2009-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,10 +36,8 @@ public void shouldSetParameter() throws Exception {
3636
@Override
3737
@Test
3838
public void shouldGetResultFromResultSetByName() throws Exception {
39-
when(rs.getFloat("column")).thenReturn(100f);
39+
when(rs.getFloat("column")).thenReturn(100f, 0f);
4040
assertEquals(Float.valueOf(100f), TYPE_HANDLER.getResult(rs, "column"));
41-
42-
when(rs.getFloat("column")).thenReturn(0f);
4341
assertEquals(Float.valueOf(0f), TYPE_HANDLER.getResult(rs, "column"));
4442
}
4543

@@ -54,10 +52,8 @@ public void shouldGetResultNullFromResultSetByName() throws Exception {
5452
@Override
5553
@Test
5654
public void shouldGetResultFromResultSetByPosition() throws Exception {
57-
when(rs.getFloat(1)).thenReturn(100f);
55+
when(rs.getFloat(1)).thenReturn(100f, 0f);
5856
assertEquals(Float.valueOf(100f), TYPE_HANDLER.getResult(rs, 1));
59-
60-
when(rs.getFloat(1)).thenReturn(0f);
6157
assertEquals(Float.valueOf(0f), TYPE_HANDLER.getResult(rs, 1));
6258
}
6359

@@ -72,10 +68,8 @@ public void shouldGetResultNullFromResultSetByPosition() throws Exception {
7268
@Override
7369
@Test
7470
public void shouldGetResultFromCallableStatement() throws Exception {
75-
when(cs.getFloat(1)).thenReturn(100f);
71+
when(cs.getFloat(1)).thenReturn(100f, 0f);
7672
assertEquals(Float.valueOf(100f), TYPE_HANDLER.getResult(cs, 1));
77-
78-
when(cs.getFloat(1)).thenReturn(0f);
7973
assertEquals(Float.valueOf(0f), TYPE_HANDLER.getResult(cs, 1));
8074
}
8175

@@ -87,4 +81,4 @@ public void shouldGetResultNullFromCallableStatement() throws Exception {
8781
assertNull(TYPE_HANDLER.getResult(cs, 1));
8882
}
8983

90-
}
84+
}

src/test/java/org/apache/ibatis/type/IntegerTypeHandlerTest.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2009-2019 the original author or authors.
2+
* Copyright 2009-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,10 +36,8 @@ public void shouldSetParameter() throws Exception {
3636
@Override
3737
@Test
3838
public void shouldGetResultFromResultSetByName() throws Exception {
39-
when(rs.getInt("column")).thenReturn(100);
39+
when(rs.getInt("column")).thenReturn(100, 0);
4040
assertEquals(Integer.valueOf(100), TYPE_HANDLER.getResult(rs, "column"));
41-
42-
when(rs.getInt("column")).thenReturn(0);
4341
assertEquals(Integer.valueOf(0), TYPE_HANDLER.getResult(rs, "column"));
4442
}
4543

@@ -54,10 +52,8 @@ public void shouldGetResultNullFromResultSetByName() throws Exception {
5452
@Override
5553
@Test
5654
public void shouldGetResultFromResultSetByPosition() throws Exception {
57-
when(rs.getInt(1)).thenReturn(100);
55+
when(rs.getInt(1)).thenReturn(100, 0);
5856
assertEquals(Integer.valueOf(100), TYPE_HANDLER.getResult(rs, 1));
59-
60-
when(rs.getInt(1)).thenReturn(0);
6157
assertEquals(Integer.valueOf(0), TYPE_HANDLER.getResult(rs, 1));
6258
}
6359

@@ -72,10 +68,8 @@ public void shouldGetResultNullFromResultSetByPosition() throws Exception {
7268
@Override
7369
@Test
7470
public void shouldGetResultFromCallableStatement() throws Exception {
75-
when(cs.getInt(1)).thenReturn(100);
71+
when(cs.getInt(1)).thenReturn(100, 0);
7672
assertEquals(Integer.valueOf(100), TYPE_HANDLER.getResult(cs, 1));
77-
78-
when(cs.getInt(1)).thenReturn(0);
7973
assertEquals(Integer.valueOf(0), TYPE_HANDLER.getResult(cs, 1));
8074
}
8175

@@ -87,4 +81,4 @@ public void shouldGetResultNullFromCallableStatement() throws Exception {
8781
assertNull(TYPE_HANDLER.getResult(cs, 1));
8882
}
8983

90-
}
84+
}

src/test/java/org/apache/ibatis/type/LongTypeHandlerTest.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2009-2019 the original author or authors.
2+
* Copyright 2009-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,10 +36,8 @@ public void shouldSetParameter() throws Exception {
3636
@Override
3737
@Test
3838
public void shouldGetResultFromResultSetByName() throws Exception {
39-
when(rs.getLong("column")).thenReturn(100L);
39+
when(rs.getLong("column")).thenReturn(100L, 0L);
4040
assertEquals(Long.valueOf(100L), TYPE_HANDLER.getResult(rs, "column"));
41-
42-
when(rs.getLong("column")).thenReturn(0L);
4341
assertEquals(Long.valueOf(0L), TYPE_HANDLER.getResult(rs, "column"));
4442
}
4543

@@ -54,10 +52,8 @@ public void shouldGetResultNullFromResultSetByName() throws Exception {
5452
@Override
5553
@Test
5654
public void shouldGetResultFromResultSetByPosition() throws Exception {
57-
when(rs.getLong(1)).thenReturn(100L);
55+
when(rs.getLong(1)).thenReturn(100L, 0L);
5856
assertEquals(Long.valueOf(100L), TYPE_HANDLER.getResult(rs, 1));
59-
60-
when(rs.getLong(1)).thenReturn(0L);
6157
assertEquals(Long.valueOf(0L), TYPE_HANDLER.getResult(rs, 1));
6258
}
6359

@@ -72,10 +68,8 @@ public void shouldGetResultNullFromResultSetByPosition() throws Exception {
7268
@Override
7369
@Test
7470
public void shouldGetResultFromCallableStatement() throws Exception {
75-
when(cs.getLong(1)).thenReturn(100L);
71+
when(cs.getLong(1)).thenReturn(100L, 0L);
7672
assertEquals(Long.valueOf(100L), TYPE_HANDLER.getResult(cs, 1));
77-
78-
when(cs.getLong(1)).thenReturn(0L);
7973
assertEquals(Long.valueOf(0L), TYPE_HANDLER.getResult(cs, 1));
8074
}
8175

@@ -87,4 +81,4 @@ public void shouldGetResultNullFromCallableStatement() throws Exception {
8781
assertNull(TYPE_HANDLER.getResult(cs, 1));
8882
}
8983

90-
}
84+
}

src/test/java/org/apache/ibatis/type/MonthTypeHandlerTest.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2009-2019 the original author or authors.
2+
* Copyright 2009-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -42,10 +42,8 @@ public void shouldSetParameter() throws Exception {
4242
@Override
4343
@Test
4444
public void shouldGetResultFromResultSetByName() throws Exception {
45-
when(rs.getInt("column")).thenReturn(INSTANT.getValue());
45+
when(rs.getInt("column")).thenReturn(INSTANT.getValue(), 0);
4646
assertEquals(INSTANT, TYPE_HANDLER.getResult(rs, "column"));
47-
48-
when(rs.getInt("column")).thenReturn(0);
4947
try {
5048
TYPE_HANDLER.getResult(rs, "column");
5149
fail();
@@ -65,10 +63,8 @@ public void shouldGetResultNullFromResultSetByName() throws Exception {
6563
@Override
6664
@Test
6765
public void shouldGetResultFromResultSetByPosition() throws Exception {
68-
when(rs.getInt(1)).thenReturn(INSTANT.getValue());
66+
when(rs.getInt(1)).thenReturn(INSTANT.getValue(), 0);
6967
assertEquals(INSTANT, TYPE_HANDLER.getResult(rs, 1));
70-
71-
when(rs.getInt(1)).thenReturn(0);
7268
try {
7369
TYPE_HANDLER.getResult(rs, 1);
7470
fail();
@@ -88,10 +84,8 @@ public void shouldGetResultNullFromResultSetByPosition() throws Exception {
8884
@Override
8985
@Test
9086
public void shouldGetResultFromCallableStatement() throws Exception {
91-
when(cs.getInt(1)).thenReturn(INSTANT.getValue());
87+
when(cs.getInt(1)).thenReturn(INSTANT.getValue(), 0);
9288
assertEquals(INSTANT, TYPE_HANDLER.getResult(cs, 1));
93-
94-
when(cs.getInt(1)).thenReturn(0);
9589
try {
9690
TYPE_HANDLER.getResult(cs, 1);
9791
fail();

src/test/java/org/apache/ibatis/type/ShortTypeHandlerTest.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2009-2019 the original author or authors.
2+
* Copyright 2009-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,10 +36,8 @@ public void shouldSetParameter() throws Exception {
3636
@Override
3737
@Test
3838
public void shouldGetResultFromResultSetByName() throws Exception {
39-
when(rs.getShort("column")).thenReturn((short) 100);
39+
when(rs.getShort("column")).thenReturn((short) 100, (short) 0);
4040
assertEquals(Short.valueOf((short) 100), TYPE_HANDLER.getResult(rs, "column"));
41-
42-
when(rs.getShort("column")).thenReturn((short) 0);
4341
assertEquals(Short.valueOf((short) 0), TYPE_HANDLER.getResult(rs, "column"));
4442
}
4543

@@ -54,10 +52,8 @@ public void shouldGetResultNullFromResultSetByName() throws Exception {
5452
@Override
5553
@Test
5654
public void shouldGetResultFromResultSetByPosition() throws Exception {
57-
when(rs.getShort(1)).thenReturn((short) 100);
55+
when(rs.getShort(1)).thenReturn((short) 100, (short) 0);
5856
assertEquals(Short.valueOf((short) 100), TYPE_HANDLER.getResult(rs, 1));
59-
60-
when(rs.getShort(1)).thenReturn((short) 0);
6157
assertEquals(Short.valueOf((short) 0), TYPE_HANDLER.getResult(rs, 1));
6258
}
6359

@@ -72,10 +68,8 @@ public void shouldGetResultNullFromResultSetByPosition() throws Exception {
7268
@Override
7369
@Test
7470
public void shouldGetResultFromCallableStatement() throws Exception {
75-
when(cs.getShort(1)).thenReturn((short) 100);
71+
when(cs.getShort(1)).thenReturn((short) 100, (short) 0);
7672
assertEquals(Short.valueOf((short) 100), TYPE_HANDLER.getResult(cs, 1));
77-
78-
when(cs.getShort(1)).thenReturn((short) 0);
7973
assertEquals(Short.valueOf((short) 0), TYPE_HANDLER.getResult(cs, 1));
8074
}
8175

@@ -87,4 +81,4 @@ public void shouldGetResultNullFromCallableStatement() throws Exception {
8781
assertNull(TYPE_HANDLER.getResult(cs, 1));
8882
}
8983

90-
}
84+
}

0 commit comments

Comments
 (0)