Search in sources :

Example 1 with TestSuiteKeyConf

use of ee.ria.xroad.proxy.testsuite.TestSuiteKeyConf 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();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ProxyMessage(ee.ria.xroad.proxy.protocol.ProxyMessage) TestSuiteGlobalConf(ee.ria.xroad.proxy.testsuite.TestSuiteGlobalConf) DescriptionType(ee.ria.xroad.common.conf.serverconf.model.DescriptionType) TestSuiteKeyConf(ee.ria.xroad.proxy.testsuite.TestSuiteKeyConf) TestSuiteServerConf(ee.ria.xroad.proxy.testsuite.TestSuiteServerConf) HttpClient(org.apache.http.client.HttpClient) HttpServletResponse(javax.servlet.http.HttpServletResponse) WireMockServer(com.github.tomakehurst.wiremock.WireMockServer) ServiceId(ee.ria.xroad.common.identifier.ServiceId) Before(org.junit.Before)

Example 2 with TestSuiteKeyConf

use of ee.ria.xroad.proxy.testsuite.TestSuiteKeyConf 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);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) TestSuiteGlobalConf(ee.ria.xroad.proxy.testsuite.TestSuiteGlobalConf) TestSuiteKeyConf(ee.ria.xroad.proxy.testsuite.TestSuiteKeyConf) HttpClient(org.apache.http.client.HttpClient) HttpServletResponse(javax.servlet.http.HttpServletResponse) Before(org.junit.Before)

Example 3 with TestSuiteKeyConf

use of ee.ria.xroad.proxy.testsuite.TestSuiteKeyConf 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);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ProxyMessage(ee.ria.xroad.proxy.protocol.ProxyMessage) TestSuiteGlobalConf(ee.ria.xroad.proxy.testsuite.TestSuiteGlobalConf) TestSuiteKeyConf(ee.ria.xroad.proxy.testsuite.TestSuiteKeyConf) TestSuiteServerConf(ee.ria.xroad.proxy.testsuite.TestSuiteServerConf) SecurityServerId(ee.ria.xroad.common.identifier.SecurityServerId) Matchers.containsString(org.hamcrest.Matchers.containsString) Before(org.junit.Before)

Example 4 with TestSuiteKeyConf

use of ee.ria.xroad.proxy.testsuite.TestSuiteKeyConf in project X-Road by nordic-institute.

the class MetadataServiceHandlerTest method init.

/**
 * Init data for tests
 */
@Before
public void init() throws IOException {
    GlobalConf.reload(new TestSuiteGlobalConf());
    KeyConf.reload(new TestSuiteKeyConf());
    ServerConf.reload(new TestSuiteServerConf());
    httpClientMock = mock(HttpClient.class);
    mockRequest = mock(HttpServletRequest.class);
    mockResponse = mock(HttpServletResponse.class);
    mockServletOutputStream = new MetaserviceTestUtil.StubServletOutputStream();
    when(mockResponse.getOutputStream()).thenReturn(mockServletOutputStream);
    mockProxyMessage = mock(ProxyMessage.class);
    when(mockProxyMessage.getSoapContentType()).thenReturn(MimeTypes.TEXT_XML_UTF8);
    this.mockServer = new WireMockServer(options().port(WSDL_SERVER_PORT));
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ProxyMessage(ee.ria.xroad.proxy.protocol.ProxyMessage) TestSuiteGlobalConf(ee.ria.xroad.proxy.testsuite.TestSuiteGlobalConf) TestSuiteKeyConf(ee.ria.xroad.proxy.testsuite.TestSuiteKeyConf) TestSuiteServerConf(ee.ria.xroad.proxy.testsuite.TestSuiteServerConf) HttpClient(org.apache.http.client.HttpClient) HttpServletResponse(javax.servlet.http.HttpServletResponse) WireMockServer(com.github.tomakehurst.wiremock.WireMockServer) MetaserviceTestUtil(ee.ria.xroad.proxy.util.MetaserviceTestUtil) Before(org.junit.Before)

Example 5 with TestSuiteKeyConf

use of ee.ria.xroad.proxy.testsuite.TestSuiteKeyConf in project X-Road by nordic-institute.

the class ProxyMonitorServiceHandlerMetricsTest 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);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ProxyMessage(ee.ria.xroad.proxy.protocol.ProxyMessage) TestSuiteGlobalConf(ee.ria.xroad.proxy.testsuite.TestSuiteGlobalConf) TestSuiteKeyConf(ee.ria.xroad.proxy.testsuite.TestSuiteKeyConf) TestSuiteServerConf(ee.ria.xroad.proxy.testsuite.TestSuiteServerConf) SecurityServerId(ee.ria.xroad.common.identifier.SecurityServerId) Before(org.junit.Before)

Aggregations

TestSuiteGlobalConf (ee.ria.xroad.proxy.testsuite.TestSuiteGlobalConf)7 TestSuiteKeyConf (ee.ria.xroad.proxy.testsuite.TestSuiteKeyConf)7 HttpServletRequest (javax.servlet.http.HttpServletRequest)6 Before (org.junit.Before)6 TestSuiteServerConf (ee.ria.xroad.proxy.testsuite.TestSuiteServerConf)5 ProxyMessage (ee.ria.xroad.proxy.protocol.ProxyMessage)4 HttpServletResponse (javax.servlet.http.HttpServletResponse)4 SecurityServerId (ee.ria.xroad.common.identifier.SecurityServerId)3 HttpClient (org.apache.http.client.HttpClient)3 WireMockServer (com.github.tomakehurst.wiremock.WireMockServer)2 MetaserviceTestUtil (ee.ria.xroad.proxy.util.MetaserviceTestUtil)2 DescriptionType (ee.ria.xroad.common.conf.serverconf.model.DescriptionType)1 ServiceId (ee.ria.xroad.common.identifier.ServiceId)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1