Exemplo n.º 1
0
        public void testGetUserMetadata() {
            // Create an object with user metadata
            MetadataList mlist = new MetadataList();
            Metadata listable = new Metadata( "listable", "foo", true );
            Metadata unlistable = new Metadata( "unlistable", "bar", false );
            Metadata listable2 = new Metadata( "listable2", "foo2 foo2", true );
            Metadata unlistable2 = new Metadata( "unlistable2", "bar2 bar2", false );
            mlist.AddMetadata( listable );
            mlist.AddMetadata( unlistable );
            mlist.AddMetadata( listable2 );
            mlist.AddMetadata( unlistable2 );
            ObjectId id = this.esu.CreateObject( null, mlist, null, null );
            Assert.IsNotNull( id, "null ID returned" );
            cleanup.Add( id );

            // Read only part of the metadata
            MetadataTags mtags = new MetadataTags();
            mtags.AddTag( new MetadataTag( "listable", true ) );
            mtags.AddTag( new MetadataTag( "unlistable", false ) );
            MetadataList meta = this.esu.GetUserMetadata( id, mtags );
            Assert.AreEqual( "foo", meta.GetMetadata( "listable" ).Value, "value of 'listable' wrong" );
            Assert.IsNull( meta.GetMetadata( "listable2" ), "value of 'listable2' should not have been returned" );
            Assert.AreEqual( "bar", meta.GetMetadata( "unlistable" ).Value, "value of 'unlistable' wrong" );
            Assert.IsNull( meta.GetMetadata( "unlistable2" ), "value of 'unlistable2' should not have been returned" );

        }
Exemplo n.º 2
0
        public void testDeleteUserMetadata() {
            // Create an object with metadata
            MetadataList mlist = new MetadataList();
            Metadata listable = new Metadata( "listable", "foo", true );
            Metadata unlistable = new Metadata( "unlistable", "bar", false );
            Metadata listable2 = new Metadata( "listable2", "foo2 foo2", true );
            Metadata unlistable2 = new Metadata( "unlistable2", "bar2 bar2", false );
            mlist.AddMetadata( listable );
            mlist.AddMetadata( unlistable );
            mlist.AddMetadata( listable2 );
            mlist.AddMetadata( unlistable2 );
            ObjectId id = this.esu.CreateObject( null, mlist, null, null );
            Assert.IsNotNull( id,"null ID returned" );
            cleanup.Add( id );

            // Delete a couple of the metadata entries
            MetadataTags mtags = new MetadataTags();
            mtags.AddTag( new MetadataTag( "listable2", true ) );
            mtags.AddTag( new MetadataTag( "unlistable2", false ) );
            this.esu.DeleteUserMetadata( id, mtags );

            // Read back the metadata for the object and ensure the deleted
            // entries don't exist
            MetadataList meta = this.esu.GetUserMetadata( id, null );
            Assert.AreEqual( "foo", meta.GetMetadata( "listable" ).Value, "value of 'listable' wrong" );
            Assert.IsNull( meta.GetMetadata( "listable2" ), "value of 'listable2' should not have been returned" );
            Assert.AreEqual( "bar", meta.GetMetadata( "unlistable" ).Value, "value of 'unlistable' wrong" );
            Assert.IsNull( meta.GetMetadata( "unlistable2" ), "value of 'unlistable2' should not have been returned" );
        }
Exemplo n.º 3
0
        public void testUpdateObjectMetadata() {
            // Create an object
            MetadataList mlist = new MetadataList();
            Metadata unlistable = new Metadata( "unlistable", "foo", false );
            mlist.AddMetadata( unlistable );
            ObjectId id = this.esu.CreateObject( null, mlist, Encoding.UTF8.GetBytes( "hello" ), null );
            Assert.IsNotNull( id,"null ID returned" );
            cleanup.Add( id );

            // Update the metadata
            unlistable.Value = "bar";
            this.esu.SetUserMetadata( id, mlist );

            // Re-read the metadata
            MetadataList meta = this.esu.GetUserMetadata( id, null );
            Assert.AreEqual( "bar", meta.GetMetadata( "unlistable" ).Value, "value of 'unlistable' wrong" );
            
            // Check that content was not modified
            string content = Encoding.UTF8.GetString( this.esu.ReadObject( id, null, null ) );
            Assert.AreEqual( "hello", content, "object content wrong" );

        }
