Search in sources :

Example 36 with RestOperationMeta

use of org.apache.servicecomb.common.rest.definition.RestOperationMeta in project incubator-servicecomb-java-chassis by apache.

the class TestMicroservicePaths method testAddResourceDynamic.

@Test
public void testAddResourceDynamic() {
    RestOperationMeta dynamicRes = UnitTestRestUtils.createRestOperationMeta("POST", "/dynamic/{id}");
    MicroservicePaths paths = new MicroservicePaths();
    paths.addResource(dynamicRes);
    Assert.assertSame(dynamicRes, paths.getDynamicPathOperationList().get(0));
}
Also used : RestOperationMeta(org.apache.servicecomb.common.rest.definition.RestOperationMeta) Test(org.junit.Test)

Example 37 with RestOperationMeta

use of org.apache.servicecomb.common.rest.definition.RestOperationMeta in project incubator-servicecomb-java-chassis by apache.

the class TestMicroservicePaths method testAddResourceStaticDuplicatedHttpMethod.

@Test
public void testAddResourceStaticDuplicatedHttpMethod() {
    RestOperationMeta staticResPost = UnitTestRestUtils.createRestOperationMeta("POST", "/static");
    MicroservicePaths paths = new MicroservicePaths();
    paths.addResource(staticResPost);
    try {
        paths.addResource(staticResPost);
        Assert.fail("must throw exception");
    } catch (ServiceCombException e) {
        Assert.assertEquals("operation with url /static, method POST is duplicated.", e.getMessage());
    }
}
Also used : RestOperationMeta(org.apache.servicecomb.common.rest.definition.RestOperationMeta) ServiceCombException(org.apache.servicecomb.foundation.common.exceptions.ServiceCombException) Test(org.junit.Test)

Example 38 with RestOperationMeta

use of org.apache.servicecomb.common.rest.definition.RestOperationMeta in project incubator-servicecomb-java-chassis by apache.

the class TestMicroservicePaths method testSortPath.

@Test
public void testSortPath() {
    // only test base rule
    // completely rule test by TestRestOperationComparator
    RestOperationMeta dynamicResLessStatic = UnitTestRestUtils.createRestOperationMeta("POST", "/a/{id}");
    RestOperationMeta dynamicResMoreStatic = UnitTestRestUtils.createRestOperationMeta("POST", "/abc/{id}");
    MicroservicePaths paths = new MicroservicePaths();
    paths.addResource(dynamicResLessStatic);
    paths.addResource(dynamicResMoreStatic);
    paths.sortPath();
    Assert.assertSame(dynamicResMoreStatic, paths.getDynamicPathOperationList().get(0));
    Assert.assertSame(dynamicResLessStatic, paths.getDynamicPathOperationList().get(1));
}
Also used : RestOperationMeta(org.apache.servicecomb.common.rest.definition.RestOperationMeta) Test(org.junit.Test)

Example 39 with RestOperationMeta

use of org.apache.servicecomb.common.rest.definition.RestOperationMeta in project incubator-servicecomb-java-chassis by apache.

the class TestMicroservicePaths method testAddResourceStaticAddToGroup.

@Test
public void testAddResourceStaticAddToGroup() {
    RestOperationMeta staticResPost = UnitTestRestUtils.createRestOperationMeta("POST", "/static");
    RestOperationMeta staticResGet = UnitTestRestUtils.createRestOperationMeta("GET", "/static");
    MicroservicePaths paths = new MicroservicePaths();
    paths.addResource(staticResPost);
    paths.addResource(staticResGet);
    Assert.assertSame(staticResPost, paths.getStaticPathOperationMap().get("/static").findValue("POST"));
    Assert.assertSame(staticResGet, paths.getStaticPathOperationMap().get("/static").findValue("GET"));
}
Also used : RestOperationMeta(org.apache.servicecomb.common.rest.definition.RestOperationMeta) Test(org.junit.Test)

Example 40 with RestOperationMeta

use of org.apache.servicecomb.common.rest.definition.RestOperationMeta in project incubator-servicecomb-java-chassis by apache.

the class TestOperationLocator method testLocateDynamicFound.

@Test
public void testLocateDynamicFound() {
    RestOperationMeta rom = addRestOperationMeta("GET", "/dynamic/{id}");
    locator.locate("ms", "/dynamic/1/", "GET", paths);
    Assert.assertSame(rom, locator.getOperation());
    Assert.assertEquals("1", locator.getPathVarMap().get("id"));
}
Also used : RestOperationMeta(org.apache.servicecomb.common.rest.definition.RestOperationMeta) Test(org.junit.Test)

Aggregations

RestOperationMeta (org.apache.servicecomb.common.rest.definition.RestOperationMeta)55 OperationMeta (org.apache.servicecomb.core.definition.OperationMeta)24 Test (org.junit.Test)20 InvocationException (org.apache.servicecomb.swagger.invocation.exception.InvocationException)10 Response (org.apache.servicecomb.swagger.invocation.Response)9 CommonExceptionData (org.apache.servicecomb.swagger.invocation.exception.CommonExceptionData)9 InvocationStageTrace (org.apache.servicecomb.core.invocation.InvocationStageTrace)8 HttpClientWithContext (org.apache.servicecomb.foundation.vertx.client.http.HttpClientWithContext)7 Invocation (org.apache.servicecomb.core.Invocation)6 URIEndpointObject (org.apache.servicecomb.foundation.common.net.URIEndpointObject)6 HttpServletResponseEx (org.apache.servicecomb.foundation.vertx.http.HttpServletResponseEx)6 HttpClientRequest (io.vertx.core.http.HttpClientRequest)5 HttpMethod (io.vertx.core.http.HttpMethod)5 HashMap (java.util.HashMap)5 RestClientRequestImpl (org.apache.servicecomb.common.rest.codec.param.RestClientRequestImpl)5 ProduceProcessor (org.apache.servicecomb.common.rest.codec.produce.ProduceProcessor)5 HttpServletRequestEx (org.apache.servicecomb.foundation.vertx.http.HttpServletRequestEx)5 AsyncResponse (org.apache.servicecomb.swagger.invocation.AsyncResponse)5 HttpClientResponse (io.vertx.core.http.HttpClientResponse)4 RequestOptions (io.vertx.core.http.RequestOptions)4