KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > importexport > TestCmsImport


1 /*
2  * File : $Source: /usr/local/cvs/opencms/test/org/opencms/importexport/TestCmsImport.java,v $
3  * Date : $Date: 2005/06/26 11:23:00 $
4  * Version: $Revision: 1.9 $
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.importexport;
33
34 import junit.framework.TestCase;
35
36 /**
37  * Basic test cases for import/export utilities.<p>
38  *
39  * @author Alexander Kandzior
40  * @author Carsten Weinholz
41  *
42  * @version $Revision: 1.9 $
43  *
44  * @since 6.0.0
45  */

46 public class TestCmsImport extends TestCase {
47
48     /**
49      * Default JUnit constructor.<p>
50      *
51      * @param arg0 JUnit parameters
52      */

53     public TestCmsImport(String JavaDoc arg0) {
54
55         super(arg0);
56     }
57
58     /**
59      * Runs a test for the conversion of the digest encoding.<p>
60      *
61      * @throws Throwable if something goes wrong
62      */

63     public void testConvertDigestEncoding() throws Throwable JavaDoc {
64
65         A_CmsImport imp = new CmsImportVersion4();
66         String JavaDoc result;
67
68         // test 'password'
69
result = imp.convertDigestEncoding("dfcd4cbbda27e5569d03a75e38024f19");
70         assertEquals(result, "X03MO1qnZdYdgyfeuILPmQ==");
71
72         // test 'admin'
73
result = imp.convertDigestEncoding("a1a3afa9fad72527c309ca8eca009f43");
74         assertEquals(result, "ISMvKXpXpadDiUoOSoAfww==");
75
76         // test 'test'
77
result = imp.convertDigestEncoding("890feb4dc6a153f34a5ece03a6a73476");
78         assertEquals(result, "CY9rzUYh03PK3k6DJie09g==");
79
80         // test '12345678901234567890'
81
result = imp.convertDigestEncoding("7d0566ad1b6bc5c207f16ce8049832f1");
82         assertEquals(result, "/YXmLZvrRUKHcexohBiycQ==");
83
84         // test 'undnocheins'
85
result = imp.convertDigestEncoding("7fd2de3ccff5567c2fc64fe744283452");
86         assertEquals(result, "/1JevE911vyvRs9nxKi00g==");
87     }
88
89     /**
90      * Runs a test for the import of content.<p>
91      */

92     public void testSetDirectories() {
93
94         String JavaDoc[] rules = {
95             "s#/default/vfs/content/bodys/(.*)#/default/vfs/system/bodies/$1#",
96             "s#/default/vfs/pics/system/(.*)#/default/vfs/system/workplace/resources/$1#",
97             "s#/default/vfs/pics/(.*)#/default/vfs/system/galleries/pics/$1#",
98             "s#/default/vfs/download/(.*)#/default/vfs/system/galleries/download/$1#",
99             "s#/default/vfs/externallinks/(.*)#/default/vfs/system/galleries/externallinks/$1#",
100             "s#/default/vfs/htmlgalleries/(.*)#/default/vfs/system/galleries/htmlgalleries/$1#",
101             "s#/default/vfs/content/(.*)#/default/vfs/system/modules/org.opencms.default/$1#",
102             "s#/default/vfs/moduledemos/(.*)#/default/vfs/system/moduledemos/$1#",
103             "s#/default/vfs/system/workplace/config/language/(.*)#/default/vfs/system/workplace/locales/$1#",
104             "s#/default/vfs/system/workplace/css/(.*)#/default/vfs/system/workplace/resources/$1#",
105             "s#/default/vfs/system/workplace/templates/js/(.*)#/default/vfs/system/workplace/scripts/$1#"};
106
107         String JavaDoc content, result;
108
109         content = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"
110             + "<PAGE>\n"
111             + " <class>com.opencms.template.CmsXmlTemplate</class>\n"
112             + " <masterTemplate>/system/modules/org.opencms.frontend/templates/group_main</masterTemplate>\n"
113             + " <ELEMENTDEF name=\"body\">\n"
114             + " <CLASS>com.opencms.template.CmsXmlTemplate</CLASS>\n"
115             + " <TEMPLATE>/content/bodys/group/de/index.html</TEMPLATE>\n"
116             + " </ELEMENTDEF>\n"
117             + "</PAGE>";
118
119         result = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"
120             + "<PAGE>\n"
121             + " <class>com.opencms.template.CmsXmlTemplate</class>\n"
122             + " <masterTemplate>/system/modules/org.opencms.frontend/templates/group_main</masterTemplate>\n"
123             + " <ELEMENTDEF name=\"body\">\n"
124             + " <CLASS>com.opencms.template.CmsXmlTemplate</CLASS>\n"
125             + " <TEMPLATE>/system/bodies/group/de/index.html</TEMPLATE>\n"
126             + " </ELEMENTDEF>\n"
127             + "</PAGE>";
128
129         content = CmsImportVersion2.setDirectories(content, rules);
130         assertEquals(content, result);
131
132         content = ".hbackground {background:url(/open/cms/system/modules/li.castle.frontend/pics/bg_1.gif) no-repeat; background-color:#FFFFFF; }\n"
133             + ".hibackground {background:url(/open/cms/system/modules/li.castle.frontend/pics/bg_1_cai_cpe.gif); no-repeat; background-color:#FFFFFF; }"
134             + "<img SRC=\"{OpenCmsContext}/pics/test/\">\n"
135             + "picDir=/system/modules/li.castle.frontend/pics/\n"
136             + "<img alt=\"Slogan CPE\" SRC=\"]]><LINK><![CDATA[/pics/castle/slogan_cpe_de.gif]]></LINK><![CDATA[\">";
137
138         result = ".hbackground {background:url(/open/cms/system/modules/li.castle.frontend/pics/bg_1.gif) no-repeat; background-color:#FFFFFF; }\n"
139             + ".hibackground {background:url(/open/cms/system/modules/li.castle.frontend/pics/bg_1_cai_cpe.gif); no-repeat; background-color:#FFFFFF; }"
140             + "<img SRC=\"{OpenCmsContext}/system/galleries/pics/test/\">\n"
141             + "picDir=/system/modules/li.castle.frontend/pics/\n"
142             + "<img alt=\"Slogan CPE\" SRC=\"]]><LINK><![CDATA[/system/galleries/pics/castle/slogan_cpe_de.gif]]></LINK><![CDATA[\">";
143
144         content = CmsImportVersion2.setDirectories(content, rules);
145
146         System.out.println(content);
147         assertEquals(content, result);
148     }
149 }
150
Popular Tags