Exemplo n.º 4
0
	    public void testGetAllMetadataByPath() {
    	    ObjectPath op = new ObjectPath( "/" + rand8char() + ".tmp" );
            // Create an object with an ACL
            Acl acl = new Acl();
            acl.AddGrant(new Grant(new Grantee(esu.GetUid(), Grantee.GRANTEE_TYPE.USER), Permission.FULL_CONTROL));
            acl.AddGrant( new Grant( Grantee.OTHER, Permission.READ ) );
            MetadataList mlist = new MetadataList();
            Metadata listable = new Metadata( "listable", "foo", true );
            Metadata unlistable = new Metadata( "unlistable", "bar", false );
            Metadata listable2 = new Metadata( "listable2", "foo2 foo2", true );
            Metadata unlistable2 = new Metadata( "unlistable2", "bar2 bar2", false );
            mlist.AddMetadata( listable );
            mlist.AddMetadata( unlistable );
            mlist.AddMetadata( listable2 );
            mlist.AddMetadata( unlistable2 );

            ObjectId id = this.esu.CreateObjectOnPath( op, acl, null, null, null );
            this.esu.UpdateObject( op, null, mlist, null, null, null );
            Assert.IsNotNull( id, "null ID returned" );
            cleanup.Add( op );
            
            // Read it back with HEAD call
            ObjectMetadata om = this.esu.GetAllMetadata( op );
            Assert.IsNotNull( om.Metadata.GetMetadata( "listable" ), "value of 'listable' missing" );
            Assert.IsNotNull( om.Metadata.GetMetadata("unlistable"), "value of 'unlistable' missing" );
            Assert.IsNotNull( om.Metadata.GetMetadata("atime"), "value of 'atime' missing" );
            Assert.IsNotNull( om.Metadata.GetMetadata("ctime"), "value of 'ctime' missing" );
            Assert.AreEqual( "foo", om.Metadata.GetMetadata("listable").Value, "value of 'listable' wrong" );
            Assert.AreEqual( "bar", om.Metadata.GetMetadata("unlistable").Value, "value of 'unlistable' wrong" );

            // Check the ACL
            // not checking this by path because an extra groupid is added 
            // during the create calls by path.
            //Assert.AreEqual( acl, om.getAcl(), "ACLs don't match" );

	    }
Exemplo n.º 5
0
        public void testListObjectsPaged()
        {
            // Create an object
            MetadataList mlist = new MetadataList();
            Metadata listable = new Metadata("listable", "foo", true);
            Metadata unlistable = new Metadata("unlistable", "bar", false);
            Metadata listable2 = new Metadata("listable2", "foo2 foo2", true);
            Metadata unlistable2 = new Metadata("unlistable2", "bar2 bar2", false);
            mlist.AddMetadata(listable);
            mlist.AddMetadata(unlistable);
            mlist.AddMetadata(listable2);
            mlist.AddMetadata(unlistable2);
            ObjectId id = this.esu.CreateObject(null, mlist, null, null);
            ObjectId id2 = this.esu.CreateObject(null, mlist, null, null);
            Assert.IsNotNull(id, "null ID returned");
            cleanup.Add(id);
            cleanup.Add(id2);

            // List the objects.  Make sure the one we created is in the list
            ListOptions options = new ListOptions();
            options.Limit = 1;
            List<ObjectResult> objects = this.esu.ListObjects("listable", options);
            while (options.Token != null)
            {
                Debug.WriteLine("Continuing results with token " + options.Token);
                objects.AddRange(this.esu.ListObjects("listable", options));
            }
            Assert.IsTrue(objects.Count > 0, "No objects returned");
            Assert.IsTrue(containsId(objects, id), "object not found in list");
            Assert.IsTrue(containsId(objects, id2), "object2 not found in list");
        }
Exemplo n.º 6
0
        public void testGetListableTags() {
            // Create an object
            MetadataList mlist = new MetadataList();
            Metadata listable = new Metadata( "listable", "foo", true );
            Metadata unlistable = new Metadata( "unlistable", "bar", false );
            Metadata listable2 = new Metadata( "list/able/2", "foo2 foo2", true );
            Metadata unlistable2 = new Metadata( "list/able/not", "bar2 bar2", false );
            mlist.AddMetadata( listable );
            mlist.AddMetadata( unlistable );
            mlist.AddMetadata( listable2 );
            mlist.AddMetadata( unlistable2 );
            ObjectId id = this.esu.CreateObject( null, mlist, null, null );
            Assert.IsNotNull( id,"null ID returned" );
            cleanup.Add( id );

            // List tags.  Ensure our object's tags are in the list.
            MetadataTags tags = this.esu.GetListableTags( (string)null );
            Assert.IsTrue( tags.Contains( "listable" ), "listable tag not returned" );
            Assert.IsTrue( tags.Contains( "list" ), "list/able/2 root tag not returned" );
            Assert.IsFalse( tags.Contains( "list/able/not" ), "list/able/not tag returned" );

            // List child tags
            tags = this.esu.GetListableTags( "list/able" );
            Assert.IsFalse( tags.Contains( "listable" ), "non-child returned" );
            Assert.IsTrue( tags.Contains( "2" ), "list/able/2 tag not returned" );
            Assert.IsFalse( tags.Contains( "not" ), "list/able/not tag returned" );

        }
