Commit 2243da9f authored by nobodyiam's avatar nobodyiam

fix legacy mock issue

parent 50f0e6eb
...@@ -7,6 +7,7 @@ import com.ctrip.framework.apollo.biz.service.AppService; ...@@ -7,6 +7,7 @@ import com.ctrip.framework.apollo.biz.service.AppService;
import com.ctrip.framework.apollo.common.dto.AppDTO; import com.ctrip.framework.apollo.common.dto.AppDTO;
import com.ctrip.framework.apollo.common.entity.App; import com.ctrip.framework.apollo.common.entity.App;
import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
...@@ -31,6 +32,8 @@ public class ControllerIntegrationExceptionTest extends AbstractControllerTest { ...@@ -31,6 +32,8 @@ public class ControllerIntegrationExceptionTest extends AbstractControllerTest {
@Mock @Mock
AdminService adminService; AdminService adminService;
private Object realAdminService;
@Autowired @Autowired
AppService appService; AppService appService;
...@@ -39,9 +42,17 @@ public class ControllerIntegrationExceptionTest extends AbstractControllerTest { ...@@ -39,9 +42,17 @@ public class ControllerIntegrationExceptionTest extends AbstractControllerTest {
@Before @Before
public void setUp() { public void setUp() {
MockitoAnnotations.initMocks(this); MockitoAnnotations.initMocks(this);
realAdminService = ReflectionTestUtils.getField(appController, "adminService");
ReflectionTestUtils.setField(appController, "adminService", adminService); ReflectionTestUtils.setField(appController, "adminService", adminService);
} }
@After
public void tearDown() throws Exception {
ReflectionTestUtils.setField(appController, "adminService", realAdminService);
}
private String getBaseAppUrl() { private String getBaseAppUrl() {
return "http://localhost:" + port + "/apps/"; return "http://localhost:" + port + "/apps/";
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment