springBoot dubbo junit 单元测试
依赖
<dependency><groupId>junit</groupId><artifactId>junit</artifactId><version> 4.12</version></dependency>
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency>
spring boot启动类
package com.zscat;import com.alibaba.dubbo.config.spring.context.annotation.DubboComponentScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.Bean;@DubboComponentScan("com.zscat.*.service")
@ServletComponentScan
@SpringBootApplication
public class BootdoApplication {public static void main(String[] args) {SpringApplication.run(BootdoApplication.class, args);System.out.println(" ______ _ ______ \n" + "|_ _ \\ / |_|_ _ `. \n"+ " | |_) | .--. .--. `| |-' | | `. \\ .--. \n"+ " | __'. / .'`\\ \\/ .'`\\ \\| | | | | |/ .'`\\ \\\n"+ " _| |__) || \\__. || \\__. || |, _| |_.' /| \\__. | \n"+ "|_______/ '.__.' '.__.' \\__/|______.' '.__.' ");}@Beanpublic EmbeddedServletContainerCustomizer containerCustomizer() {return new EmbeddedServletContainerCustomizer() {
// ErrorPage error401Page = new ErrorPage(HttpStatus.UNAUTHORIZED, "/401.html");
// ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/404.html");
// ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/500.html");@Overridepublic void customize(ConfigurableEmbeddedServletContainer container) {
// container.addErrorPages(error401Page, error404Page, error500Page);container.setSessionTimeout(3600*6);// 单位为S 6个小时}};}
}
单元测试类
package com.jjz.test;import cn.hutool.json.JSONUtil;
import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.dubbo.config.spring.context.annotation.DubboComponentScan;
import com.alibaba.fastjson.JSON;
import com.zscat.BootdoApplication;
import com.zscat.auxiliarySupplier.domain.Purchase_OrderList;
import com.zscat.auxiliarySupplier.service.Purchase_OrderListService;
import com.zscat.erp.domain.SaleOrderDO;
import com.zscat.erp.goods.service.SkuService;
import com.zscat.erp.service.SaleOrderRealService;
import com.zscat.erp.service.SaleOrderService;
import org.apache.commons.collections.map.HashedMap;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit4.SpringRunner;import java.io.File;
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.*;@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = BootdoApplication.class)
public class TestT{@Reference(version = "1.0.0")private SaleOrderService saleOrderService;@Reference(version = "1.0.0")private SaleOrderRealService saleOrderRealService;@Testpublic void test8(){System.out.println("测试开始*************************!");SaleOrderDO sd=saleOrderService.get(10);saleOrderRealService.synchronizationERP(sd,null,null);System.out.println("测试结束*************************!");}@Testpublic void test(){try {Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");}catch (Exception e){e.printStackTrace();}String url = "jdbc:sqlserver://47.93.186.191:1433;DatabaseName=WMS_JiangJiang_Test";Connection conn;try{conn = DriverManager.getConnection(url,"wms_dev","wms@123qaz");Statement stmt = conn.createStatement();System.out.println("Mysql数据库连接成功!");String sql = "select SourceId from dbo.Purchase_OrderList where OrderList_Id = 4185";ResultSet rs = stmt.executeQuery(sql);System.out.println("测试数据::::::");while (rs.next()){System.out.print(rs.getString(1) + "\t");System.out.println();}rs.close();stmt.close();conn.close();}catch (Exception e){e.printStackTrace();}System.out.println("-----测试完毕-------");}public static void main(String[] args) {List<jsonmodel> list=new ArrayList<>();jsonmodel jsonmodel=new jsonmodel();jsonmodel.setBelongid(1);jsonmodel.setImgurl("df::asd");jsonmodel.setFiledesc("azh这和");list.add(jsonmodel);jsonmodel jsonmodel1=new jsonmodel();jsonmodel1.setBelongid(2);jsonmodel1.setImgurl("苏尼加");jsonmodel1.setFiledesc("饿不也不用");list.add(jsonmodel1);list.remove(0);System.out.println(list.get(0));}}
springBoot dubbo junit 单元测试相关推荐
- springboot使用junit单元测试是发生报错 Field taskUtils in com.xxx.xxx.xxxx.xxx required a bean of type 'xxx.xxx.
使用junit单元测试mybatis时发生如下错误 Error starting ApplicationContext. To display the conditions report re-run ...
- SpringBoot Junit单元测试
Junit单元测试 import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.te ...
- springBoot+dubbo整合Redis - 脚手架系列(三)
1.介绍 Redis(Remote Dictionary Server) 是一个使用 C 语言编写的,开源的(BSD许可)高性能非关系型(NoSQL)的键值对数据库. Redis 可以存储键和五种不同 ...
- java 单元测试_在springboot中写单元测试解决依赖注入和执行后事务回滚问题
往期文章 「Java并发编程」谈谈Java中的内存模型JMM 面试官:说说你知道多少种线程池拒绝策略 为什么不要在MySQL中使用UTF-8编码方式 前言 很多公司都有写单元测试的硬性要求,在提交代码 ...
- springboot 事务嵌套问题_在springboot中写单元测试解决依赖注入和执行后事务回滚问题...
往期文章 「Java并发编程」谈谈Java中的内存模型JMM 面试官:说说你知道多少种线程池拒绝策略 为什么不要在MySQL中使用UTF-8编码方式 前言 很多公司都有写单元测试的硬性要求,在提交代码 ...
- springboot+dubbo
本节将简单整合SpringBoot+Duboo吐舌头 1.Zookeeper的安装: 1 从官网下载你喜欢的zookeeper的版本: http://mirrors.hust.edu.cn/apach ...
- springboot集成Junit在执行测试类的时候提示Failed to resolve异常
项目场景:springboot集成Junit在执行测试类的时候提示Failed to resolve异常 项目场景:springboot版本2.5.7,Junit版本:4.13.2,在执行测试类的时候 ...
- spring-boot重头再来 6 分布式理论 RPC远程过程调用 Zookeeper安装 Dubbo SpringBoot + Dubbo + zookeeper Spring Security
spring-boot重头再来 6 文章目录 spring-boot重头再来 6 分布式理论 RPC远程过程调用 Zookeeper安装 Dubbo dubbo-admin安装 dubbo-admin ...
- springboot+dubbo+zookeeper+maven搭建微服务详细教程
前言: 本文将使用springboot+dubbo+zookeeper+maven搭建一套微服务. 需要提前在本地配置的环境: maven环境 zookeeper环境(在我本地zookeeper在21 ...
- SpringBoot+Dubbo+环信(即时通信)整合
SpringBoot+Dubbo+环信(即时通信)整合 1.注册环信账号 官网:https://www.easemob.com/ 稳定健壮,消息必达,亿级并发的即时通讯云 2. 了解平台架构 文档地址 ...
最新文章
- Python工具 | 9个用来爬取网络站点的 Python 库
- [20181204]低版本toad 9.6直连与ora-12505.txt
- 清单文件,测试,打电话和发短信应用
- Linux新手上路命令
- html框架实验总结,网页设计实训心得
- VS2015配置内核WDK7600环境,32位下.
- opencv (一) 学习通过OpenCV图形界面及基础
- C#递归、动态规划计算斐波那契数列
- 跨越原理优缺点_请教:单管跨越式和双管式的优缺点
- 教你做炫酷的蜂巢式图片墙
- 永远不要随便告诉别人自己的工资,工资是职场最大的陷阱
- openmv自然光下寻找激光点
- 计算机没有无线网卡驱动程序,win10系统的无线网卡驱动没了的解决方法
- python内置函数dict()
- 算法:(七)模拟算法
- 地铁口多了一堆小卡片,事情并不简单?
- 屌丝Cent OS服务解密
- 入门级C语言—利用特殊符号绘制简易中国象棋棋盘(无棋子)
- 论文笔记27 -- (视频压缩)Learned Video Codec with Enriched Reconstruction for CLIC P-frame Coding
- Instant-Meshes-标架场方法