~ubuntu-core-dev/eucalyptus/ubuntu-karmic

« back to all changes in this revision

Viewing changes to clc/modules/storage-manager/src/edu/ucsb/eucalyptus/cloud/ws/tests/ObjectTest.java

  • Committer: Dmitrii Zagorodnov
  • Date: 2009-01-27 21:53:41 UTC
  • mfrom: (25.1.112 eucalyptus-main)
  • Revision ID: dmitrii@cs.ucsb.edu-20090127215341-i0f0v6cmbpljmg02
merged with current main

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Software License Agreement (BSD License)
 
3
 *
 
4
 * Copyright (c) 2008, Regents of the University of California
 
5
 * All rights reserved.
 
6
 *
 
7
 * Redistribution and use of this software in source and binary forms, with or
 
8
 * without modification, are permitted provided that the following conditions
 
9
 * are met:
 
10
 *
 
11
 * * Redistributions of source code must retain the above
 
12
 *   copyright notice, this list of conditions and the
 
13
 *   following disclaimer.
 
14
 *
 
15
 * * Redistributions in binary form must reproduce the above
 
16
 *   copyright notice, this list of conditions and the
 
17
 *   following disclaimer in the documentation and/or other
 
18
 *   materials provided with the distribution.
 
19
 *
 
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 
21
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
23
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 
24
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 
27
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 
28
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 
29
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 
30
 * POSSIBILITY OF SUCH DAMAGE.
 
31
 *
 
32
 * Author: Sunil Soman sunils@cs.ucsb.edu
 
33
 */
 
34
 
 
35
package edu.ucsb.eucalyptus.cloud.ws.tests;
 
36
 
 
37
import edu.ucsb.eucalyptus.cloud.ws.Bukkit;
 
38
import edu.ucsb.eucalyptus.keys.Hashes;
 
39
import edu.ucsb.eucalyptus.msgs.*;
 
40
import junit.framework.TestCase;
 
41
 
 
42
import java.util.ArrayList;
 
43
 
 
44
public class ObjectTest extends TestCase {
 
45
 
 
46
        static Bukkit bukkit;
 
47
        public void testObject() throws Throwable {
 
48
 
 
49
                String bucketName = "halo" + Hashes.getRandom(6);
 
50
                String objectName = "key" + Hashes.getRandom(6);
 
51
                String userId = "admin";
 
52
 
 
53
                CreateBucketType createBucketRequest = new CreateBucketType(bucketName);
 
54
                createBucketRequest.setBucket(bucketName);
 
55
                createBucketRequest.setUserId(userId);
 
56
        createBucketRequest.setEffectiveUserId("eucalyptus");
 
57
                AccessControlListType acl = new AccessControlListType();
 
58
                createBucketRequest.setAccessControlList(acl);
 
59
                CreateBucketResponseType reply = bukkit.CreateBucket(createBucketRequest);
 
60
                System.out.println(reply);
 
61
 
 
62
                PutObjectInlineType putObjectRequest = new PutObjectInlineType();
 
63
                putObjectRequest.setBucket(bucketName);
 
64
                putObjectRequest.setKey(objectName);
 
65
        String data = "hi here is some data";
 
66
                putObjectRequest.setContentLength(String.valueOf(data.length()));
 
67
                putObjectRequest.setBase64Data(data);
 
68
                putObjectRequest.setUserId(userId);
 
69
        ArrayList<MetaDataEntry> metaData = new ArrayList<MetaDataEntry>();
 
70
        MetaDataEntry metaDataEntry = new MetaDataEntry();
 
71
        metaDataEntry.setName("mammalType");
 
72
        metaDataEntry.setValue("walrus");
 
73
        metaData.add(metaDataEntry);
 
74
        putObjectRequest.setMetaData(metaData);
 
75
        PutObjectInlineResponseType putObjectReply = bukkit.PutObjectInline(putObjectRequest);
 
76
                System.out.println(putObjectReply);
 
77
 
 
78
        ListBucketType listBucketRequest = new ListBucketType();
 
79
        listBucketRequest.setBucket(bucketName);
 
80
        listBucketRequest.setUserId(userId);
 
81
        ListBucketResponseType listBucketReply = bukkit.ListBucket(listBucketRequest);
 
82
        System.out.println(listBucketReply);        
 
83
 
 
84
        GetObjectAccessControlPolicyType acpRequest = new GetObjectAccessControlPolicyType();
 
85
                acpRequest.setBucket(bucketName);
 
86
        acpRequest.setKey(objectName);
 
87
        acpRequest.setUserId(userId);
 
88
                GetObjectAccessControlPolicyResponseType acpResponse = bukkit.GetObjectAccessControlPolicy(acpRequest);
 
89
                System.out.println(acpResponse);
 
90
 
 
91
        GetObjectType getObjectRequest = new GetObjectType();
 
92
        getObjectRequest.setUserId(userId);
 
93
        getObjectRequest.setBucket(bucketName);
 
94
        getObjectRequest.setKey(objectName);
 
95
        getObjectRequest.setGetData(true);
 
96
        getObjectRequest.setGetMetaData(true);
 
97
        getObjectRequest.setInlineData(true);
 
98
        GetObjectResponseType getObjectReply = bukkit.GetObject(getObjectRequest);
 
99
        System.out.println(getObjectReply);
 
100
 
 
101
        DeleteObjectType deleteObjectRequest = new DeleteObjectType();
 
102
                deleteObjectRequest.setBucket(bucketName);
 
103
                deleteObjectRequest.setKey(objectName);
 
104
                deleteObjectRequest.setUserId(userId);
 
105
                DeleteObjectResponseType deleteObjectReply = bukkit.DeleteObject(deleteObjectRequest);
 
106
                System.out.println(deleteObjectReply);
 
107
 
 
108
                DeleteBucketType deleteBucketRequest = new DeleteBucketType();
 
109
                deleteBucketRequest.setUserId(userId);
 
110
                deleteBucketRequest.setBucket(bucketName);
 
111
                DeleteBucketResponseType deleteResponse = bukkit.DeleteBucket(deleteBucketRequest);
 
112
                System.out.println(deleteResponse);
 
113
        }
 
114
 
 
115
    public void setUp() {
 
116
        bukkit = new Bukkit();
 
117
   }        
 
118
}
 
 
b'\\ No newline at end of file'