Package org.amdatu.web.resourcehandler

Examples of org.amdatu.web.resourcehandler.ResourceEntryMap


     * @param key the string value of the {@link Constants#WEB_RESOURCE_KEY}, can be <code>null</code> or empty.
     * @return a map of entries, the key denotes the context ID and the value is a list of register items.
     * @throws InvalidEntryException when a entry in the given argument is considered invalid.
     */
    public static ResourceEntryMap getEntries(String key) throws InvalidEntryException {
        ResourceEntryMap result = new ResourceEntryMap();

        if ((key != null) && !"".equals(key.trim())) {
            Scanner scanner = new Scanner(key);
            scanner.useDelimiter(",\\s*");

            while (scanner.hasNext()) {
                Entry entry = new Entry(scanner.next());

                result.addEntry(entry.m_contextId, entry.m_alias, entry.m_path);
            }

            scanner.close();
        }

View Full Code Here


/**
* Test cases for {@link ResourceKeyParser}.
*/
public class ResourseKeyParserTest extends TestCase {
    public void testAliasOnlyOk() throws Exception {
        ResourceEntryMap entries = getEntries("path");

        List<ResourceEntry> list = entries.getEntry("");
        ResourceEntry item = list.get(0);

        assertEquals("/path", item.getAlias());
        assertPaths(item, "/path");
    }
View Full Code Here

        assertPaths(item, "/path");
    }

    public void testAliasPath() throws Exception {
        String entryText = "alias ; path";
        ResourceEntryMap entries = getEntries(entryText);

        Collection<String> contextIDs = entries.getContextIDs();
        assertEquals(1, contextIDs.size());
        assertTrue(contextIDs.contains(""));
    }
View Full Code Here

        assertTrue(contextIDs.contains(""));
    }

    public void testAliasPathContext() throws Exception {
        String entryText = "alias; path; context";
        ResourceEntryMap entries = getEntries(entryText);

        Collection<String> contextIDs = entries.getContextIDs();
        assertEquals(1, contextIDs.size());
        assertTrue(contextIDs.contains("context"));
    }
View Full Code Here

        assertTrue(contextIDs.contains("context"));
    }

    public void testCoercePathsForSameAliasOk() throws Exception {
        String entryText = "alias1;/path1, alias1;/path2, alias2;/path3, alias1;/path4";
        ResourceEntryMap entries = getEntries(entryText);

        List<ResourceEntry> list = entries.getEntry("");
        assertEquals(2, list.size());

        ResourceEntry entry;

        entry = list.get(0);
View Full Code Here

        assertEquals("/alias2", entry.getAlias());
        assertPaths(entry, "/path3");
    }

    public void testEmptyEntryOk() throws InvalidEntryException {
        ResourceEntryMap entries = getEntries(" ");
        assertTrue(entries.getContextIDs().isEmpty());
    }
View Full Code Here

        }
    }

    public void testMulipleContextsAndAliassesAndPaths() throws Exception {
        String entryText = "alias1;path1;context1, alias1;/path2;context2, alias2;/path3, alias3;path2;context1, ";
        ResourceEntryMap entries = getEntries(entryText);

        List<ResourceEntry> list;
        ResourceEntry item;

        list = entries.getEntry("context1");
        assertEquals(2, list.size());

        item = list.get(0);
        assertEquals("/alias1", item.getAlias());
        assertPaths(item, "/path1");

        item = list.get(1);
        assertEquals("/alias3", item.getAlias());
        assertPaths(item, "/path2");

        list = entries.getEntry("");
        assertEquals(1, list.size());

        item = list.get(0);
        assertEquals("/alias2", item.getAlias());
        assertPaths(item, "/path3");

        list = entries.getEntry("context2");
        assertEquals(1, list.size());

        item = list.get(0);
        assertEquals("/alias1", item.getAlias());
        assertPaths(item, "/path2");
View Full Code Here

        assertEquals("/alias1", item.getAlias());
        assertPaths(item, "/path2");
    }

    public void testNullEntryOk() throws InvalidEntryException {
        ResourceEntryMap entries = getEntries(null);
        assertTrue(entries.getContextIDs().isEmpty());
    }
View Full Code Here

TOP

Related Classes of org.amdatu.web.resourcehandler.ResourceEntryMap

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.