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 7774c9df Add test cases to verify apache/dubbo#13224 (#1006)
7774c9df is described below
commit 7774c9df92d29fec75249ad4841172e85b0424bc
Author: Albumen Kevin <[email protected]>
AuthorDate: Wed Nov 15 10:12:51 2023 +0800
Add test cases to verify apache/dubbo#13224 (#1006)
---
.../case-configuration.yml | 23 +++
.../dubbo-samples-test-13224/case-versions.conf | 24 +++
99-integration/dubbo-samples-test-13224/pom.xml | 108 +++++++++++++
.../apache/dubbo/samples/api/GreetingsService.java | 22 +++
.../dubbo/samples/api/SerializationTypeWrap.java | 40 +++++
.../apache/dubbo/samples/provider/Application.java | 53 +++++++
.../samples/provider/GreetingsServiceImpl.java | 30 ++++
.../samples/provider/SerializationSetWrapper.java | 172 +++++++++++++++++++++
...org.apache.dubbo.common.serialize.Serialization | 1 +
.../src/main/resources/log4j.properties | 25 +++
.../src/main/resources/logback.xml | 30 ++++
.../dubbo/samples/client/GreetingServiceIT.java | 162 +++++++++++++++++++
...org.apache.dubbo.common.serialize.Serialization | 1 +
99-integration/pom.xml | 1 +
14 files changed, 692 insertions(+)
diff --git a/99-integration/dubbo-samples-test-13224/case-configuration.yml
b/99-integration/dubbo-samples-test-13224/case-configuration.yml
new file mode 100644
index 00000000..a1389deb
--- /dev/null
+++ b/99-integration/dubbo-samples-test-13224/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-13224
+ main_class: org.apache.dubbo.samples.provider.Application
+ dubbo_port: 50051
+ check_log: "DubboBootstrap awaiting ..."
diff --git a/99-integration/dubbo-samples-test-13224/case-versions.conf
b/99-integration/dubbo-samples-test-13224/case-versions.conf
new file mode 100644
index 00000000..3f3f58a0
--- /dev/null
+++ b/99-integration/dubbo-samples-test-13224/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 ]
diff --git a/99-integration/dubbo-samples-test-13224/pom.xml
b/99-integration/dubbo-samples-test-13224/pom.xml
new file mode 100644
index 00000000..18ea6748
--- /dev/null
+++ b/99-integration/dubbo-samples-test-13224/pom.xml
@@ -0,0 +1,108 @@
+<?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-13224</artifactId>
+ <name>Dubbo Samples Test for 13078</name>
+ <description>Dubbo Samples Test for 13078</description>
+
+ <properties>
+ <dubbo.version>3.2.8-SNAPSHOT</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>
+ <slf4j-log4j12.version>1.7.33</slf4j-log4j12.version>
+ <awaitility.version>4.2.0</awaitility.version>
+ </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>
+ <exclusions>
+ <exclusion>
+ <artifactId>logback-classic</artifactId>
+ <groupId>ch.qos.logback</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>logback-core</artifactId>
+ <groupId>ch.qos.logback</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>${slf4j-log4j12.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.protobuf</groupId>
+ <artifactId>protobuf-java</artifactId>
+ <version>3.22.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.awaitility</groupId>
+ <artifactId>awaitility</artifactId>
+ <version>${awaitility.version}</version>
+ </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-13224/src/main/java/org/apache/dubbo/samples/api/GreetingsService.java
b/99-integration/dubbo-samples-test-13224/src/main/java/org/apache/dubbo/samples/api/GreetingsService.java
new file mode 100644
index 00000000..a222b279
--- /dev/null
+++
b/99-integration/dubbo-samples-test-13224/src/main/java/org/apache/dubbo/samples/api/GreetingsService.java
@@ -0,0 +1,22 @@
+/*
+ * 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 {
+ SerializationTypeWrap echo(SerializationTypeWrap name);
+}
diff --git
a/99-integration/dubbo-samples-test-13224/src/main/java/org/apache/dubbo/samples/api/SerializationTypeWrap.java
b/99-integration/dubbo-samples-test-13224/src/main/java/org/apache/dubbo/samples/api/SerializationTypeWrap.java
new file mode 100644
index 00000000..04653a5c
--- /dev/null
+++
b/99-integration/dubbo-samples-test-13224/src/main/java/org/apache/dubbo/samples/api/SerializationTypeWrap.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.api;
+
+import java.io.Serializable;
+
+public class SerializationTypeWrap implements Serializable {
+ private String params;
+ private String contentType;
+
+ public String getParams() {
+ return params;
+ }
+
+ public void setParams(String params) {
+ this.params = params;
+ }
+
+ public String getContentType() {
+ return contentType;
+ }
+
+ public void setContentType(String contentType) {
+ this.contentType = contentType;
+ }
+}
diff --git
a/99-integration/dubbo-samples-test-13224/src/main/java/org/apache/dubbo/samples/provider/Application.java
b/99-integration/dubbo-samples-test-13224/src/main/java/org/apache/dubbo/samples/provider/Application.java
new file mode 100644
index 00000000..25daf57c
--- /dev/null
+++
b/99-integration/dubbo-samples-test-13224/src/main/java/org/apache/dubbo/samples/provider/Application.java
@@ -0,0 +1,53 @@
+/*
+ * 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.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> service1 = new ServiceConfig<>();
+ service1.setInterface(GreetingsService.class);
+ service1.setRef(new GreetingsServiceImpl());
+ service1.setVersion("hessian2");
+ service1.setSerialization("hessian2");
+
+ ServiceConfig<GreetingsService> service2 = new ServiceConfig<>();
+ service2.setInterface(GreetingsService.class);
+ service2.setRef(new GreetingsServiceImpl());
+ service2.setVersion("fastjson2");
+ service2.setSerialization("fastjson2");
+
+ DubboBootstrap.getInstance()
+ .application("first-dubbo-provider")
+ .registry(new RegistryConfig(ZOOKEEPER_ADDRESS))
+ .protocol(new ProtocolConfig("tri", -1))
+ .service(service1)
+ .service(service2)
+ .start()
+ .await();
+ }
+}
diff --git
a/99-integration/dubbo-samples-test-13224/src/main/java/org/apache/dubbo/samples/provider/GreetingsServiceImpl.java
b/99-integration/dubbo-samples-test-13224/src/main/java/org/apache/dubbo/samples/provider/GreetingsServiceImpl.java
new file mode 100644
index 00000000..def38b56
--- /dev/null
+++
b/99-integration/dubbo-samples-test-13224/src/main/java/org/apache/dubbo/samples/provider/GreetingsServiceImpl.java
@@ -0,0 +1,30 @@
+/*
+ * 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;
+import org.apache.dubbo.samples.api.SerializationTypeWrap;
+
+public class GreetingsServiceImpl implements GreetingsService {
+ @Override
+ public SerializationTypeWrap echo(SerializationTypeWrap name) {
+ SerializationTypeWrap serializationTypeWrap = new
SerializationTypeWrap();
+ serializationTypeWrap.setParams(name.getContentType());
+ return serializationTypeWrap;
+ }
+}
diff --git
a/99-integration/dubbo-samples-test-13224/src/main/java/org/apache/dubbo/samples/provider/SerializationSetWrapper.java
b/99-integration/dubbo-samples-test-13224/src/main/java/org/apache/dubbo/samples/provider/SerializationSetWrapper.java
new file mode 100644
index 00000000..61db7d00
--- /dev/null
+++
b/99-integration/dubbo-samples-test-13224/src/main/java/org/apache/dubbo/samples/provider/SerializationSetWrapper.java
@@ -0,0 +1,172 @@
+/*
+ * 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.common.URL;
+import org.apache.dubbo.common.serialize.ObjectInput;
+import org.apache.dubbo.common.serialize.ObjectOutput;
+import org.apache.dubbo.common.serialize.Serialization;
+import org.apache.dubbo.samples.api.SerializationTypeWrap;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.reflect.Type;
+import java.util.Map;
+
+public class SerializationSetWrapper implements Serialization {
+ private final Serialization serialization;
+
+ public SerializationSetWrapper(Serialization serialization) {
+ this.serialization = serialization;
+ }
+
+ @Override
+ public byte getContentTypeId() {
+ return serialization.getContentTypeId();
+ }
+
+ @Override
+ public String getContentType() {
+ return serialization.getContentType();
+ }
+
+ @Override
+ public ObjectOutput serialize(URL url, OutputStream output) throws
IOException {
+ return serialization.serialize(url, output);
+ }
+
+ @Override
+ public ObjectInput deserialize(URL url, InputStream input) throws
IOException {
+ ObjectInput origin = serialization.deserialize(url, input);
+ return new ObjectInput() {
+ @Override
+ public Object readObject() throws IOException,
ClassNotFoundException {
+ Object obj = origin.readObject();
+ if (obj instanceof SerializationTypeWrap) {
+ ((SerializationTypeWrap)
obj).setContentType(serialization.getContentType());
+ }
+ if (obj.getClass().isArray()) {
+ Object map = ((Object[])obj)[0];
+ if (map instanceof Map) {
+ ((Map<String, String>) map).put("contentType",
serialization.getContentType());
+ }
+ }
+ if (obj instanceof Map) {
+ ((Map<String, String>) obj).put("contentType",
serialization.getContentType());
+ }
+ return obj;
+ }
+
+ @Override
+ public <T> T readObject(Class<T> cls) throws IOException,
ClassNotFoundException {
+ T obj = origin.readObject(cls);
+ if (obj instanceof SerializationTypeWrap) {
+ ((SerializationTypeWrap)
obj).setContentType(serialization.getContentType());
+ }
+ if (obj.getClass().isArray()) {
+ Object map = ((Object[])obj)[0];
+ if (map instanceof Map) {
+ ((Map<String, String>) map).put("contentType",
serialization.getContentType());
+ }
+ }
+ if (obj instanceof Map) {
+ ((Map<String, String>) obj).put("contentType",
serialization.getContentType());
+ }
+ return obj;
+ }
+
+ @Override
+ public <T> T readObject(Class<T> cls, Type type) throws
IOException, ClassNotFoundException {
+ T obj = origin.readObject(cls, type);
+ if (obj instanceof SerializationTypeWrap) {
+ ((SerializationTypeWrap)
obj).setContentType(serialization.getContentType());
+ }
+ if (obj.getClass().isArray()) {
+ Object map = ((Object[])obj)[0];
+ if (map instanceof Map) {
+ ((Map<String, String>) map).put("contentType",
serialization.getContentType());
+ }
+ }
+ if (obj instanceof Map) {
+ ((Map<String, String>) obj).put("contentType",
serialization.getContentType());
+ }
+ return obj;
+ }
+
+ @Override
+ public boolean readBool() throws IOException {
+ return origin.readBool();
+ }
+
+ @Override
+ public byte readByte() throws IOException {
+ return origin.readByte();
+ }
+
+ @Override
+ public short readShort() throws IOException {
+ return origin.readShort();
+ }
+
+ @Override
+ public int readInt() throws IOException {
+ return origin.readInt();
+ }
+
+ @Override
+ public long readLong() throws IOException {
+ return origin.readLong();
+ }
+
+ @Override
+ public float readFloat() throws IOException {
+ return origin.readFloat();
+ }
+
+ @Override
+ public double readDouble() throws IOException {
+ return origin.readDouble();
+ }
+
+ @Override
+ public String readUTF() throws IOException {
+ return origin.readUTF();
+ }
+
+ @Override
+ public byte[] readBytes() throws IOException {
+ return origin.readBytes();
+ }
+
+ @Override
+ public Throwable readThrowable() throws IOException,
ClassNotFoundException {
+ return origin.readThrowable();
+ }
+
+ @Override
+ public String readEvent() throws IOException,
ClassNotFoundException {
+ return origin.readEvent();
+ }
+
+ @Override
+ public Map<String, Object> readAttachments() throws IOException,
ClassNotFoundException {
+ return origin.readAttachments();
+ }
+ };
+ }
+}
diff --git
a/99-integration/dubbo-samples-test-13224/src/main/resources/META-INF/services/org.apache.dubbo.common.serialize.Serialization
b/99-integration/dubbo-samples-test-13224/src/main/resources/META-INF/services/org.apache.dubbo.common.serialize.Serialization
new file mode 100644
index 00000000..c7a9814c
--- /dev/null
+++
b/99-integration/dubbo-samples-test-13224/src/main/resources/META-INF/services/org.apache.dubbo.common.serialize.Serialization
@@ -0,0 +1 @@
+set=org.apache.dubbo.samples.provider.SerializationSetWrapper
diff --git
a/99-integration/dubbo-samples-test-13224/src/main/resources/log4j.properties
b/99-integration/dubbo-samples-test-13224/src/main/resources/log4j.properties
new file mode 100644
index 00000000..93130269
--- /dev/null
+++
b/99-integration/dubbo-samples-test-13224/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
diff --git
a/99-integration/dubbo-samples-test-13224/src/main/resources/logback.xml
b/99-integration/dubbo-samples-test-13224/src/main/resources/logback.xml
new file mode 100644
index 00000000..39fae26e
--- /dev/null
+++ b/99-integration/dubbo-samples-test-13224/src/main/resources/logback.xml
@@ -0,0 +1,30 @@
+<?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>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%-4relative [%thread] %-5level %logger{35} - %msg
%n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="INFO">
+ <appender-ref ref="STDOUT" />
+ </root>
+</configuration>
diff --git
a/99-integration/dubbo-samples-test-13224/src/test/java/org/apache/dubbo/samples/client/GreetingServiceIT.java
b/99-integration/dubbo-samples-test-13224/src/test/java/org/apache/dubbo/samples/client/GreetingServiceIT.java
new file mode 100644
index 00000000..da858396
--- /dev/null
+++
b/99-integration/dubbo-samples-test-13224/src/test/java/org/apache/dubbo/samples/client/GreetingServiceIT.java
@@ -0,0 +1,162 @@
+/*
+ * 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.utils.PojoUtils;
+import org.apache.dubbo.config.ApplicationConfig;
+import org.apache.dubbo.config.ReferenceConfig;
+import org.apache.dubbo.config.RegistryConfig;
+import org.apache.dubbo.rpc.model.FrameworkModel;
+import org.apache.dubbo.rpc.service.GenericService;
+import org.apache.dubbo.samples.api.GreetingsService;
+import org.apache.dubbo.samples.api.SerializationTypeWrap;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class GreetingServiceIT {
+ private static String zookeeperHost =
System.getProperty("zookeeper.address", "127.0.0.1");
+
+ @Test
+ public void test1() {
+ ReferenceConfig<GreetingsService> referenceHessian2 = new
ReferenceConfig<>();
+ referenceHessian2.setApplication(new
ApplicationConfig("first-dubbo-consumer"));
+ referenceHessian2.setRegistry(new RegistryConfig("zookeeper://" +
zookeeperHost + ":2181"));
+ referenceHessian2.setInterface(GreetingsService.class);
+ referenceHessian2.setVersion("hessian2");
+ GreetingsService hessian2Service = referenceHessian2.get();
+
+ SerializationTypeWrap serializationTypeWrap = hessian2Service.echo(new
SerializationTypeWrap());
+ Assertions.assertEquals("x-application/hessian2",
serializationTypeWrap.getContentType());
+ Assertions.assertEquals("x-application/hessian2",
serializationTypeWrap.getParams());
+
+ ReferenceConfig<GreetingsService> referenceFastjson2 = new
ReferenceConfig<>();
+ referenceFastjson2.setApplication(new
ApplicationConfig("first-dubbo-consumer"));
+ referenceFastjson2.setRegistry(new RegistryConfig("zookeeper://" +
zookeeperHost + ":2181"));
+ referenceFastjson2.setInterface(GreetingsService.class);
+ referenceFastjson2.setVersion("fastjson2");
+ GreetingsService fastjson2Service = referenceFastjson2.get();
+
+ serializationTypeWrap = fastjson2Service.echo(new
SerializationTypeWrap());
+ Assertions.assertEquals("text/jsonb",
serializationTypeWrap.getContentType());
+ Assertions.assertEquals("text/jsonb",
serializationTypeWrap.getParams());
+
+ FrameworkModel.destroyAll();
+ }
+
+ @Test
+ public void test2() {
+ ReferenceConfig<GreetingsService> referenceFastjson2 = new
ReferenceConfig<>();
+ referenceFastjson2.setApplication(new
ApplicationConfig("first-dubbo-consumer"));
+ referenceFastjson2.setRegistry(new RegistryConfig("zookeeper://" +
zookeeperHost + ":2181"));
+ referenceFastjson2.setInterface(GreetingsService.class);
+ referenceFastjson2.setVersion("fastjson2");
+ GreetingsService fastjson2Service = referenceFastjson2.get();
+
+ SerializationTypeWrap serializationTypeWrap =
fastjson2Service.echo(new SerializationTypeWrap());
+ Assertions.assertEquals("text/jsonb",
serializationTypeWrap.getContentType());
+ Assertions.assertEquals("text/jsonb",
serializationTypeWrap.getParams());
+
+ ReferenceConfig<GreetingsService> referenceHessian2 = new
ReferenceConfig<>();
+ referenceHessian2.setApplication(new
ApplicationConfig("first-dubbo-consumer"));
+ referenceHessian2.setRegistry(new RegistryConfig("zookeeper://" +
zookeeperHost + ":2181"));
+ referenceHessian2.setInterface(GreetingsService.class);
+ referenceHessian2.setVersion("hessian2");
+ GreetingsService hessian2Service = referenceHessian2.get();
+
+ serializationTypeWrap = hessian2Service.echo(new
SerializationTypeWrap());
+ Assertions.assertEquals("x-application/hessian2",
serializationTypeWrap.getContentType());
+ Assertions.assertEquals("x-application/hessian2",
serializationTypeWrap.getParams());
+
+ FrameworkModel.destroyAll();
+ }
+
+ @Test
+ public void testGeneric1() {
+ ReferenceConfig<GenericService> referenceHessian2 = new
ReferenceConfig<>();
+ referenceHessian2.setApplication(new
ApplicationConfig("first-dubbo-consumer"));
+ referenceHessian2.setRegistry(new RegistryConfig("zookeeper://" +
zookeeperHost + ":2181"));
+ referenceHessian2.setInterface(GreetingsService.class);
+ referenceHessian2.setGeneric("true");
+ referenceHessian2.setVersion("hessian2");
+ GenericService hessian2Service = referenceHessian2.get();
+
+ Object res = hessian2Service.$invoke("echo",
+ new String[]{SerializationTypeWrap.class.getName()},
+ new Object[]{PojoUtils.generalize(new
SerializationTypeWrap())});
+ SerializationTypeWrap serializationTypeWrap =
+ (SerializationTypeWrap) PojoUtils.realize(res,
SerializationTypeWrap.class);
+ Assertions.assertEquals("x-application/hessian2",
serializationTypeWrap.getContentType());
+ Assertions.assertEquals("x-application/hessian2",
serializationTypeWrap.getParams());
+
+ ReferenceConfig<GenericService> referenceFastjson2 = new
ReferenceConfig<>();
+ referenceFastjson2.setApplication(new
ApplicationConfig("first-dubbo-consumer"));
+ referenceFastjson2.setRegistry(new RegistryConfig("zookeeper://" +
zookeeperHost + ":2181"));
+ referenceFastjson2.setInterface(GreetingsService.class);
+ referenceFastjson2.setVersion("fastjson2");
+ referenceFastjson2.setGeneric("true");
+ GenericService fastjson2Service = referenceFastjson2.get();
+
+ res = fastjson2Service.$invoke("echo",
+ new String[]{SerializationTypeWrap.class.getName()},
+ new Object[]{PojoUtils.generalize(new
SerializationTypeWrap())});
+ serializationTypeWrap =
+ (SerializationTypeWrap) PojoUtils.realize(res,
SerializationTypeWrap.class);
+ Assertions.assertEquals("text/jsonb",
serializationTypeWrap.getContentType());
+ Assertions.assertEquals("text/jsonb",
serializationTypeWrap.getParams());
+
+ FrameworkModel.destroyAll();
+ }
+
+ @Test
+ public void testGeneric2() {
+ ReferenceConfig<GenericService> referenceFastjson2 = new
ReferenceConfig<>();
+ referenceFastjson2.setApplication(new
ApplicationConfig("first-dubbo-consumer"));
+ referenceFastjson2.setRegistry(new RegistryConfig("zookeeper://" +
zookeeperHost + ":2181"));
+ referenceFastjson2.setInterface(GreetingsService.class);
+ referenceFastjson2.setVersion("fastjson2");
+ referenceFastjson2.setGeneric("true");
+ GenericService fastjson2Service = referenceFastjson2.get();
+
+ Object res = fastjson2Service.$invoke("echo",
+ new String[]{SerializationTypeWrap.class.getName()},
+ new Object[]{PojoUtils.generalize(new
SerializationTypeWrap())});
+ SerializationTypeWrap serializationTypeWrap =
+ (SerializationTypeWrap) PojoUtils.realize(res,
SerializationTypeWrap.class);
+ Assertions.assertEquals("text/jsonb",
serializationTypeWrap.getContentType());
+ Assertions.assertEquals("text/jsonb",
serializationTypeWrap.getParams());
+
+ ReferenceConfig<GenericService> referenceHessian2 = new
ReferenceConfig<>();
+ referenceHessian2.setApplication(new
ApplicationConfig("first-dubbo-consumer"));
+ referenceHessian2.setRegistry(new RegistryConfig("zookeeper://" +
zookeeperHost + ":2181"));
+ referenceHessian2.setInterface(GreetingsService.class);
+ referenceHessian2.setGeneric("true");
+ referenceHessian2.setVersion("hessian2");
+ GenericService hessian2Service = referenceHessian2.get();
+
+ res = hessian2Service.$invoke("echo",
+ new String[]{SerializationTypeWrap.class.getName()},
+ new Object[]{PojoUtils.generalize(new
SerializationTypeWrap())});
+ serializationTypeWrap =
+ (SerializationTypeWrap) PojoUtils.realize(res,
SerializationTypeWrap.class);
+ Assertions.assertEquals("x-application/hessian2",
serializationTypeWrap.getContentType());
+ Assertions.assertEquals("x-application/hessian2",
serializationTypeWrap.getParams());
+
+ FrameworkModel.destroyAll();
+ }
+}
diff --git
a/99-integration/dubbo-samples-test-13224/src/test/resources/META-INF/services/org.apache.dubbo.common.serialize.Serialization
b/99-integration/dubbo-samples-test-13224/src/test/resources/META-INF/services/org.apache.dubbo.common.serialize.Serialization
new file mode 100644
index 00000000..c7a9814c
--- /dev/null
+++
b/99-integration/dubbo-samples-test-13224/src/test/resources/META-INF/services/org.apache.dubbo.common.serialize.Serialization
@@ -0,0 +1 @@
+set=org.apache.dubbo.samples.provider.SerializationSetWrapper
diff --git a/99-integration/pom.xml b/99-integration/pom.xml
index c4391a15..c342215b 100644
--- a/99-integration/pom.xml
+++ b/99-integration/pom.xml
@@ -69,6 +69,7 @@
<module>dubbo-samples-test-12697</module>
<module>dubbo-samples-test-13078</module>
<module>dubbo-samples-test-13133</module>
+ <module>dubbo-samples-test-13224</module>
<module>dubbo-samples-test-abc-async</module>
<module>dubbo-samples-test-register</module>
<module>dubbo-samples-test-register-3-3</module>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]