Exemplo n.º 7
0
        public void testUtf8DeleteMetadata() {
            String oneByteCharacters = "Hello! ";
            String twoByteCharacters = "\u0410\u0411\u0412\u0413"; // Cyrillic letters
            String fourByteCharacters = "\ud841\udf0e\ud841\udf31\ud841\udf79\ud843\udc53"; // Chinese symbols
            String utf8String = oneByteCharacters + twoByteCharacters + fourByteCharacters;

            MetadataList metaList = new MetadataList();
            metaList.AddMetadata( new Metadata( "utf8Key", utf8String, false ) );
            metaList.AddMetadata( new Metadata( utf8String, "utf8Value", false ) );

            ObjectId id = this.esu.CreateObject( null, metaList, null, null );
            cleanup.Add( id );

            // delete the UTF8 tag
            MetadataTags tags = new MetadataTags();
            tags.AddTag( new MetadataTag( utf8String, false ) );
            this.esu.DeleteUserMetadata( id, tags );

            // verify delete was successful
            tags = this.esu.ListUserMetadataTags( id );
            Assert.IsFalse( tags.Contains( utf8String ), "UTF8 key was not deleted" );
        }
Exemplo n.º 8
0
        /// <summary>
        /// Test listing the versions of an object
        /// </summary>
        public void testDeleteVersion()
        {
            // Create an object
            MetadataList mlist = new MetadataList();
            Metadata listable = new Metadata("listable", "foo", true);
            Metadata unlistable = new Metadata("unlistable", "bar", false);
            Metadata listable2 = new Metadata("listable2", "foo2 foo2", true);
            Metadata unlistable2 = new Metadata("unlistable2", "bar2 bar2", false);
            mlist.AddMetadata(listable);
            mlist.AddMetadata(unlistable);
            mlist.AddMetadata(listable2);
            mlist.AddMetadata(unlistable2);
            ObjectId id = this.esu.CreateObject(null, mlist, null, null);
            Assert.IsNotNull(id, "null ID returned");
            cleanup.Add(id);

            // Version the object
            ObjectId vid1 = this.esu.VersionObject(id);
            cleanup.Add(vid1);
            Assert.IsNotNull(vid1, "null version ID returned");
            ObjectId vid2 = this.esu.VersionObject(id);
            cleanup.Add(vid2);
            Assert.IsNotNull(vid2, "null version ID returned");

            // List the versions and ensure their IDs are correct
            List<ObjectId> versions = this.esu.ListVersions(id);
            Assert.AreEqual(3, versions.Count, "Wrong number of versions returned");
            Assert.IsTrue(versions.Contains(vid1), "version 1 not found in version list");
            Assert.IsTrue(versions.Contains(vid2), "version 2 not found in version list");
            Assert.IsTrue(versions.Contains(id), "base object not found in version list");

            // Delete a version
            this.esu.DeleteVersion(vid2);
            versions = this.esu.ListVersions(id);
            Assert.AreEqual(2, versions.Count, "Wrong number of versions returned");
            Assert.IsTrue(versions.Contains(vid1), "version 1 not found in version list");
            Assert.IsFalse(versions.Contains(vid2), "version 2 found in version list (should be deleted)");
            Assert.IsTrue(versions.Contains(id), "base object not found in version list");
        }
Exemplo n.º 9
0
        public void testUtf8Metadata() {
            String oneByteCharacters = "Hello! ";
            String twoByteCharacters = "\u0410\u0411\u0412\u0413"; // Cyrillic letters
            String fourByteCharacters = "\ud841\udf0e\ud841\udf31\ud841\udf79\ud843\udc53"; // Chinese symbols
            String utf8String = oneByteCharacters + twoByteCharacters + fourByteCharacters;

            MetadataList metaList = new MetadataList();
            metaList.AddMetadata( new Metadata( "utf8Key", utf8String, false ) );
            metaList.AddMetadata( new Metadata( utf8String, "utf8Value", false ) );

            ObjectId id = this.esu.CreateObject( null, metaList, null, null );
            cleanup.Add( id );

            // list all tags and make sure the UTF8 tag is in the list
            MetadataTags tags = this.esu.ListUserMetadataTags( id );
            Assert.IsTrue( tags.Contains( utf8String ), "UTF8 key not found in tag list" );

            // get the user metadata and make sure all UTF8 characters are accurate
            metaList = this.esu.GetUserMetadata( id, null );
            Metadata meta = metaList.GetMetadata( utf8String );
            Assert.AreEqual( meta.Name, utf8String, "UTF8 key does not match" );
            Assert.AreEqual( meta.Value, "utf8Value", "UTF8 key value does not match" );
            Assert.AreEqual( metaList.GetMetadata( "utf8Key" ).Value, utf8String, "UTF8 value does not match" );

            // test set metadata with UTF8
            metaList = new MetadataList();
            metaList.AddMetadata( new Metadata( "newKey", utf8String + "2", false ) );
            metaList.AddMetadata( new Metadata( utf8String + "2", "newValue", false ) );
            this.esu.SetUserMetadata( id, metaList );

            // verify set metadata call (also testing getAllMetadata)
            ObjectMetadata objMeta = this.esu.GetAllMetadata( id );
            metaList = objMeta.Metadata;
            meta = metaList.GetMetadata( utf8String + "2" );
            Assert.AreEqual( meta.Name, utf8String + "2", "UTF8 key does not match" );
            Assert.AreEqual( meta.Value, "newValue", "UTF8 key value does not match" );
            Assert.AreEqual( metaList.GetMetadata( "newKey" ).Value, utf8String + "2", "UTF8 value does not match" );
        }
