Skip to content

Commit 8c34089

Browse files
committed
Merge pull request #133 from longbai/fixed-unit-test
update doc
2 parents c1d3962 + 12291cd commit 8c34089

File tree

6 files changed

+33
-46
lines changed

6 files changed

+33
-46
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
[![Qiniu Logo](http://qiniutek.com/images/logo-2.png)](http://qiniu.com/)
66

7-
此 Java SDK 适用于 Java 6 及以上版本,基于 [七牛云存储官方API](http://docs.qiniutek.com/v2/api/) 构建。使用此 SDK 构建您的网络应用程序,能让您以非常便捷地方式将数据安全地存储到七牛云存储上。无论您的网络应用是一个网站程序,还是包括从云端(服务端程序)到终端(手持设备应用)的架构的服务或应用,通过七牛云存储及其 SDK,都能让您应用程序的终端用户高速上传和下载,同时也让您的服务端更加轻盈。
7+
此 Java SDK 适用于 Java 6 及以上版本,基于 [七牛云存储官方API](http://developer.qiniu.com/docs/v6/sdk/java-sdk.html) 构建。使用此 SDK 构建您的网络应用程序,能让您以非常便捷地方式将数据安全地存储到七牛云存储上。无论您的网络应用是一个网站程序,还是包括从云端(服务端程序)到终端(手持设备应用)的架构的服务或应用,通过七牛云存储及其 SDK,都能让您应用程序的终端用户高速上传和下载,同时也让您的服务端更加轻盈。
88

99

1010
## 安装
@@ -38,7 +38,7 @@
3838

3939
## 许可证
4040

41-
Copyright (c) 2012 qiniutek.com
41+
Copyright (c) 2012-2014 qiniu.com
4242

4343
基于 MIT 协议发布:
4444

src/test/java/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Qiniu Resource (Cloud) Storage SDK demo for Java
1+
# Qiniu Resource (Cloud) Storage SDK demo for Java
22

33
# 关于
44
这些demo都是基于 Qiniu Resource (Cloud) Storage SDK for Java 开发的。其中RSDemo.java演示了服务端进行资源上传,下载,删除,发布,取消发布等功能的演示。
5-
其中Notifier.java 和 UpDemo.java 演示了客户端进行断点续上传。
5+
其中Notifier.java 和 UpDemo.java 演示了客户端进行断点续上传。
66
在ResumableNotifier.java和ResumablePutDemo.java中对客户端在断点续上传过程中的状态进行了序列化,使客户在上传过程中即使程序崩溃或者退出在下次重新启动时还可以接着上次继续上次。
77
ResumableGUINotifier.java 和 ResumableGUIputDemo.java 则添加了客户在断点续上传时的UI,使上传更加直观。
88

@@ -13,15 +13,15 @@
1313

1414
## 使用
1515
要接入七牛云存储,您需要拥有一对有效的 Access Key 和 Secret Key 用来进行签名认证。可以通过如下步骤获得:
16-
[开通七牛开发者账号](https://dev.qiniutek.com/signup)
17-
[登录七牛开发者自助平台,查看Access Key 和 Secret Key](https://dev.qiniutek.com/account/keys)
16+
[开通七牛开发者账号](https://portal.qiniu.com/signup)
17+
[登录七牛开发者自助平台,查看Access Key 和 Secret Key](https://portal.qiniu.com/setting/key)
1818
然后把得到的Access Key 和 Secret Key 写入每个demo中后。
1919
1.RSDemo可以直接运行。
2020
2.ResumablePutDemo 和 ResumableGUIPutDemo 则需要传入 要上传文件的具体路径加文件名 作为参数。
2121
在eclipse中您可以这样添加:选中您要运行的demo-->右键-->选中 Build Path-->Run/Debug Settings-->双击你要运行的demo-->选中 ‘(x)=Arguments’ 选项卡-->在Program arguments中加入要传入的参数。
2222
在命令窗口下:”java 您要运行的demo 参数” 把参数改成你的实际参数。
2323
(你也可以在demo中把 String inputFile = args[0];中的args[0]换成你的参数)
24-
参考文档:[七牛云存储 Java SDK 使用指南](http://docs.qiniutek.com/v2/sdk/java/)
24+
参考文档:[七牛云存储 Java SDK 使用指南](http://developer.qiniu.com/docs/v6/sdk/java-sdk.html)
2525

2626
## 贡献代码
2727

@@ -33,7 +33,7 @@
3333

3434
## 许可证
3535

36-
Copyright (c) 2012 qiniutek.com
36+
Copyright (c) 2012-2014 qiniu.com
3737

3838
基于 MIT 协议发布:
3939

src/test/java/com/qiniu/testing/IOTest.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -106,53 +106,53 @@ private String getJsonValue(JSONObject jsonObject, String name){
106106
return null;
107107
}
108108
}
109-
109+
110110
public void testNoLengthStream() throws Exception {
111111
PutPolicy p = new PutPolicy(bucketName);
112112
p.returnBody = "{\"key\": $(key), \"hash\": $(etag),\"mimeType\": $(mimeType)}";
113113
String upToken = p.token(mac);
114-
115-
HttpEntity en = getHttpEntity("http://qiniuphotos.qiniudn.com/gogopher.jpg");
116-
114+
115+
HttpEntity en = getHttpEntity("http://testres.qiniudn.com/gogopher.jpg");
116+
117117
class MyInputStream extends InputStream{
118118
InputStream in;
119119
MyInputStream(InputStream is){
120120
this.in = is;
121121
}
122-
122+
123123
@Override
124124
public int read() throws IOException {
125125
// TODO Auto-generated method stub
126126
return in.read();
127127
}
128-
128+
129129
public int available() throws IOException {
130130
throw new IOException();
131131
}
132-
132+
133133
public void close() throws IOException {
134134
in.close();
135135
}
136-
136+
137137
}
138-
139138

140-
139+
140+
141141
PutRet ret = IoApi.Put(upToken, key, new MyInputStream(en.getContent()), null);
142-
142+
143143
assertTrue(ret.ok());
144144
}
145-
145+
146146
public void testSetLengthStream() throws Exception {
147147
PutPolicy p = new PutPolicy(bucketName);
148148
p.returnBody = "{\"key\": $(key), \"hash\": $(etag),\"mimeType\": $(mimeType)}";
149149
String upToken = p.token(mac);
150-
151-
HttpEntity en = getHttpEntity("http://qiniuphotos.qiniudn.com/gogopher.jpg");
150+
151+
HttpEntity en = getHttpEntity("http://testres.qiniudn.com/gogopher.jpg");
152152
PutExtra extra = new PutExtra();
153153
extra.mimeType = en.getContentType().getValue();
154154
PutRet ret = IoApi.Put(upToken, key, en.getContent(), extra, en.getContentLength());
155-
155+
156156
assertTrue(ret.ok());
157157
}
158158

src/test/java/com/qiniu/testing/RSFTest.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class RSFTest extends TestCase {
2525
public final String expectedHash = "FmDZwqadA4-ib_15hYfQpb7UXUYR";
2626

2727
public String bucketName;
28-
28+
2929
public Mac mac;
3030
@Override
3131
public void setUp() {
@@ -41,7 +41,6 @@ public void setUp() {
4141
mac = new Mac(Config.ACCESS_KEY, Config.SECRET_KEY);
4242
}
4343

44-
// just upload an image in testdata.
4544
public void testRSF() throws Exception {
4645
{
4746
String uptoken = new PutPolicy(bucketName).token(mac);
@@ -56,14 +55,14 @@ public void testRSF() throws Exception {
5655
assertTrue(ret.ok());
5756
assertTrue(expectedHash.equals(ret.getHash()));
5857
}
59-
58+
6059
}
6160
// we don't checkout the result of how may items are in the buckets.
6261
// not very convient, it's better, although.
6362
{
6463
RSFClient client = new RSFClient(mac);
6564
String marker = "";
66-
65+
6766
List<ListItem> all = new ArrayList<ListItem>();
6867
ListPrefixRet ret = null;
6968
while (true) {
@@ -77,14 +76,9 @@ public void testRSF() throws Exception {
7776
}
7877
if (ret.exception.getClass() != RSFEofException.class) {
7978
// error handler
80-
}
81-
79+
}
80+
8281
assertTrue(all.size() >= 3);
8382
}
8483
}
85-
86-
@Override
87-
public void tearDown() {
88-
// do nothing here.
89-
}
90-
}
84+
}

src/test/java/com/qiniu/testing/ResumeableioTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,15 @@ private void uploadStream() throws AuthException, JSONException, FileNotFoundExc
112112
assertEquals(mimeType, mt);
113113
}
114114
}
115-
115+
116116
public void testStream() throws Exception {
117117
PutPolicy p = new PutPolicy(bucketName);
118118
p.returnBody = "{\"key\": $(key), \"hash\": $(etag),\"mimeType\": $(mimeType)}";
119119
String upToken = p.token(mac);
120-
121-
HttpEntity en = getHttpEntity("http://qiniuphotos.qiniudn.com/gogopher.jpg");
120+
121+
HttpEntity en = getHttpEntity("http://testres.qiniudn.com/gogopher.jpg");
122122
PutRet ret = ResumeableIoApi.put(en.getContent(), upToken, currentKey, en.getContentType().getValue(), en.getContentLength());
123-
123+
124124
assertTrue(ret.ok());
125125
}
126126

src/test/java/com/qiniu/testing/UtilTest.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,11 @@
66
import com.qiniu.api.net.EncodeUtils;
77

88
public class UtilTest extends TestCase {
9-
10-
// just upload an image in testdata.
119
public void test() throws Exception {
1210
String expectString = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ~!@#$%^&*()_+}{:?><-=,./;'[]";
1311
String encodedString = "MTIzNDU2Nzg5MGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVp-IUAjJCVeJiooKV8rfXs6Pz48LT0sLi87J1td";
1412
byte[] rawBytes = EncodeUtils.urlsafeBase64Decode(encodedString);
1513
String decoded = new String(rawBytes);
1614
assertTrue(expectString.equals(decoded));
1715
}
18-
19-
@Override
20-
public void tearDown() {
21-
// do nothing here.
22-
}
2316
}

0 commit comments

Comments
 (0)