/**
- Created by duanchangliang on 16/6/27. */
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TestGenerator;
import com.yunpian.sdk.common.Config;
import com.yunpian.sdk.model.*;
import com.yunpian.sdk.service.*;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.*;
import java.util.*;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import static org.testng.Assert.assertEquals;
@RunWith(Parameterized.class)
public class SmsTest {
//private String getTellphone;
public static YunpianRestClient client;
// YunpianRestClient client = new YunpianRestClient();
@BeforeClass
public void init() {
client = new YunpianRestClient("your apikey");
}
@Parameters
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][]{
{"单条发送短信","18868212479","【测试内容】请提供",0,"发送成功","aa1c3eec10d5d52d560028833eee41b4" }
});
}
/***
* 第一个测试用例名称
* 第二、三个是为传参
* 第四、五个是为预期结果
* 第六个为apikey
* */
@Parameter(value = 0)
public String testcase;
@Parameter(value = 1)
public String tellphone;
@Parameter(value = 2)
public String smsmsg;
@Parameter(value = 3)
public int smscode;
@Parameter(value = 4)
public String backmsg;
@Parameter(value = 5)
public String apikey;
@Test
public void testSendSms() throws UnsupportedEncodingException{
YunpianRestClient client = new YunpianRestClient(apikey);
SmsOperator smsOperator = client.getSmsOperator();
System.out.println("apikey值为:" + apikey);
System.out.println("用户手机号为:" + tellphone);
// 单条发送
ResultDO<SendSingleSmsInfo> r1 =
smsOperator.singleSend(tellphone, smsmsg);
System.out.println(r1);
int code = r1.getData().getCode();
String msg = r1.getData().getMsg();
assertEquals(code, smscode);
assertEquals(msg,backmsg);
System.out.print(code);
}
}