spring 整合dubbo 測試搭建
zookeeper:
<!-- zookeeper工具包 -->
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.3.5</version>
</dependency>
<!-- zookeeper 第三方client -->
<dependency>
<groupId>com.101tec</groupId>
<artifactId>zkclient</artifactId>
<version>0.7</version>
</dependency>
dubbo:
<!-- dubbo -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>2.4.9</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
</exclusions>
</dependency>
junit
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>4.1.7.RELEASE</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
</dependency>
package com.konglingfu.dubbo;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.xinnet.app.nofc.api.NewOfficeAPI;
import com.xinnet.app.nofc.vo.NewOfficeVO;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:spring-dubbo.xml")
public class DubboTest extends AbstractJUnit4SpringContextTests {
@Autowired
private NewOfficeAPI newOffice;
@Test
public void testDubbo(){
NewOfficeVO newOfficeVO = new NewOfficeVO();
newOfficeVO.setProductCode("AE0363421893383816");
newOfficeVO.setServiceCode("A75906223276350");
newOfficeVO.setGoodCode("63324082302807");
newOfficeVO.setGoodsType("01");
newOfficeVO.setServiceType("01");//服務狀態 開通 續費 升級 停止
newOfficeVO.setAgentCode("hy439009");
newOfficeVO.setYear(5D);
newOfficeVO.setUserNumbers("120");
newOfficeVO.setCompanyName("xinnent");
newOfficeVO.setAccount("hy439009");
newOfficeVO.setMemberName("xingzejiang");
newOfficeVO.setEmail("konglingfu@xinnet.com");
newOfficeVO.setMobile("18210568873");
newOfficeVO.setEdition("standard");
String result = newOffice.openService(newOfficeVO);
System.out.println(result);
}
@Test
public void testDubbo1(){
List<NewOfficeVO> list = newOffice.getNewOfficeByAgentCode("hy439009");
for(NewOfficeVO vo:list){
System.out.println(vo.toString());
}
}
}
consumer-nofc.xml 消費者
<?xml version="1.0" encoding="UTF-8"?>
<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.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<!-- 消費方:呼叫介面 -->
<!-- 測試: 引入新辦公服務介面 -->
<dubbo:reference id="newOffice" interface="com.xinnet.app.nofc.api.NewOfficeAPI" check="false" />
</beans>
spring-dubbo.xml
<?xml version="1.0" encoding="UTF-8"?>
<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-4.2.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<!-- 提供方應用資訊,用於計算依賴關係 -->
<dubbo:application name="xinnetMemberFront-provider" />
<!-- 使用zookeeper註冊中心暴露服務地址 -->
<dubbo:registry protocol="zookeeper" address="IP地址:埠2181" />
<!-- 用dubbo協議在20880埠暴露服務 -->
<dubbo:protocol name="dubbo" port="20882" />
<import resource="classpath*:consumer-*.xml" />
</beans>
相關文章
- spring boot 整合測試Spring Boot
- Spring+ActiveMQ整合測試SpringMQ
- Spring Boot 整合 Apache DubboSpring BootApache
- Spring+MyBatis+JUnit整合測試的搭建過程總結SpringMyBatis
- Spring+SpringMvc+Mybatis框架整合搭建教程三(框架整合測試程式開發)SpringMVCMyBatis框架
- Dubbo想要個閘道器怎麼辦?試試整合Spring Cloud GatewaySpringCloudGateway
- Mokito 單元測試與 Spring-Boot 整合測試Springboot
- Dubbo原始碼分析(一)Dubbo與Spring整合例項原始碼Spring
- Spring+SpringMvc+Mybatis框架整合搭建教程四(專案部署及測試)SpringMVCMyBatis框架
- Spring、Spring Boot和TestNG測試指南 – 整合測試中用Docker建立資料庫Spring BootDocker資料庫
- Spring Boot單元和整合測試概述 | rieckpilSpring BootKPI
- 如何在Spring Boot中實現整合測試?Spring Boot
- Jmeter實現 Dubbo介面測試JMeter
- .netcore持續整合測試篇之搭建記憶體伺服器進行整合測試一NetCore記憶體伺服器
- 整合測試——Spring TestContext框架支援詳細解說SpringContext框架
- 使用 MeterSphere 進行 Dubbo 介面測試
- 微服務整合Spring Cloud Zipkin實現鏈路追蹤並整合Dubbo微服務SpringCloud
- flutter driver 整合測試Flutter
- 搭建持續整合介面測試平臺(Jenkins+Ant+Jmeter)JenkinsJMeter
- Flutter 學習之路 - 測試(單元測試,Widget 測試,整合測試)Flutter
- 官方 Dubbo Spring Boot Starter 1.0.0 公測版Spring Boot
- SpringBoot整合測試Spring Boot
- Jenkins+Ant+Jmeter搭建持續整合的介面測試平臺JenkinsJMeter
- Spring、Spring Boot和TestNG測試指南 – 共享測試配置Spring Boot
- Shiro(環境搭建與Spring整合)Spring
- 乾貨 | Dubbo 介面測試技術,測試開發進階必備
- 開發者測試(4)-採用精準測試工具對dubbo微服務應用進行測試微服務
- SpringBoot整合DubboSpring Boot
- .Net單元測試xUnit和整合測試指南(1)
- Dubbo環境搭建
- 黑盒測試、白盒測試、單元測試、整合測試、系統測試、驗收測試的區別與聯絡...
- spring mvc dubbo ios android整合cms內容釋出平臺SpringMVCiOSAndroid
- Spring+SpringMVC+Mybatis框架整合搭建教程SpringMVCMyBatis框架
- Jbpm4環境搭建和整合SpringSpring
- 軟體測試---單元、整合、系統、驗收測試
- 測試你的前端程式碼 – part4(整合測試)前端
- Go 單元測試之Mysql資料庫整合測試GoMySql資料庫
- 基於Dubbo的http自動測試工具分享HTTP