Search in sources :

Example 1 with CentralServiceId

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());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ClientId(ee.ria.xroad.common.identifier.ClientId) CentralServiceId(ee.ria.xroad.common.identifier.CentralServiceId) CentralServiceId(ee.ria.xroad.common.identifier.CentralServiceId) ServiceId(ee.ria.xroad.common.identifier.ServiceId) Test(org.junit.Test)

Example 2 with CentralServiceId

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"));
}
Also used : CentralServiceId(ee.ria.xroad.common.identifier.CentralServiceId) CentralServiceId(ee.ria.xroad.common.identifier.CentralServiceId) ServiceId(ee.ria.xroad.common.identifier.ServiceId) Test(org.junit.Test)

Example 3 with CentralServiceId

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()));
}
Also used : TestSuiteGlobalConf(ee.ria.xroad.proxy.testsuite.TestSuiteGlobalConf) List(java.util.List) CentralServiceId(ee.ria.xroad.common.identifier.CentralServiceId) Test(org.junit.Test)

Example 4 with CentralServiceId

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());
}
Also used : ClientId(ee.ria.xroad.common.identifier.ClientId) CentralServiceId(ee.ria.xroad.common.identifier.CentralServiceId) Test(org.junit.Test)

Aggregations

CentralServiceId (ee.ria.xroad.common.identifier.CentralServiceId)4 Test (org.junit.Test)4 ClientId (ee.ria.xroad.common.identifier.ClientId)2 ServiceId (ee.ria.xroad.common.identifier.ServiceId)2 TestSuiteGlobalConf (ee.ria.xroad.proxy.testsuite.TestSuiteGlobalConf)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 List (java.util.List)1