提交 22f8d25a 编写于 作者: K kezhenxu94 提交者: min

bugfix: test parameter type conversion. resolve #328 (#332)

* bugfix: test parameter type conversion. resolve #328

* remove unused import

* add kryo dependency

* add license
上级 da09fb28
......@@ -276,6 +276,7 @@ The text of each license is the standard Apache 2.0 license.
* Apache: dubbo 2.7.0 https://raw.githubusercontent.com/apache/incubator-dubbo/dubbo-2.7.0/LICENSE Apache 2.0
- dubbo-2.7.0.jar
- dubbo-serialization-kryo-2.7.0.jar
* Google: gson 2.8.4 https://raw.githubusercontent.com/google/gson/gson-parent-2.8.4/LICENSE Apache 2.0
- gson-2.8.4.jar
......@@ -412,6 +413,7 @@ The text of each license is also included at licenses/LICENSE-[project].
* vuejs: vue-router 3.0.1 https://raw.githubusercontent.com/vuejs/vue-router/v3.0.1/LICENSE MIT
* vuetifyjs: vuetify 1.2.2 https://raw.githubusercontent.com/vuetifyjs/vuetify/v1.2.2/LICENSE MIT
* vuejs: vuex 3.0.1 https://raw.githubusercontent.com/vuejs/vuex/v3.0.1/LICENSE MIT
* lodash: lodash 4.17.11 https://raw.githubusercontent.com/lodash/lodash/4.17.11/LICENSE MIT
========================================================================
......
The MIT License
Copyright JS Foundation and other contributors <https://js.foundation/>
Based on Underscore.js, copyright Jeremy Ashkenas,
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/lodash/lodash
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
Copyright and related rights for sample code are waived via CC0. Sample
code is defined as all source code displayed within the prose of the
documentation.
CC0: http://creativecommons.org/publicdomain/zero/1.0/
====
Files located in the node_modules and vendor directories are externally
maintained libraries used by this software which have their own
licenses; we recommend you read them, as their terms may differ from the
terms above.
......@@ -129,6 +129,11 @@
<artifactId>netty-all</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-serialization-kryo</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
......
......@@ -23,7 +23,6 @@ import org.apache.dubbo.config.ReferenceConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.registry.Registry;
import org.apache.dubbo.rpc.service.GenericService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
......@@ -31,8 +30,11 @@ import javax.annotation.PostConstruct;
@Component
public class GenericServiceImpl {
private ApplicationConfig applicationConfig;
@Autowired
private Registry registry;
private final Registry registry;
public GenericServiceImpl(Registry registry) {
this.registry = registry;
}
@PostConstruct
public void init() {
......@@ -42,7 +44,6 @@ public class GenericServiceImpl {
applicationConfig = new ApplicationConfig();
applicationConfig.setName("dubbo-admin");
applicationConfig.setRegistry(registryConfig);
}
public Object invoke(String service, String method, String[] parameterTypes, Object[] params) {
......@@ -57,6 +58,7 @@ public class GenericServiceImpl {
reference.setVersion(version);
reference.setGroup(group);
GenericService genericService = reference.get();
return genericService.$invoke(method, parameterTypes, params);
}
}
......@@ -16,6 +16,7 @@
"http-status": "^1.2.0",
"js-yaml": "^3.12.0",
"jsoneditor": "^5.26.2",
"lodash": "^4.17.11",
"vue": "^2.5.2",
"vue-clipboard2": "^0.2.1",
"vue-i18n": "^8.6.0",
......
......@@ -52,6 +52,8 @@
import JsonEditor from '@/components/public/JsonEditor'
import Breadcrumb from '@/components/public/Breadcrumb'
import axios from 'axios'
import set from 'lodash/set'
import util from '@/util'
export default {
name: 'TestMethod',
......@@ -110,11 +112,13 @@
},
convertType (params, types) {
for (let i = 0; i < params.length; i++) {
if (typeof types[i] === 'string' && typeof params[i] !== 'string') {
params[i] = String(params[i])
const p = util.flattenObject(params)
const t = util.flattenObject(types)
Object.keys(p).forEach(key => {
if (typeof t[key] === 'string' && typeof p[key] !== 'string') {
set(params, key, String(p[key]))
}
}
})
}
},
mounted () {
......
......@@ -36,8 +36,35 @@ const toggleFullScreen = () => {
}
}
// Flatten all nested keys of an object to one level with values, whose keys can be parameter of lodash.set
// e.g.: [{username: 'a', age: 3}, {username: 'b', age: 4}] => {'0.username': 'a', '0.age': 3, '1.username': 'b', '1.age': 4}
const flattenObject = obj => {
const toReturn = {}
for (let i in obj) {
if (!obj.hasOwnProperty(i)) {
continue
}
if ((typeof obj[i]) === 'object' && obj[i] !== null) {
const flatObject = flattenObject(obj[i])
for (let x in flatObject) {
if (!flatObject.hasOwnProperty(x)) {
continue
}
toReturn[i + '.' + x] = flatObject[x]
}
} else {
toReturn[i] = obj[i]
}
}
return toReturn
}
export default {
randomElement,
toggleFullScreen,
kebab
kebab,
flattenObject
}
......@@ -113,6 +113,12 @@
<version>${dubbo-version}</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-serialization-kryo</artifactId>
<version>${dubbo-version}</version>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册