1 17 package org.alfresco.service.namespace; 18 19 20 import junit.framework.TestCase; 21 22 28 public class QNamePatternTest extends TestCase 29 { 30 private static final String TEST_NAMESPACE = "http://www.alfresco.org/QNamePatternTest"; 31 32 QName check1; 33 QName check2; 34 QName check3; 35 36 public QNamePatternTest(String name) 37 { 38 super(name); 39 } 40 41 public void setUp() throws Exception 42 { 43 check1 = QName.createQName(null, "ABC"); 44 check2 = QName.createQName(TEST_NAMESPACE, "XYZ"); 45 check3 = QName.createQName(TEST_NAMESPACE, "ABC"); 46 } 47 48 public void testSimpleQNamePattern() throws Exception 49 { 50 QNamePattern pattern = QName.createQName(TEST_NAMESPACE, "ABC"); 51 52 assertFalse("Simple match failed: " + check1, pattern.isMatch(check1)); 54 assertFalse("Simple match failed: " + check2, pattern.isMatch(check2)); 55 assertTrue("Simple match failed: " + check3, pattern.isMatch(check3)); 56 } 57 58 public void testRegexQNamePatternMatcher() throws Exception 59 { 60 QNamePattern pattern = new RegexQNamePattern(".*alfresco.*", "A.?C"); 61 62 assertFalse("Regex match failed: " + check1, pattern.isMatch(check1)); 64 assertFalse("Regex match failed: " + check2, pattern.isMatch(check2)); 65 assertTrue("Regex match failed: " + check3, pattern.isMatch(check3)); 66 67 assertTrue("All match failed: " + check1, RegexQNamePattern.MATCH_ALL.isMatch(check1)); 68 assertTrue("All match failed: " + check2, RegexQNamePattern.MATCH_ALL.isMatch(check2)); 69 assertTrue("All match failed: " + check3, RegexQNamePattern.MATCH_ALL.isMatch(check3)); 70 } 71 } 72 | Popular Tags |