Esempio n. 1
0
        /// <summary>
        /// Compares this identifier to another and returns true if they are equal.
        /// Both objects must be ObjectKeys and have the same key-pool and key value.
        /// </summary>
        /// <param name="obj">The other object to compare against this object.</param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            ObjectKey ok = obj as ObjectKey;

            if (ok == null)
            {
                return(false);
            }

            return(pool == ok.pool && key == ok.key);
        }
Esempio n. 2
0
        public void testKeysOther()
        {
            ObjectKey key = new ObjectKey("Test_key-pool#@!$%^..", "KEY_TEST2");
            string content = "Key tests!";
            byte[] data = Encoding.UTF8.GetBytes(content);

            ObjectId oid = this.esu.CreateObjectWithKey(key, null, null, data, "text/plain");
            cleanup.Add(oid);

            // test getting stuff
            Acl acl = this.esu.GetAcl(key);
            Assert.IsNotNull(acl, "ACL is null");
            ObjectMetadata objectMeta = this.esu.GetAllMetadata(key);
            Assert.IsTrue(objectMeta.Metadata.Count() > 0, "Object metadata is null");
            ObjectInfo info = this.esu.GetObjectInfo(key);
            Assert.IsNotNull(info.ObjectID, "GetObjectInfo object ID is null");
            Assert.IsTrue(this.esu.GetSystemMetadata(key, null).Count() > 0, "System Metadata is empty");
            Assert.IsTrue(this.esu.GetUserMetadata(key, null).Count() == 0, "User Metadata is not empty");

            // test setting stuff
            foreach (Grant grant in acl) {
                if (grant.Grantee.Name == "other")
                {
                    grant.Permission = Permission.READ;
                    break;
                }
            }
            this.esu.SetAcl(key, acl);
            Assert.AreEqual(acl, this.esu.GetAcl(key), "ACL is different");
            MetadataList mList = new MetadataList();
            mList.AddMetadata(new Metadata("foo", "bar", false));
            mList.AddMetadata(new Metadata("listable", "", true));
            this.esu.SetUserMetadata(key, mList);
            MetadataList readList = this.esu.GetUserMetadata(key, null);
            Assert.AreEqual(mList.ToString(), readList.ToString(), "User meta is different");
        }
Esempio n. 3
0
        public void testObjectKeyCRUD()
        {
            ObjectKey key = new ObjectKey("Test_key-pool#@!$%^..", "KEY_TEST");
            try
            {
                string content = "Hello World!";
                byte[] data = Encoding.UTF8.GetBytes(content);

                ObjectId oid = this.esu.CreateObjectWithKey(key, null, null, data, "text/plain");

                Assert.IsNotNull(oid, "Null object ID returned");

                string readContent = Encoding.UTF8.GetString(this.esu.ReadObject(key, null, null));
                Assert.AreEqual(content, readContent, "content mismatch");

                content = "Hello Waldo!";
                data = Encoding.UTF8.GetBytes(content);
                this.esu.UpdateObject(key, null, null, null, data, null);

                readContent = Encoding.UTF8.GetString(this.esu.ReadObject(key, null, null));
                Assert.AreEqual(content, readContent, "content mismatch");

            }
            finally
            {
                this.esu.DeleteObject(key);
            }

            try
            {
                this.esu.ReadObject(key, null, null);
                Assert.Fail("Object still exists");
            }
            catch (EsuException e)
            {
                if (e.Code != 1003) throw e;
            }
        }