Skip to content

Commit

Permalink
Merge 5e809f2 into 8a77e34
Browse files Browse the repository at this point in the history
  • Loading branch information
lijasonvip committed Apr 8, 2018
2 parents 8a77e34 + 5e809f2 commit 03f1dc3
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
Expand Up @@ -24,7 +24,7 @@ public class HelloConsumer {
private final RestTemplate restTemplate = RestTemplateBuilder.create();

public void invokeHello(){
String result = restTemplate.getForObject("cse://business-service/hello", String.class);
restTemplate.getForObject("cse://business-service/hello", String.class);
}

}
Expand Up @@ -34,13 +34,11 @@ public CseAsyncRestTemplate() {
}

@Override
@SuppressWarnings("unchecked")
protected <T> AsyncRequestCallback httpEntityCallback(HttpEntity<T> requestBody) {
return new CseAsyncRequestCallback(requestBody);
}

@Override
@SuppressWarnings("unchecked")
protected <T> AsyncRequestCallback httpEntityCallback(HttpEntity<T> requestBody, Type responseType) {
return new CseAsyncRequestCallback(requestBody);
}
Expand Down
Expand Up @@ -61,8 +61,8 @@ public void teardown() {

@RequestMapping(path = "SpringmvcImpl")
static class SpringmvcImpl {
@RequestMapping(path = "/bytes", method = RequestMethod.POST)
public byte[] bytes(@RequestBody byte[] input) {
@RequestMapping(path = "/testbytes", method = RequestMethod.POST)
public byte[] testbytes(@RequestBody byte[] input) {
input[0] = (byte) (input[0] + 1);
return input;
}
Expand All @@ -89,17 +89,18 @@ public void testNormal() {
serviceRegistry.init();
RegistryUtils.setServiceRegistry(serviceRegistry);
UnitTestMeta meta = new UnitTestMeta();

CseContext.getInstance()
.getSchemaListenerManager()
.setSchemaListenerList(Arrays.asList(new RestEngineSchemaListener()));

SchemaMeta schemaMeta = meta.getOrCreateSchemaMeta(CseAsyncClientHttpRequestTest.SpringmvcImpl.class);
SchemaMeta schemaMeta = meta.getOrCreateSchemaMeta("app", "test","testNormal", CseAsyncClientHttpRequestTest.SpringmvcImpl.class);
CseContext.getInstance().getSchemaListenerManager().notifySchemaListener(schemaMeta);

Holder<Invocation> holder = new Holder<>();
CseAsyncClientHttpRequest client =
new CseAsyncClientHttpRequest(URI.create(
"cse://app:test/" + CseAsyncClientHttpRequestTest.SpringmvcImpl.class.getSimpleName() + "/bytes"),
"cse://app:test/" + CseAsyncClientHttpRequestTest.SpringmvcImpl.class.getSimpleName() + "/testbytes"),
HttpMethod.POST) {
@Override
protected CompletableFuture<ClientHttpResponse> doAsyncInvoke(Invocation invocation) {
Expand All @@ -125,15 +126,15 @@ public void testFail() {
.getSchemaListenerManager()
.setSchemaListenerList(Arrays.asList(new RestEngineSchemaListener()));

SchemaMeta schemaMeta = meta.getOrCreateSchemaMeta(CseAsyncClientHttpRequestTest.SpringmvcImpl.class);
SchemaMeta schemaMeta = meta.getOrCreateSchemaMeta("app", "test2","testFail", CseAsyncClientHttpRequestTest.SpringmvcImpl.class);
CseContext.getInstance().getSchemaListenerManager().notifySchemaListener(schemaMeta);

Throwable error = new Error("failed");
Response response = Response.createConsumerFail(error);

CseAsyncClientHttpRequest client =
new CseAsyncClientHttpRequest(URI.create(
"cse://app:test/" + CseAsyncClientHttpRequestTest.SpringmvcImpl.class.getSimpleName() + "/bytes"),
"cse://app:test2/" + CseAsyncClientHttpRequestTest.SpringmvcImpl.class.getSimpleName() + "/testbytes"),
HttpMethod.POST) {
@Override
protected CompletableFuture<ClientHttpResponse> doAsyncInvoke(Invocation invocation) {
Expand Down
Expand Up @@ -24,6 +24,7 @@

import mockit.Injectable;

@SuppressWarnings("unchecked")
public class CseAsyncRequestCallbackTest {
@Test
public void testNormal() {
Expand Down
Expand Up @@ -16,8 +16,6 @@
*/
package org.apache.servicecomb.samples.springmvc.consumer;

import java.lang.invoke.MethodHandles;

import org.apache.servicecomb.foundation.common.utils.BeanUtils;
import org.apache.servicecomb.foundation.common.utils.Log4jUtils;
import org.apache.servicecomb.provider.pojo.RpcReference;
Expand All @@ -37,7 +35,7 @@

@Component
public class SpringmvcConsumerMain {
private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private static final Logger LOG = LoggerFactory.getLogger(SpringmvcConsumerMain.class);
private static RestTemplate restTemplate = RestTemplateBuilder.create();

@RpcReference(microserviceName = "springmvc", schemaId = "springmvcHello")
Expand Down

0 comments on commit 03f1dc3

Please sign in to comment.