33import com .qiniu .cdn .CdnManager ;
44import com .qiniu .common .QiniuException ;
55import com .qiniu .http .Response ;
6+ import com .qiniu .util .StringMap ;
67import org .junit .Assert ;
78import org .junit .Test ;
89
@@ -87,16 +88,55 @@ public void testGetCdnLogList() {
8788 }
8889
8990 @ Test
90- public void testCreateTimestampAntiLeechUrlSimple () {
91- String host = "http://img.abc.com" ;
92- String fileName = "2017/01/07/测试.png" ;
93- String queryString = "" ;
91+ public void testCreateTimestampAntiLeechUrlSimple1 () {
92+ String host = "http://video.example.com" ;
93+ String fileName = "2017/01/07/test.png" ;
94+
95+ long deadline = System .currentTimeMillis () / 1000 + 3600 ;
96+ String encryptKey = "xxx" ;
97+ String signedUrl ;
98+ try {
99+ signedUrl = CdnManager .createTimestampAntiLeechUrl (host , fileName ,
100+ null , encryptKey , deadline );
101+ System .out .println (signedUrl );
102+ } catch (Exception ex ) {
103+ ex .printStackTrace ();
104+ Assert .fail ();
105+ }
106+ }
107+
108+ @ Test
109+ public void testCreateTimestampAntiLeechUrlSimple2 () {
110+ String host = "http://video.example.com" ;
111+ String fileName = "基本概括.mp4" ;
112+ long deadline = System .currentTimeMillis () / 1000 + 3600 ;
113+ String encryptKey = "xxx" ;
114+ String signedUrl ;
115+ try {
116+ signedUrl = CdnManager .createTimestampAntiLeechUrl (host , fileName ,
117+ null , encryptKey , deadline );
118+ System .out .println (signedUrl );
119+ } catch (Exception ex ) {
120+ ex .printStackTrace ();
121+ Assert .fail ();
122+ }
123+ }
124+
125+
126+ @ Test
127+ public void testCreateTimestampAntiLeechUrlWithQueryString1 () {
128+ String host = "http://video.example.com" ;
129+ String fileName = "2017/01/07/test.png" ;
130+ StringMap queryStringMap = new StringMap ();
131+ queryStringMap .put ("name" , "七牛" );
132+ queryStringMap .put ("year" , 2017 );
133+ queryStringMap .put ("年龄" , 28 );
94134 long deadline = System .currentTimeMillis () / 1000 + 3600 ;
95- String encryptKey = "" ;
135+ String encryptKey = "xxx " ;
96136 String signedUrl ;
97137 try {
98138 signedUrl = CdnManager .createTimestampAntiLeechUrl (host , fileName ,
99- queryString , encryptKey , deadline );
139+ queryStringMap , encryptKey , deadline );
100140 System .out .println (signedUrl );
101141 } catch (Exception ex ) {
102142 ex .printStackTrace ();
@@ -105,16 +145,19 @@ public void testCreateTimestampAntiLeechUrlSimple() {
105145 }
106146
107147 @ Test
108- public void testCreateTimestampAntiLeechUrlWithQueryString () {
109- String host = "http://video.abc.com" ;
110- String fileName = "测试.mp4" ;
111- String queryString = "name=七牛&year=2017" ;
148+ public void testCreateTimestampAntiLeechUrlWithQueryString2 () {
149+ String host = "http://video.example.com" ;
150+ String fileName = "基本概括.mp4" ;
151+ StringMap queryStringMap = new StringMap ();
152+ queryStringMap .put ("name" , "七牛" );
153+ queryStringMap .put ("year" , 2017 );
154+ queryStringMap .put ("年龄" , 28 );
112155 long deadline = System .currentTimeMillis () / 1000 + 3600 ;
113- String encryptKey = "" ;
156+ String encryptKey = "xxx " ;
114157 String signedUrl ;
115158 try {
116159 signedUrl = CdnManager .createTimestampAntiLeechUrl (host , fileName ,
117- queryString , encryptKey , deadline );
160+ queryStringMap , encryptKey , deadline );
118161 System .out .println (signedUrl );
119162 } catch (Exception ex ) {
120163 ex .printStackTrace ();
0 commit comments