Search in sources :

Example 21 with RestOperationMeta

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

the class TestMicroservicePaths method testPrintPaths.

@Test
public void testPrintPaths() {
    RestOperationMeta staticRes = UnitTestRestUtils.createRestOperationMeta("POST", "/static");
    RestOperationMeta dynamicRes = UnitTestRestUtils.createRestOperationMeta("POST", "/dynamic/{id}");
    MicroservicePaths paths = new MicroservicePaths();
    paths.addResource(staticRes);
    paths.addResource(dynamicRes);
    WriterAppender appender = new WriterAppender();
    Writer writer = new StringWriter();
    appender.setWriter(writer);
    appender.setLayout(new SimpleLayout());
    Logger.getRootLogger().addAppender(appender);
    paths.printPaths();
    String[] lines = writer.toString().split("\n");
    Assert.assertEquals("INFO - Swagger mapped \"{[/static], method=[POST], produces=[application/json]}\" onto null", lines[0].trim());
    Assert.assertEquals("INFO - Swagger mapped \"{[/dynamic/{id}], method=[POST], produces=[application/json]}\" onto null", lines[1].trim());
    Logger.getRootLogger().removeAppender(appender);
}
Also used : SimpleLayout(org.apache.log4j.SimpleLayout) StringWriter(java.io.StringWriter) RestOperationMeta(org.apache.servicecomb.common.rest.definition.RestOperationMeta) WriterAppender(org.apache.log4j.WriterAppender) StringWriter(java.io.StringWriter) Writer(java.io.Writer) Test(org.junit.Test)

Example 22 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)

Example 23 with RestOperationMeta

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

the class ServerRestArgsFilter method afterReceiveRequest.

@Override
public Response afterReceiveRequest(Invocation invocation, HttpServletRequestEx requestEx) {
    OperationMeta operationMeta = invocation.getOperationMeta();
    RestOperationMeta restOperationMeta = operationMeta.getExtData(RestConst.SWAGGER_REST_OPERATION);
    Object[] args = RestCodec.restToArgs(requestEx, restOperationMeta);
    invocation.setSwaggerArguments(args);
    return null;
}
Also used : RestOperationMeta(org.apache.servicecomb.common.rest.definition.RestOperationMeta) OperationMeta(org.apache.servicecomb.core.definition.OperationMeta) RestOperationMeta(org.apache.servicecomb.common.rest.definition.RestOperationMeta)

Example 24 with RestOperationMeta

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

the class TestRequestMeta method testGetSwaggerRestOperation.

@Test
public void testGetSwaggerRestOperation() {
    RestOperationMeta value = requestmeta.getSwaggerRestOperation();
    Assert.assertNotNull(value);
}
Also used : RestOperationMeta(org.apache.servicecomb.common.rest.definition.RestOperationMeta) Test(org.junit.Test)

Aggregations

RestOperationMeta (org.apache.servicecomb.common.rest.definition.RestOperationMeta)24 Test (org.junit.Test)14 OperationMeta (org.apache.servicecomb.core.definition.OperationMeta)11 Endpoint (org.apache.servicecomb.core.Endpoint)4 Invocation (org.apache.servicecomb.core.Invocation)4 HttpClientRequest (io.vertx.core.http.HttpClientRequest)3 ProduceProcessor (org.apache.servicecomb.common.rest.codec.produce.ProduceProcessor)3 URLPathBuilder (org.apache.servicecomb.common.rest.definition.path.URLPathBuilder)3 AsyncResponse (org.apache.servicecomb.swagger.invocation.AsyncResponse)3 HttpClientResponse (io.vertx.core.http.HttpClientResponse)2 RestClientRequestImpl (org.apache.servicecomb.common.rest.codec.param.RestClientRequestImpl)2 IpPort (org.apache.servicecomb.foundation.common.net.IpPort)2 URIEndpointObject (org.apache.servicecomb.foundation.common.net.URIEndpointObject)2 Context (io.vertx.core.Context)1 Buffer (io.vertx.core.buffer.Buffer)1 HttpClient (io.vertx.core.http.HttpClient)1 HttpMethod (io.vertx.core.http.HttpMethod)1 StringWriter (java.io.StringWriter)1 Writer (java.io.Writer)1 ArrayList (java.util.ArrayList)1