Exemplo n.º 10
0
        public void testUtf8MetadataFilter() {
            String oneByteCharacters = "Hello! ";
            String twoByteCharacters = "\u0410\u0411\u0412\u0413"; // Cyrillic letters
            String fourByteCharacters = "\ud841\udf0e\ud841\udf31\ud841\udf79\ud843\udc53"; // Chinese symbols
            String utf8String = oneByteCharacters + twoByteCharacters + fourByteCharacters;

            MetadataList metaList = new MetadataList();
            metaList.AddMetadata( new Metadata( "utf8Key", utf8String, false ) );
            metaList.AddMetadata( new Metadata( utf8String, "utf8Value", false ) );

            ObjectId id = this.esu.CreateObject( null, metaList, null, null );
            cleanup.Add( id );

            // apply a filter that includes the UTF8 tag
            MetadataTags tags = new MetadataTags();
            tags.AddTag( new MetadataTag( utf8String, false ) );
            metaList = this.esu.GetUserMetadata( id, tags );
            Assert.AreEqual( metaList.Count(), 1, "UTF8 filter was not honored" );
            Assert.IsNotNull( metaList.GetMetadata( utf8String ), "UTF8 key was not found in filtered results" );
        }
Exemplo n.º 11
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");
        }
Exemplo n.º 12
0
        public void testGetObjectInfo()
        {
            MetadataList mlist = new MetadataList();
            Metadata policy = new Metadata("policy", "retaindelete", false);
            mlist.AddMetadata(policy);
            ObjectId id = this.esu.CreateObject(null, mlist, Encoding.UTF8.GetBytes("hello"), "text/plain");
            Assert.IsNotNull(id, "null ID returned");
            cleanup.Add(id);

            // Read back the content
            string content = Encoding.UTF8.GetString(this.esu.ReadObject(id, null, null));
            Assert.AreEqual("hello", content, "object content wrong");

            ObjectInfo info = this.esu.GetObjectInfo(id);
            Assert.IsNotNull(info, "ObjectInfo null");
            Assert.IsNotNull(info.ObjectID, "ObjectId null");
            Assert.IsNotNull(info.RawXml, "Raw XML null");
            Assert.IsNotNull(info.Replicas, "Replicas is null");
            Assert.IsTrue(info.Replicas.Count > 0, "Zero replicas found");
            Assert.IsNotNull(info.Retention, "No retention information");
            Assert.IsNotNull(info.Expiration, "Expiration null");
            Assert.IsNotNull(info.Selection, "Selection null");

            Debug.WriteLine("Expires: " + info.Expiration.EndAt);
            Debug.WriteLine("Retention ends: " + info.Retention.EndAt);
        }
Exemplo n.º 13
0
	    public void testGetAllMetadataById() {
            // Create an object with an ACL
            Acl acl = new Acl();
            acl.AddGrant(new Grant(new Grantee(getUid(esu.GetUid()), Grantee.GRANTEE_TYPE.USER), Permission.FULL_CONTROL));
            acl.AddGrant( new Grant( Grantee.OTHER, Permission.READ ) );
            MetadataList mlist = new MetadataList();
            Metadata listable = new Metadata( "listable", "foo", true );
            Metadata unlistable = new Metadata( "unlistable", "bar", false );
            Metadata listable2 = new Metadata( "listable2", "foo2 foo2", true );
            Metadata unlistable2 = new Metadata( "unlistable2", "bar2 bar2", false );
            mlist.AddMetadata(listable);
            mlist.AddMetadata(unlistable);
            mlist.AddMetadata(listable2);
            mlist.AddMetadata(unlistable2);

            ObjectId id = this.esu.CreateObject( acl, mlist, null, null );
            Assert.IsNotNull( id, "null ID returned" );
            cleanup.Add( id );
            
            // Read it back with HEAD call
            ObjectMetadata om = this.esu.GetAllMetadata( id );
            Assert.IsNotNull(om.Metadata.GetMetadata("listable"), "value of 'listable' missing");
            Assert.IsNotNull(om.Metadata.GetMetadata("unlistable"), "value of 'unlistable' missing");
            Assert.IsNotNull(om.Metadata.GetMetadata("atime"), "value of 'atime' missing");
            Assert.IsNotNull(om.Metadata.GetMetadata("ctime"), "value of 'ctime' missing");
            Assert.AreEqual("foo", om.Metadata.GetMetadata("listable").Value, "value of 'listable' wrong");
            Assert.AreEqual("bar", om.Metadata.GetMetadata("unlistable").Value, "value of 'unlistable' wrong");

            // Check the ACL
            Assert.AreEqual( acl, om.ACL, "ACLs don't match" );
    		
	    }
