mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add constructor
This commit is contained in:
@@ -30,7 +30,7 @@ public class CaptchaTest {
|
||||
@Test
|
||||
public void lineCaptchaTest1() {
|
||||
// 定义图形验证码的长和宽
|
||||
final LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(200, 100);
|
||||
final LineCaptcha lineCaptcha = CaptchaUtil.ofLineCaptcha(200, 100);
|
||||
Assertions.assertNotNull(lineCaptcha.getCode());
|
||||
Assertions.assertTrue(lineCaptcha.verify(lineCaptcha.getCode()));
|
||||
}
|
||||
@@ -39,7 +39,7 @@ public class CaptchaTest {
|
||||
@Disabled
|
||||
public void lineCaptchaTest3() {
|
||||
// 定义图形验证码的长和宽
|
||||
final LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(200, 70, 4, 15);
|
||||
final LineCaptcha lineCaptcha = CaptchaUtil.ofLineCaptcha(200, 70, 4, 15);
|
||||
lineCaptcha.setBackground(Color.yellow);
|
||||
lineCaptcha.write("f:/test/captcha/tellow.png");
|
||||
}
|
||||
@@ -48,7 +48,7 @@ public class CaptchaTest {
|
||||
@Disabled
|
||||
public void lineCaptchaWithMathTest() {
|
||||
// 定义图形验证码的长和宽
|
||||
final LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(200, 80);
|
||||
final LineCaptcha lineCaptcha = CaptchaUtil.ofLineCaptcha(200, 80);
|
||||
lineCaptcha.setGenerator(new MathGenerator());
|
||||
lineCaptcha.setTextAlpha(0.8f);
|
||||
lineCaptcha.write("f:/captcha/math.png");
|
||||
@@ -59,7 +59,7 @@ public class CaptchaTest {
|
||||
public void lineCaptchaTest2() {
|
||||
|
||||
// 定义图形验证码的长和宽
|
||||
final LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(200, 100);
|
||||
final LineCaptcha lineCaptcha = CaptchaUtil.ofLineCaptcha(200, 100);
|
||||
// LineCaptcha lineCaptcha = new LineCaptcha(200, 100, 4, 150);
|
||||
// 图形验证码写出,可以写出到文件,也可以写出到流
|
||||
lineCaptcha.write("f:/captcha/line.png");
|
||||
@@ -79,7 +79,7 @@ public class CaptchaTest {
|
||||
public void circleCaptchaTest() {
|
||||
|
||||
// 定义图形验证码的长和宽
|
||||
final CircleCaptcha captcha = CaptchaUtil.createCircleCaptcha(200, 100, 4, 20);
|
||||
final CircleCaptcha captcha = CaptchaUtil.ofCircleCaptcha(200, 100, 4, 20);
|
||||
// CircleCaptcha captcha = new CircleCaptcha(200, 100, 4, 20);
|
||||
// 图形验证码写出,可以写出到文件,也可以写出到流
|
||||
captcha.write("f:/captcha/circle.png");
|
||||
@@ -92,7 +92,7 @@ public class CaptchaTest {
|
||||
public void shearCaptchaTest() {
|
||||
|
||||
// 定义图形验证码的长和宽
|
||||
final ShearCaptcha captcha = CaptchaUtil.createShearCaptcha(203, 100, 4, 4);
|
||||
final ShearCaptcha captcha = CaptchaUtil.ofShearCaptcha(203, 100, 4, 4);
|
||||
// ShearCaptcha captcha = new ShearCaptcha(200, 100, 4, 4);
|
||||
// 图形验证码写出,可以写出到文件,也可以写出到流
|
||||
captcha.write("f:/captcha/shear.png");
|
||||
@@ -116,7 +116,7 @@ public class CaptchaTest {
|
||||
@Disabled
|
||||
public void ShearCaptchaWithMathTest() {
|
||||
// 定义图形验证码的长和宽
|
||||
final ShearCaptcha captcha = CaptchaUtil.createShearCaptcha(200, 45, 4, 4);
|
||||
final ShearCaptcha captcha = CaptchaUtil.ofShearCaptcha(200, 45, 4, 4);
|
||||
captcha.setGenerator(new MathGenerator());
|
||||
// ShearCaptcha captcha = new ShearCaptcha(200, 100, 4, 4);
|
||||
// 图形验证码写出,可以写出到文件,也可以写出到流
|
||||
@@ -128,7 +128,7 @@ public class CaptchaTest {
|
||||
@Test
|
||||
@Disabled
|
||||
public void GifCaptchaTest() {
|
||||
final GifCaptcha captcha = CaptchaUtil.createGifCaptcha(200, 100, 4);
|
||||
final GifCaptcha captcha = CaptchaUtil.ofGifCaptcha(200, 100, 4);
|
||||
captcha.write("d:/test/gif_captcha.gif");
|
||||
assert captcha.verify(captcha.getCode());
|
||||
}
|
||||
@@ -136,7 +136,7 @@ public class CaptchaTest {
|
||||
@Test
|
||||
@Disabled
|
||||
public void bgTest(){
|
||||
final LineCaptcha captcha = CaptchaUtil.createLineCaptcha(200, 100, 4, 1);
|
||||
final LineCaptcha captcha = CaptchaUtil.ofLineCaptcha(200, 100, 4, 1);
|
||||
captcha.setBackground(Color.WHITE);
|
||||
captcha.write("d:/test/test.jpg");
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ public class CaptchaUtilTest {
|
||||
@Disabled
|
||||
public void createTest() {
|
||||
for(int i = 0; i < 1; i++) {
|
||||
CaptchaUtil.createShearCaptcha(320, 240);
|
||||
CaptchaUtil.ofShearCaptcha(320, 240);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user