Source Code Cross Referenced for AbstractCollectionTest.java in  » Content-Management-System » daisy » org » outerj » daisy » repository » test » 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 » daisy » org.outerj.daisy.repository.test 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2004 Outerthought bvba and Schaubroeck nv
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *     http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package org.outerj.daisy.repository.test;
017:
018:        import org.outerj.daisy.repository.testsupport.AbstractDaisyTestCase;
019:        import org.outerj.daisy.repository.*;
020:        import org.outerj.daisy.repository.user.Role;
021:
022:        public abstract class AbstractCollectionTest extends
023:                AbstractDaisyTestCase {
024:            protected boolean resetDataStores() {
025:                return true;
026:            }
027:
028:            protected abstract RepositoryManager getRepositoryManager()
029:                    throws Exception;
030:
031:            public void testCollections() throws Exception {
032:                RepositoryManager repositoryManager = getRepositoryManager();
033:                Repository repository = repositoryManager
034:                        .getRepository(new Credentials("testuser", "testuser"));
035:                repository.switchRole(Role.ADMINISTRATOR);
036:
037:                CollectionManager collectionManager = repository
038:                        .getCollectionManager();
039:
040:                DocumentCollection collection1 = collectionManager
041:                        .createCollection("collection1");
042:                collection1.save();
043:
044:                DocumentCollection fetchedCollection1 = collectionManager
045:                        .getCollection(collection1.getId(), true);
046:                assertEquals("collection name is stored correctly", collection1
047:                        .getName(), fetchedCollection1.getName());
048:
049:                //some extra tests on the object we just fetched
050:                assertTrue("data store id of stored collection is -1 or less",
051:                        fetchedCollection1.getId() > -1);
052:                assertNotNull(
053:                        "last modified date of stored collection is null",
054:                        fetchedCollection1.getLastModified());
055:                assertTrue("last modifier of stored collection is invalid",
056:                        fetchedCollection1.getLastModifier() >= -1);
057:                assertNotNull(
058:                        "xml object returned by stored collection is null",
059:                        fetchedCollection1.getXml());
060:
061:                // try to modify the collection
062:                collection1.setName(collection1.getName() + "x");
063:                collection1.save();
064:                assertEquals("collection name change correctly saved",
065:                        collection1.getName(), collectionManager.getCollection(
066:                                collection1.getId(), true).getName());
067:
068:                // try to retrieve the collection by name
069:                assertEquals(
070:                        "retrieving collection by name should give collection with correct id",
071:                        collection1.getId(), collectionManager
072:                                .getCollectionByName(collection1.getName(),
073:                                        true).getId());
074:
075:                /* at this point there should be at least one collection in the list of all collections,
076:                 * so the collection list can easily be loaded here.
077:                 */
078:                DocumentCollections collections = collectionManager
079:                        .getCollections(true);
080:                assertNotNull(collections);
081:                DocumentCollection[] collArray = collections.getArray();
082:                assertNotNull(collArray);
083:
084:                for (int i = 0; i < collArray.length; i++) {
085:                    DocumentCollection collection = collArray[i];
086:                    assertNotNull(collection);
087:                }
088:
089:                //
090:                // test proper invalidation of collection caches (if any)
091:                //
092:                DocumentCollection collection2 = collectionManager
093:                        .createCollection("collection2");
094:                collection2.save();
095:
096:                // line below should NOT throw an CollectionNotFoundException
097:                collectionManager.getCollection(collection2.getId(), false);
098:
099:                collection2.setName("collection2-modified");
100:                collection2.save();
101:
102:                DocumentCollection collection2Refetched = collectionManager
103:                        .getCollection(collection2.getId(), false);
104:                assertEquals(collection2.getName(), collection2Refetched
105:                        .getName());
106:
107:                collectionManager.deleteCollection(collection2.getId());
108:                try {
109:                    collectionManager.getCollection(collection2.getId(), false);
110:                    fail("Getting a deleted exception should throw an exception.");
111:                } catch (CollectionNotFoundException e) {
112:                }
113:
114:                DocumentCollection collection3 = collectionManager
115:                        .createCollection("a b");
116:                collection3.save();
117:                assertEquals(collection3.getId(), collectionManager
118:                        .getCollectionByName("a b", true).getId());
119:                assertEquals(collection3.getId(), collectionManager
120:                        .getCollectionByName("a b", false).getId());
121:
122:                // NOTE: test of assigning collections to documents are part of the AbstractDocumentTest
123:            }
124:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.