Ejemplo n.º 1
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" );

        }
Ejemplo n.º 2
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");
        }
Ejemplo n.º 3
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");

            
        }
Ejemplo n.º 4
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");
        }
Ejemplo n.º 5
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");
            }
        }
Ejemplo n.º 6
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" );

	    }
Ejemplo n.º 7
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" );
        }
Ejemplo n.º 8
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" );

        }
Ejemplo n.º 9
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" );
        }
Ejemplo n.º 10
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");

        }
Ejemplo n.º 11
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");

        }
Ejemplo n.º 12
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");

        }
Ejemplo n.º 13
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);
        }
Ejemplo n.º 14
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" );
    		
	    }
Ejemplo n.º 15
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" );
        }
Ejemplo n.º 16
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");

        }
Ejemplo n.º 17
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" );

        }
Ejemplo n.º 18
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");
        }