dubbo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From i...@apache.org
Subject [incubator-dubbo-samples] branch master updated: clean up code for mock samples
Date Tue, 09 Apr 2019 06:35:24 GMT
This is an automated email from the ASF dual-hosted git repository.

iluo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo-samples.git


The following commit(s) were added to refs/heads/master by this push:
     new 86a75b8  clean up code for mock samples
86a75b8 is described below

commit 86a75b871dd0f3b16d8078d0eefafc464187e596
Author: Ian Luo <ian.luo@gmail.com>
AuthorDate: Tue Apr 9 14:35:01 2019 +0800

    clean up code for mock samples
---
 dubbo-samples-mock/pom.xml                                     | 10 ++++++++++
 .../main/java/org/apache/dubbo/samples/mock/MockConsumer.java  |  5 ++++-
 .../org/apache/dubbo/samples/mock/api/DemoServiceMock.java     |  6 +++++-
 .../java/org/apache/dubbo/samples/mock/zk/Configurator.java    |  2 +-
 4 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/dubbo-samples-mock/pom.xml b/dubbo-samples-mock/pom.xml
index 46b0ac5..784ed83 100644
--- a/dubbo-samples-mock/pom.xml
+++ b/dubbo-samples-mock/pom.xml
@@ -30,6 +30,7 @@
         <source.level>1.8</source.level>
         <target.level>1.8</target.level>
         <dubbo.version>2.7.1</dubbo.version>
+        <slf4j-log4j12.version>1.7.25</slf4j-log4j12.version>
         <maven_checkstyle_version>3.0.0</maven_checkstyle_version>
         <apache-rat-plugin.version>0.12</apache-rat-plugin.version>
     </properties>
@@ -58,6 +59,15 @@
             <version>${dubbo.version}</version>
             <type>pom</type>
         </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <version>${slf4j-log4j12.version}</version>
+        </dependency>
     </dependencies>
 
     <build>
diff --git a/dubbo-samples-mock/src/main/java/org/apache/dubbo/samples/mock/MockConsumer.java
b/dubbo-samples-mock/src/main/java/org/apache/dubbo/samples/mock/MockConsumer.java
index a75e79e..699ac66 100644
--- a/dubbo-samples-mock/src/main/java/org/apache/dubbo/samples/mock/MockConsumer.java
+++ b/dubbo-samples-mock/src/main/java/org/apache/dubbo/samples/mock/MockConsumer.java
@@ -19,15 +19,18 @@ package org.apache.dubbo.samples.mock;
 
 import org.apache.dubbo.samples.mock.api.DemoService;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 public class MockConsumer {
+    private static Logger logger = LoggerFactory.getLogger(MockConsumer.class);
 
     public static void main(String[] args) {
         ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/mock-consumer.xml");
         context.start();
         DemoService demoService = context.getBean("demoService", DemoService.class);
         String hello = demoService.sayHello("world");
-        System.out.println(hello);
+        logger.info("result: " + hello);
     }
 }
diff --git a/dubbo-samples-mock/src/main/java/org/apache/dubbo/samples/mock/api/DemoServiceMock.java
b/dubbo-samples-mock/src/main/java/org/apache/dubbo/samples/mock/api/DemoServiceMock.java
index 3681249..cbbd897 100644
--- a/dubbo-samples-mock/src/main/java/org/apache/dubbo/samples/mock/api/DemoServiceMock.java
+++ b/dubbo-samples-mock/src/main/java/org/apache/dubbo/samples/mock/api/DemoServiceMock.java
@@ -17,10 +17,14 @@
 
 package org.apache.dubbo.samples.mock.api;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 public class DemoServiceMock implements DemoService {
+    private static Logger logger = LoggerFactory.getLogger(DemoServiceMock.class);
 
     public String sayHello(String name) {
-        System.err.println("about to execute the local mock impl");
+        logger.warn("about to execute mock: " + DemoServiceMock.class.getSimpleName());
         return "mock " + name;
     }
 }
diff --git a/dubbo-samples-mock/src/main/java/org/apache/dubbo/samples/mock/zk/Configurator.java
b/dubbo-samples-mock/src/main/java/org/apache/dubbo/samples/mock/zk/Configurator.java
index a14c281..0500699 100644
--- a/dubbo-samples-mock/src/main/java/org/apache/dubbo/samples/mock/zk/Configurator.java
+++ b/dubbo-samples-mock/src/main/java/org/apache/dubbo/samples/mock/zk/Configurator.java
@@ -40,7 +40,7 @@ public class Configurator {
                 "- addresses: [0.0.0.0]\n" +
                 "  side: consumer\n" +
                 "  parameters:\n" +
-                "    mock: return null\n"
+                "    mock: return configured-mock-value\n"
                 + "...\n";
 
         System.out.println(str);


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Mime
View raw message