Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update test #118

Merged
merged 2 commits into from
Jun 10, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
language: java

before_script:
- export QINIU_ACCESS_KEY=iN7NgwM31j4-BZacMjPrOQBs34UG1maYCAQmhdCV
- export QINIU_SECRET_KEY=6QTOr2Jg1gcZEWDQXKOGZh5PziC2MCV5KsntT70j
- export QINIU_ACCESS_KEY=QWYn5TFQsLLU1pL5MFEmX3s5DmHdUThav9WyOWOm
- export QINIU_SECRET_KEY=Bxckh6FA-Fbs9Yt3i3cbKVK22UPBmAOHJcL95pGz
- export QINIU_UP_HOST=http://up.qbox.me
- export QINIU_RS_HOST=http://rs.qbox.me
- export QINIU_IO_HOST=http://iovip.qbox.me
- export QINIU_TEST_BUCKET=junit_bucket
- export QINIU_TEST_BUCKET=javasdk
- export QINIU_TEST_SRC_BUCKET=testsrc
- export QINIU_TEST_DOMAIN=javasdk.qiniudn.com
26 changes: 13 additions & 13 deletions src/test/java/com/qiniu/testing/BatchCopyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ public class BatchCopyTest extends TestCase {
public final String expectedHash = "FmDZwqadA4-ib_15hYfQpb7UXUYR";

public String bucketName;
public final String key1 = "BatchCopyTest-key1";
public final String key2 = "BatchCopyTest-key2";
public final String key1 = "java-BatchCopyTest-key1";
public final String key2 = "java-BatchCopyTest-key2";

public final String srcBucket = System.getenv("QINIU_TEST_SRC_BUCKET");
public final String destBucket = System.getenv("QINIU_TEST_BUCKET");

public final String srcBucket = "junit_bucket_src";
public final String destBucket = "junit_bucket_dest";
public Mac mac;

@Override
public void setUp() throws Exception {
// get the config
{
Config.ACCESS_KEY = System.getenv("QINIU_ACCESS_KEY");
Config.SECRET_KEY = System.getenv("QINIU_SECRET_KEY");
Config.RS_HOST = System.getenv("QINIU_RS_HOST");
bucketName = System.getenv("QINIU_TEST_BUCKET");
mac = new Mac(Config.ACCESS_KEY, Config.SECRET_KEY);
}

Expand All @@ -49,7 +49,6 @@ public void setUp() throws Exception {
assertNotNull(Config.ACCESS_KEY);
assertNotNull(Config.SECRET_KEY);
assertNotNull(Config.RS_HOST);
assertNotNull(bucketName);
}

// upload a file to src bucket with key1, key2
Expand All @@ -63,8 +62,9 @@ public void setUp() throws Exception {
String localFile = dir + "/testdata/" + "logo.png";

PutExtra extra = new PutExtra();

PutRet ret = IoApi.putFile(uptoken, key1, localFile, extra);

assertTrue(ret.ok());
assertTrue(expectedHash.equals(ret.getHash()));

Expand Down Expand Up @@ -173,7 +173,7 @@ public void testBatchCopy() throws Exception {
}
// the dest bucket should have the keys
{

RSClient rs = new RSClient(mac);

List<EntryPath> entries = new ArrayList<EntryPath>();
Expand Down Expand Up @@ -228,7 +228,7 @@ public void tearDown() {

// delete keys from the dest bucket
{

RSClient rs = new RSClient(mac);
List<EntryPath> entries = new ArrayList<EntryPath>();

Expand All @@ -250,10 +250,10 @@ public void tearDown() {
assertTrue(r.ok());
}
}

// use batchStat to check src bucket
{

RSClient rs = new RSClient(mac);
List<EntryPath> entries = new ArrayList<EntryPath>();

Expand All @@ -271,7 +271,7 @@ public void tearDown() {
// check batchCall
assertTrue(!bsRet.ok());
}

// use batchstat checks dest bucket again.
{
RSClient rs = new RSClient(mac);
Expand Down
58 changes: 28 additions & 30 deletions src/test/java/com/qiniu/testing/BatchMoveTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,21 @@ public class BatchMoveTest extends TestCase {
public final String expectedHash = "FmDZwqadA4-ib_15hYfQpb7UXUYR";

public String bucketName;
public final String key1 = "BatchMoveTest-key1";
public final String key2 = "BatchMoveTest-key2";
public final String srcBucket = "junit_bucket_src";
public final String destBucket = "junit_bucket_dest";
public final String key1 = "java-BatchMoveTest-key1";
public final String key2 = "java-BatchMoveTest-key2";

public final String srcBucket = System.getenv("QINIU_TEST_SRC_BUCKET");
public final String destBucket = System.getenv("QINIU_TEST_BUCKET");

public Mac mac;

@Override
public void setUp() throws Exception {
// get the config
{
Config.ACCESS_KEY = System.getenv("QINIU_ACCESS_KEY");
Config.SECRET_KEY = System.getenv("QINIU_SECRET_KEY");
Config.RS_HOST = System.getenv("QINIU_RS_HOST");
bucketName = System.getenv("QINIU_TEST_BUCKET");
mac = new Mac(Config.ACCESS_KEY, Config.SECRET_KEY);
}

Expand All @@ -50,7 +49,6 @@ public void setUp() throws Exception {
assertNotNull(Config.ACCESS_KEY);
assertNotNull(Config.SECRET_KEY);
assertNotNull(Config.RS_HOST);
assertNotNull(bucketName);
}

// upload a file to the bucket with key1, key2
Expand Down Expand Up @@ -107,41 +105,41 @@ public void testBatchMove() throws Exception {
{
RSClient rs = new RSClient(mac);
List<EntryPathPair> entries = new ArrayList<EntryPathPair>();

EntryPathPair pair1 = new EntryPathPair();

EntryPath src = new EntryPath();
src.bucket = srcBucket;
src.key = key1;

EntryPath dest = new EntryPath();
dest.bucket = destBucket;
dest.key = key1;

pair1.src = src;
pair1.dest = dest;

EntryPathPair pair2 = new EntryPathPair();

EntryPath src2 = new EntryPath();
src2.bucket = srcBucket;
src2.key = key2;

EntryPath dest2 = new EntryPath();
dest2.bucket = destBucket;
dest2.key = key2;

pair2.src = src2;
pair2.dest = dest2;

entries.add(pair1);
entries.add(pair2);

BatchCallRet ret = rs.batchMove(entries);

// check batchMove
assertTrue(ret.ok());

List<CallRet> results = ret.results;
for (CallRet r : results) {
assertTrue(r.ok());
Expand All @@ -150,41 +148,41 @@ public void testBatchMove() throws Exception {
// the src keys should not be available in src bucket
{
RSClient rs = new RSClient(mac);

List<EntryPath> entries = new ArrayList<EntryPath>();
EntryPath e1 = new EntryPath();
e1.bucket = srcBucket;
e1.key = key1;

EntryPath e2 = new EntryPath();
e2.bucket = srcBucket;
e2.key = key2;

entries.add(e1);
entries.add(e2);

BatchStatRet ret = rs.batchStat(entries);
assertTrue(!ret.ok());
}
// the dest bucket should have the keys
{
RSClient rs = new RSClient(mac);

List<EntryPath> entries = new ArrayList<EntryPath>();
EntryPath e1 = new EntryPath();
e1.bucket = destBucket;
e1.key = key1;

EntryPath e2 = new EntryPath();
e2.bucket = destBucket;
e2.key = key2;

entries.add(e1);
entries.add(e2);

BatchStatRet ret = rs.batchStat(entries);
assertTrue(ret.ok());

List<Entry> results = ret.results;
for (Entry r : results) {
assertTrue(r.ok());
Expand Down Expand Up @@ -221,7 +219,7 @@ public void tearDown() {

// use batchstat checks it again.
{

RSClient rs = new RSClient(mac);
List<EntryPath> entries = new ArrayList<EntryPath>();

Expand Down
8 changes: 4 additions & 4 deletions src/test/java/com/qiniu/testing/BatchStatTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public class BatchStatTest extends TestCase {
public final String expectedHash = "FmDZwqadA4-ib_15hYfQpb7UXUYR";

public String bucketName;
public final String key1 = "BatchStatTest-key1";
public final String key2 = "BatchStatTest-key2";
public final String key1 = "java-BatchStatTest-key1";
public final String key2 = "java-BatchStatTest-key2";
public Mac mac;

@Override
public void setUp() throws Exception {
// get the config
Expand Down Expand Up @@ -59,7 +59,7 @@ public void setUp() throws Exception {
String localFile = dir + "/testdata/" + "logo.png";

PutExtra extra = new PutExtra();

PutRet ret = IoApi.putFile(uptoken, key1, localFile, extra);
assertTrue(ret.ok());
assertTrue(expectedHash.equals(ret.getHash()));
Expand Down
28 changes: 5 additions & 23 deletions src/test/java/com/qiniu/testing/CopyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,19 @@ public class CopyTest extends TestCase {

public final String expectedHash = "FmDZwqadA4-ib_15hYfQpb7UXUYR";

public String bucketName;
public final String key = "CopyTest-key";
public final String key = "java-CopyTest-key";

public final String srcBucket = "junit_bucket_src";
public final String destBucket = "junit_bucket_dest";
public final String srcBucket = System.getenv("QINIU_TEST_SRC_BUCKET");
public final String destBucket = System.getenv("QINIU_TEST_BUCKET");
public Mac mac;

@Override
public void setUp() throws Exception {
// get the config
{
Config.ACCESS_KEY = System.getenv("QINIU_ACCESS_KEY");
Config.SECRET_KEY = System.getenv("QINIU_SECRET_KEY");
Config.RS_HOST = System.getenv("QINIU_RS_HOST");
bucketName = System.getenv("QINIU_TEST_BUCKET");
mac = new Mac(Config.ACCESS_KEY, Config.SECRET_KEY);
}

Expand All @@ -42,7 +40,6 @@ public void setUp() throws Exception {
assertNotNull(Config.ACCESS_KEY);
assertNotNull(Config.SECRET_KEY);
assertNotNull(Config.RS_HOST);
assertNotNull(bucketName);
}

// upload a file to the bucket
Expand All @@ -62,22 +59,7 @@ public void setUp() throws Exception {
}
}

public void testMove() throws Exception {
// upload a file to the srcbucket
{
String uptoken = "";
try {
uptoken = new PutPolicy(bucketName).token(mac);
} catch (AuthException ignore) {
}
String dir = System.getProperty("user.dir");
String localFile = dir + "/testdata/" + "logo.png";

PutExtra extra = new PutExtra();
PutRet ret = IoApi.putFile(uptoken, key, localFile, extra);
assertTrue(ret.ok());
assertTrue(expectedHash.equals(ret.getHash()));
}
public void testCopy() throws Exception {
// test move
{
RSClient rs = new RSClient(mac);
Expand Down
Loading