Skip to content

Commit

Permalink
Polish apache#4265 : Add test dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
mercyblitz committed Jun 7, 2019
1 parent 7c0eb3d commit 3ac778c
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 3 deletions.
36 changes: 36 additions & 0 deletions dubbo-bootstrap/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,42 @@
<version>${project.parent.version}</version>
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-registry-zookeeper</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-configcenter-zookeeper</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-rpc-dubbo</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-remoting-netty4</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-serialization-hessian2</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>

</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
public class DubboConsumerBootstrap {

public static void main(String[] args) throws IOException {
public static void main(String[] args) throws IOException, InterruptedException {

ApplicationConfig application = new ApplicationConfig();
application.setName("dubbo-consumer-demo");
Expand All @@ -47,11 +47,15 @@ public static void main(String[] args) throws IOException {
reference.setInterface(DemoService.class);
reference.setVersion("1.0.0");
reference.setProtocol("dubbo");
reference.setCheck(false);

// 和本地bean一样使用xxxService
DemoService demoService1 = reference.get();

System.out.println(demoService1.sayName("Hello,World"));
for (int i = 0; i < 1000; i++) {
System.out.println(demoService1.sayName("Hello,World"));
Thread.sleep(1000);
}

System.in.read();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,27 @@
*/
package org.apache.dubbo.config.provider.impl;

import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.config.api.Box;
import org.apache.dubbo.config.api.DemoException;
import org.apache.dubbo.config.api.DemoService;
import org.apache.dubbo.config.api.User;
import org.apache.dubbo.rpc.RpcContext;

import java.util.List;

import static java.lang.String.format;

/**
* DemoServiceImpl
*/
public class DemoServiceImpl implements DemoService {

private final Logger logger = LoggerFactory.getLogger(getClass());

public String sayName(String name) {
return "say:" + name;
return log("say:" + name);
}

public Box getBox() {
Expand All @@ -48,4 +55,12 @@ public int echo(int i) {
return i;
}

private <T> T log(T object) {
RpcContext rpcContext = RpcContext.getContext();
logger.info(format("RPC Invocation [ client - %s:%s , provider - %s:%s] : %s",
rpcContext.getRemoteHost(), rpcContext.getRemotePort(),
rpcContext.getLocalHost(), rpcContext.getLocalPort(),
object));
return object;
}
}
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
<module>dubbo-dependencies</module>
<module>dubbo-event</module>
<module>dubbo-metadata</module>
<module>dubbo-bootstrap</module>
</modules>

<dependencyManagement>
Expand Down

0 comments on commit 3ac778c

Please sign in to comment.