junit

Activiti流程引擎配置实战

*爱你&永不变心* 提交于 2020-04-14 12:04:58
【推荐阅读】微服务还能火多久?>>> 一 pom <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.0.RELEASE</version> <relativePath/> </parent> <groupId>com.syc.activiti</groupId> <artifactId>activiti6-helloworld</artifactId> <version>1.0-SNAPSHOT</version> <dependencies>

Unit Testing - Wiremock verify failing with connection error

孤者浪人 提交于 2020-04-14 05:05:10
问题 I'm testing a spring-boot application and using wiremock stubs to mock external API. In one test case I want to make sure that my stub gets called exactly once but it's failing with connection error. My Test File: @SpringBootTest @AutoConfigureWebTestClient @ActiveProfiles("test") class ControllerTest { @Autowired private lateinit var webClient: WebTestClient private lateinit var wireMockServer: WireMockServer @BeforeEach fun setup() { wireMockServer = WireMockServer(8081) wireMockServer

谷歌Java编程风格指南

百般思念 提交于 2020-04-12 17:47:41
前言 这份文档是Google Java编程风格规范的完整定义。当且仅当一个Java源文件符合此文档中的规则, 我们才认为它符合Google的Java编程风格。 与其它的编程风格指南一样,这里所讨论的不仅仅是编码格式美不美观的问题, 同时也讨论一些约定及编码标准。然而,这份文档主要侧重于我们所普遍遵循的规则, 对于那些不是明确强制要求的,我们尽量避免提供意见。 1.1 术语说明 在本文档中,除非另有说明: 术语class可表示一个普通类,枚举类,接口或是annotation类型( @interface ) 术语comment只用来指代实现的注释(implementation comments),我们不使用“documentation comments”一词,而是用Javadoc。 其他的术语说明会偶尔在后面的文档出现。 1.2 指南说明 本文档中的示例代码并不作为规范。也就是说,虽然示例代码是遵循Google编程风格,但并不意味着这是展现这些代码的唯一方式。 示例中的格式选择不应该被强制定为规则。 源文件基础 2.1 文件名 源文件以其最顶层的类名来命名,大小写敏感,文件扩展名为 .java 。 2.2 文件编码:UTF-8 源文件编码格式为UTF-8。 2.3 特殊字符 2.3.1 空白字符 除了行结束符序列,ASCII水平空格字符(0x20,即空格

Servlet

╄→尐↘猪︶ㄣ 提交于 2020-04-11 13:40:45
Servlet 初始Servlet Servlet是sun公司提供的一门用于开发动态web资源的技术。   Sun公司在其API中提供了一个servlet接口,用户若想用发一个动态web资源(即开发一个Java程序向浏览器输出数据),需要完成以下2个步骤:   1、编写一个Java类,继承servlet接口。   2、把开发好的Java类部署到web服务器中。 按照一种约定俗成的称呼习惯,通常我们也把实现了servlet接口的java程序,称之为Servlet 用户可以通过浏览器的url访问到的一个Java小程序 单例多线程 创建web项目 Test_Servlet 第一个Servlet 1. 写一个Servlet类 2. 配置web.xml文件 //处理请求乱码 req.setCharacterEncoding("utf-8"); //处理响应乱码 resp.setContentType("text/html;charset=utf-8"); web项目的引入jar方式 1. 复制jar到项目\WebContent\WEB-INF\lib 下 2. Add to Build Path (若jar包没有自动出现) 进一步了解Servlet 1. 转发 携带数据 1.1 地址栏不变; 1.2 服务器内部跳转,浏览器不知道 1.3 公用一个request

Junit单元测试

谁说我不能喝 提交于 2020-04-11 13:18:56
单元测试Junit 一.测试的分类: 1.黑盒测试:不需要写代码,给输入值,看是否可以得到预期的结果。 2.白盒测试:需要写代码,需要关注程序具体的执行流程。 二.Junit使用 1.Junit属于白盒测试 步骤: 1.定义一个测试类(测试用例) 建议: 测试类名:被测试类+test 包名:xxx.xxx.xxx.tset 2.定义测试方法:可以独立运行 建议: 方法名:test+测试的方法名 返回值:void 参数列表:空参 3.给方法就爱注解(@test) @Before就是在执行一个方法之前必须要执行一些资源,那么我们可以将这些资源放在一个方法中,并添加@before注解 @After在方法执行结束后,进行一些扫尾的处理,例如关闭资源等 4.导入Junit的依赖环境 判定结果: 红色:失败 绿色:成功 在Junit中一般我们会进行断言操作(因为在Junit中一般会通过程序执行后的颜色来判断,而不是直接输出结果) 具体代码演示:以一个计算器的加减法为例 首先我们以main方法进行测试,代码如下: package com.gcy.calculate; /** * 创建一个计算器类(只做加法和减法) */ public class Calculate { /** * 加法 * @param a * @param b * @return */ public int add(int a

Using TestNG, is it possible to dynamically change the test name?

▼魔方 西西 提交于 2020-04-11 05:04:58
问题 Using TestNG, is it possible to dynamically change the test name with a method such as this one below? @Test(testName = "defaultName", dataProvider="tests") public void testLogin( int num, String reportName ) { System.out.println("Starting " + num + ": " + reportName); changeTestName("Test" + num); } 回答1: No, but your test class can implement org.testng.ITest and override getTestName() to return the name of your test. 回答2: For anybody still facing this. This can be done by implementing the

Unit Testing Freemarker templates in SpringBoot - unable to initialize freemarker configuration

我与影子孤独终老i 提交于 2020-04-10 14:57:26
问题 we are using Freemarker for generating the HTML code for the emails our application is going to be sending. Our usage and configuration is based off of https://github.com/hdineth/SpringBoot-freemaker-email-send Particularly: package com.example.techmagister.sendingemail.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.io.ResourceLoader; import org.springframework.ui.freemarker

Unit Testing Freemarker templates in SpringBoot - unable to initialize freemarker configuration

馋奶兔 提交于 2020-04-10 14:57:08
问题 we are using Freemarker for generating the HTML code for the emails our application is going to be sending. Our usage and configuration is based off of https://github.com/hdineth/SpringBoot-freemaker-email-send Particularly: package com.example.techmagister.sendingemail.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.io.ResourceLoader; import org.springframework.ui.freemarker

用栅栏(CyclicBarrier)实现高并发测试

杀马特。学长 韩版系。学妹 提交于 2020-04-10 14:38:58
CyclicBarrier 含义 栅栏允许两个或者多个线程在某个集合点同步。当一个线程到达集合点时,它将调用await()方法等待其它的线程。线程调用await()方法后,CyclicBarrier将阻塞这个线程并将它置入休眠状态等待其它线程的到来。等最后一个线程调用await()方法时,CyclicBarrier将唤醒所有等待的线程然后这些线程将继续执行。CyclicBarrier可以传入另一个Runnable对象作为初始化参数。当所有的线程都到达集合点后,CyclicBarrier类将Runnable对象作为线程执行。 方法 await():使线程置入休眠直到最后一个线程的到来之后唤醒所有休眠的线程 代码实现 原理:设置赛马集合点(线程启动需要一些时间),然后一起赛跑 package org.java; import java.util.concurrent.CyclicBarrier; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import org.junit.Test; public class TestCyclic { @Test public void test01() { int count = 10;// 并发 线程数