1 package org.jahia.urls; 2 3 import junit.framework.*; 4 5 public class TestServletURL extends TestCase { 6 private ServletURL servletURL = null; 7 8 protected void setUp() throws Exception { 9 super.setUp(); 10 11 servletURL = new ServletURL(); 12 } 13 14 protected void tearDown() throws Exception { 15 servletURL = null; 16 super.tearDown(); 17 } 18 19 public void testMatchesServletPattern() { 20 String pattern = null; 21 String servletPath = null; 22 boolean expectedReturn = false; 23 boolean actualReturn = servletURL.matchesServletPattern(pattern, servletPath); 24 assertEquals("return value", expectedReturn, actualReturn); 25 26 27 29 pattern = "/Jahia/*"; 30 servletPath = "/Jahia"; 31 expectedReturn = true; 32 actualReturn = servletURL.matchesServletPattern(pattern, servletPath); 33 assertEquals("return value", expectedReturn, actualReturn); 34 35 pattern = "*.do"; 36 servletPath = "/Jahia.do"; 37 expectedReturn = true; 38 actualReturn = servletURL.matchesServletPattern(pattern, servletPath); 39 assertEquals("return value", expectedReturn, actualReturn); 40 41 pattern = "/exact/Mapping"; 42 servletPath = "/exact/Mapping"; 43 expectedReturn = true; 44 actualReturn = servletURL.matchesServletPattern(pattern, servletPath); 45 assertEquals("return value", expectedReturn, actualReturn); 46 47 pattern = "/"; 48 servletPath = "/any/mapping"; 49 expectedReturn = true; 50 actualReturn = servletURL.matchesServletPattern(pattern, servletPath); 51 assertEquals("return value", expectedReturn, actualReturn); 52 53 pattern = "/Jahia/*"; 55 servletPath = "Jahia"; 56 expectedReturn = false; 57 actualReturn = servletURL.matchesServletPattern(pattern, servletPath); 58 assertEquals("return value", expectedReturn, actualReturn); 59 60 pattern = "*.do"; 61 servletPath = ".do.test"; 62 expectedReturn = false; 63 actualReturn = servletURL.matchesServletPattern(pattern, servletPath); 64 assertEquals("return value", expectedReturn, actualReturn); 65 66 pattern = "/exact/Mapping"; 67 servletPath = "/exact/mapping"; 68 expectedReturn = false; 69 actualReturn = servletURL.matchesServletPattern(pattern, servletPath); 70 assertEquals("return value", expectedReturn, actualReturn); 71 72 } 73 74 } 75 | Popular Tags |