Exemplo n.º 14
0
        public void testVersionObject()
        {
            // Create an object
            MetadataList mlist = new MetadataList();
            Metadata listable = new Metadata("listable", "foo", true);
            Metadata unlistable = new Metadata("unlistable", "bar", false);
            Metadata listable2 = new Metadata("listable2", "foo2 foo2", true);
            Metadata unlistable2 = new Metadata("unlistable2", "bar2 bar2", false);
            mlist.AddMetadata(listable);
            mlist.AddMetadata(unlistable);
            mlist.AddMetadata(listable2);
            mlist.AddMetadata(unlistable2);
            ObjectId id = this.esu.CreateObject(null, mlist, null, null);
            Assert.IsNotNull(id, "null ID returned");
            cleanup.Add(id);

            // Version the object
            ObjectId vid = this.esu.VersionObject(id);
            cleanup.Add(vid);
            Assert.IsNotNull(vid, "null version ID returned");

            Assert.IsFalse(id.Equals(vid), "Version ID shoudn't be same as original ID");

            // Fetch the version and read its data
            MetadataList meta = this.esu.GetUserMetadata(vid, null);
            Assert.AreEqual("foo", meta.GetMetadata("listable").Value, "value of 'listable' wrong");
            Assert.AreEqual("foo2 foo2", meta.GetMetadata("listable2").Value, "value of 'listable2' wrong");
            Assert.AreEqual("bar", meta.GetMetadata("unlistable").Value, "value of 'unlistable' wrong");
            Assert.AreEqual("bar2 bar2", meta.GetMetadata("unlistable2").Value, "value of 'unlistable2' wrong");

        }
Exemplo n.º 15
0
        public void testUtf8ListableMetadata() {
            String oneByteCharacters = "Hello! ";
            String twoByteCharacters = "\u0410\u0411\u0412\u0413"; // Cyrillic letters
            String fourByteCharacters = "\ud841\udf0e\ud841\udf31\ud841\udf79\ud843\udc53"; // Chinese symbols
            String utf8String = oneByteCharacters + twoByteCharacters + fourByteCharacters;

            MetadataList metaList = new MetadataList();
            metaList.AddMetadata( new Metadata( utf8String, "utf8Value", true ) );

            ObjectId id = this.esu.CreateObject( null, metaList, null, null );
            cleanup.Add( id );

            metaList = this.esu.GetUserMetadata( id, null );
            Metadata meta = metaList.GetMetadata( utf8String );
            Assert.AreEqual( meta.Name, utf8String, "UTF8 key does not match" );
            Assert.AreEqual( meta.Value, "utf8Value", "UTF8 key value does not match" );
            Assert.IsTrue( meta.Listable, "UTF8 metadata is not listable" );

            // verify we can list the tag and see our object
            bool found = false;
            foreach ( ObjectResult result in this.esu.ListObjects( utf8String, null ) ) {
                if ( result.Id.Equals( id ) ) {
                    found = true;
                    break;
                }
            }
            Assert.IsTrue( found, "UTF8 tag listing did not contain the correct object ID" );

            // verify we can list child tags of the UTF8 tag
            MetadataTags tags = this.esu.GetListableTags( new MetadataTag( utf8String, true ) );
            Assert.IsNotNull( tags, "UTF8 child tag listing was null" );
        }
Exemplo n.º 16
0
        public void testGetSystemMetadata() {
            // Create an object
            MetadataList mlist = new MetadataList();
            Metadata listable = new Metadata( "listable", "foo", true );
            Metadata unlistable = new Metadata( "unlistable", "bar", false );
            Metadata listable2 = new Metadata( "listable2", "foo2 foo2", true );
            Metadata unlistable2 = new Metadata( "unlistable2", "bar2 bar2", false );
            mlist.AddMetadata( listable );
            mlist.AddMetadata( unlistable );
            mlist.AddMetadata( listable2 );
            mlist.AddMetadata( unlistable2 );
            ObjectId id = this.esu.CreateObject( null, mlist, null, null );
            Assert.IsNotNull( id,"null ID returned" );
            cleanup.Add( id );

            // Read only part of the metadata
            MetadataTags mtags = new MetadataTags();
            mtags.AddTag( new MetadataTag( "atime", false ) );
            mtags.AddTag( new MetadataTag( "ctime", false ) );
            MetadataList meta = this.esu.GetSystemMetadata( id, mtags );
            Assert.IsNotNull( meta.GetMetadata( "atime" ), "value of 'atime' missing" );
            Assert.IsNull( meta.GetMetadata( "mtime" ), "value of 'mtime' should not have been returned" );
            Assert.IsNotNull( meta.GetMetadata( "ctime" ), "value of 'ctime' missing" );
            Assert.IsNull( meta.GetMetadata( "gid" ), "value of 'gid' should not have been returned" );
            Assert.IsNull( meta.GetMetadata( "listable" ), "value of 'listable' should not have been returned" );
        }
