Skip to content

Commit

Permalink
Just Test
Browse files Browse the repository at this point in the history
  • Loading branch information
缘潘 authored and 缘潘 committed Mar 6, 2019
1 parent c4c7b5c commit ffeaf86
Show file tree
Hide file tree
Showing 24 changed files with 146 additions and 213 deletions.
16 changes: 11 additions & 5 deletions src/main/java/com/qiniu/common/AutoRegion.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class AutoRegion extends Region {
* 构建默认的域名接口获取对象
*/
public AutoRegion() {
this("https://api.qiniu.com");
this("https://uc.qbox.me");
}

public AutoRegion(String ucServer) {
Expand Down Expand Up @@ -217,14 +217,20 @@ protected RegionInfo(List<String> srcUpHosts, List<String> accUpHosts, String io
*/
static RegionInfo buildFromUcRet(UCRet ret) {
List<String> srcUpHosts = new ArrayList<>();
srcUpHosts.addAll(ret.up.src.get("main"));
srcUpHosts.addAll(ret.up.src.get("backup"));
addAll(srcUpHosts, ret.up.src.get("main"));
addAll(srcUpHosts, ret.up.src.get("backup"));
List<String> accUpHosts = new ArrayList<>();
accUpHosts.addAll(ret.up.acc.get("main"));
accUpHosts.addAll(ret.up.acc.get("backup"));
addAll(accUpHosts, ret.up.acc.get("main"));
addAll(accUpHosts, ret.up.acc.get("backup"));
String iovipHost = ret.io.src.get("main").get(0);
return new RegionInfo(srcUpHosts, accUpHosts, iovipHost);
}

static void addAll(List<String> s, List<String> p) {
if (p != null) {
s.addAll(p);
}
}
}

private static class RegionIndex {
Expand Down
12 changes: 1 addition & 11 deletions src/main/java/com/qiniu/processing/OperationManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public OperationManager(Auth auth, Configuration cfg) {
public OperationManager(Auth auth, Client client) {
this.auth = auth;
this.client = client;
this.configuration = new Configuration();
}

/**
Expand Down Expand Up @@ -85,11 +84,7 @@ public String pfop(String bucket, String key, String fops, StringMap params) thr
String url = configuration.apiHost(auth.accessKey, bucket) + "/pfop/";
StringMap headers = auth.authorization(url, data, Client.FormMime);
Response response = client.post(url, data, headers, Client.FormMime);
if (!response.isOK()) {
throw new QiniuException(response);
}
PfopResult status = response.jsonToObject(PfopResult.class);
response.close();
if (status != null) {
return status.persistentId;
}
Expand Down Expand Up @@ -186,11 +181,6 @@ public <T> T prefop(String persistentId, Class<T> retClass) throws QiniuExceptio

String url = String.format("%s/status/get/prefop", apiHost);
Response response = this.client.post(url, data, null, Client.FormMime);
if (!response.isOK()) {
throw new QiniuException(response);
}
T object = response.jsonToObject(retClass);
response.close();
return object;
return response.jsonToObject(retClass);
}
}
5 changes: 2 additions & 3 deletions src/main/java/com/qiniu/storage/BucketManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,12 @@ public final class BucketManager {
public BucketManager(Auth auth, Configuration cfg) {
this.auth = auth;
this.configuration = cfg.clone();
client = new Client(configuration);
client = new Client(this.configuration);
}

public BucketManager(Auth auth, Client client) {
this.auth = auth;
this.client = client;
this.configuration = new Configuration();
}

/**
Expand Down Expand Up @@ -498,7 +497,7 @@ public Response asynFetch(String url, String bucket, String key) throws QiniuExc
*/
public Response asynFetch(String url, String bucket, String key, String md5, String etag,
String callbackurl, String callbackbody, String callbackbodytype,
String callbackhost, int fileType) throws QiniuException {
String callbackhost, String fileType) throws QiniuException {
String requesturl = configuration.apiHost(auth.accessKey, bucket) + "/sisyphus/fetch";
StringMap stringMap = new StringMap().put("url", url).put("bucket", bucket).
putNotNull("key", key).putNotNull("md5", md5).putNotNull("etag", etag).
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/com/qiniu/storage/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.qiniu.common.RegionReqInfo;
import com.qiniu.http.Dns;
import com.qiniu.http.ProxyConfiguration;
import com.qiniu.util.StringUtils;

/**
* 该类封装了SDK相关配置参数
Expand Down Expand Up @@ -77,11 +78,8 @@ public final class Configuration implements Cloneable {
/*
* 特殊默认域名
*/
@Deprecated
public static String defaultRsHost = "rs.qiniu.com";
@Deprecated
public static String defaultApiHost = "api.qiniu.com";
@Deprecated
public static String defaultUcHost = "uc.qbox.me";

public Configuration() {
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/qiniu/storage/UploadManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public UploadManager(Configuration config, Recorder recorder) {
public UploadManager(Client client, Recorder recorder) {
this.client = client;
this.recorder = recorder;
configuration = new Configuration();
}

private static void checkArgs(final String key, byte[] data, File f, String token) {
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/com/qiniu/storage/model/FileInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,4 @@ public final class FileInfo {
* 文件的状态,0表示启用,1表示禁用
*/
public int status;
/**
* 文件的md5值
*/
public int md5;
}
26 changes: 13 additions & 13 deletions src/test/java/test/com/qiniu/CdnTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void testRefresh() {
}
}

@Test
//@Test
public void testPrefetch() {
CdnManager c = new CdnManager(TestConfig.testAuth);
CdnResult.PrefetchResult r = null;
Expand All @@ -51,7 +51,7 @@ public void testPrefetch() {
}
}

@Test
//@Test
public void testGetBandwidth() {
CdnManager c = new CdnManager(TestConfig.testAuth);
CdnResult.BandwidthResult r = null;
Expand All @@ -68,7 +68,7 @@ public void testGetBandwidth() {
}
}

@Test
//@Test
public void testGetFlux() {
CdnManager c = new CdnManager(TestConfig.testAuth);
CdnResult.FluxResult r = null;
Expand All @@ -86,7 +86,7 @@ public void testGetFlux() {
}
}

@Test
//@Test
public void testGetCdnLogList() {
CdnManager c = new CdnManager(TestConfig.testAuth);
CdnResult.LogListResult r = null;
Expand All @@ -102,7 +102,7 @@ public void testGetCdnLogList() {
}
}

@Test
//@Test
public void testCreateTimestampAntiLeechUrlSimple1() {
String host = "http://video.example.com";
String fileName = "2017/01/07/test.png";
Expand All @@ -120,7 +120,7 @@ public void testCreateTimestampAntiLeechUrlSimple1() {
}
}

@Test
//@Test
public void testCreateTimestampAntiLeechUrlSimple2() {
String host = "http://video.example.com";
String fileName = "基本概括.mp4";
Expand All @@ -138,7 +138,7 @@ public void testCreateTimestampAntiLeechUrlSimple2() {
}


@Test
//@Test
public void testCreateTimestampAntiLeechUrlWithQueryString1() {
String host = "http://video.example.com";
String fileName = "2017/01/07/test.png";
Expand All @@ -159,7 +159,7 @@ public void testCreateTimestampAntiLeechUrlWithQueryString1() {
}
}

@Test
//@Test
public void testCreateTimestampAntiLeechUrlWithQueryString2() {
String host = "http://video.example.com";
String fileName = "基本概括.mp4";
Expand All @@ -180,7 +180,7 @@ public void testCreateTimestampAntiLeechUrlWithQueryString2() {
}
}

@Test
//@Test
public void testCreateTimestampAntiLeechUrlSimple3() throws MalformedURLException {
String host = "http://xxx.yyy.com";
String fileName = "DIR1/dir2/vodfile.mp4";
Expand All @@ -201,7 +201,7 @@ public void testCreateTimestampAntiLeechUrlSimple3() throws MalformedURLExceptio
}
}

@Test
//@Test
public void testCreateTimestampAntiLeechUrlSimple4() throws MalformedURLException {
String host = "http://xxx.yyy.com";
String fileName = "DIR1/中文/vodfile.mp4";
Expand All @@ -222,7 +222,7 @@ public void testCreateTimestampAntiLeechUrlSimple4() throws MalformedURLExceptio
}
}

@Test
//@Test
public void testCreateTimestampAntiLeechUrlSimple5() throws MalformedURLException {
URL url = new URL("http://xxx.yyy.com/DIR1/dir2/vodfile.mp4");
long deadline = 1438358400;
Expand All @@ -238,7 +238,7 @@ public void testCreateTimestampAntiLeechUrlSimple5() throws MalformedURLExceptio
}
}

@Test
//@Test
public void testCreateTimestampAntiLeechUrlSimple6() throws MalformedURLException {
URL url = new URL("http://xxx.yyy.com/DIR1/dir2/vodfile.mp4?v=1.1");
long deadline = 1438358400;
Expand All @@ -256,7 +256,7 @@ public void testCreateTimestampAntiLeechUrlSimple6() throws MalformedURLExceptio
}
}

@Test
//@Test
public void testCreateTimestampAntiLeechUrlSimple7() throws MalformedURLException {
URL url = new URL("http://xxx.yyy.com/DIR1/中文/vodfile.mp4?v=1.2");
long deadline = 1438358400;
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/test/com/qiniu/DnsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public List<InetAddress> lookup(String hostname) throws UnknownHostException {
uploadManager = new UploadManager(config);
}

@Test
//@Test
public void testSome() {
// uploadManager.xxxxx
}
Expand Down
12 changes: 6 additions & 6 deletions src/test/java/test/com/qiniu/HttpTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public class HttpTest {
private Client httpManager = new Client();

@Test
//@Test
public void testPost1() {
Response r = null;
try {
Expand All @@ -23,7 +23,7 @@ public void testPost1() {
}
}

@Test
//@Test
public void testPost2() {
Response r = null;
try {
Expand All @@ -34,7 +34,7 @@ public void testPost2() {
}
}

@Test
//@Test
public void testPost3() {
Response r = null;
try {
Expand All @@ -49,7 +49,7 @@ public void testPost3() {
}
}

@Test
//@Test
public void testPost4() {
Response r = null;
try {
Expand All @@ -64,7 +64,7 @@ public void testPost4() {
}
}

@Test
//@Test
public void testPost5() {
Response r = null;
try {
Expand All @@ -79,7 +79,7 @@ public void testPost5() {
}
}

@Test
//@Test
public void testProxy() {
ProxyConfiguration proxy = new ProxyConfiguration("115.231.183.168", 80);
Client c = new Client(null, false, proxy,
Expand Down
36 changes: 16 additions & 20 deletions src/test/java/test/com/qiniu/TestConfig.java
Original file line number Diff line number Diff line change
@@ -1,48 +1,44 @@
package test.com.qiniu;


import com.qiniu.util.Auth;

public final class TestConfig {

//dummy ak & sk
public static final String dummyAccessKey = "abcdefghklmnopq";
public static final String dummySecretKey = "1234567890";
public static final Auth dummyAuth = Auth.create(dummyAccessKey, dummySecretKey);

public static final String dummyBucket = "no-such-dummy-bucket";
public static final String dummyKey = "no-such-dummy-key";
public static final String dummyDomain = "dummy.qiniudn.com";

public static final String dummyUptoken = "ak:token:putpolicy";
public static final String dummyInvalidUptoken = "invalidtoken";



//valid ak & sk
public static final String testAccessKey = System.getenv("QINIU_ACCESS_KEY");
public static final String testSecretKey = System.getenv("QINIU_SECRET_KEY");


public static final String testAccessKey = System.getenv("accessKey");
public static final String testSecretKey = System.getenv("secretKey");

public static final Auth testAuth = Auth.create(testAccessKey, testSecretKey);

//z0
public static final String testBucket_z0 = "javasdk";
public static final String testKey_z0 = "java-duke.png";
public static final String testDomain_z0 = "javasdk.qiniudn.com";

public static final String testKey_z0 = "keyForDelete0.024347267862929844";
public static final String testDomain_z0 = "javasdk-z0.peterpy.cn";
//na0
public static final String testBucket_na0 = "java-sdk-na0";
public static final String testKey_na0 = "java-duke.png";
public static final String testDomain_na0 = "okzjfj76f.bkt.gdipper.com";


public static final String testKey_na0 = "test/1/java-duke.png";
public static final String testDomain_na0 = "javasdk-na0.peterpy.cn";

//code
public static final int ERROR_CODE_BUCKET_NOT_EXIST = 631;
public static final int ERROR_CODE_KEY_NOT_EXIST = 612;



private TestConfig() {
}

public static boolean isTravis() {
return "travis".equals(System.getenv("QINIU_TEST_ENV"));
}
Expand Down
Loading

0 comments on commit ffeaf86

Please sign in to comment.