Skip to content

Commit cbc097e

Browse files
authored
Merge pull request #397 from YangSen-qn/master
change changelog
2 parents cb4de6f + d4c52ea commit cbc097e

File tree

18 files changed

+216
-46
lines changed

18 files changed

+216
-46
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#Changelog
22

3+
# 7.6.4
4+
* 修复io异常
5+
36
# 7.6.3
47
* 新增表单上传日志打点
58

Qiniu_Android.iml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module external.linked.project.id="Qiniu_Android" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
3+
<component name="FacetManager">
4+
<facet type="java-gradle" name="Java-Gradle">
5+
<configuration>
6+
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
7+
<option name="BUILDABLE" value="false" />
8+
</configuration>
9+
</facet>
10+
</component>
11+
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="true">
12+
<exclude-output />
13+
<content url="file://$MODULE_DIR$">
14+
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
15+
</content>
16+
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
17+
<orderEntry type="sourceFolder" forTests="false" />
18+
</component>
19+
</module>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.qiniu.android;
2+
3+
import android.test.AndroidTestCase;
4+
5+
import com.qiniu.android.bigdata.Configuration;
6+
7+
public class BigDataConfigurationTest extends AndroidTestCase {
8+
9+
public void testCopy(){
10+
Configuration configuration = new Configuration();
11+
configuration.connectTimeout = 15;
12+
13+
Configuration configurationCopy = Configuration.copy(configuration);
14+
15+
assertTrue(configurationCopy.connectTimeout == configuration.connectTimeout);
16+
}
17+
18+
public void testCopyNoValue(){
19+
Configuration configuration = null;
20+
21+
Configuration configurationCopy = Configuration.copy(configuration);
22+
23+
assertTrue(configurationCopy != null);
24+
}
25+
}

