添加简单的单元测试

This commit is contained in:
wangkang
2017-08-17 20:17:33 +08:00
parent ebf393d85b
commit cd2699db96
3 changed files with 46 additions and 1 deletions
+7
View File
@@ -15,6 +15,13 @@
</parent>
<!-- 依赖 -->
<dependencies>
<!-- spring-boot-starter-test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- udf-starter-core -->
<dependency>
<groupId>org.itkk.udf</groupId>
<artifactId>udf-starter-core</artifactId>
@@ -179,7 +179,7 @@ public class QrcodeService {
op.setDetectOptions(detectOptions);
}
// 背景相关
if (StringUtils.isBlank(request.getBgImg())) {
if (StringUtils.isNotBlank(request.getBgImg())) {
BgImgOptions bgImgOptions = new BgImgOptions();
bgImgOptions.setBgImg(ImageUtil.getByPath(request.getBgImg()));
bgImgOptions.setBgw(request.getBgw() == null ? 0 : request.getBgw());
@@ -0,0 +1,38 @@
package org.itkk.udf.qrcode;
import com.google.zxing.ChecksumException;
import com.google.zxing.FormatException;
import com.google.zxing.NotFoundException;
import org.itkk.udf.qrcode.domain.QrCodeRequest;
import org.itkk.udf.qrcode.service.QrcodeService;
import org.junit.Test;
import java.io.IOException;
/**
* QrCodeTest
*/
public class QrCodeTest {
@Test
public void testDepaseQrCode() throws FormatException, ChecksumException, NotFoundException, IOException {
String img = "https://static.oschina.net/uploads/img/201707/09205944_0PzS.jpg";
String ans = new QrcodeService().decode(img);
System.out.println(ans);
}
@Test
public void testGenQrCode1() {
String msg = "http://itkk.org:81";
try {
QrCodeRequest request = new QrCodeRequest();
request.setContent(msg);
String out = new QrcodeService().parse(request);
System.out.println("<img src=\"data:image/png;base64," + out + "\" />");
} catch (Exception e) {
e.printStackTrace();
}
}
}