Source Code Cross Referenced for StreamCorrupted.java in  » Database-DBMS » JDBM » jdbm » btree » 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 » Database DBMS » JDBM » jdbm.btree 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:
003:         * JDBM LICENSE v1.00
004:
005:         *
006:
007:         * Redistribution and use of this software and associated documentation
008:
009:         * ("Software"), with or without modification, are permitted provided
010:
011:         * that the following conditions are met:
012:
013:         *
014:
015:         * 1. Redistributions of source code must retain copyright
016:
017:         *    statements and notices.  Redistributions must also contain a
018:
019:         *    copy of this document.
020:
021:         *
022:
023:         * 2. Redistributions in binary form must reproduce the
024:
025:         *    above copyright notice, this list of conditions and the
026:
027:         *    following disclaimer in the documentation and/or other
028:
029:         *    materials provided with the distribution.
030:
031:         *
032:
033:         * 3. The name "JDBM" must not be used to endorse or promote
034:
035:         *    products derived from this Software without prior written
036:
037:         *    permission of Cees de Groot.  For written permission,
038:
039:         *    please contact cg@cdegroot.com.
040:
041:         *
042:
043:         * 4. Products derived from this Software may not be called "JDBM"
044:
045:         *    nor may "JDBM" appear in their names without prior written
046:
047:         *    permission of Cees de Groot.
048:
049:         *
050:
051:         * 5. Due credit should be given to the JDBM Project
052:
053:         *    (http://jdbm.sourceforge.net/).
054:
055:         *
056:
057:         * THIS SOFTWARE IS PROVIDED BY THE JDBM PROJECT AND CONTRIBUTORS
058:
059:         * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
060:
061:         * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
062:
063:         * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
064:
065:         * CEES DE GROOT OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
066:
067:         * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
068:
069:         * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
070:
071:         * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
072:
073:         * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
074:
075:         * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
076:
077:         * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
078:
079:         * OF THE POSSIBILITY OF SUCH DAMAGE.
080:
081:         *
082:
083:         * Copyright 2000 (C) Cees de Groot. All Rights Reserved.
084:
085:         * Contributions are Copyright (C) 2000 by their associated contributors.
086:
087:         *
088:
089:         */package jdbm.btree;
090:
091:        import jdbm.RecordManager;
092:
093:        import jdbm.RecordManagerFactory;
094:
095:        import jdbm.helper.StringComparator;
096:
097:        import jdbm.recman.TestRecordFile;
098:
099:        import jdbm.btree.BTree;
100:
101:        import java.io.IOException;
102:
103:        import junit.framework.*;
104:
105:        /**
106:
107:         * Contributed test case for BTree by Christof Dallermassl (cdaller@iicm.edu):
108:
109:         *
110:
111:         * -= quote from original message posted on jdbm-general =-
112:
113:         * <pre>
114:
115:         *
116:
117:         * I tried to insert a couple of elements into a BTree and then remove
118:
119:         * them one by one. After a number or removals, there is always (if more
120:
121:         * than 20 elements in btree) a java.io.StreamCorruptedException thrown.
122:
123:         *
124:
125:         * The strange thing is, that on 50 elements, the exception is thrown
126:
127:         * after removing 22, on 200 it is thrown after 36, on 1000 it is thrown
128:
129:         * after 104, on 10000 it is thrown after 1003....
130:
131:         *
132:
133:         * The full stackTrace is here:
134:
135:         * ---------------------- snip ------- snap -------------------------
136:
137:         * java.io.StreamCorruptedException: Caught EOFException while reading the
138:
139:         * stream header
140:
141:         *   at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:845)
142:
143:         *   at java.io.ObjectInputStream.<init>(ObjectInputStream.java:168)
144:
145:         *   at jdbm.recman.RecordManager.byteArrayToObject(RecordManager.java:296)
146:
147:         *   at jdbm.recman.RecordManager.fetchObject(RecordManager.java:239)
148:
149:         *   at jdbm.helper.ObjectCache.fetchObject(ObjectCache.java:104)
150:
151:         *   at jdbm.btree.BPage.loadBPage(BPage.java:670)
152:
153:         *   at jdbm.btree.BPage.remove(BPage.java:492)
154:
155:         *   at jdbm.btree.BPage.remove(BPage.java:437)
156:
157:         *   at jdbm.btree.BTree.remove(BTree.java:313)
158:
159:         *   at JDBMTest.main(JDBMTest.java:41)
160:
161:         *
162:
163:         * </pre>
164:
165:         *
166:
167:         *  @author <a href="mailto:cdaller@iicm.edu">Christof Dallermassl</a>
168:
169:         *  @version $Id: StreamCorrupted.java,v 1.4 2003/09/21 15:49:02 boisvert Exp $
170:
171:         */
172:
173:        public class StreamCorrupted
174:
175:        extends TestCase
176:
177:        {
178:
179:            public StreamCorrupted(String name) {
180:
181:                super (name);
182:
183:            }
184:
185:            public void setUp() {
186:
187:                TestRecordFile.deleteTestFile();
188:
189:            }
190:
191:            public void tearDown() {
192:
193:                TestRecordFile.deleteTestFile();
194:
195:            }
196:
197:            /**
198:
199:             *  Basic tests
200:
201:             */
202:
203:            public void testStreamCorrupted()
204:
205:            throws IOException
206:
207:            {
208:
209:                RecordManager recman;
210:
211:                BTree btree;
212:
213:                int iterations;
214:
215:                iterations = 100; // 23 works :-(((((
216:
217:                // open database
218:
219:                recman = RecordManagerFactory
220:                        .createRecordManager(TestRecordFile.testFileName);
221:
222:                // create a new B+Tree data structure
223:
224:                btree = BTree.createInstance(recman, new StringComparator());
225:
226:                recman.setNamedObject("testbtree", btree.getRecid());
227:
228:                // action:
229:
230:                // insert data
231:
232:                for (int count = 0; count < iterations; count++) {
233:
234:                    btree.insert("num" + count, new Integer(count), true);
235:
236:                }
237:
238:                // delete data
239:
240:                for (int count = 0; count < iterations; count++) {
241:
242:                    btree.remove("num" + count);
243:
244:                }
245:
246:                // close database
247:
248:                recman.close();
249:
250:                recman = null;
251:
252:            }
253:
254:            /**
255:
256:             *  Runs all tests in this class
257:
258:             */
259:
260:            public static void main(String[] args) {
261:
262:                junit.textui.TestRunner
263:                        .run(new TestSuite(StreamCorrupted.class));
264:
265:            }
266:
267:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.