library/src/androidTest/java/com/qiniu/android/CancelTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public boolean isCancelled() {
112112
});
113113
runTestOnUiThread(new Runnable() { // THIS IS THE KEY TO SUCCESS
114114
public void run() {
115-
uploadManager.put(tempFile, expectKey, TestConfig.token_z0, new UpCompletionHandler() {
115+
uploadManager.put(tempFile, expectKey, TestConfig.commonToken, new UpCompletionHandler() {
116116
public void complete(String k, ResponseInfo rinfo, JSONObject response) {
117117
temp.expectKey = expectKey;
118118
temp.key = k;
@@ -179,7 +179,7 @@ public boolean isCancelled() {
179179
});
180180
runTestOnUiThread(new Runnable() { // THIS IS THE KEY TO SUCCESS
181181
public void run() {
182-
uploadManager.put(tempDate, expectKey, TestConfig.token_z0, new UpCompletionHandler() {
182+
uploadManager.put(tempDate, expectKey, TestConfig.commonToken, new UpCompletionHandler() {
183183
public void complete(String k, ResponseInfo rinfo, JSONObject response) {
184184
temp.expectKey = expectKey;
185185
temp.key = k;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.qiniu.android;
2+
3+
import android.test.AndroidTestCase;
4+
5+
import com.qiniu.android.collect.Config;
6+
7+
public class CollectConfigTest extends AndroidTestCase {
8+
9+
public void testQuick(){
10+
Config.quick();
11+
assertTrue(Config.uploadThreshold == 1024);
12+
assertTrue(Config.interval == 2);
13+
}
14+
15+
public void testNormal(){
16+
Config.normal();
17+
assertTrue(Config.uploadThreshold == 4*1024);
18+
assertTrue(Config.interval == 10);
19+
}
20+
21+
public void testSlow(){
22+
Config.slow();
23+
assertTrue(Config.uploadThreshold == 150*1024);
24+
assertTrue(Config.interval == 300);
25+
}
26+
}

library/src/androidTest/java/com/qiniu/android/DnsApiTest.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import java.io.IOException;
2727
import java.net.InetAddress;
2828
import java.net.UnknownHostException;
29+
import java.util.ArrayList;
30+
import java.util.HashMap;
2931
import java.util.List;
3032
import java.util.concurrent.ConcurrentHashMap;
3133

@@ -39,6 +41,33 @@ public class DnsApiTest extends AndroidTestCase {
3941
@Override
4042
protected void setUp() throws Exception {
4143
configuration = new Configuration.Builder().build();
44+
DnsPrefetcher dnsPrefetcher = DnsPrefetcher.getDnsPrefetcher();
45+
dnsPrefetcher.setToken(TestConfig.commonToken);
46+
}
47+
48+
public void testConcurrentHashMap(){
49+
InetAddress address = null;
50+
try {
51+
address = InetAddress.getByName("127.0.0.1");
52+
} catch (UnknownHostException e) {
53+
e.printStackTrace();
54+
}
55+
56+
if (address == null){
57+
return;
58+
}
59+
60+
List<InetAddress> addressList = new ArrayList<>();
61+
addressList.add(address);
62+
63+
ConcurrentHashMap<String, List<InetAddress>> hashMap = new ConcurrentHashMap<>();
64+
hashMap.put("localhost", addressList);
65+
66+
DnsPrefetcher dnsPrefetcher = DnsPrefetcher.getDnsPrefetcher();
67+
dnsPrefetcher.setConcurrentHashMap(hashMap);
68+
69+
assertTrue(hashMap == dnsPrefetcher.getConcurrentHashMap());
70+
4271
}
4372

4473
public void testDns() throws Throwable {

library/src/androidTest/java/com/qiniu/android/FormUploadTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,23 @@ public class FormUploadTest extends InstrumentationTestCase {
3131
public void setUp() throws Exception {
3232
this.uploadManager = new UploadManager();
3333
this.bucketTokenMap = new HashMap<>();
34-
this.bucketTokenMap.put(TestConfig.bucket_z0, TestConfig.token_z0);
35-
this.bucketTokenMap.put(TestConfig.bucket_z1, TestConfig.token_z1);
36-
this.bucketTokenMap.put(TestConfig.bucket_z2, TestConfig.token_z2);
34+
// this.bucketTokenMap.put(TestConfig.bucket_z0, TestConfig.token_z0);
35+
// this.bucketTokenMap.put(TestConfig.bucket_z1, TestConfig.token_z1);
36+
// this.bucketTokenMap.put(TestConfig.bucket_z2, TestConfig.token_z2);
3737
this.bucketTokenMap.put(TestConfig.bucket_na0, TestConfig.token_na0);
3838

3939
this.bucketZoneMap = new HashMap<>();
40-
//this.bucketZoneMap.put(TestConfig.bucket_z0, FixedZone.zone0);
41-
this.bucketZoneMap.put(TestConfig.bucket_z1, FixedZone.zone1);
42-
this.bucketZoneMap.put(TestConfig.bucket_z2, FixedZone.zone2);
43-
//this.bucketZoneMap.put(TestConfig.bucket_na0, FixedZone.zoneNa0);
40+
// this.bucketZoneMap.put(TestConfig.bucket_z0, FixedZone.zone0);
41+
// this.bucketZoneMap.put(TestConfig.bucket_z1, FixedZone.zone1);
42+
// this.bucketZoneMap.put(TestConfig.bucket_z2, FixedZone.zone2);
43+
this.bucketZoneMap.put(TestConfig.bucket_na0, FixedZone.zoneNa0);
4444

4545

4646
//mock
4747
this.mockBucketZoneMap = new HashMap<>();
48-
this.mockBucketZoneMap.put(TestConfig.bucket_z0, TestConfig.mock_bucket_zone0);
49-
this.mockBucketZoneMap.put(TestConfig.bucket_z1, TestConfig.mock_bucket_zone1);
50-
this.mockBucketZoneMap.put(TestConfig.bucket_z2, TestConfig.mock_bucket_zone2);
48+
// this.mockBucketZoneMap.put(TestConfig.bucket_z0, TestConfig.mock_bucket_zone0);
49+
// this.mockBucketZoneMap.put(TestConfig.bucket_z1, TestConfig.mock_bucket_zone1);
50+
// this.mockBucketZoneMap.put(TestConfig.bucket_z2, TestConfig.mock_bucket_zone2);
5151
this.mockBucketZoneMap.put(TestConfig.bucket_na0, TestConfig.mock_bucket_zoneNa0);
5252

5353
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package com.qiniu.android;
2+
import android.test.AndroidTestCase;
3+
4+
import com.qiniu.android.http.Headers;
5+
6+
import java.util.HashMap;
7+
8+
public class HttpHeaderTest extends AndroidTestCase {
9+
10+
private Headers headers;
11+
12+
@Override
13+
protected void setUp() throws Exception {
14+
super.setUp();
15+
16+
HashMap<String, String> keyVaules = new HashMap<>();
17+
keyVaules.put("date", "2020-07-15 07:40:01");
18+
keyVaules.put("host", "127.0.0.1");
19+
// keyVaules.put("", "illegal key");
20+
headers = Headers.of(keyVaules);
21+
}
22+
23+
public void testValue(){
24+
25+
assertTrue(headers.values("date") != null);
26+
assertTrue(headers.values("host") != null);
27+
}
28+
29+
public void testCount(){
30+
31+
assertTrue(headers.get("host") != null);
32+
assertTrue(headers.values("host") != null);
33+
}
34+
35+
public void testBuilder(){
36+
String dateKey = "date";
37+
String dateValue = "2020-07-15 20:02:30";
38+
String hostKey = "host";
39+
String hostValue = "127.0.0.1";
40+
41+
Headers.Builder builder0 = new Headers.Builder();
42+
builder0.add(dateKey, dateValue);
43+
builder0.add(hostKey + ":" + hostValue);
44+
Headers headers0 = builder0.build();
45+
46+
String host = headers0.get(hostKey);
47+
assertTrue(headers0.get(dateKey).equals(dateValue));
48+
assertTrue(headers0.get(hostKey).equals(hostValue));
49+
50+
Headers.Builder builder1 = new Headers.Builder();
51+
builder1.addAll(headers0);
52+
assertTrue(builder1.get(dateKey).equals(dateValue));
53+
54+
}
55+
}

library/src/androidTest/java/com/qiniu/android/HttpTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ protected void setUp() throws Exception {
4747
@SmallTest
4848
public void testPost1() throws Throwable {
4949
httpManager.asyncPost(null,"http://www.baidu.com",
50-
"hello".getBytes(), null, UpToken.parse(TestConfig.token_z0), "hello".getBytes().length,
50+
"hello".getBytes(), null, UpToken.parse(TestConfig.commonToken), "hello".getBytes().length,
5151
null, new CompletionHandler() {
5252
@Override
5353
public void complete(ResponseInfo rinfo, JSONObject response) {
@@ -70,7 +70,7 @@ public void complete(ResponseInfo rinfo, JSONObject response) {
7070
public void testPost2() throws Throwable {
7171

7272
httpManager.asyncPost(null,"http://up.qiniu.com", "hello".getBytes(), null,
73-
UpToken.parse(TestConfig.token_z0), "hello".getBytes().length,
73+
UpToken.parse(TestConfig.commonToken), "hello".getBytes().length,
7474
null, new CompletionHandler() {
7575
@Override
7676
public void complete(ResponseInfo rinfo, JSONObject response) {
@@ -93,7 +93,7 @@ public void testPost3() throws Throwable {
9393
runTestOnUiThread(new Runnable() { // THIS IS THE KEY TO SUCCESS
9494
public void run() {
9595
httpManager.asyncPost(null,"http://httpbin.org/status/500", "hello".getBytes(),
96-
null, UpToken.parse(TestConfig.token_z0), "hello".getBytes().length,
96+
null, UpToken.parse(TestConfig.commonToken), "hello".getBytes().length,
9797
null, new CompletionHandler() {
9898
@Override
9999
public void complete(ResponseInfo rinfo, JSONObject response) {
@@ -120,7 +120,7 @@ public void testPost4() throws Throwable {
120120
public void run() {
121121
httpManager.asyncPost(null,"http://httpbin.org/status/418",
122122
"hello".getBytes(),
123-
null, UpToken.parse(TestConfig.token_z0), "hello".getBytes().length,
123+
null, UpToken.parse(TestConfig.commonToken), "hello".getBytes().length,
124124
null, new CompletionHandler() {
125125
@Override
126126
public void complete(ResponseInfo rinfo, JSONObject response) {
@@ -145,7 +145,7 @@ public void complete(ResponseInfo rinfo, JSONObject response) {
145145
public void testPostNoDomain() throws Throwable {
146146

147147
httpManager.asyncPost(null,"http://no-domain.qiniu.com", "hello".getBytes(),
148-
null, UpToken.parse(TestConfig.token_z0), "hello".getBytes().length,
148+
null, UpToken.parse(TestConfig.commonToken), "hello".getBytes().length,
149149
null, new CompletionHandler() {
150150
@Override
151151
public void complete(ResponseInfo rinfo, JSONObject response) {
@@ -195,7 +195,7 @@ public void complete(ResponseInfo rinfo, JSONObject response) {
195195
public void testPostIP() throws Throwable {
196196
StringMap x = new StringMap().put("Host", "up.qiniu.com");
197197
httpManager.asyncPost(null,"http://218.98.28.29", "hello".getBytes(),
198-
x, UpToken.parse(TestConfig.token_z0), "hello".getBytes().length,
198+
x, UpToken.parse(TestConfig.commonToken), "hello".getBytes().length,
199199
null, new CompletionHandler() {
200200
@Override
201201
public void complete(ResponseInfo rinfo, JSONObject response) {
@@ -220,7 +220,7 @@ public void testProxy() throws Throwable {
220220
ProxyConfiguration p = new ProxyConfiguration("115.238.101.32", 80);
221221
Client c = new Client(p, 10, 30, null, null);
222222
c.asyncPost(null,"http://upproxy1.qiniu.com", "hello".getBytes(),
223-
x, UpToken.parse(TestConfig.token_z0), "hello".getBytes().length,
223+
x, UpToken.parse(TestConfig.commonToken), "hello".getBytes().length,
224224
null, new CompletionHandler() {
225225
@Override
226226
public void complete(ResponseInfo rinfo, JSONObject response) {

library/src/androidTest/java/com/qiniu/android/HttpsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ protected void setUp() throws Exception {
4141
@SmallTest
4242
public void testPost1() throws Throwable {
4343
httpManager.asyncPost(null,"https://www.baidu.com/", "hello".getBytes(), null,
44-
UpToken.parse(TestConfig.token_z0), "hello".getBytes().length, null, new CompletionHandler() {
44+
UpToken.parse(TestConfig.commonToken), "hello".getBytes().length, null, new CompletionHandler() {
4545
@Override
4646
public void complete(ResponseInfo rinfo, JSONObject response) {
4747
Log.d("qiniutest", rinfo.toString());
@@ -62,7 +62,7 @@ public void complete(ResponseInfo rinfo, JSONObject response) {
6262
@SmallTest
6363
public void testPost2() throws Throwable {
6464
httpManager.asyncPost(null,"https://static-fw.qbox.me/public/v28812/add-on/ga/analytics.js",
65-
"hello".getBytes(), null, UpToken.parse(TestConfig.token_z0), "hello".getBytes().length,
65+
"hello".getBytes(), null, UpToken.parse(TestConfig.commonToken), "hello".getBytes().length,
6666
null, new CompletionHandler() {
6767
@Override
6868
public void complete(ResponseInfo rinfo, JSONObject response) {

0 commit comments

Comments
 (0)