Exemplo n.º 17
0
        public void testUtf8ListableTagWithComma() {
            String stringWithComma = "Hello, you!";

            MetadataList metaList = new MetadataList();
            metaList.AddMetadata( new Metadata( stringWithComma, "value", true ) );

            ObjectId id = this.esu.CreateObject( null, metaList, null, null );
            cleanup.Add( id );

            metaList = this.esu.GetUserMetadata( id, null );
            Metadata meta = metaList.GetMetadata( stringWithComma );
            Assert.AreEqual( meta.Name, stringWithComma, "key does not match" );
            Assert.IsTrue( meta.Listable, "metadata is not listable" );

            bool found = false;
            foreach ( ObjectResult result in this.esu.ListObjects( stringWithComma, null ) ) {
                if ( result.Id.Equals( id ) ) {
                    found = true;
                    break;
                }
            }
            Assert.IsTrue( found, "listing did not contain the correct object ID" );
        }
Exemplo n.º 18
0
        public void testListObjects()
        {
            // Create an object
            MetadataList mlist = new MetadataList();
            Metadata listable = new Metadata("listable", "foo", true);
            Metadata unlistable = new Metadata("unlistable", "bar", false);
            Metadata listable2 = new Metadata("listable2", "foo2 foo2", true);
            Metadata unlistable2 = new Metadata("unlistable2", "bar2 bar2", false);
            mlist.AddMetadata(listable);
            mlist.AddMetadata(unlistable);
            mlist.AddMetadata(listable2);
            mlist.AddMetadata(unlistable2);
            ObjectId id = this.esu.CreateObject(null, mlist, null, null);
            Assert.IsNotNull(id, "null ID returned");
            cleanup.Add(id);

            // List the objects.  Make sure the one we created is in the list
            List<ObjectResult> objects = this.esu.ListObjects("listable", null);
            Assert.IsTrue(objects.Count > 0, "No objects returned");
            Assert.IsTrue(containsId(objects, id), "object not found in list");

            // Check for unlisted
            try
            {
                this.esu.ListObjects("unlistable", null);
                Assert.Fail("Exception not thrown!");
            }
            catch (EsuException e)
            {
                // This should happen.
                Assert.AreEqual(1003, e.Code, "Expected 1003 for not found");
            }
        }
Exemplo n.º 19
0
        public void testCreateObjectWithNBSP()
        {
            MetadataList mlist = new MetadataList();
            Metadata nbspValue = new Metadata("nbspvalue", "Nobreak\u00A0Value", false);
            Metadata nbspName = new Metadata("Nobreak\u00A0Name", "regular text here", false);
            Console.WriteLine("NBSP Value: " + nbspValue);
            Console.WriteLine("NBSP Name: " + nbspName);

            mlist.AddMetadata(nbspValue);
            mlist.AddMetadata(nbspName);
            ObjectId id = this.esu.CreateObject(null, mlist, null, null);
            Assert.IsNotNull(id, "null ID returned");
            cleanup.Add(id);

            // Read and validate the metadata
            MetadataList meta = this.esu.GetUserMetadata(id, null);
            Console.WriteLine("Read Back:");
            Console.WriteLine("NBSP Value: " + meta.GetMetadata("nbspvalue"));
            Console.WriteLine("NBSP Name: " + meta.GetMetadata("Nobreak\u00A0Name"));
            Assert.AreEqual("Nobreak\u00A0Value", meta.GetMetadata("nbspvalue").Value, "value of 'nobreakvalue' wrong");

        }
Exemplo n.º 20
0
        public void testListObjectsWithMetadata()
        {
            // Create an object
            MetadataList mlist = new MetadataList();
            Metadata listable = new Metadata("listable", "foo", true);
            Metadata unlistable = new Metadata("unlistable", "bar", false);
            Metadata listable2 = new Metadata("listable2", "foo2 foo2", true);
            Metadata unlistable2 = new Metadata("unlistable2", "bar2 bar2", false);
            mlist.AddMetadata(listable);
            mlist.AddMetadata(unlistable);
            mlist.AddMetadata(listable2);
            mlist.AddMetadata(unlistable2);
            ObjectId id = this.esu.CreateObject(null, mlist, null, null);
            Assert.IsNotNull(id, "null ID returned");
            cleanup.Add(id);

            // List the objects.  Make sure the one we created is in the list
            ListOptions options = new ListOptions();
            options.IncludeMetadata = true;
            List<ObjectResult> objects = this.esu.ListObjects("listable", options);
            Assert.IsTrue(objects.Count > 0, "No objects returned");

            bool found = false;
            foreach (ObjectResult or in objects)
            {
                if (or.Id.Equals(id))
                {
                    found = true;
                    //Test metadata value
                    Assert.AreEqual("foo", or.meta.GetMetadata("listable").Value, "Metadata value wrong");
                }
            }

            Assert.IsTrue(found, "object not found in list");

            
        }
