use of com.ctrip.framework.apollo.core.dto.ServiceDTO in project apollo by ctripcorp.
the class BaseIntegrationTest method mockMetaServerHandler.
protected ContextHandler mockMetaServerHandler(final boolean failedAtFirstTime) {
final ServiceDTO someServiceDTO = new ServiceDTO();
someServiceDTO.setAppName(someAppName);
someServiceDTO.setInstanceId(someInstanceId);
someServiceDTO.setHomepageUrl(configServiceURL);
final AtomicInteger counter = new AtomicInteger(0);
ContextHandler context = new ContextHandler("/services/config");
context.setHandler(new AbstractHandler() {
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
if (failedAtFirstTime && counter.incrementAndGet() == 1) {
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
baseRequest.setHandled(true);
return;
}
response.setContentType("application/json;charset=UTF-8");
response.setStatus(HttpServletResponse.SC_OK);
response.getWriter().println(gson.toJson(Lists.newArrayList(someServiceDTO)));
baseRequest.setHandled(true);
}
});
return context;
}
use of com.ctrip.framework.apollo.core.dto.ServiceDTO in project apollo by ctripcorp.
the class RemoteConfigLongPollServiceTest method setUp.
@Before
public void setUp() throws Exception {
MockInjector.setInstance(HttpClient.class, httpClient);
someServerUrl = "http://someServer";
ServiceDTO serviceDTO = mock(ServiceDTO.class);
when(serviceDTO.getHomepageUrl()).thenReturn(someServerUrl);
when(configServiceLocator.getConfigServices()).thenReturn(Lists.newArrayList(serviceDTO));
MockInjector.setInstance(ConfigServiceLocator.class, configServiceLocator);
MockInjector.setInstance(ConfigUtil.class, new MockConfigUtil());
remoteConfigLongPollService = new RemoteConfigLongPollService();
responseType = (Type) ReflectionTestUtils.getField(remoteConfigLongPollService, "m_responseType");
someAppId = "someAppId";
someCluster = "someCluster";
}
Aggregations