This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-samples.git
The following commit(s) were added to refs/heads/master by this push:
new 10d58c3b6 Add Condition rule v3.1 test case (#1186)
10d58c3b6 is described below
commit 10d58c3b61b3aa37db5375caaaa029e6a7f1d8d3
Author: 王聪洋 <[email protected]>
AuthorDate: Fri Oct 25 17:02:10 2024 +0800
Add Condition rule v3.1 test case (#1186)
* add test case
* fix ci
* fix ci
* fix ci
---
.../case-configuration.yml | 68 ++++++++
.../case-versions.conf | 25 +++
.../dubbo-samples-conditionrouterv31/pom.xml | 176 +++++++++++++++++++++
.../dubbo/samples/governance/BasicConsumer.java | 47 ++++++
.../dubbo/samples/governance/BasicProvider.java | 37 +++++
.../samples/governance/BasicProvider28081.java | 35 ++++
.../apache/dubbo/samples/governance/ZKTools.java | 103 ++++++++++++
.../dubbo/samples/governance/api/DemoService.java | 26 +++
.../dubbo/samples/governance/api/DemoService2.java | 26 +++
.../samples/governance/impl/DemoServiceImpl.java | 40 +++++
.../samples/governance/impl/DemoServiceImpl2.java | 40 +++++
.../main/resources/dubbo-routers-conditionv31.yml | 42 +++++
.../src/main/resources/log4j2.xml | 29 ++++
.../main/resources/spring/dubbo-demo-consumer.xml | 39 +++++
.../main/resources/spring/dubbo-demo-consumer2.xml | 39 +++++
.../resources/spring/dubbo-demo-provider-28081.xml | 46 ++++++
.../main/resources/spring/dubbo-demo-provider.xml | 46 ++++++
.../dubbo/samples/governance/DemoService2IT.java | 59 +++++++
.../dubbo/samples/governance/DemoServiceIT.java | 60 +++++++
4-governance/pom.xml | 1 +
20 files changed, 984 insertions(+)
diff --git
a/4-governance/dubbo-samples-conditionrouterv31/case-configuration.yml
b/4-governance/dubbo-samples-conditionrouterv31/case-configuration.yml
new file mode 100644
index 000000000..846e5aa7a
--- /dev/null
+++ b/4-governance/dubbo-samples-conditionrouterv31/case-configuration.yml
@@ -0,0 +1,68 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+services:
+ zookeeper:
+ image: zookeeper:latest
+
+ dubbo-samples-conditionrouterv31-1:
+ type: app
+ basedir: .
+ mainClass: org.apache.dubbo.samples.governance.BasicProvider
+ systemProps:
+ - zookeeper.address=zookeeper
+ - zookeeper.port=2181
+ - dubbo.port=28080
+ waitPortsBeforeRun:
+ - zookeeper:2181
+ checkPorts:
+ - 28080
+ checkLog: "dubbo service started"
+ depends_on:
+ - zookeeper
+
+ dubbo-samples-conditionrouterv31-2:
+ type: app
+ basedir: .
+ mainClass: org.apache.dubbo.samples.governance.BasicProvider28081
+ systemProps:
+ - zookeeper.address=zookeeper
+ - zookeeper.port=2181
+ - dubbo.port=28081
+ waitPortsBeforeRun:
+ - zookeeper:2181
+ checkPorts:
+ - 28081
+ checkLog: "dubbo service started"
+ depends_on:
+ - zookeeper
+
+ dubbo-samples-configconditionrouter-test:
+ type: test
+ basedir: .
+ tests:
+ - "**/*IT.class"
+ systemProps:
+ - zookeeper.address=zookeeper
+ - zookeeper.port=2181
+ waitPortsBeforeRun:
+ - zookeeper:2181
+ - dubbo-samples-conditionrouterv31-1:28080
+ - dubbo-samples-conditionrouterv31-2:28081
+ depends_on:
+ - zookeeper
+ - dubbo-samples-conditionrouterv31-1
+ - dubbo-samples-conditionrouterv31-2
diff --git a/4-governance/dubbo-samples-conditionrouterv31/case-versions.conf
b/4-governance/dubbo-samples-conditionrouterv31/case-versions.conf
new file mode 100644
index 000000000..518c581c8
--- /dev/null
+++ b/4-governance/dubbo-samples-conditionrouterv31/case-versions.conf
@@ -0,0 +1,25 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+
+# Supported component versions of the test case
+
+# Spring app
+dubbo.version= [>= 3.3.1]
+spring.version=4.*, 5.*
+java.version= [>= 8]
diff --git a/4-governance/dubbo-samples-conditionrouterv31/pom.xml
b/4-governance/dubbo-samples-conditionrouterv31/pom.xml
new file mode 100644
index 000000000..a1281438d
--- /dev/null
+++ b/4-governance/dubbo-samples-conditionrouterv31/pom.xml
@@ -0,0 +1,176 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ ~
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <groupId>org.apache.dubbo</groupId>
+ <version>1.0-SNAPSHOT</version>
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>dubbo-samples-conditionrouterv31</artifactId>
+ <name>Dubbo Samples Config Condition Router</name>
+ <description>Dubbo Samples Config Condition Router</description>
+
+ <properties>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <maven.compiler.target>1.8</maven.compiler.target>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+
+ <dubbo.version>3.3.1</dubbo.version>
+ <spring.version>4.3.30.RELEASE</spring.version>
+ <log4j2.version>2.20.0</log4j2.version>
+ <junit.version>4.13.1</junit.version>
+
+ <maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-framework-bom</artifactId>
+ <version>${spring.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-bom</artifactId>
+ <version>${dubbo.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-dependencies-zookeeper-curator5</artifactId>
+ <version>${dubbo.version}</version>
+ <type>pom</type>
+ <exclusions>
+ <exclusion>
+ <artifactId>logback-classic</artifactId>
+ <groupId>ch.qos.logback</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>logback-core</artifactId>
+ <groupId>ch.qos.logback</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>log4j</artifactId>
+ <groupId>log4j</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>slf4j-log4j12</artifactId>
+ <groupId>org.slf4j</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context-support</artifactId>
+ <version>${spring.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-dependencies-zookeeper-curator5</artifactId>
+ <type>pom</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ <version>${log4j2.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <!-- For jdk 11 above JavaEE annotation -->
+ <profile>
+ <id>javax.annotation</id>
+ <activation>
+ <jdk>[1.11,)</jdk>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>javax.annotation-api</artifactId>
+ <version>1.3.2</version>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>${maven-compiler-plugin.version}</version>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>apache.snapshots.https</id>
+ <name>Apache Development Snapshot Repository</name>
+
<url>https://repository.apache.org/content/repositories/snapshots</url>
+ <layout>default</layout>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ <updatePolicy>daily</updatePolicy>
+ </snapshots>
+ </repository>
+ </repositories>
+</project>
diff --git
a/4-governance/dubbo-samples-conditionrouterv31/src/main/java/org/apache/dubbo/samples/governance/BasicConsumer.java
b/4-governance/dubbo-samples-conditionrouterv31/src/main/java/org/apache/dubbo/samples/governance/BasicConsumer.java
new file mode 100644
index 000000000..d79f444e6
--- /dev/null
+++
b/4-governance/dubbo-samples-conditionrouterv31/src/main/java/org/apache/dubbo/samples/governance/BasicConsumer.java
@@ -0,0 +1,47 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.dubbo.samples.governance;
+
+import org.apache.dubbo.samples.governance.api.DemoService;
+import org.apache.dubbo.samples.governance.api.DemoService2;
+
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.util.Assert;
+
+public class BasicConsumer {
+
+ public static void main(String[] args) {
+ ClassPathXmlApplicationContext context = new
ClassPathXmlApplicationContext("spring/dubbo-demo-consumer.xml");
+ context.start();
+
+ DemoService demoService = context.getBean("demoService",
DemoService.class);
+ DemoService2 demoService2 = context.getBean("demoService2",
DemoService2.class);
+
+ String hello = demoService.sayHello("world");
+ Assert.isTrue(hello.contains("28081"));
+ Assert.isTrue(!hello.contains("gray"));
+ System.out.println(hello);
+
+ String hello2 = demoService2.sayHello("world again");
+ Assert.isTrue(hello2.contains("28081"));
+ Assert.isTrue(!hello.contains("gray"));
+ System.out.println(hello2);
+ }
+}
diff --git
a/4-governance/dubbo-samples-conditionrouterv31/src/main/java/org/apache/dubbo/samples/governance/BasicProvider.java
b/4-governance/dubbo-samples-conditionrouterv31/src/main/java/org/apache/dubbo/samples/governance/BasicProvider.java
new file mode 100644
index 000000000..9de161e7c
--- /dev/null
+++
b/4-governance/dubbo-samples-conditionrouterv31/src/main/java/org/apache/dubbo/samples/governance/BasicProvider.java
@@ -0,0 +1,37 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.dubbo.samples.governance;
+
+import org.apache.dubbo.config.ServiceConfig;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+
+public class BasicProvider {
+
+ public static void main(String[] args) throws Exception {
+ ClassPathXmlApplicationContext context = new
ClassPathXmlApplicationContext("spring/dubbo-demo-provider.xml");
+ context.start();
+
+ System.out.println("dubbo service started");
+ new CountDownLatch(1).await();
+ }
+}
diff --git
a/4-governance/dubbo-samples-conditionrouterv31/src/main/java/org/apache/dubbo/samples/governance/BasicProvider28081.java
b/4-governance/dubbo-samples-conditionrouterv31/src/main/java/org/apache/dubbo/samples/governance/BasicProvider28081.java
new file mode 100644
index 000000000..3d614bfb0
--- /dev/null
+++
b/4-governance/dubbo-samples-conditionrouterv31/src/main/java/org/apache/dubbo/samples/governance/BasicProvider28081.java
@@ -0,0 +1,35 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.dubbo.samples.governance;
+
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import java.util.concurrent.CountDownLatch;
+
+public class BasicProvider28081 {
+
+ public static void main(String[] args) throws Exception {
+ ClassPathXmlApplicationContext context = new
ClassPathXmlApplicationContext("spring/dubbo-demo-provider-28081.xml");
+ context.start();
+
+ System.out.println("dubbo service started");
+ new CountDownLatch(1).await();
+ }
+}
diff --git
a/4-governance/dubbo-samples-conditionrouterv31/src/main/java/org/apache/dubbo/samples/governance/ZKTools.java
b/4-governance/dubbo-samples-conditionrouterv31/src/main/java/org/apache/dubbo/samples/governance/ZKTools.java
new file mode 100644
index 000000000..3675f15cb
--- /dev/null
+++
b/4-governance/dubbo-samples-conditionrouterv31/src/main/java/org/apache/dubbo/samples/governance/ZKTools.java
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.samples.governance;
+
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.CuratorFrameworkFactory;
+import org.apache.curator.retry.ExponentialBackoffRetry;
+
+public class ZKTools {
+ private static String zookeeperHost =
System.getProperty("zookeeper.address", "127.0.0.1");
+ private static String zookeeperPort = System.getProperty("zookeeper.port",
"2181");
+ private static CuratorFramework client;
+
+ public static void main(String[] args) throws Exception {
+ initClient();
+ generateAppevelRouter();
+ generateAppevelRouter2();
+ }
+
+ public static void start(){
+ initClient();
+ generateAppevelRouter();
+ generateAppevelRouter2();
+ }
+
+ public static void initClient() {
+ client = CuratorFrameworkFactory.newClient(zookeeperHost + ":" +
zookeeperPort, 60 * 1000, 60 * 1000,
+ new ExponentialBackoffRetry(1000, 3));
+ client.start();
+ }
+
+ public static void generateAppevelRouter() {
+ String str = "configVersion: v3.1\n" + "scope: application\n"
+// + "key:
org.apache.dubbo.samples.governance.api.DemoService\n"
+ + "key: governance-conditionrouterv31-consumer\n"
+ + "force: false\n"
+ + "runtime: true\n"
+ + "enabled: true\n"
+ + "conditions:\n"
+ + " - from:\n"
+ + " match: env=gray\n"
+ + " to:\n"
+ + " - match: env!=$env\n"
+ + " weight: 100";
+
+ System.out.println(str);
+
+ try {
+ String path =
"/dubbo/config/dubbo/governance-conditionrouterv31-consumer.condition-router";
+ if (client.checkExists().forPath(path) == null) {
+ client.create().creatingParentsIfNeeded().forPath(path);
+ }
+ setData(path, str);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static void generateAppevelRouter2() {
+ String str = "configVersion: v3.1\n" + "scope: application\n"
+// + "key:
org.apache.dubbo.samples.governance.api.DemoService2\n"
+ + "key: governance-conditionrouterv31-consumer-2\n"
+ + "force: false\n"
+ + "runtime: true\n"
+ + "enabled: true\n"
+ + "conditions:\n"
+ + " - from:\n"
+ + " match: env=white\n"
+ + " to:\n"
+ + " - match: env!=$env\n"
+ + " weight: 100";
+
+ System.out.println(str);
+
+ try {
+ String path =
"/dubbo/config/dubbo/governance-conditionrouterv31-consumer-2.condition-router";
+ if (client.checkExists().forPath(path) == null) {
+ client.create().creatingParentsIfNeeded().forPath(path);
+ }
+ setData(path, str);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ private static void setData(String path, String data) throws Exception {
+ client.setData().forPath(path, data.getBytes());
+ }
+
+}
diff --git
a/4-governance/dubbo-samples-conditionrouterv31/src/main/java/org/apache/dubbo/samples/governance/api/DemoService.java
b/4-governance/dubbo-samples-conditionrouterv31/src/main/java/org/apache/dubbo/samples/governance/api/DemoService.java
new file mode 100644
index 000000000..bde5f6eb6
--- /dev/null
+++
b/4-governance/dubbo-samples-conditionrouterv31/src/main/java/org/apache/dubbo/samples/governance/api/DemoService.java
@@ -0,0 +1,26 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.dubbo.samples.governance.api;
+
+public interface DemoService {
+
+ String sayHello(String name);
+
+}
diff --git
a/4-governance/dubbo-samples-conditionrouterv31/src/main/java/org/apache/dubbo/samples/governance/api/DemoService2.java
b/4-governance/dubbo-samples-conditionrouterv31/src/main/java/org/apache/dubbo/samples/governance/api/DemoService2.java
new file mode 100644
index 000000000..828d87c91
--- /dev/null
+++
b/4-governance/dubbo-samples-conditionrouterv31/src/main/java/org/apache/dubbo/samples/governance/api/DemoService2.java
@@ -0,0 +1,26 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.dubbo.samples.governance.api;
+
+public interface DemoService2 {
+
+ String sayHello(String name);
+
+}
diff --git
a/4-governance/dubbo-samples-conditionrouterv31/src/main/java/org/apache/dubbo/samples/governance/impl/DemoServiceImpl.java
b/4-governance/dubbo-samples-conditionrouterv31/src/main/java/org/apache/dubbo/samples/governance/impl/DemoServiceImpl.java
new file mode 100644
index 000000000..a0fceb3f0
--- /dev/null
+++
b/4-governance/dubbo-samples-conditionrouterv31/src/main/java/org/apache/dubbo/samples/governance/impl/DemoServiceImpl.java
@@ -0,0 +1,40 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.dubbo.samples.governance.impl;
+
+import org.apache.dubbo.rpc.RpcContext;
+import org.apache.dubbo.samples.governance.api.DemoService;
+
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Date;
+
+public class DemoServiceImpl implements DemoService {
+
+ @Override
+ public String sayHello(String name) {
+ String res = "[" + new SimpleDateFormat("HH:mm:ss").format(new Date())
+ "] Hello " +
+ name + ", request from consumer: " +
RpcContext.getContext().getRemoteAddress()
+ + ",response from provider:" +
RpcContext.getContext().getLocalAddress() + "port : " +
RpcContext.getServiceContext().getLocalPort()
+ + " env = " +
RpcContext.getCurrentServiceContext().getUrl().getParameter("env");
+ return res;
+ }
+
+}
diff --git
a/4-governance/dubbo-samples-conditionrouterv31/src/main/java/org/apache/dubbo/samples/governance/impl/DemoServiceImpl2.java
b/4-governance/dubbo-samples-conditionrouterv31/src/main/java/org/apache/dubbo/samples/governance/impl/DemoServiceImpl2.java
new file mode 100644
index 000000000..037dad62a
--- /dev/null
+++
b/4-governance/dubbo-samples-conditionrouterv31/src/main/java/org/apache/dubbo/samples/governance/impl/DemoServiceImpl2.java
@@ -0,0 +1,40 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.dubbo.samples.governance.impl;
+
+import org.apache.dubbo.rpc.RpcContext;
+import org.apache.dubbo.samples.governance.api.DemoService2;
+
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Date;
+
+public class DemoServiceImpl2 implements DemoService2 {
+
+ @Override
+ public String sayHello(String name) {
+ String res = "[" + new SimpleDateFormat("HH:mm:ss").format(new Date())
+ "] Hello " +
+ name + ", request from consumer: " +
RpcContext.getContext().getRemoteAddress()
+ + ",response from provider:" +
RpcContext.getContext().getLocalAddress() + "port : " +
RpcContext.getServiceContext().getLocalPort()
+ + " env = " +
RpcContext.getCurrentServiceContext().getUrl().getParameter("env");
+ return res;
+ }
+
+}
diff --git
a/4-governance/dubbo-samples-conditionrouterv31/src/main/resources/dubbo-routers-conditionv31.yml
b/4-governance/dubbo-samples-conditionrouterv31/src/main/resources/dubbo-routers-conditionv31.yml
new file mode 100644
index 000000000..78fb5cef4
--- /dev/null
+++
b/4-governance/dubbo-samples-conditionrouterv31/src/main/resources/dubbo-routers-conditionv31.yml
@@ -0,0 +1,42 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+---
+configVersion: v3.1
+scope: service
+key: org.apache.dubbo.samples.CommentService
+force: false
+runtime: true
+enabled: true
+
+#######
+conditions:
+ - from:
+ match: tag=tag1 # disable traffic
+ - from:
+ match: tag=gray
+ to:
+ - match: tag!=gray
+ weight: 100
+ - match: tag=gray
+ weight: 900
+ - from:
+ match: version=v1
+ to:
+ - match: version=v1
+...
diff --git
a/4-governance/dubbo-samples-conditionrouterv31/src/main/resources/log4j2.xml
b/4-governance/dubbo-samples-conditionrouterv31/src/main/resources/log4j2.xml
new file mode 100644
index 000000000..69e1321d2
--- /dev/null
+++
b/4-governance/dubbo-samples-conditionrouterv31/src/main/resources/log4j2.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<Configuration status="WARN">
+ <Appenders>
+ <Console name="Console" target="SYSTEM_OUT" follow="true">
+ <PatternLayout pattern="%style{%d{HH:mm:ss.SSS}}{Magenta}
%style{|-}{White}%highlight{%-5p} [%t] %style{%40.40c}{Cyan}:%style{%-3L}{Blue}
%style{-|}{White}
%m%n%rEx{filters(jdk.internal.reflect,java.lang.reflect,sun.reflect)}"
disableAnsi="false" charset="UTF-8"/>
+ </Console>
+ </Appenders>
+ <Loggers>
+ <Root level="info">
+ <AppenderRef ref="Console"/>
+ </Root>
+ </Loggers>
+</Configuration>
diff --git
a/4-governance/dubbo-samples-conditionrouterv31/src/main/resources/spring/dubbo-demo-consumer.xml
b/4-governance/dubbo-samples-conditionrouterv31/src/main/resources/spring/dubbo-demo-consumer.xml
new file mode 100644
index 000000000..e76158057
--- /dev/null
+++
b/4-governance/dubbo-samples-conditionrouterv31/src/main/resources/spring/dubbo-demo-consumer.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ ~
+ -->
+
+<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
+ xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://dubbo.apache.org/schema/dubbo
http://dubbo.apache.org/schema/dubbo/dubbo.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
+ <context:property-placeholder/>
+
+ <dubbo:application name="governance-conditionrouterv31-consumer">
+ <dubbo:parameter key="env" value="gray"/>
+<!-- <dubbo:parameter key="version" value="${version:v1}"/>-->
+ </dubbo:application>
+
+ <dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:2181"/>
+
+ <dubbo:config-center
address="zookeeper://${zookeeper.address:127.0.0.1}:2181"/>
+
+ <dubbo:reference id="demoService" check="false"
interface="org.apache.dubbo.samples.governance.api.DemoService"/>
+ <dubbo:reference id="demoService2" check="false"
interface="org.apache.dubbo.samples.governance.api.DemoService2"/>
+</beans>
diff --git
a/4-governance/dubbo-samples-conditionrouterv31/src/main/resources/spring/dubbo-demo-consumer2.xml
b/4-governance/dubbo-samples-conditionrouterv31/src/main/resources/spring/dubbo-demo-consumer2.xml
new file mode 100644
index 000000000..6c0d026d4
--- /dev/null
+++
b/4-governance/dubbo-samples-conditionrouterv31/src/main/resources/spring/dubbo-demo-consumer2.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ ~
+ -->
+
+<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
+ xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://dubbo.apache.org/schema/dubbo
http://dubbo.apache.org/schema/dubbo/dubbo.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
+ <context:property-placeholder/>
+
+ <dubbo:application name="governance-conditionrouterv31-consumer-2">
+ <dubbo:parameter key="env" value="white"/>
+<!-- <dubbo:parameter key="version" value="${version:v2}"/>-->
+ </dubbo:application>
+
+ <dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:2181"/>
+
+ <dubbo:config-center
address="zookeeper://${zookeeper.address:127.0.0.1}:2181"/>
+
+ <dubbo:reference id="demoService" check="false"
interface="org.apache.dubbo.samples.governance.api.DemoService"/>
+ <dubbo:reference id="demoService2" check="false"
interface="org.apache.dubbo.samples.governance.api.DemoService2"/>
+</beans>
diff --git
a/4-governance/dubbo-samples-conditionrouterv31/src/main/resources/spring/dubbo-demo-provider-28081.xml
b/4-governance/dubbo-samples-conditionrouterv31/src/main/resources/spring/dubbo-demo-provider-28081.xml
new file mode 100644
index 000000000..17b35ad6b
--- /dev/null
+++
b/4-governance/dubbo-samples-conditionrouterv31/src/main/resources/spring/dubbo-demo-provider-28081.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ ~
+ -->
+
+<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
+ xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://dubbo.apache.org/schema/dubbo
http://dubbo.apache.org/schema/dubbo/dubbo.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
+ <context:property-placeholder/>
+
+ <dubbo:application name="governance-conditionrouterv31-provider-28081">
+ <dubbo:parameter key="env" value="white"/>
+ </dubbo:application>
+
+ <dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:2181"/>
+<!-- <dubbo:provider token="true"/>-->
+
+ <dubbo:protocol name="dubbo" port="${dubbo.port:28081}"/>
+
+ <dubbo:config-center
address="zookeeper://${zookeeper.address:127.0.0.1}:2181"/>
+
+ <bean id="demoService"
class="org.apache.dubbo.samples.governance.impl.DemoServiceImpl"/>
+ <dubbo:service
interface="org.apache.dubbo.samples.governance.api.DemoService"
ref="demoService" >
+ </dubbo:service>
+
+ <bean id="demoService2"
class="org.apache.dubbo.samples.governance.impl.DemoServiceImpl2"/>
+ <dubbo:service
interface="org.apache.dubbo.samples.governance.api.DemoService2"
ref="demoService2">
+ </dubbo:service>
+</beans>
diff --git
a/4-governance/dubbo-samples-conditionrouterv31/src/main/resources/spring/dubbo-demo-provider.xml
b/4-governance/dubbo-samples-conditionrouterv31/src/main/resources/spring/dubbo-demo-provider.xml
new file mode 100644
index 000000000..2d6a1134c
--- /dev/null
+++
b/4-governance/dubbo-samples-conditionrouterv31/src/main/resources/spring/dubbo-demo-provider.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ ~
+ -->
+
+<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
+ xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://dubbo.apache.org/schema/dubbo
http://dubbo.apache.org/schema/dubbo/dubbo.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
+ <context:property-placeholder/>
+
+ <dubbo:application name="governance-conditionrouterv31-provider">
+ <dubbo:parameter key="env" value="gray"/>
+ </dubbo:application>
+
+ <dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:2181"/>
+<!-- <dubbo:provider token="true"/>-->
+
+ <dubbo:protocol name="dubbo" port="${dubbo.port:28080}"/>
+
+ <dubbo:config-center
address="zookeeper://${zookeeper.address:127.0.0.1}:2181"/>
+
+ <bean id="demoService"
class="org.apache.dubbo.samples.governance.impl.DemoServiceImpl"/>
+ <dubbo:service
interface="org.apache.dubbo.samples.governance.api.DemoService"
ref="demoService" >
+ </dubbo:service>
+
+ <bean id="demoService2"
class="org.apache.dubbo.samples.governance.impl.DemoServiceImpl2"/>
+ <dubbo:service
interface="org.apache.dubbo.samples.governance.api.DemoService2"
ref="demoService2">
+ </dubbo:service>
+</beans>
diff --git
a/4-governance/dubbo-samples-conditionrouterv31/src/test/java/org/apache/dubbo/samples/governance/DemoService2IT.java
b/4-governance/dubbo-samples-conditionrouterv31/src/test/java/org/apache/dubbo/samples/governance/DemoService2IT.java
new file mode 100644
index 000000000..909e1844d
--- /dev/null
+++
b/4-governance/dubbo-samples-conditionrouterv31/src/test/java/org/apache/dubbo/samples/governance/DemoService2IT.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dubbo.samples.governance;
+
+import org.apache.dubbo.rpc.RpcContext;
+import org.apache.dubbo.samples.governance.api.DemoService;
+import org.apache.dubbo.samples.governance.api.DemoService2;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations =
{"classpath:/spring/dubbo-demo-consumer2.xml"})
+public class DemoService2IT {
+ @Autowired
+ private DemoService demoService;
+
+ @Autowired
+ private DemoService2 demoService2;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ ZKTools.start();
+ Thread.sleep(2000);
+ }
+
+ @Test
+ public void testDemoService() throws Exception {
+ String result = demoService.sayHello("world");
+ Assert.assertTrue(result.contains("28080"));
+ Assert.assertTrue(!result.contains("white"));
+ }
+
+ @Test
+ public void testDemoService2() throws Exception {
+ String result = demoService2.sayHello("world");
+ Assert.assertTrue(result.contains("28080"));
+ Assert.assertTrue(!result.contains("white"));
+ }
+}
diff --git
a/4-governance/dubbo-samples-conditionrouterv31/src/test/java/org/apache/dubbo/samples/governance/DemoServiceIT.java
b/4-governance/dubbo-samples-conditionrouterv31/src/test/java/org/apache/dubbo/samples/governance/DemoServiceIT.java
new file mode 100644
index 000000000..b99706f46
--- /dev/null
+++
b/4-governance/dubbo-samples-conditionrouterv31/src/test/java/org/apache/dubbo/samples/governance/DemoServiceIT.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dubbo.samples.governance;
+
+import org.apache.dubbo.rpc.RpcContext;
+import org.apache.dubbo.samples.governance.api.DemoService;
+import org.apache.dubbo.samples.governance.api.DemoService2;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations =
{"classpath:/spring/dubbo-demo-consumer.xml"})
+public class DemoServiceIT {
+ @Autowired
+ private DemoService demoService;
+
+ @Autowired
+ private DemoService2 demoService2;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ ZKTools.start();
+ Thread.sleep(2000);
+ }
+
+ @Test
+ public void testDemoService() throws Exception {
+ String result = demoService.sayHello("world");
+ Assert.assertTrue(result.contains("28081"));
+ Assert.assertTrue(!result.contains("gray"));
+ }
+
+ @Test
+ public void testDemoService2() throws Exception {
+ String result = demoService2.sayHello("world");
+ Assert.assertTrue(result.contains("28081"));
+ Assert.assertTrue(!result.contains("gray"));
+ }
+}
diff --git a/4-governance/pom.xml b/4-governance/pom.xml
index 4b8192baf..2868d9956 100644
--- a/4-governance/pom.xml
+++ b/4-governance/pom.xml
@@ -29,6 +29,7 @@
<modules>
<module>dubbo-samples-applevel-override</module>
<module>dubbo-samples-configconditionrouter</module>
+ <module>dubbo-samples-conditionrouterv31</module>
<module>dubbo-samples-meshrule-router</module>
<module>dubbo-samples-metrics-prometheus</module>
<module>dubbo-samples-metrics-spring-boot</module>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]