Exemplo n.º 21
0
        public void testCreateObjectWithMetadataNormalizeSpaces()
        {
            MetadataList mlist = new MetadataList();
            Metadata listable = new Metadata("listable", "foo", true);
            Metadata unlistable = new Metadata("unlistable", "bar  bar", false);
            Metadata listable2 = new Metadata("listable2", "foo2    foo2", true);
            Metadata unlistable2 = new Metadata("unlistable2", "bar2       bar2", false);
            Metadata empty = new Metadata("empty", "", false);
            //Metadata withEqual = new Metadata("withEqual", "x=y=z", false);
            mlist.AddMetadata(listable);
            mlist.AddMetadata(unlistable);
            mlist.AddMetadata(listable2);
            mlist.AddMetadata(unlistable2);
            mlist.AddMetadata(empty);
            //mlist.AddMetadata(withEqual);
            ObjectId id = this.esu.CreateObject(null, mlist, null, null);
            Assert.IsNotNull(id, "null ID returned");
            cleanup.Add(id);

            // Read and validate the metadata
            MetadataList meta = this.esu.GetUserMetadata(id, null);
            Assert.AreEqual("foo", meta.GetMetadata("listable").Value, "value of 'listable' wrong");
            Assert.AreEqual("foo2    foo2", meta.GetMetadata("listable2").Value, "value of 'listable2' wrong");
            Assert.AreEqual("bar  bar", meta.GetMetadata("unlistable").Value, "value of 'unlistable' wrong");
            Assert.AreEqual("bar2       bar2", meta.GetMetadata("unlistable2").Value, "value of 'unlistable2' wrong");
            Assert.AreEqual("", meta.GetMetadata("empty").Value, "value of 'empty' wrong");
            //Assert.AreEqual("x=y=z", meta.GetMetadata("withEqual").Value, "value of 'withEqual' wrong");

        }
Exemplo n.º 22
0
        public void testListUserMetadataTags() {
            // Create an object
            MetadataList mlist = new MetadataList();
            Metadata listable = new Metadata( "listable", "foo", true );
            Metadata unlistable = new Metadata( "unlistable", "bar", false );
            Metadata listable2 = new Metadata( "list/able/2", "foo2 foo2", true );
            Metadata unlistable2 = new Metadata( "list/able/not", "bar2 bar2", false );
            mlist.AddMetadata( listable );
            mlist.AddMetadata( unlistable );
            mlist.AddMetadata( listable2 );
            mlist.AddMetadata( unlistable2 );
            ObjectId id = this.esu.CreateObject( null, mlist, null, null );
            Assert.IsNotNull( id,"null ID returned" );
            cleanup.Add( id );

            // List tags
            MetadataTags tags = this.esu.ListUserMetadataTags( id );
            Assert.IsTrue( tags.Contains( "listable" ), "listable tag not returned" );
            Assert.IsTrue( tags.Contains( "list/able/2" ), "list/able/2 tag not returned" );
            Assert.IsTrue( tags.Contains( "unlistable" ), "unlistable tag not returned" );
            Assert.IsTrue( tags.Contains( "list/able/not" ), "list/able/not tag not returned" );
            Assert.IsFalse( tags.Contains( "unknowntag" ), "unknown tag returned" );

            // Check listable flag
            Assert.IsTrue( tags.GetTag( "listable" ).Listable, "'listable' is not listable" );
            Assert.IsTrue( tags.GetTag( "list/able/2" ).Listable, "'list/able/2' is not listable" );
            Assert.IsFalse( tags.GetTag( "unlistable" ).Listable, "'unlistable' is listable" );
            Assert.IsFalse( tags.GetTag( "list/able/not" ).Listable, "'list/able/not' is listable" );
        }
