Esempio n. 1
0
        public void testAppend()
        {
            // could possibly split this into different tests
            String uri = "/localhost/user/folders/files/%00%0F";
            Name name = new Name(uri);
            Name name2 = new Name("/localhost").append(new Name("/user/folders/"));
            Assert.AssertEquals("Name constructed by appending names has " + name2.size()
                    + " components instead of 3", 3, name2.size());
            Assert.AssertTrue("Name constructed with append has wrong suffix", name2
                    .get(2).getValue().equals(new Blob("folders")));
            name2 = name2.append("files");
            Assert.AssertEquals("Name constructed by appending string has " + name2.size()
                    + " components instead of 4", 4, name2.size());
            name2 = name2.appendSegment(15);
            Assert.AssertTrue(
                    "Name constructed by appending segment has wrong segment value",
                    name2.get(4).getValue()
                            .equals(new Blob(new int[] { 0x00, 0x0F })));

            Assert.AssertTrue(
                    "Name constructed with append is not equal to URI constructed name",
                    name2.equals(name));
            Assert.AssertEquals("Name constructed with append has wrong URI",
                    name.toUri(), name2.toUri());
        }