Skip to content

Commit 2243da9

Browse files
committed
fix legacy mock issue
1 parent 50f0e6e commit 2243da9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/ControllerIntegrationExceptionTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.ctrip.framework.apollo.common.dto.AppDTO;
88
import com.ctrip.framework.apollo.common.entity.App;
99

10+
import org.junit.After;
1011
import org.junit.Assert;
1112
import org.junit.Before;
1213
import org.junit.Test;
@@ -31,6 +32,8 @@ public class ControllerIntegrationExceptionTest extends AbstractControllerTest {
3132
@Mock
3233
AdminService adminService;
3334

35+
private Object realAdminService;
36+
3437
@Autowired
3538
AppService appService;
3639

@@ -39,9 +42,17 @@ public class ControllerIntegrationExceptionTest extends AbstractControllerTest {
3942
@Before
4043
public void setUp() {
4144
MockitoAnnotations.initMocks(this);
45+
46+
realAdminService = ReflectionTestUtils.getField(appController, "adminService");
47+
4248
ReflectionTestUtils.setField(appController, "adminService", adminService);
4349
}
4450

51+
@After
52+
public void tearDown() throws Exception {
53+
ReflectionTestUtils.setField(appController, "adminService", realAdminService);
54+
}
55+
4556
private String getBaseAppUrl() {
4657
return "http://localhost:" + port + "/apps/";
4758
}

0 commit comments

Comments
 (0)