KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > util > TestCmsExportFolderMatcher


1 /*
2  * File : $Source: /usr/local/cvs/opencms/test/org/opencms/util/TestCmsExportFolderMatcher.java,v $
3  * Date : $Date: 2005/06/23 14:27:27 $
4  * Version: $Revision: 1.7 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.util;
33
34 import org.opencms.staticexport.CmsExportFolderMatcher;
35
36 import java.util.ArrayList JavaDoc;
37
38 import junit.framework.TestCase;
39
40 /**
41  * @author Alexander Kandzior
42  *
43  * @version $Revision: 1.7 $
44  *
45  * @since 6.0.0
46  */

47 public class TestCmsExportFolderMatcher extends TestCase {
48
49     private static String JavaDoc checkRes = "/system/opencms.ini";
50
51     /**
52      * Default JUnit constructor.<p>
53      *
54      * @param arg0 JUnit parameters
55      */

56     public TestCmsExportFolderMatcher(String JavaDoc arg0) {
57
58         super(arg0);
59     }
60
61     /**
62      * Tests for the resource name translation.<p>
63      */

64     public void testTranslateResource() {
65
66         /** default folders. */
67         ArrayList JavaDoc folders = new ArrayList JavaDoc();
68
69         folders.add("\\/sites\\/.*");
70         folders.add("\\/system\\/galleries\\/.*");
71         folders.add("\\/system\\/modules\\/.*\\/resources\\/.*");
72
73         CmsExportFolderMatcher matcher = new CmsExportFolderMatcher(folders, checkRes);
74
75         boolean test;
76         test = matcher.match("/system/opencms.ini");
77         assertEquals(test, true);
78
79         test = matcher.match("/sites/default/index.html");
80         assertEquals(test, true);
81
82         test = matcher.match("/sites/default/folder/index.html");
83         assertEquals(test, true);
84
85         test = matcher.match("/gibtsnicht/index.html");
86         assertEquals(test, false);
87
88         test = matcher.match("/system/galleries/pics/demo.gif");
89         assertEquals(test, true);
90
91         test = matcher.match("/system/modules/org.opencms.welcome/resources/test.gif");
92         assertEquals(test, true);
93
94         test = matcher.match("/system/modules/org.opencms.welcome/templates/test.jsp");
95         assertEquals(test, false);
96
97     }
98
99 }
100
Popular Tags