Package org.amdatu.web.resourcehandler

Examples of org.amdatu.web.resourcehandler.DefaultPages


     * @param key the key to parse, can be <code>null</code> or empty.
     * @return the {@link DefaultPages} instance with the parsed information, never <code>null</code>.
     * @throws InvalidEntryException in case the given key contained an invalid entry.
     */
    public static DefaultPages parseDefaultPages(String key) throws InvalidEntryException {
        DefaultPages defaultPages = new DefaultPages();

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

 
View Full Code Here


* Test cases for {@link DefaultPageParser}.
*/
public class DefaultPageParserTest extends TestCase {

    public void testAddGlobalAndLocalDefaultOk() throws Exception {
        DefaultPages defaultPages = parseDefaultPages("default.html, /a=index.html");
        Collection<String> pages;

        pages = defaultPages.getDefaultPagesFor("/");
        assertTrue(pages.contains("/default.html"));

        pages = defaultPages.getDefaultPagesFor("/a");
        assertTrue(pages.contains("/a/index.html"));

        pages = defaultPages.getDefaultPagesFor("/a/b");
        assertTrue(pages.contains("/a/default.html"));
        assertTrue(pages.contains("/a/b/default.html"));

        pages = defaultPages.getDefaultPagesFor("/c");
        assertTrue(pages.contains("/c/default.html"));
    }
View Full Code Here

        pages = defaultPages.getDefaultPagesFor("/c");
        assertTrue(pages.contains("/c/default.html"));
    }

    public void testAddLocalDefaultOk() throws Exception {
        DefaultPages defaultPages = parseDefaultPages("/a=index.html");
        Collection<String> pages;

        pages = defaultPages.getDefaultPagesFor("/");
        assertTrue(pages.isEmpty());

        pages = defaultPages.getDefaultPagesFor("/a");
        assertTrue(pages.contains("/a/index.html"));

        pages = defaultPages.getDefaultPagesFor("/aaa");
        assertTrue(pages.isEmpty());

        pages = defaultPages.getDefaultPagesFor("/a/b");
        assertTrue(pages.isEmpty());
    }
View Full Code Here

        pages = defaultPages.getDefaultPagesFor("/a/b");
        assertTrue(pages.isEmpty());
    }

    public void testAddPartlyOverlappingLocalDefaultsOk() throws Exception {
        DefaultPages defaultPages = parseDefaultPages("/a=b.html, /a/b=c.html, /a/b/c=d.html, default.html");
        Collection<String> pages;

        pages = defaultPages.getDefaultPagesFor("/");
        assertTrue(pages.contains("/default.html"));

        pages = defaultPages.getDefaultPagesFor("/a");
        assertTrue(pages.contains("/a/b.html"));

        pages = defaultPages.getDefaultPagesFor("/a/b");
        assertTrue(pages.contains("/a/b/c.html"));

        pages = defaultPages.getDefaultPagesFor("/a/b/c");
        assertTrue(pages.contains("/a/b/c/d.html"));

        pages = defaultPages.getDefaultPagesFor("/a/b/c/d");
        assertTrue(pages.contains("/a/b/c/d/default.html"));

        pages = defaultPages.getDefaultPagesFor("/c");
        assertTrue(pages.contains("/c/default.html"));
    }
View Full Code Here

            // Ok; expected...
        }
    }

    public void testParseEmptyKeyOk() throws Exception {
        DefaultPages defaultPages = parseDefaultPages(" ");
        Collection<String> pages;

        pages = defaultPages.getDefaultPagesFor("/");
        assertTrue(pages.isEmpty());

        pages = defaultPages.getDefaultPagesFor("/a");
        assertTrue(pages.isEmpty());
    }
View Full Code Here

            // Ok; expected...
        }
    }

    public void testParseEntryWithoutPathOk() throws Exception {
        DefaultPages defaultPages = parseDefaultPages("=index.html");

        Collection<String> pages = defaultPages.getDefaultPagesFor("");
        assertTrue(pages.contains("/index.html"));
    }
View Full Code Here

        Collection<String> pages = defaultPages.getDefaultPagesFor("");
        assertTrue(pages.contains("/index.html"));
    }

    public void testParseGlobalEntryOk() throws Exception {
        DefaultPages defaultPages = parseDefaultPages("index.html");

        Collection<String> pages = defaultPages.getDefaultPagesFor("/");
        assertTrue(pages.contains("/index.html"));

        pages = defaultPages.getDefaultPagesFor("/a");
        assertTrue(pages.contains("/a/index.html"));
    }
View Full Code Here

        pages = defaultPages.getDefaultPagesFor("/a");
        assertTrue(pages.contains("/a/index.html"));
    }

    public void testParseNullKeyOk() throws Exception {
        DefaultPages defaultPages = parseDefaultPages(null);
        Collection<String> pages;

        pages = defaultPages.getDefaultPagesFor("/");
        assertTrue(pages.isEmpty());

        pages = defaultPages.getDefaultPagesFor("/a");
        assertTrue(pages.isEmpty());
    }
View Full Code Here

TOP

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

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.