diff --git a/udf-starter-qrcode/src/test/java/org/itkk/udf/qrcode/QrCodeTest.java b/udf-starter-qrcode/src/test/java/org/itkk/udf/qrcode/QrCodeTest.java index 1cf3a22..b98d3c7 100644 --- a/udf-starter-qrcode/src/test/java/org/itkk/udf/qrcode/QrCodeTest.java +++ b/udf-starter-qrcode/src/test/java/org/itkk/udf/qrcode/QrCodeTest.java @@ -6,18 +6,30 @@ import com.google.zxing.NotFoundException; import org.itkk.udf.qrcode.domain.QrCodeRequest; import org.itkk.udf.qrcode.service.QrcodeService; import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; import java.io.IOException; /** * QrCodeTest */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = QrcodeService.class) public class QrCodeTest { + /** + * qrcodeService + */ + @Autowired + private QrcodeService qrcodeService; + @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); + String ans = qrcodeService.decode(img); System.out.println(ans); } @@ -28,7 +40,7 @@ public class QrCodeTest { try { QrCodeRequest request = new QrCodeRequest(); request.setContent(msg); - String out = new QrcodeService().parse(request); + String out = qrcodeService.parse(request); System.out.println(""); } catch (Exception e) { e.printStackTrace();