-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
373 additions
and
640 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,6 @@ | |
* Created by ken.lj on 2017/9/24. | ||
*/ | ||
public interface AsyncService { | ||
|
||
String asyncMethod(); | ||
} |
10 changes: 0 additions & 10 deletions
10
api/src/main/java/com/alibaba/dubbo/test/service/chain/CatService.java
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
api/src/main/java/com/alibaba/dubbo/test/service/chain/DogService.java
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
api/src/main/java/com/alibaba/dubbo/test/service/chain/LionService.java
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
api/src/main/java/com/alibaba/dubbo/test/service/chain/MouseService.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
consumer-test/src/main/java/com/alibaba/dubbo/test/DubboServiceTestRunner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package com.alibaba.dubbo.test; | ||
|
||
import com.alibaba.dubbo.common.logger.Logger; | ||
import com.alibaba.dubbo.common.logger.LoggerFactory; | ||
import com.alibaba.dubbo.config.annotation.Reference; | ||
import com.alibaba.dubbo.rpc.service.GenericService; | ||
import com.alibaba.dubbo.test.service.AnnotateService; | ||
import com.alibaba.dubbo.test.service.AsyncService; | ||
import com.alibaba.dubbo.test.service.DemoService; | ||
|
||
import org.springframework.beans.BeansException; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.context.ApplicationContextAware; | ||
import org.springframework.stereotype.Service; | ||
|
||
import javax.annotation.PostConstruct; | ||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
/** | ||
* 自动执行一遍所有服务调用 | ||
* | ||
* @author ken.lj | ||
* @date 2017/11/3 | ||
*/ | ||
@Service | ||
public class DubboServiceTestRunner implements ApplicationContextAware { | ||
Logger logger = LoggerFactory.getLogger(DubboServiceTestRunner.class); | ||
private ApplicationContext context; | ||
|
||
@Autowired | ||
private DemoService demoService; | ||
|
||
@Autowired | ||
private AsyncService asyncService; | ||
|
||
@Reference | ||
private AnnotateService annotateService; | ||
|
||
@PostConstruct | ||
public void start() { | ||
logger.info("****** start testcase! ******"); | ||
try { | ||
runSimple(); | ||
runAync(); | ||
runAnnotate(); | ||
runGeneric(); | ||
} catch (Throwable t) { | ||
logger.error("有测试用例报错,请检查!", t); | ||
} | ||
} | ||
|
||
public void runSimple() { | ||
demoService.testString("string param"); | ||
} | ||
|
||
public void runAync() { | ||
asyncService.asyncMethod(); | ||
} | ||
|
||
public void runAnnotate() { | ||
annotateService.sayHello(); | ||
} | ||
|
||
public void runGeneric() { | ||
GenericService genericService = (GenericService) context.getBean("genericTestService"); | ||
Map<String, Set<String>> map = new HashMap<String, Set<String>>(); | ||
Set<String> set = new HashSet<String>(); | ||
set.add("v1"); | ||
set.add("v2"); | ||
map.put("key", set); | ||
Object result = genericService.$invoke("testGenericWithJsonSerialization", new String[]{"java.util.Map"}, new Object[]{map}); | ||
} | ||
|
||
@Override | ||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { | ||
this.context = applicationContext; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...er-test/src/main/java/com/alibaba/dubbo/test/web/AnnotationParentReferenceController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.alibaba.dubbo.test.web; | ||
|
||
import com.alibaba.dubbo.config.annotation.Reference; | ||
import com.alibaba.dubbo.test.service.AnnotateService; | ||
|
||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
/** | ||
* @author ken.lj | ||
* @date 2017/09/10 | ||
*/ | ||
@RestController("annotation") | ||
public class AnnotationParentReferenceController extends BaseController<AnnotateService> { | ||
|
||
@Reference | ||
public AnnotateService annotateServiceSub; | ||
|
||
@RequestMapping("/subclass") | ||
String subHello() { | ||
return annotateServiceSub.sayHello(); | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
consumer-test/src/main/java/com/alibaba/dubbo/test/web/AsyncController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.alibaba.dubbo.test.web; | ||
|
||
import com.alibaba.dubbo.rpc.RpcContext; | ||
import com.alibaba.dubbo.test.service.AsyncService; | ||
|
||
import org.junit.Assert; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.concurrent.Future; | ||
|
||
/** | ||
* @author ken.lj | ||
* @date 2017/11/3 | ||
*/ | ||
@RestController | ||
@RequestMapping("/async") | ||
public class AsyncController { | ||
@Autowired(required = false) | ||
private AsyncService asyncService; | ||
|
||
@RequestMapping("/hello") | ||
public String testSimple() throws Exception { | ||
String result = asyncService.asyncMethod(); | ||
Assert.assertNull(result); | ||
Future<String> future = RpcContext.getContext().getFuture(); | ||
|
||
return future.get(); | ||
} | ||
} |
5 changes: 4 additions & 1 deletion
5
consumer-test/src/main/java/com/alibaba/dubbo/test/web/BaseController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
consumer-test/src/main/java/com/alibaba/dubbo/test/web/GenericReferenceController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.alibaba.dubbo.test.web; | ||
|
||
import com.alibaba.dubbo.rpc.service.GenericService; | ||
|
||
import org.springframework.beans.BeansException; | ||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.context.ApplicationContextAware; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
/** | ||
* @author ken.lj | ||
* @date 2017/11/3 | ||
*/ | ||
@RestController | ||
@RequestMapping("/simple") | ||
public class GenericReferenceController implements ApplicationContextAware { | ||
|
||
private ApplicationContext context; | ||
|
||
@RequestMapping("/reference/generic") | ||
public String testReferenceGeneric() { | ||
GenericService genericService = (GenericService) context.getBean("genericTestService"); | ||
Map<String, Set<String>> map = new HashMap<String, Set<String>>(); | ||
Set<String> set = new HashSet<String>(); | ||
set.add("v1"); | ||
set.add("v2"); | ||
map.put("key", set); | ||
Object result = genericService.$invoke("testGenericWithJsonSerialization", new String[]{"java.util.Map"}, new Object[]{map}); | ||
return "generic"; | ||
} | ||
|
||
@Override | ||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { | ||
this.context = applicationContext; | ||
} | ||
} |
15 changes: 0 additions & 15 deletions
15
consumer-test/src/main/java/com/alibaba/dubbo/test/web/HelloController.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.