Exemplo n.º 23
0
        public void testReadObjectStream()
        {
            Acl acl = new Acl();
            acl.AddGrant(new Grant(new Grantee(getUid(esu.GetUid()), Grantee.GRANTEE_TYPE.USER), Permission.FULL_CONTROL));
            acl.AddGrant(new Grant(Grantee.OTHER, Permission.READ));
            MetadataList mlist = new MetadataList();
            Metadata listable = new Metadata("listable", "foo", true);
            Metadata unlistable = new Metadata("unlistable", "bar", false);
            Metadata listable2 = new Metadata("listable2", "foo2 foo2", true);
            Metadata unlistable2 = new Metadata("unlistable2", "bar2 bar2", false);
            Metadata empty = new Metadata("empty", "", false);
            //Metadata withEqual = new Metadata("withEqual", "x=y=z", false);
            mlist.AddMetadata(listable);
            mlist.AddMetadata(unlistable);
            mlist.AddMetadata(listable2);
            mlist.AddMetadata(unlistable2);
            mlist.AddMetadata(empty);

            ObjectId id = esu.CreateObject(acl, mlist, Encoding.UTF8.GetBytes("hello"), "text/plain; charset=UTF-8");
            cleanup.Add(id);

            // Read back
            ReadObjectStreamResponse response = esu.ReadObjectStream(id, null);

            // Check content
            Assert.AreEqual(5, response.Length, "Content length incorrect");
            Assert.AreEqual("text/plain; charset=UTF-8", response.ContentType, "Content type incorrect");
            byte[] buffer = new byte[1024];
            int count = response.Content.Read(buffer, 0, buffer.Length);
            response.Close();

            Assert.AreEqual(5, count, "Incorrect number of bytes read from stream");
            string content = Encoding.UTF8.GetString(buffer, 0, count);
            Assert.AreEqual("hello", content, "Stream content incorrect");

            // Check metadata
            MetadataList meta = response.Metadata;
            Assert.AreEqual("foo", meta.GetMetadata("listable").Value, "value of 'listable' wrong");
            Assert.AreEqual("foo2 foo2", meta.GetMetadata("listable2").Value, "value of 'listable2' wrong");
            Assert.AreEqual("bar", meta.GetMetadata("unlistable").Value, "value of 'unlistable' wrong");
            Assert.AreEqual("bar2 bar2", meta.GetMetadata("unlistable2").Value, "value of 'unlistable2' wrong");
            Assert.AreEqual("", meta.GetMetadata("empty").Value, "value of 'empty' wrong");

            // Check ACL
            Acl newacl = response.Acl;
            Debug.WriteLine("Comparing " + newacl + " with " + acl);

            Assert.AreEqual(acl, newacl, "ACLs don't match");

            // Read a segment of the data back
            Extent extent = new Extent(1, 2);
            response = esu.ReadObjectStream(id, extent);
            count = response.Content.Read(buffer, 0, buffer.Length);
            response.Close();
            Assert.AreEqual(2, count, "Incorrect number of bytes read from stream");
            content = Encoding.UTF8.GetString(buffer, 0, count);
            Assert.AreEqual("el", content, "Stream content incorrect");

        }
Exemplo n.º 24
0
        private void readMetadata( MetadataList meta, string header, bool listable )
        {
            if( header == null ) {
                return;
            }

            string[] attrs = header.Split( new string[] { "," }, StringSplitOptions.RemoveEmptyEntries );
            for( int i = 0; i < attrs.Length; i++ ) {
                string[] nvpair = attrs[i].Split( new string[] { "=" }, 2, StringSplitOptions.RemoveEmptyEntries );
                string name = nvpair[0];
                string value = "";
                if (nvpair.Length > 1)
                {
                    value = nvpair[1];
                }

                name = name.Trim();

                if (utf8Enabled)
                {
                    name = utf8Decode(name);
                    value = utf8Decode(value);
                }

                Metadata m = new Metadata( name, value, listable );
                log.TraceEvent(TraceEventType.Verbose, 0,  "Meta: " + m );
                meta.AddMetadata( m );
            }
        }
Exemplo n.º 25
0
        public void testListDirectoryWithMetadata()
        {
            // Create an object
            MetadataList mlist = new MetadataList();
            Metadata listable = new Metadata("listable", "foo", true);
            Metadata unlistable = new Metadata("unlistable", "bar", false);
            Metadata listable2 = new Metadata("listable2", "foo2 foo2", true);
            Metadata unlistable2 = new Metadata("unlistable2", "bar2 bar2", false);
            mlist.AddMetadata(listable);
            mlist.AddMetadata(unlistable);
            mlist.AddMetadata(listable2);
            mlist.AddMetadata(unlistable2);
            string dir = rand8char();
            string file = rand8char();
            ObjectPath dirPath = new ObjectPath("/" + dir + "/");
            ObjectPath op = new ObjectPath("/" + dir + "/" + file);

            ObjectId dirId = this.esu.CreateObjectOnPath(dirPath, null, null, null, null);
            ObjectId id = this.esu.CreateObjectOnPath(op, null, mlist, null, null);
            cleanup.Add(op);
            cleanup.Add(dirPath);
            Debug.WriteLine("Path: " + op + " ID: " + id);
            Assert.IsNotNull(id);
            Assert.IsNotNull(dirId);

            // Read back the content
            string content = Encoding.UTF8.GetString(this.esu.ReadObject(op, null, null));
            Assert.AreEqual("", content, "object content wrong");
            content = Encoding.UTF8.GetString(this.esu.ReadObject(id, null, null));
            Assert.AreEqual("", content, "object content wrong when reading by id");

            // List the parent path
            ListOptions options = new ListOptions();
            options.IncludeMetadata = true;
            //options.UserMetadata = new List<string>();
            //options.UserMetadata.Add("listable");
            List<DirectoryEntry> dirList = esu.ListDirectory(dirPath, options);
            Debug.WriteLine("Dir content: " + content);
            DirectoryEntry ent = findInDirectory(dirList, op);
            Assert.IsNotNull(ent, "File not found in directory");

            // Check metadata
            Assert.IsNotNull(ent.SystemMetadata.GetMetadata("size"), "Size missing from metadata");
            Assert.AreEqual("foo", ent.UserMetadata.GetMetadata("listable").Value, "Metadata value wrong");

            // listable2 should not be present
            //Assert.IsNull(ent.UserMetadata.GetMetadata("listable2"), "listable2 shouldn't be present");
        }