Skip to content

Commit

Permalink
DUBBO-627 为ServiceConfig 支持配置 generic添加单元测试,覆盖使用 xml 配置时 url 中是否带上了 正…
Browse files Browse the repository at this point in the history
…确的 generic 配置
  • Loading branch information
kimi committed Jan 9, 2013
1 parent 3dccbc6 commit e8970a0
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,6 @@ public void testReferGenericExport() throws Exception {
sc.setInterface(DemoService.class.getName());
sc.setRef(new GenericService() {

@Override
public Object $invoke(String method, String[] parameterTypes, Object[] args) throws GenericException {
return null;
}
Expand Down Expand Up @@ -962,6 +961,19 @@ public void testGenericServiceConfig() throws Exception {
}
}

@Test
public void testGenericServiceConfigThroughSpring() throws Exception {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/generic-export.xml");
try {
ctx.start();
ServiceConfig serviceConfig = (ServiceConfig) ctx.getBean("dubboDemoService");
URL url = (URL)serviceConfig.getExportedUrls().get(0);
Assert.assertEquals(Constants.GENERIC_SERIALIZATION_BEAN, url.getParameter(Constants.GENERIC_KEY));
} finally {
ctx.destroy();
}
}

private static void unexportService(ServiceConfig<?> config) {
if (config != null) {
config.unexport();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.alibaba.dubbo.config.spring;

import com.alibaba.dubbo.rpc.service.GenericException;
import com.alibaba.dubbo.rpc.service.GenericService;

/**
* @author <a href="mailto:[email protected]">kimi</a>
*/
public class GenericDemoService implements GenericService {

public Object $invoke(String method, String[] parameterTypes, Object[] args) throws GenericException {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!--
- Copyright 1999-2011 Alibaba Group.
-
- Licensed 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
-
- https://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="https://www.springframework.org/schema/beans"
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="https://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="https://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.5.xsd
https://code.alibabatech.com/schema/dubbo https://code.alibabatech.com/schema/dubbo/dubbo.xsd
">

<!-- 当前应用信息配置 -->
<dubbo:application name="generic-provider" />

<!-- 连接注册中心配置 -->
<dubbo:registry address="N/A" />

<!-- 暴露服务协议配置 -->
<dubbo:protocol name="dubbo" port="20813" />

<!-- 暴露服务配置 -->
<dubbo:service id="dubboDemoService" generic="bean" interface="com.alibaba.dubbo.config.spring.api.DemoService" ref="demoService" />

<bean id="demoService" class="com.alibaba.dubbo.config.spring.GenericDemoService" />

</beans>

0 comments on commit e8970a0

Please sign in to comment.