1 package com.foxinmy.weixin4j.mp.test;
2
3 import java.io.IOException;
4
5 import org.junit.Assert;
6 import org.junit.Before;
7 import org.junit.Test;
8
9 import com.foxinmy.weixin4j.exception.WeixinException;
10 import com.foxinmy.weixin4j.model.qr.QRParameter;
11 import com.foxinmy.weixin4j.model.qr.QRResult;
12 import com.foxinmy.weixin4j.mp.api.QrApi;
13
14
15
16
17
18
19
20
21
22 public class QRTest extends TokenTest {
23 private QrApi qrApi;
24
25 @Before
26 public void init() throws WeixinException {
27 qrApi = new QrApi(tokenManager);
28 }
29
30 @Test
31 public void temp_qr() throws WeixinException, IOException {
32 QRResult result = qrApi.createQR(QRParameter.createTemporaryQR(1200,
33 1200L));
34 Assert.assertTrue(!result.getTicket().isEmpty());
35 }
36
37 @Test
38 public void forever_qr_int() throws WeixinException, IOException {
39 QRResult result = qrApi.createQR(QRParameter.createPermanenceQR(2));
40 Assert.assertTrue(!result.getTicket().isEmpty());
41 }
42
43 @Test
44 public void forever_qr_str() throws WeixinException, IOException {
45 QRResult result = qrApi.createQR(QRParameter
46 .createPermanenceQR("1200中文"));
47 Assert.assertTrue(!result.getTicket().isEmpty());
48 }
49 }