Skip to content

Commit

Permalink
fix legacy mock issue
Browse files Browse the repository at this point in the history
  • Loading branch information
nobodyiam committed Oct 4, 2018
1 parent 50f0e6e commit 2243da9
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.ctrip.framework.apollo.common.dto.AppDTO;
import com.ctrip.framework.apollo.common.entity.App;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -31,6 +32,8 @@ public class ControllerIntegrationExceptionTest extends AbstractControllerTest {
@Mock
AdminService adminService;

private Object realAdminService;

@Autowired
AppService appService;

Expand All @@ -39,9 +42,17 @@ public class ControllerIntegrationExceptionTest extends AbstractControllerTest {
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);

realAdminService = ReflectionTestUtils.getField(appController, "adminService");

ReflectionTestUtils.setField(appController, "adminService", adminService);
}

@After
public void tearDown() throws Exception {
ReflectionTestUtils.setField(appController, "adminService", realAdminService);
}

private String getBaseAppUrl() {
return "http://localhost:" + port + "/apps/";
}
Expand Down

0 comments on commit 2243da9

Please sign in to comment.