Search in sources :

Example 1 with UrlWithServiceNameClientHttpRequest

use of org.apache.servicecomb.provider.springmvc.reference.UrlWithServiceNameClientHttpRequestFactory.UrlWithServiceNameClientHttpRequest in project incubator-servicecomb-java-chassis by apache.

the class TestUrlWithServiceNameClientHttpRequestFactory method invoke_checkPath.

@Test
public void invoke_checkPath(@Mocked Invocation invocation, @Mocked RequestMeta requestMeta) {
    Map<String, String> handlerContext = new HashMap<>();
    UrlWithServiceNameClientHttpRequest request = new UrlWithServiceNameClientHttpRequest(uri, HttpMethod.GET) {

        @Override
        protected Response doInvoke(Invocation invocation) {
            return Response.ok(null);
        }
    };
    new Expectations(InvocationFactory.class) {

        {
            invocation.getHandlerContext();
            result = handlerContext;
            InvocationFactory.forConsumer((ReferenceConfig) any, (OperationMeta) any, (Object[]) any);
            result = invocation;
        }
    };
    Deencapsulation.setField(request, "requestMeta", requestMeta);
    Deencapsulation.setField(request, "path", request.findUriPath(uri));
    Deencapsulation.invoke(request, "invoke", new Object[] { new Object[] {} });
    Assert.assertEquals("/ms/v1/path?null", handlerContext.get(RestConst.REST_CLIENT_REQUEST_PATH));
}
Also used : Expectations(mockit.Expectations) Invocation(org.apache.servicecomb.core.Invocation) HashMap(java.util.HashMap) UrlWithServiceNameClientHttpRequest(org.apache.servicecomb.provider.springmvc.reference.UrlWithServiceNameClientHttpRequestFactory.UrlWithServiceNameClientHttpRequest) Test(org.junit.Test)

Example 2 with UrlWithServiceNameClientHttpRequest

use of org.apache.servicecomb.provider.springmvc.reference.UrlWithServiceNameClientHttpRequestFactory.UrlWithServiceNameClientHttpRequest in project incubator-servicecomb-java-chassis by apache.

the class TestUrlWithServiceNameClientHttpRequestFactory method findUriPath.

@Test
public void findUriPath() throws IOException {
    UrlWithServiceNameClientHttpRequest request = (UrlWithServiceNameClientHttpRequest) factory.createRequest(uri, HttpMethod.GET);
    Assert.assertEquals("/ms/v1/path", request.findUriPath(uri));
}
Also used : UrlWithServiceNameClientHttpRequest(org.apache.servicecomb.provider.springmvc.reference.UrlWithServiceNameClientHttpRequestFactory.UrlWithServiceNameClientHttpRequest) Test(org.junit.Test)

Aggregations

UrlWithServiceNameClientHttpRequest (org.apache.servicecomb.provider.springmvc.reference.UrlWithServiceNameClientHttpRequestFactory.UrlWithServiceNameClientHttpRequest)2 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 Expectations (mockit.Expectations)1 Invocation (org.apache.servicecomb.core.Invocation)1