use of ee.ria.xroad.proxy.testsuite.TestSuiteGlobalConf in project X-Road by nordic-institute.
the class RestMetadataServiceHandlerTest method init.
/**
* Init data for tests
*/
@Before
public void init() {
GlobalConf.reload(new TestSuiteGlobalConf());
KeyConf.reload(new TestSuiteKeyConf());
ServerConf.reload(new TestSuiteServerConf() {
@Override
public DescriptionType getDescriptionType(ServiceId service) {
return DescriptionType.OPENAPI3;
}
@Override
public String getServiceDescriptionURL(ServiceId service) {
if (SUBSYSTEM_FOR_JSON_FILE.equals(service.getSubsystemCode())) {
return "http://localhost:9858/petstore.json";
} else if (SUBSYSTEM_FOR_UNSUPPORTED_YAML_FILE.equals(service.getSubsystemCode())) {
return "http://localhost:9858/openapi_incompatible_version.yaml";
} else {
return "http://localhost:9858/petstore.yaml";
}
}
});
httpClientMock = mock(HttpClient.class);
mockRequest = mock(HttpServletRequest.class);
mockResponse = mock(HttpServletResponse.class);
mockProxyMessage = mock(ProxyMessage.class);
mockServer = new WireMockServer(options().port(MOCK_SERVER_PORT));
mockServer.stubFor(WireMock.any(urlPathEqualTo("/petstore.json")).willReturn(aResponse().withBodyFile("petstore.json")));
mockServer.stubFor(WireMock.any(urlPathEqualTo("/petstore.yaml")).willReturn(aResponse().withBodyFile("petstore.yaml")));
mockServer.start();
}
use of ee.ria.xroad.proxy.testsuite.TestSuiteGlobalConf in project X-Road by nordic-institute.
the class GetListClientsMessage method startUp.
@Override
protected void startUp() throws Exception {
super.startUp();
GlobalConf.reload(new TestSuiteGlobalConf() {
@Override
public List<MemberInfo> getMembers(String... instanceIdentifier) {
String[] instances = instanceIdentifier;
assertThat("Wrong Xroad instance in query", instances, arrayContaining(EXPECTED_XR_INSTANCE));
return expectedMembers;
}
});
}
use of ee.ria.xroad.proxy.testsuite.TestSuiteGlobalConf in project X-Road by nordic-institute.
the class MetadataClientRequestProcessorTest method shouldProcessListClients.
@Test
public void shouldProcessListClients() throws Exception {
final List<MemberInfo> expectedMembers = Arrays.asList(createMember("producer", null), createMember("producer", "subsystem"), createMember("anothermemeber", null), createMember("anothermemeber", "somesub"), createMember("thirdmember", null));
GlobalConf.reload(new TestSuiteGlobalConf() {
@Override
public List<MemberInfo> getMembers(String... instanceIdentifier) {
String[] instances = instanceIdentifier;
assertThat("Wrong Xroad instance in query", instances, arrayContaining(EXPECTED_XR_INSTANCE));
return expectedMembers;
}
});
MetadataClientRequestProcessor processorToTest = new MetadataClientRequestProcessor(LIST_CLIENTS, mockRequest, mockResponse);
processorToTest.process();
assertContentTypeIsIn(xmlUtf8ContentTypes());
List<MemberInfo> members = unmarshaller.unmarshal(mockServletOutputStream.getResponseSource(), ClientListType.class).getValue().getMember().stream().map(clientType -> new MemberInfo(clientType.getId(), clientType.getName())).collect(Collectors.toList());
assertThat("Wrong amount of clients", members.size(), is(expectedMembers.size()));
assertThat("Wrong members", members, containsInAnyOrder(expectedMembers.toArray()));
}
use of ee.ria.xroad.proxy.testsuite.TestSuiteGlobalConf in project X-Road by nordic-institute.
the class MetadataHandlerTest method init.
/**
* Init common data for tests
*/
@Before
public void init() {
GlobalConf.reload(new TestSuiteGlobalConf());
KeyConf.reload(new TestSuiteKeyConf());
httpClientMock = mock(HttpClient.class);
mockRequest = mock(HttpServletRequest.class);
mockResponse = mock(HttpServletResponse.class);
}
use of ee.ria.xroad.proxy.testsuite.TestSuiteGlobalConf in project X-Road by nordic-institute.
the class ProxyMonitorServiceHandlerTest method init.
/**
* Init data for tests
*/
@Before
public void init() throws IOException {
GlobalConf.reload(new TestSuiteGlobalConf() {
@Override
public String getInstanceIdentifier() {
return EXPECTED_XR_INSTANCE;
}
});
KeyConf.reload(new TestSuiteKeyConf());
ServerConf.reload(new TestSuiteServerConf() {
@Override
public SecurityServerId getIdentifier() {
return DEFAULT_OWNER_SERVER;
}
});
mockRequest = mock(HttpServletRequest.class);
mockProxyMessage = mock(ProxyMessage.class);
when(mockProxyMessage.getSoapContentType()).thenReturn(MimeTypes.TEXT_XML_UTF8);
}
Aggregations