Skip to content

Commit cd15fd7

Browse files
authored
🎨 降级 Mockito 至 4.11.0 以兼容 Java 8
1 parent 474f4fd commit cd15fd7

File tree

6 files changed

+74
-6
lines changed

6 files changed

+74
-6
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@
258258
<dependency>
259259
<groupId>org.mockito</groupId>
260260
<artifactId>mockito-core</artifactId>
261-
<version>5.14.2</version>
261+
<version>4.11.0</version>
262262
<scope>test</scope>
263263
</dependency>
264264
<dependency>

weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpCustomizedServiceImplTest.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import me.chanjar.weixin.cp.tp.service.WxCpTpCustomizedService;
99
import org.mockito.Mock;
1010
import org.mockito.MockitoAnnotations;
11+
import org.testng.annotations.AfterClass;
1112
import org.testng.annotations.BeforeClass;
1213
import org.testng.annotations.Test;
1314

@@ -34,17 +35,29 @@ public class WxCpTpCustomizedServiceImplTest {
3435

3536
private WxCpTpCustomizedService wxCpTpCustomizedService;
3637

38+
private AutoCloseable mockitoAnnotations;
39+
3740
/**
3841
* Sets up.
3942
*/
4043
@BeforeClass
4144
public void setUp() {
42-
MockitoAnnotations.initMocks(this);
45+
mockitoAnnotations = MockitoAnnotations.openMocks(this);
4346
configStorage = new WxCpTpDefaultConfigImpl();
4447
when(wxCpTpService.getWxCpTpConfigStorage()).thenReturn(configStorage);
4548
wxCpTpCustomizedService = new WxCpTpCustomizedServiceImpl(wxCpTpService);
4649
}
4750

51+
/**
52+
* Tear down.
53+
*
54+
* @throws Exception the exception
55+
*/
56+
@AfterClass
57+
public void tearDown() throws Exception {
58+
mockitoAnnotations.close();
59+
}
60+
4861
/**
4962
* 测试获取应用模板列表
5063
*

weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpEditionServiceImplTest.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import me.chanjar.weixin.cp.tp.service.WxCpTpEditionService;
88
import org.mockito.Mock;
99
import org.mockito.MockitoAnnotations;
10+
import org.testng.annotations.AfterClass;
1011
import org.testng.annotations.BeforeClass;
1112
import org.testng.annotations.Test;
1213

@@ -29,18 +30,31 @@ public class WxCpTpEditionServiceImplTest {
2930

3031
private WxCpTpEditionService wxCpTpEditionService;
3132

33+
private AutoCloseable mockitoAnnotations;
34+
3235
/**
3336
* Sets up.
3437
*/
3538
@BeforeClass
3639
public void setUp() {
37-
MockitoAnnotations.openMocks(this);
40+
mockitoAnnotations = MockitoAnnotations.openMocks(this);
3841
configStorage = new WxCpTpDefaultConfigImpl();
3942
when(wxCpTpService.getWxCpTpConfigStorage()).thenReturn(configStorage);
4043
wxCpTpEditionService = new WxCpTpEditionServiceImpl(wxCpTpService);
4144
}
4245

4346

47+
/**
48+
* Tear down.
49+
*
50+
* @throws Exception the exception
51+
*/
52+
@AfterClass
53+
public void tearDown() throws Exception {
54+
mockitoAnnotations.close();
55+
}
56+
57+
4458
/**
4559
* 延长试用期
4660
*

weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpLicenseServiceImplTest.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import me.chanjar.weixin.cp.tp.service.WxCpTpLicenseService;
1111
import org.mockito.Mock;
1212
import org.mockito.MockitoAnnotations;
13+
import org.testng.annotations.AfterClass;
1314
import org.testng.annotations.BeforeClass;
1415
import org.testng.annotations.Test;
1516

@@ -36,18 +37,31 @@ public class WxCpTpLicenseServiceImplTest {
3637

3738
private WxCpTpLicenseService wxCpTpLicenseService;
3839

40+
private AutoCloseable mockitoAnnotations;
41+
3942
/**
4043
* Sets up.
4144
*/
4245
@BeforeClass
4346
public void setUp() {
44-
MockitoAnnotations.openMocks(this);
47+
mockitoAnnotations = MockitoAnnotations.openMocks(this);
4548
configStorage = new WxCpTpDefaultConfigImpl();
4649
when(wxCpTpService.getWxCpTpConfigStorage()).thenReturn(configStorage);
4750
wxCpTpLicenseService = new WxCpTpLicenseServiceImpl(wxCpTpService);
4851
}
4952

5053

54+
/**
55+
* Tear down.
56+
*
57+
* @throws Exception the exception
58+
*/
59+
@AfterClass
60+
public void tearDown() throws Exception {
61+
mockitoAnnotations.close();
62+
}
63+
64+
5165
/**
5266
* Test crate new order.
5367
*

weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpOrderServiceImplTest.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.apache.commons.lang3.time.DateUtils;
1010
import org.mockito.Mock;
1111
import org.mockito.MockitoAnnotations;
12+
import org.testng.annotations.AfterClass;
1213
import org.testng.annotations.BeforeClass;
1314
import org.testng.annotations.Test;
1415

@@ -35,18 +36,31 @@ public class WxCpTpOrderServiceImplTest {
3536

3637
private WxCpTpOrderService wxCpTpOrderService;
3738

39+
private AutoCloseable mockitoAnnotations;
40+
3841
/**
3942
* Sets up.
4043
*/
4144
@BeforeClass
4245
public void setUp() {
43-
MockitoAnnotations.openMocks(this);
46+
mockitoAnnotations = MockitoAnnotations.openMocks(this);
4447
configStorage = new WxCpTpDefaultConfigImpl();
4548
when(wxCpTpService.getWxCpTpConfigStorage()).thenReturn(configStorage);
4649
wxCpTpOrderService = new WxCpTpOrderServiceImpl(wxCpTpService);
4750
}
4851

4952

53+
/**
54+
* Tear down.
55+
*
56+
* @throws Exception the exception
57+
*/
58+
@AfterClass
59+
public void tearDown() throws Exception {
60+
mockitoAnnotations.close();
61+
}
62+
63+
5064
/**
5165
* 获取订单详情
5266
*

weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpTagServiceImplTest.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import me.chanjar.weixin.cp.tp.service.WxCpTpTagService;
1010
import org.mockito.Mock;
1111
import org.mockito.MockitoAnnotations;
12+
import org.testng.annotations.AfterClass;
1213
import org.testng.annotations.BeforeClass;
1314
import org.testng.annotations.Test;
1415
import org.testng.collections.CollectionUtils;
@@ -36,17 +37,29 @@ public class WxCpTpTagServiceImplTest {
3637

3738
private WxCpTpTagService wxCpTpTagService;
3839

40+
private AutoCloseable mockitoAnnotations;
41+
3942
/**
4043
* Sets up.
4144
*/
4245
@BeforeClass
4346
public void setUp() {
44-
MockitoAnnotations.openMocks(this);
47+
mockitoAnnotations = MockitoAnnotations.openMocks(this);
4548
configStorage = new WxCpTpDefaultConfigImpl();
4649
when(wxCpTpService.getWxCpTpConfigStorage()).thenReturn(configStorage);
4750
wxCpTpTagService = new WxCpTpTagServiceImpl(wxCpTpService);
4851
}
4952

53+
/**
54+
* Tear down.
55+
*
56+
* @throws Exception the exception
57+
*/
58+
@AfterClass
59+
public void tearDown() throws Exception {
60+
mockitoAnnotations.close();
61+
}
62+
5063
/**
5164
* Test create.
5265
*

0 commit comments

Comments
 (0)