Skip to content

Commit

Permalink
DUBBO-194 增加覆盖测试用例
Browse files Browse the repository at this point in the history
git-svn-id: http://code.alibabatech.com/svn/dubbo/trunk@903 1a56cb94-b969-4eaa-88fa-be21384802f2
  • Loading branch information
william.liangf committed Feb 6, 2012
1 parent ed0d52b commit a956bd9
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -424,19 +424,44 @@ public void testSystemPropertyOverrideMultiProtocol() throws Exception {

@SuppressWarnings("unchecked")
@Test
public void testSystemPropertyOverride() throws Exception {
public void testSystemPropertyOverrideXmlDefault() throws Exception {
System.setProperty("dubbo.application.name", "sysover");
System.setProperty("dubbo.registry.address", "N/A");
System.setProperty("dubbo.protocol.name", "dubbo");
System.setProperty("dubbo.protocol.port", "20819");
ClassPathXmlApplicationContext providerContext = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/system-properties-override-default.xml");
providerContext.start();
try {
ServiceConfig<DemoService> service = (ServiceConfig<DemoService>) providerContext.getBean("demoServiceConfig");
assertEquals("sysover", service.getApplication().getName());
assertEquals("N/A", service.getRegistry().getAddress());
assertEquals("dubbo", service.getProtocol().getName());
assertEquals(20819, service.getProtocol().getPort().intValue());
} finally {
System.setProperty("dubbo.application.name", "");
System.setProperty("dubbo.registry.address", "");
System.setProperty("dubbo.protocol.name", "");
System.setProperty("dubbo.protocol.port", "");
providerContext.stop();
providerContext.close();
}
}

@SuppressWarnings("unchecked")
@Test
public void testSystemPropertyOverrideXml() throws Exception {
System.setProperty("dubbo.application.name", "sysover");
System.setProperty("dubbo.registry.address", "N/A");
System.setProperty("dubbo.protocol.name", "dubbo");
System.setProperty("dubbo.protocol.port", "20819");
ClassPathXmlApplicationContext providerContext = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/system-properties-override.xml");
providerContext.start();
try {
ServiceConfig<DemoService> serviceConfig = (ServiceConfig<DemoService>) providerContext.getBean("demoServiceConfig");
assertEquals("sysover", serviceConfig.getApplication().getName());
assertEquals("N/A", serviceConfig.getRegistry().getAddress());
assertEquals("dubbo", serviceConfig.getProtocol().getName());
assertEquals(20819, serviceConfig.getProtocol().getPort().intValue());
ServiceConfig<DemoService> service = (ServiceConfig<DemoService>) providerContext.getBean("demoServiceConfig");
URL url = service.toUrls().get(0);
assertEquals("sysover", url.getParameter("application"));
assertEquals("dubbo", url.getProtocol());
assertEquals(20819, url.getPort());
} finally {
System.setProperty("dubbo.application.name", "");
System.setProperty("dubbo.registry.address", "");
Expand Down Expand Up @@ -499,8 +524,8 @@ public void testSystemPropertyOverrideApi() throws Exception {
service.setProtocol(protocol);
service.export();

URL url = service.toUrls().get(0);
try {
URL url = service.toUrls().get(0);
assertEquals("sysover", url.getParameter("application"));
assertEquals("dubbo", url.getProtocol());
assertEquals(20834, url.getPort());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!--
- 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
-
- 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="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd
">

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

<bean id="demoService" class="com.alibaba.dubbo.config.provider.impl.DemoServiceImpl" />

</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@
http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd
">

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

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

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

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

Expand Down

0 comments on commit a956bd9

Please sign in to comment.