Source Code Cross Referenced for DefaultSiteTreeTest.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » lenya » cms » site » tree » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Content Management System » apache lenya 2.0 » org.apache.lenya.cms.site.tree 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         *
017:         */
018:
019:        /* $Id: DefaultSiteTreeTest.java 568271 2007-08-21 20:49:18Z andreas $  */
020:
021:        package org.apache.lenya.cms.site.tree;
022:
023:        import junit.framework.TestCase;
024:
025:        import org.apache.avalon.framework.container.ContainerUtil;
026:        import org.apache.lenya.ac.impl.AbstractAccessControlTest;
027:        import org.apache.lenya.cms.publication.Publication;
028:        import org.apache.lenya.cms.publication.PublicationException;
029:        import org.apache.lenya.cms.repository.RepositoryException;
030:        import org.apache.lenya.cms.site.Link;
031:        import org.apache.lenya.cms.site.SiteException;
032:        import org.apache.lenya.cms.site.SiteNode;
033:        import org.apache.lenya.cms.site.tree.DefaultSiteTree;
034:        import org.apache.lenya.cms.site.tree.SiteTreeNode;
035:
036:        /**
037:         * Test class for the default site tree
038:         */
039:        public class DefaultSiteTreeTest extends AbstractAccessControlTest {
040:
041:            private DefaultSiteTree siteTree = null;
042:
043:            /**
044:             * @see TestCase#setUp()
045:             */
046:            public void setUp() throws Exception {
047:                super .setUp();
048:                Publication pub = getPublication("test");
049:                this .siteTree = new DefaultSiteTree(getFactory(), pub, "test",
050:                        getManager(), getLogger());
051:                ContainerUtil.enableLogging(this .siteTree, getLogger());
052:
053:                this .siteTree.getRepositoryNode().lock();
054:
055:                this .siteTree.addNode("/foo", "foo-uuid", true, null, null,
056:                        false);
057:                this .siteTree.addNode("/index", "index-uuid", true, null, null,
058:                        false);
059:                this .siteTree.addNode("/foo/bar", "foo-bar-uuid", true,
060:                        "http://exact.biz", "suffix", true);
061:                this .siteTree.addNode("/foo/lala", "foo-lala-uuid", true, null,
062:                        null, false);
063:            }
064:
065:            /**
066:             * @see TestCase#tearDown()
067:             */
068:            public void tearDown() throws Exception {
069:                super .tearDown();
070:                this .siteTree.getRepositoryNode().unlock();
071:            }
072:
073:            /**
074:             * Test for void DefaultSiteTree(String)
075:             */
076:            final public void testDefaultSiteTreeString() {
077:                // TODO Implement DefaultSiteTree().
078:            }
079:
080:            /**
081:             * Test for void DefaultSiteTree(File)
082:             */
083:            final public void testDefaultSiteTreeFile() {
084:                // TODO Implement DefaultSiteTree().
085:            }
086:
087:            /**
088:             * Test for void addNode(String, String, Label[])
089:             * 
090:             * @throws SiteException if an error occurs
091:             */
092:            final public void testAddNodeStringStringLabelArray()
093:                    throws SiteException {
094:                String uuid = "12345";
095:                this .siteTree.addNode("/foo", "tutorial", uuid, true);
096:                this .siteTree.addLabel("/foo", "en", "Tutorial");
097:                SiteNode node = this .siteTree.getNode("/foo/tutorial");
098:                assertNotNull(node);
099:                assertEquals(node.getName(), "tutorial");
100:                assertEquals(node.getUuid(), uuid);
101:            }
102:
103:            /**
104:             * Test for void addNode(SiteTreeNode)
105:             */
106:            final public void testAddNodeSiteTreeNode() {
107:                // TODO Implement addNode().
108:            }
109:
110:            /**
111:             * Test for void addNode(String, Label[], String, String, boolean)
112:             * 
113:             * @throws SiteException if an error occurs
114:             */
115:            final public void testAddNodeStringLabelArrayStringStringboolean()
116:                    throws SiteException {
117:                this .siteTree.addNode("/foo/ding", "foo-ding-uuid", true, null,
118:                        null, false);
119:                this .siteTree.addLabel("/foo/ding", "en", "Doh");
120:                this .siteTree.addLabel("/foo/ding", "de", "Ding");
121:
122:                assertNotNull(this .siteTree.getNode("/foo/ding"));
123:                assertEquals(this .siteTree.getNode("/foo/ding").getName(),
124:                        "ding");
125:            }
126:
127:            /**
128:             * Test for void addNode(String, String, Label[], String, String, boolean)
129:             * @throws SiteException if an error occurs
130:             */
131:            final public void testAddNodeStringStringLabelArrayStringStringboolean()
132:                    throws SiteException {
133:
134:                String uuid = "123";
135:
136:                this .siteTree.addNode("/foo", "baz", uuid, true, null, null,
137:                        false);
138:
139:                assertNotNull(this .siteTree.getNode("/foo/baz"));
140:                assertEquals(this .siteTree.getNode("/foo/baz").getName(), "baz");
141:            }
142:
143:            /**
144:             * Test addLabel
145:             * @throws SiteException
146:             */
147:            final public void testAddLabel() throws SiteException {
148:                this .siteTree.addLabel("/foo/bar", "en", "Tutorial");
149:                String[] labels = ((SiteTreeNode) this .siteTree
150:                        .getNode("/foo/bar")).getLanguages();
151:                assertEquals(labels.length, 1);
152:                Link label = ((SiteTreeNode) this .siteTree.getNode("/foo/bar"))
153:                        .getLink("en");
154:                assertNotNull(label);
155:                assertEquals(label.getLabel(), "Tutorial");
156:            }
157:
158:            /**
159:             * Test removeLabel
160:             * @throws SiteException
161:             */
162:            final public void testRemoveLabel() throws SiteException {
163:                this .siteTree.addLabel("/foo/bar", "de", "Hello");
164:                if (!this .siteTree.getNode("/foo/bar").hasLink("en")) {
165:                    this .siteTree.addLabel("/foo/bar", "en", "World");
166:                }
167:                assertEquals(((SiteTreeNode) this .siteTree.getNode("/foo/bar"))
168:                        .getLanguages().length, 2);
169:
170:                this .siteTree.removeLabel("/foo/bar", "de");
171:                assertEquals(((SiteTreeNode) this .siteTree.getNode("/foo/bar"))
172:                        .getLanguages().length, 1);
173:
174:                assertEquals(((SiteTreeNode) this .siteTree.getNode("/foo/bar"))
175:                        .getLanguages()[0], "en");
176:
177:                this .siteTree.addLabel("/foo/bar", "de", "Foo");
178:                assertEquals(((SiteTreeNode) this .siteTree.getNode("/foo/bar"))
179:                        .getLanguages().length, 2);
180:            }
181:
182:            /**
183:             * Test removeNode
184:             * 
185:             * @throws SiteException if an error occurs
186:             */
187:            final public void testRemoveNode() throws SiteException {
188:
189:                this .siteTree
190:                        .addNode("/hi", "hi-uuid", true, null, null, false);
191:
192:                this .siteTree.addNode("/hi/ho", "hi-ho-uuid", true, null, null,
193:                        false);
194:
195:                assertNotNull(this .siteTree.getNode("/hi/ho"));
196:
197:                this .siteTree.removeNode("/hi");
198:
199:                assertFalse(this .siteTree.contains("/hi/ho"));
200:                assertFalse(this .siteTree.contains("/hi"));
201:            }
202:
203:            /**
204:             * Test getNode
205:             * @throws SiteException
206:             * 
207:             */
208:            final public void testGetNode() throws SiteException {
209:                assertNotNull(this .siteTree.getNode("/foo/bar"));
210:                assertFalse(this .siteTree.contains("/foo/bar/baz"));
211:            }
212:
213:            /**
214:             * Test save
215:             * 
216:             */
217:            final public void testSave() {
218:                // TODO Implement save().
219:            }
220:
221:            /**
222:             * Test moving a node up
223:             * @throws RepositoryException 
224:             */
225:            final public void testMoveUp() throws RepositoryException {
226:                this .siteTree.moveUp("/foo/lala");
227:                this .siteTree.save();
228:                assertNotNull(this .siteTree.getNode("/foo/lala"));
229:            }
230:
231:            /**
232:             * Test moving a node down
233:             * @throws RepositoryException 
234:             */
235:            final public void testMoveDown() throws RepositoryException {
236:                this .siteTree.moveDown("/foo");
237:                this .siteTree.save();
238:                assertNotNull(this .siteTree.getNode("/foo"));
239:            }
240:
241:            /**
242:             * Test the import of a subtree
243:             * @throws PublicationException
244:             * @throws RepositoryException
245:             */
246:            final public void testImportSubtree() throws PublicationException,
247:                    RepositoryException {
248:                Publication pub = getPublication("test");
249:                DefaultSiteTree newSiteTree = new DefaultSiteTree(getFactory(),
250:                        pub, "test1", getManager(), getLogger());
251:                ContainerUtil.enableLogging(newSiteTree, getLogger());
252:
253:                newSiteTree.getRepositoryNode().lock();
254:
255:                newSiteTree.addNode("/root", "root-uuid", true, null, null,
256:                        false);
257:                newSiteTree.addLabel("/root", "en", "root");
258:                newSiteTree.addNode("/root/foo", "root-foo-uuid", true, null,
259:                        null, false);
260:                newSiteTree.addLabel("/root/foo", "en", "foo");
261:                newSiteTree.addNode("/root/subtree", "root-subtree-uuid", true,
262:                        "http://exact.biz", "suffix", true);
263:                newSiteTree.addLabel("/root/subtree", "en", "subtree");
264:                newSiteTree.addNode("/root/subtree/child",
265:                        "root-subtree-child-uuid", true, null, null, false);
266:                newSiteTree.addLabel("/root/subtree/child", "en", "child");
267:                SiteTreeNode node = (SiteTreeNode) newSiteTree
268:                        .getNode("/root/subtree");
269:                assertNotNull(node);
270:                SiteTreeNode parentNode = (SiteTreeNode) this .siteTree
271:                        .getNode("/foo/lala");
272:                assertNotNull(parentNode);
273:
274:                newSiteTree.getRepositoryNode().unlock();
275:            }
276:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.