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 4551c928 Add test case to verify apache/dubbo#11557 (#734)
4551c928 is described below
commit 4551c9283a82c6f8293573b9481307f4e5c933b2
Author: Albumen Kevin <[email protected]>
AuthorDate: Tue Feb 14 09:15:44 2023 +0800
Add test case to verify apache/dubbo#11557 (#734)
---
.../case-configuration.yml | 23 +++++++
.../dubbo-samples-test-11557/case-versions.conf | 24 +++++++
99-integration/dubbo-samples-test-11557/pom.xml | 78 ++++++++++++++++++++++
.../apache/dubbo/samples/api/GreetingsService.java | 23 +++++++
.../dubbo/samples/client/ConsumerFilter.java | 35 ++++++++++
.../dubbo/samples/client/ProviderFilter.java | 38 +++++++++++
.../apache/dubbo/samples/provider/Application.java | 47 +++++++++++++
.../samples/provider/GreetingsServiceImpl.java | 27 ++++++++
.../META-INF/dubbo/org.apache.dubbo.rpc.Filter | 2 +
.../src/main/resources/log4j.properties | 25 +++++++
.../dubbo/samples/client/GreetingServiceIT.java | 51 ++++++++++++++
99-integration/pom.xml | 1 +
12 files changed, 374 insertions(+)
diff --git a/99-integration/dubbo-samples-test-11557/case-configuration.yml
b/99-integration/dubbo-samples-test-11557/case-configuration.yml
new file mode 100644
index 00000000..c7089895
--- /dev/null
+++ b/99-integration/dubbo-samples-test-11557/case-configuration.yml
@@ -0,0 +1,23 @@
+# 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.
+
+from: app-external-zookeeper.yml
+
+props:
+ project_name: dubbo-samples-test-11557
+ main_class: org.apache.dubbo.samples.provider.Application
+ dubbo_port: 20880
+ check_log: "DubboBootstrap awaiting ..."
diff --git a/99-integration/dubbo-samples-test-11557/case-versions.conf
b/99-integration/dubbo-samples-test-11557/case-versions.conf
new file mode 100644
index 00000000..5610cf33
--- /dev/null
+++ b/99-integration/dubbo-samples-test-11557/case-versions.conf
@@ -0,0 +1,24 @@
+#
+#
+# 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.*
+java.version= [ >= 8 ]
\ No newline at end of file
diff --git a/99-integration/dubbo-samples-test-11557/pom.xml
b/99-integration/dubbo-samples-test-11557/pom.xml
new file mode 100644
index 00000000..2bd275e7
--- /dev/null
+++ b/99-integration/dubbo-samples-test-11557/pom.xml
@@ -0,0 +1,78 @@
+<?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">
+ <parent>
+ <groupId>org.apache</groupId>
+ <artifactId>apache</artifactId>
+ <version>23</version>
+ <relativePath/>
+ </parent>
+
+ <groupId>org.apache.dubbo</groupId>
+ <version>1.0-SNAPSHOT</version>
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>dubbo-samples-test-11557</artifactId>
+ <name>Dubbo Samples Test For Issue 11557</name>
+ <description>Dubbo Samples Test For Issue 11557</description>
+
+ <properties>
+ <dubbo.version>3.1.5</dubbo.version>
+ <junit5.version>5.9.2</junit5.version>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <maven.compiler.target>1.8</maven.compiler.target>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-dependencies-zookeeper-curator5</artifactId>
+ <version>${dubbo.version}</version>
+ <type>pom</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <version>${junit5.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <version>${junit5.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-params</artifactId>
+ <version>${junit5.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git
a/99-integration/dubbo-samples-test-11557/src/main/java/org/apache/dubbo/samples/api/GreetingsService.java
b/99-integration/dubbo-samples-test-11557/src/main/java/org/apache/dubbo/samples/api/GreetingsService.java
new file mode 100644
index 00000000..8a3fc7d4
--- /dev/null
+++
b/99-integration/dubbo-samples-test-11557/src/main/java/org/apache/dubbo/samples/api/GreetingsService.java
@@ -0,0 +1,23 @@
+/*
+ * 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.api;
+
+public interface GreetingsService {
+
+ String sayHi(String name);
+}
diff --git
a/99-integration/dubbo-samples-test-11557/src/main/java/org/apache/dubbo/samples/client/ConsumerFilter.java
b/99-integration/dubbo-samples-test-11557/src/main/java/org/apache/dubbo/samples/client/ConsumerFilter.java
new file mode 100644
index 00000000..e71c7334
--- /dev/null
+++
b/99-integration/dubbo-samples-test-11557/src/main/java/org/apache/dubbo/samples/client/ConsumerFilter.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.client;
+
+import org.apache.dubbo.common.extension.Activate;
+import org.apache.dubbo.rpc.Filter;
+import org.apache.dubbo.rpc.Invocation;
+import org.apache.dubbo.rpc.Invoker;
+import org.apache.dubbo.rpc.Result;
+import org.apache.dubbo.rpc.RpcException;
+
+@Activate(group = "consumer")
+public class ConsumerFilter implements Filter {
+ @Override
+ public Result invoke(Invoker<?> invoker, Invocation invocation) throws
RpcException {
+ if (invoker.getUrl().getPath() == null) {
+ throw new IllegalArgumentException("invoker.getUrl().getPath() is
null");
+ }
+ return invoker.invoke(invocation);
+ }
+}
diff --git
a/99-integration/dubbo-samples-test-11557/src/main/java/org/apache/dubbo/samples/client/ProviderFilter.java
b/99-integration/dubbo-samples-test-11557/src/main/java/org/apache/dubbo/samples/client/ProviderFilter.java
new file mode 100644
index 00000000..d4c3d3b6
--- /dev/null
+++
b/99-integration/dubbo-samples-test-11557/src/main/java/org/apache/dubbo/samples/client/ProviderFilter.java
@@ -0,0 +1,38 @@
+/*
+ * 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.client;
+
+import org.apache.dubbo.common.extension.Activate;
+import org.apache.dubbo.rpc.Filter;
+import org.apache.dubbo.rpc.Invocation;
+import org.apache.dubbo.rpc.Invoker;
+import org.apache.dubbo.rpc.Result;
+import org.apache.dubbo.rpc.RpcException;
+
+import static org.apache.dubbo.rpc.RpcException.FORBIDDEN_EXCEPTION;
+
+@Activate(group = "provider")
+public class ProviderFilter implements Filter {
+ @Override
+ public Result invoke(Invoker<?> invoker, Invocation invocation) throws
RpcException {
+ if (invocation.getMethodName().contains("sayHi")) {
+ throw new RpcException(FORBIDDEN_EXCEPTION, "provider filter
exception");
+ } else {
+ return invoker.invoke(invocation);
+ }
+ }
+}
diff --git
a/99-integration/dubbo-samples-test-11557/src/main/java/org/apache/dubbo/samples/provider/Application.java
b/99-integration/dubbo-samples-test-11557/src/main/java/org/apache/dubbo/samples/provider/Application.java
new file mode 100644
index 00000000..07408d8f
--- /dev/null
+++
b/99-integration/dubbo-samples-test-11557/src/main/java/org/apache/dubbo/samples/provider/Application.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.provider;
+
+import org.apache.dubbo.config.ApplicationConfig;
+import org.apache.dubbo.config.ProtocolConfig;
+import org.apache.dubbo.config.RegistryConfig;
+import org.apache.dubbo.config.ServiceConfig;
+import org.apache.dubbo.config.bootstrap.DubboBootstrap;
+import org.apache.dubbo.samples.api.GreetingsService;
+
+public class Application {
+ private static final String ZOOKEEPER_HOST =
System.getProperty("zookeeper.address", "127.0.0.1");
+ private static final String ZOOKEEPER_PORT =
System.getProperty("zookeeper.port", "2181");
+ private static final String ZOOKEEPER_ADDRESS = "zookeeper://" +
ZOOKEEPER_HOST + ":" + ZOOKEEPER_PORT;
+
+ public static void main(String[] args) {
+ ServiceConfig<GreetingsService> service = new ServiceConfig<>();
+ service.setInterface(GreetingsService.class);
+ service.setRef(new GreetingsServiceImpl());
+ ApplicationConfig applicationConfig = new
ApplicationConfig("first-dubbo-provider");
+ applicationConfig.setRegisterMode("instance");
+
+ DubboBootstrap.getInstance()
+ .application(applicationConfig)
+ .registry(new RegistryConfig(ZOOKEEPER_ADDRESS))
+ .protocol(new ProtocolConfig("dubbo", -1))
+ .service(service)
+ .start()
+ .await();
+ }
+}
diff --git
a/99-integration/dubbo-samples-test-11557/src/main/java/org/apache/dubbo/samples/provider/GreetingsServiceImpl.java
b/99-integration/dubbo-samples-test-11557/src/main/java/org/apache/dubbo/samples/provider/GreetingsServiceImpl.java
new file mode 100644
index 00000000..d0d44484
--- /dev/null
+++
b/99-integration/dubbo-samples-test-11557/src/main/java/org/apache/dubbo/samples/provider/GreetingsServiceImpl.java
@@ -0,0 +1,27 @@
+/*
+ * 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.provider;
+
+import org.apache.dubbo.samples.api.GreetingsService;
+
+public class GreetingsServiceImpl implements GreetingsService {
+ @Override
+ public String sayHi(String name) {
+ return "hi, " + name;
+ }
+}
diff --git
a/99-integration/dubbo-samples-test-11557/src/main/resources/META-INF/dubbo/org.apache.dubbo.rpc.Filter
b/99-integration/dubbo-samples-test-11557/src/main/resources/META-INF/dubbo/org.apache.dubbo.rpc.Filter
new file mode 100644
index 00000000..460d955e
--- /dev/null
+++
b/99-integration/dubbo-samples-test-11557/src/main/resources/META-INF/dubbo/org.apache.dubbo.rpc.Filter
@@ -0,0 +1,2 @@
+org.apache.dubbo.samples.client.ConsumerFilter
+org.apache.dubbo.samples.client.ProviderFilter
\ No newline at end of file
diff --git
a/99-integration/dubbo-samples-test-11557/src/main/resources/log4j.properties
b/99-integration/dubbo-samples-test-11557/src/main/resources/log4j.properties
new file mode 100644
index 00000000..e976f5c2
--- /dev/null
+++
b/99-integration/dubbo-samples-test-11557/src/main/resources/log4j.properties
@@ -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.
+#
+#
+###set log levels###
+log4j.rootLogger=info, stdout
+###output to the console###
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy hh:mm:ss:sss z}]
%t %5p %c{2}: %m%n
\ No newline at end of file
diff --git
a/99-integration/dubbo-samples-test-11557/src/test/java/org/apache/dubbo/samples/client/GreetingServiceIT.java
b/99-integration/dubbo-samples-test-11557/src/test/java/org/apache/dubbo/samples/client/GreetingServiceIT.java
new file mode 100644
index 00000000..04086090
--- /dev/null
+++
b/99-integration/dubbo-samples-test-11557/src/test/java/org/apache/dubbo/samples/client/GreetingServiceIT.java
@@ -0,0 +1,51 @@
+/*
+ * 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.client;
+
+import org.apache.dubbo.config.ApplicationConfig;
+import org.apache.dubbo.config.ReferenceConfig;
+import org.apache.dubbo.config.RegistryConfig;
+import org.apache.dubbo.config.bootstrap.DubboBootstrap;
+import org.apache.dubbo.rpc.RpcException;
+import org.apache.dubbo.samples.api.GreetingsService;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+class GreetingServiceIT {
+ private static String zookeeperHost =
System.getProperty("zookeeper.address", "127.0.0.1");
+
+ @Test
+ void test() {
+ ReferenceConfig<GreetingsService> reference = new ReferenceConfig<>();
+ reference.setInterface(GreetingsService.class);
+ DubboBootstrap.getInstance()
+ .application(new ApplicationConfig("first-dubbo-consumer"))
+ .registry(new RegistryConfig("zookeeper://" + zookeeperHost +
":2181"))
+ .reference(reference)
+ .start();
+
+ GreetingsService service = reference.get();
+ try {
+ service.sayHi("dubbo");
+ Assertions.fail();
+ } catch (RpcException rpcException) {
+ Assertions.assertTrue(rpcException.getMessage().contains("provider
filter exception"));
+ }
+ }
+}
diff --git a/99-integration/pom.xml b/99-integration/pom.xml
index d676272d..1412efd5 100644
--- a/99-integration/pom.xml
+++ b/99-integration/pom.xml
@@ -55,6 +55,7 @@
<module>dubbo-samples-test-11096</module>
<module>dubbo-samples-test-11137</module>
<module>dubbo-samples-test-11159</module>
+ <module>dubbo-samples-test-11557</module>
<module>dubbo-samples-transaction</module>
<module>dubbo-samples-rest-withtoken</module>
<module>dubbo-samples-serialize-check</module>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]