use of ee.ria.xroad.common.identifier.CentralServiceId in project X-Road by nordic-institute.
the class SoapMessageTest method shouldParseBuiltMessage.
/**
* Tests that we can parse our own created Soap messages.
* @throws Exception in case of any unexpected errors
*/
@Test
public void shouldParseBuiltMessage() throws Exception {
ClientId client = ClientId.create("EE", "BUSINESS", "producer");
ServiceId service = ServiceId.create("EE", "BUSINESS", "consumer", null, "test");
CentralServiceId centralService = CentralServiceId.create("EE", "central");
String userId = "foobar";
String queryId = "barbaz";
SoapMessageImpl built = build(client, service, userId, queryId);
assertNotNull(built);
assertEquals(userId, built.getUserId());
assertEquals(queryId, built.getQueryId());
assertEquals(client, built.getClient());
assertEquals(service, built.getService());
Soap parsedSoap = new SaxSoapParserImpl().parse(built.getContentType(), new ByteArrayInputStream(built.getBytes()));
assertTrue(parsedSoap instanceof SoapMessageImpl);
SoapMessageImpl parsed = (SoapMessageImpl) parsedSoap;
assertNotNull(parsed);
SoapUtils.checkConsistency(built, parsed);
assertEquals(built.isRequest(), parsed.isRequest());
// Central Service ----------------------------------------------------
built = build(client, centralService, userId, queryId);
assertNotNull(built);
assertEquals(userId, built.getUserId());
assertEquals(queryId, built.getQueryId());
assertEquals(client, built.getClient());
assertEquals(centralService, built.getCentralService());
parsedSoap = new SaxSoapParserImpl().parse(built.getContentType(), IOUtils.toInputStream(built.getXml()));
assertTrue(parsedSoap instanceof SoapMessageImpl);
parsed = (SoapMessageImpl) parsedSoap;
assertNotNull(parsed);
SoapUtils.checkConsistency(built, parsed);
assertEquals(built.isRequest(), parsed.isRequest());
}
use of ee.ria.xroad.common.identifier.CentralServiceId in project X-Road by nordic-institute.
the class GlobalConfTest method getServiceId.
/**
* Tests getting the actual service identifier for a given identifier.
*
* @throws Exception if an error occurs
*/
@Test
public void getServiceId() {
CentralServiceId central1 = CentralServiceId.create("EE", "central1");
ServiceId expectedServiceId = ServiceId.create("EE", "BUSINESS", "foobar", null, "bazservice");
ServiceId actualServiceId = GlobalConf.getServiceId(central1);
assertNotNull(actualServiceId);
assertEquals(expectedServiceId, actualServiceId);
actualServiceId = GlobalConf.getServiceId(expectedServiceId);
assertEquals(expectedServiceId, actualServiceId);
thrown.expectError(ErrorCodes.X_INTERNAL_ERROR);
GlobalConf.getServiceId(CentralServiceId.create("XX", "yy"));
}
use of ee.ria.xroad.common.identifier.CentralServiceId in project X-Road by nordic-institute.
the class MetadataClientRequestProcessorTest method shouldProcessListCentralServices.
@Test
public void shouldProcessListCentralServices() throws Exception {
final List<CentralServiceId> expectedCentraServices = Arrays.asList(create(EXPECTED_XR_INSTANCE, "getInfo"), create(EXPECTED_XR_INSTANCE, "someService"), create(EXPECTED_XR_INSTANCE, "getRandom"));
GlobalConf.reload(new TestSuiteGlobalConf() {
@Override
public List<CentralServiceId> getCentralServices(String instanceIdentifier) {
assertThat("Wrong Xroad instance in query", instanceIdentifier, is(EXPECTED_XR_INSTANCE));
return expectedCentraServices;
}
});
MetadataClientRequestProcessor processorToTest = new MetadataClientRequestProcessor(LIST_CENTRAL_SERVICES, mockRequest, mockResponse);
processorToTest.process();
assertContentTypeIsIn(xmlUtf8ContentTypes());
List<CentralServiceId> resultCentralServices = unmarshaller.unmarshal(mockServletOutputStream.getResponseSource(), CentralServiceListType.class).getValue().getCentralService();
assertThat("Wrong amount of services", resultCentralServices.size(), is(expectedCentraServices.size()));
assertThat("Wrong services", resultCentralServices, containsInAnyOrder(expectedCentraServices.toArray()));
}
use of ee.ria.xroad.common.identifier.CentralServiceId in project X-Road by nordic-institute.
the class SoapMessageTest method centralServiceMessage.
/**
* Test that central service query is parsed correctly.
* @throws Exception in case of any unexpected errors
*/
@Test
public void centralServiceMessage() throws Exception {
SoapMessageImpl message = createRequest("simple-centralservice.query");
ClientId expectedClient = ClientId.create("EE", "BUSINESS", "consumer");
CentralServiceId expectedService = CentralServiceId.create("EE", "centralservice");
assertTrue(message.isRequest());
assertEquals(expectedClient, message.getClient());
assertEquals(expectedService, message.getCentralService());
assertEquals("EE37702211234", message.getUserId());
assertEquals("1234567890", message.getQueryId());
}
Aggregations