Skip to content

Commit

Permalink
JAV-592 add demo for producer return CompletableFuture
Browse files Browse the repository at this point in the history
  • Loading branch information
wujimin authored and liubao68 committed Dec 27, 2017
1 parent acb84cf commit 4ab3571
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,11 @@ protected void testCodeFirstIsTrue(CodeFirstPojoIntf codeFirst) {
}

protected void testCodeFirstSayHi2(CodeFirstPojoIntf codeFirst) {
String result = codeFirst.sayHi2("world");
if (!CodeFirstPojoClientIntf.class.isInstance(codeFirst)) {
return;
}

String result = ((CodeFirstPojoClientIntf) codeFirst).sayHi2("world");
TestMgr.check("world sayhi 2", result);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@
public interface CodeFirstPojoClientIntf extends CodeFirstPojoIntf {
@ApiOperation(nickname = "sayHi", value = "")
CompletableFuture<String> sayHiAsync(String name);

String sayHi2(String name);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;

import io.servicecomb.demo.CodeFirstPojoIntf;
import io.servicecomb.demo.compute.Person;
import io.servicecomb.demo.server.User;
import io.servicecomb.provider.pojo.RpcSchema;
import io.servicecomb.swagger.invocation.context.ContextUtils;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.SwaggerDefinition;

@RpcSchema()
Expand Down Expand Up @@ -85,8 +87,11 @@ public String sayHi(String name) {
return name + " sayhi";
}

public String sayHi2(String name) {
return name + " sayhi 2";
@ApiOperation(nickname = "sayHi2", value = "")
public CompletableFuture<String> sayHi2Async(String name) {
CompletableFuture<String> future = new CompletableFuture<>();
future.complete(name + " sayhi 2");
return future;
}

public boolean isTrue() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ public interface CodeFirstPojoIntf {

String sayHi(String name);

String sayHi2(String name);

boolean isTrue();

String addString(List<String> s);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,6 @@ public void remoteCodeFirstPojo_sayHi() {
assertThat(result, is("world sayhi"));
}

@Test
public void remoteCodeFirstPojo_sayHi2() {
String result = PojoService.codeFirst.sayHi2("world");
assertThat(result, is("world sayhi 2"));
}

@Test
public void remoteCodeFirstPojo_isTrue() {
boolean result = PojoService.codeFirst.isTrue();
Expand Down

0 comments on commit 4ab3571

Please sign in to comment.