1 31 32 package org.opencms.search; 33 34 import junit.framework.TestCase; 35 36 42 public class TestCmsSearchUtils extends TestCase { 43 44 49 public TestCmsSearchUtils(String arg0) { 50 51 super(arg0); 52 } 53 54 59 public void testRootPathTokenizer() throws Exception { 60 61 String t = CmsSearchIndex.ROOT_PATH_TOKEN; 62 String s = CmsSearchIndex.ROOT_PATH_SUFFIX; 63 64 assertEquals(t, CmsSearchIndex.rootPathRewrite(null)); 65 assertEquals(t, CmsSearchIndex.rootPathRewrite("")); 66 assertEquals(t, CmsSearchIndex.rootPathRewrite("/")); 67 assertEquals(t + " sites" + s, CmsSearchIndex.rootPathRewrite("/sites/")); 68 assertEquals(t + " sites" + s, CmsSearchIndex.rootPathRewrite("/sites")); 69 assertEquals(t + " sites" + s + " default" + s, CmsSearchIndex.rootPathRewrite("/sites/default/")); 70 assertEquals(t + " sites" + s + " default" + s, CmsSearchIndex.rootPathRewrite("/sites/default")); 71 72 assertStringArray(new String [] {t}, CmsSearchIndex.rootPathSplit("/")); 73 assertStringArray(new String [] {t, "sites" + s}, CmsSearchIndex.rootPathSplit("/sites/")); 74 assertStringArray(new String [] {t, "sites" + s}, CmsSearchIndex.rootPathSplit("/sites")); 75 assertStringArray(new String [] {t, "sites" + s, "default" + s}, CmsSearchIndex.rootPathSplit("/sites/default/")); 76 assertStringArray(new String [] {t, "sites" + s, "default" + s}, CmsSearchIndex.rootPathSplit("/sites/default")); 77 78 } 79 80 85 public void assertStringArray(String [] a, String [] b) { 86 87 if ((a == null) || (b == null)) { 88 assertTrue(a == b); 89 } 90 assertEquals(a.length, b.length); 91 for (int i = 0; i < a.length; i++) { 92 assertEquals(a[i], b[i]); 93 } 94 } 95 }
| Popular Tags
|