Package org.fcrepo.server.storage.lowlevel.akubra

Examples of org.fcrepo.server.storage.lowlevel.akubra.HashPathIdMapper

Filesystem-Safe Encoding

The last part of the internal URI is a "filesystem-safe" encoding of the external URI. All characters will be UTF-8 percent-encoded ("URI escaped") except for the following: a-z A-Z 0-9 = ( ) [ ] - In addition, . (period) will be escaped as %2E when it occurs as the last character of the URI.

Example Mappings

With pattern #/#: With pattern ##/##: @author Chris Wilper

    }

    /** getExternalId should produce the expected URIs. */
    @Test
    public void testGetExternalId() {
        IdMapper mapper = new HashPathIdMapper("##/##/##");
        assertEquals(URI1, mapper.getExternalId(URI1_ENCODED));
        assertEquals(URI2, mapper.getExternalId(URI2_ENCODED));
        assertEquals(URI3, mapper.getExternalId(URI3_ENCODED));
    }
View Full Code Here


    }

    /** getInternalId should produce the expected URIs. */
    @Test
    public void testGetInternalId() {
        IdMapper mapper = new HashPathIdMapper("##/##/##");
        assertEquals(URI1_ENCODED, mapper.getInternalId(URI1));
        assertEquals(URI2_ENCODED, mapper.getInternalId(URI2));
        assertEquals(URI3_ENCODED, mapper.getInternalId(URI3));
    }
View Full Code Here

    }

    /** getInternalPrefix should throw NPE if given null. */
    @Test (expected=NullPointerException.class)
    public void testGetInternalPrefixNull() {
        new HashPathIdMapper("").getInternalPrefix(null);
    }
View Full Code Here

    /** getInternalPrefix should return encoded prefix if pattern is empty. */
    @Test
    public void testGetInternalPrefixNoPattern() {
        assertEquals("file:urn%3Atest",
                     new HashPathIdMapper("").getInternalPrefix("urn:test"));
    }
View Full Code Here

    }

    /** getInternalPrefix should return null if pattern is nonempty. */
    @Test
    public void testGetInternalPrefixWithPattern() {
        assertNull(new HashPathIdMapper("#").getInternalPrefix("urn:test"));
    }
View Full Code Here

        assertNull(new HashPathIdMapper("#").getInternalPrefix("urn:test"));
    }

    private static void runGenericTests(String pattern)
            throws Exception {
        IdMapper mapper = new HashPathIdMapper(pattern);
        checkRoundtrip(mapper, URI1);
        checkRoundtrip(mapper, URI2);
        checkRoundtrip(mapper, URI3);
    }
View Full Code Here

        assertEquals(orig, external);
    }

    private static void assertBadPattern(String pattern) {
        try {
            new HashPathIdMapper(pattern);
        } catch (Throwable th) {
            if (!(th instanceof IllegalArgumentException)) {
                fail("Bad pattern '" + pattern + "' should have thrown "
                     + "IllegalArgumentException, but threw "
                     + th.getClass().getName());
View Full Code Here

TOP

Related Classes of org.fcrepo.server.storage.lowlevel.akubra.HashPathIdMapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.