Source Code Cross Referenced for FileStoreTest.java in  » 6.0-JDK-Modules » j2me » com » sun » jumpimpl » module » contentstore » 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 » 6.0 JDK Modules » j2me » com.sun.jumpimpl.module.contentstore 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright  1990-2006 Sun Microsystems, Inc. All Rights Reserved.
003:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
004:         * 
005:         * This program is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU General Public License version
007:         * 2 only, as published by the Free Software Foundation. 
008:         * 
009:         * This program is distributed in the hope that it will be useful, but
010:         * WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012:         * General Public License version 2 for more details (a copy is
013:         * included at /legal/license.txt). 
014:         * 
015:         * You should have received a copy of the GNU General Public License
016:         * version 2 along with this work; if not, write to the Free Software
017:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
018:         * 02110-1301 USA 
019:         * 
020:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
021:         * Clara, CA 95054 or visit www.sun.com if you need additional
022:         * information or have any questions. 
023:         */
024:
025:        package com.sun.jumpimpl.module.contentstore;
026:
027:        import junit.framework.*;
028:
029:        import java.io.*;
030:        import java.io.IOException;
031:        import java.util.HashMap;
032:        import java.util.Iterator;
033:        import java.util.Map;
034:        import java.util.Properties;
035:
036:        import com.sun.jump.module.contentstore.*;
037:        import com.sun.jump.executive.JUMPExecutive;
038:
039:        public class FileStoreTest extends TestCase {
040:
041:            FileStoreTestInternal actualClass;
042:            boolean verbose = false;
043:
044:            public FileStoreTest(String testName) {
045:                super (testName);
046:            }
047:
048:            protected void setUp() {
049:                actualClass = new FileStoreTestInternal();
050:                actualClass.setupTest();
051:            }
052:
053:            public void testFileStore() {
054:                actualClass.runTest();
055:            }
056:
057:            // data URIs for tests to use.
058:            static String[] sampleDataUris = { "./Apps/Amark/title",
059:                    "./Apps/Amark/size", "./Apps/Amark/icon",
060:                    "./Apps/Amark/descriptor",
061:                    "./Apps/Amark/data/Subdata.properties",
062:                    "./Apps/Amark/Amark.properties" };
063:
064:            // Data files corresponding to sampleDataUris above.
065:            static JUMPData[] datas = { new JUMPData(true), new JUMPData(1.0f),
066:                    new JUMPData(12345), new JUMPData("String"),
067:                    new JUMPData(new Properties()),
068:                    new JUMPData(new Properties())
069:            //new JUMPData(System.getProperties())
070:            };
071:
072:            // list URIs for tests to use.
073:            static String[] sampleListUris = { "./Apps/Amark",
074:                    "./Apps/Amark/data" };
075:
076:            class FileStoreTestInternal extends JUMPContentStoreSubClass {
077:
078:                // The directory name which "." of this content store will be using.
079:
080:                void setupTest() {
081:
082:                    // For the standalone test run, emulate the executive setup
083:                    if (JUMPExecutive.getInstance() == null) {
084:                        JUMPStoreFactory factory = new com.sun.jumpimpl.module.contentstore.StoreFactoryImpl();
085:                        factory.load(com.sun.jumpimpl.process.JUMPModulesConfig
086:                                .getProperties());
087:
088:                    }
089:
090:                }
091:
092:                void runTest() {
093:
094:                    boolean testFailed = false;
095:
096:                    trace("Starting the test run");
097:
098:                    // Get the store handle from the JUMPContentStoreSubClass. 
099:                    JUMPStoreHandle storeHandle = openStore(true);
100:
101:                    trace("Got a type of JUMPStore: " + storeHandle);
102:
103:                    try {
104:                        // first, try to create list nodes.
105:                        for (int i = 0; i < sampleListUris.length; i++) {
106:                            storeHandle.createNode(sampleListUris[i]);
107:                        }
108:
109:                        // then, create all data nodes.
110:                        for (int i = 0; i < sampleDataUris.length; i++) {
111:                            storeHandle.createDataNode(sampleDataUris[i],
112:                                    datas[i]);
113:                        }
114:
115:                        // get back all the data nodes we just created and check the data content.
116:                        trace("All data created, testing equality");
117:                        for (int i = 0; i < sampleDataUris.length; i++) {
118:                            JUMPData data = ((JUMPNode.Data) storeHandle
119:                                    .getNode(sampleDataUris[i])).getData();
120:                            assertTrue(data.equals(datas[i]));
121:                        }
122:
123:                        // get the listing of all nodes starting at the root.
124:                        JUMPNode.List dirnode = (JUMPNode.List) storeHandle
125:                                .getNode(".");
126:
127:                        trace("List of storeHandle content");
128:                        printChildren(dirnode, "   ");
129:
130:                        // try updating a node content.
131:                        trace("Testing update of storeHandle content");
132:                        storeHandle.updateDataNode(sampleDataUris[0], datas[1]);
133:                        JUMPData data = ((JUMPNode.Data) storeHandle
134:                                .getNode(sampleDataUris[0])).getData();
135:                        assertTrue(data.equals(datas[1]));
136:
137:                        // now, delete all list nodes.
138:                        trace("Delete all");
139:                        for (int i = 0; i < sampleListUris.length; i++) {
140:                            storeHandle.deleteNode(sampleListUris[i]);
141:                        }
142:
143:                        //trace("List of storeHandle content");
144:                        //printChildren(dirnode, "   ");
145:                    } catch (IOException ioe) {
146:                        trace("IOException was thrown!");
147:                        ioe.printStackTrace(System.out);
148:                        testFailed = true;
149:                    }
150:
151:                    trace("Closing the store");
152:                    closeStore(storeHandle);
153:
154:                    trace("Done.");
155:
156:                    assertTrue(!testFailed);
157:                }
158:
159:                // Recursively print all the nodes in the tree.
160:                void printChildren(JUMPNode jumpNode, String tab) {
161:                    if (jumpNode != null) {
162:                        trace(tab + jumpNode);
163:                        if (jumpNode instanceof  JUMPNode.List) {
164:                            JUMPNode.List list = (JUMPNode.List) jumpNode;
165:                            for (Iterator itn = list.getChildren(); itn
166:                                    .hasNext();) {
167:                                JUMPNode node = (JUMPNode) itn.next();
168:                                printChildren(node, tab + "   ");
169:                            }
170:                        }
171:                    }
172:                }
173:
174:                void trace(String output) {
175:                    if (verbose)
176:                        System.out.println(output);
177:                }
178:            }
179:
180:            class JUMPContentStoreSubClass extends JUMPContentStore {
181:
182:                protected JUMPStore getStore() {
183:                    return JUMPStoreFactory.getInstance().getModule(
184:                            JUMPStoreFactory.TYPE_FILE);
185:                }
186:
187:                public void load(Map map) {
188:                }
189:
190:                public void unload() {
191:                }
192:            }
193:
194:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.