Source Code Cross Referenced for Simple.java in  » IDE-Netbeans » xml » org » netbeans » tax » 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 » IDE Netbeans » xml » org.netbeans.tax.test 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:        package org.netbeans.tax.test;
042:
043:        import java.lang.reflect.*;
044:        import java.util.*;
045:        import java.io.*;
046:
047:        import org.netbeans.tax.*;
048:        import org.netbeans.tax.io.*;
049:        import org.netbeans.tax.decl.*;
050:
051:        /**
052:         */
053:        public class Simple {
054:
055:            /** Creates new Tests. */
056:            public Simple() {
057:            }
058:
059:            /**
060:             * @param args the command line arguments
061:             */
062:            public static void main(String args[]) throws Exception {
063:
064:                System.out.println("Runnig_tests...");
065:                testEncodings();
066:                //          testMerge("tests/merge/merge", "tests/merge/peer", "tests/merge/out"); // NOI18N
067:                //        testDTDBuilder ("XMLsamples/ParserTest.dtd"); // NOI18N
068:                //        testDTDBuilder ("xml/simple.dtd"); // NOI18N
069:                //        testTree();
070:                //  	  testAllTree();
071:
072:                testUtilities();
073:            }
074:
075:            private static boolean testEncodings() {
076:                System.out
077:                        .println("This test check all 'supported' encoding if they are realy supported!"); // NOI18N
078:
079:                int invalid = 0;
080:                Iterator it = TreeUtilities.getSupportedEncodings().iterator();
081:                while (it.hasNext()) {
082:                    String encoding = (String) it.next();
083:                    boolean valid = TreeUtilities
084:                            .isValidDocumentEncoding(encoding);
085:                    String prefix;
086:                    String suffix;
087:                    if (valid) {
088:                        prefix = "    "; // NOI18N
089:                        suffix = "is valid."; // NOI18N
090:                    } else {
091:                        invalid++;
092:                        prefix = "!!! "; // NOI18N
093:                        suffix = "is *INVALID* !!!"; // NOI18N
094:                    }
095:                    StringBuffer sb = new StringBuffer();
096:                    sb.append(prefix).append("encoding = '").append(encoding)
097:                            .append("'\t").append(suffix); // NOI18N
098:                    System.out.println(sb.toString());
099:                }
100:
101:                if (invalid != 0) {
102:                    System.out.println("I found " + invalid
103:                            + " invalid encodings!"); // NOI18N
104:                }
105:
106:                return (invalid == 0);
107:            }
108:
109:            private static void testTree() throws Exception {
110:                Class clazz = Class
111:                        .forName("org.netbeans.tax.TreeAttlistDeclAttributeDef"); // NOI18N
112:                clazz = TreeAttlistDeclAttributeDef.class;
113:                System.out.println("AttributeDef.class = " + clazz); // NOI18N
114:
115:                TreeAttlistDecl attlistDecl = new TreeAttlistDecl("elemName"); // NOI18N
116:                TreeAttlistDeclAttributeDef attrDef;
117:                attlistDecl
118:                        .setAttributeDef(attrDef = new TreeAttlistDeclAttributeDef(
119:                                "attr1",
120:                                TreeAttlistDeclAttributeDef.TYPE_CDATA, null,
121:                                TreeAttlistDeclAttributeDef.DEFAULT_TYPE_FIXED,
122:                                "value")); // NOI18N
123:                println(attlistDecl);
124:                System.out.println("AttributeDef.class = "
125:                        + attrDef.getClass().getName()); // NOI18N
126:
127:                TreeCharacterReference charRef = new TreeCharacterReference(
128:                        "#35"); // NOI18N
129:                println(charRef);
130:                charRef = new TreeCharacterReference("#x35"); // NOI18N
131:                println(charRef);
132:
133:                TreeDocumentType doctype = createDocumentType();
134:                println(doctype);
135:
136:                System.out.println("===create=document======="); // NOI18N
137:                TreeDocument doc = new TreeDocument("1.0", null, "no"); // NOI18N
138:                doc.appendChild(new TreeComment("==============")); // NOI18N
139:                TreeElement elem = new TreeElement("xxx"); // NOI18N
140:                doc.setDocumentElement(elem);
141:
142:                elem.addAttribute(new TreeAttribute("attr", "value")); // NOI18N
143:                elem.addAttribute(new TreeAttribute("attr", "value2")); // NOI18N
144:                elem.addAttribute(new TreeAttribute("attr3", "value3")); // NOI18N
145:                System.out.println("CYCLE: elem.appendChild (elem);"); // NOI18N
146:
147:                elem.appendChild(new TreeComment(
148:                        "Chtel bych vyzkouset get[Previous|Next]Sibling")); // NOI18N
149:                elem.appendChild(new TreeCDATASection("<!-------------><BLA>")); // NOI18N
150:                elem.appendChild(new TreeElement("BLA")); // NOI18N
151:                elem.appendChild(new TreeComment(
152:                        "... tak jeste zaverecny komentar!")); // NOI18N
153:
154:                println(doc);
155:
156:                elem = doc.getDocumentElement();
157:                println(elem);
158:                TreeChild child = elem.item(1);
159:                println(child);
160:                child = child.getNextSibling();
161:                println(child);
162:
163:                //
164:                // TreeDTD
165:                //
166:                TreeDTD dtd = new TreeDTD(null, null);
167:                //         dtd.appendChild (new TreeElementDecl ("elem", "(xxx,yyy?)")); // NOI18N
168:                TreeAttlistDecl attlist = new TreeAttlistDecl("elem"); // NOI18N
169:                attlist.setAttributeDef(new TreeAttlistDeclAttributeDef("attr",
170:                        TreeAttlistDeclAttributeDef.TYPE_ID, null,
171:                        TreeAttlistDeclAttributeDef.DEFAULT_TYPE_REQUIRED,
172:                        "bla")); // NOI18N
173:                dtd.appendChild(attlist);
174:
175:                //         dtd.appendChild (new TreeElementDecl ("elem2", "ANY")); // NOI18N
176:                attlist = new TreeAttlistDecl("elem2"); // NOI18N
177:                attlist.setAttributeDef(new TreeAttlistDeclAttributeDef(
178:                        "attr2", TreeAttlistDeclAttributeDef.TYPE_NOTATION,
179:                        new String[] { "abc", "def" },
180:                        TreeAttlistDeclAttributeDef.DEFAULT_TYPE_NULL, "bla")); // NOI18N
181:                dtd.appendChild(attlist);
182:
183:                println(dtd);
184:                child = dtd.item(3);
185:                println(child);
186:                child = child.getPreviousSibling();
187:                println(child);
188:
189:            }
190:
191:            protected static TreeDocumentType createDocumentType()
192:                    throws Exception {
193:                TreeDocumentType docType = new TreeDocumentType("element"); // NOI18N
194:
195:                docType.setSystemId("xml/simple.dtd"); // NOI18N
196:
197:                TreeDTD treeDTD = null;
198:                System.out.println("TreeDTD: "
199:                        + XMLStringResult.toString(treeDTD));//d // NOI18N
200:                System.out.println("LastChild: "
201:                        + XMLStringResult.toString(treeDTD.getLastChild()));//d // NOI18N
202:
203:                TreeChild child = treeDTD.getFirstChild();
204:                while (child != null) {
205:                    //docType.appendChild((TreeChild) child.clone());
206:                    System.out.println("Sibling: "
207:                            + XMLStringResult.toString(child));//d // NOI18N
208:                    child = child.getNextSibling();
209:                    System.out.println("NextSibling: "
210:                            + XMLStringResult.toString(child) + " :: " + child);//d // NOI18N
211:                }
212:                /*    
213:                TreeObjectList childList = treeDTD.getChildNodes();
214:                for (int i = 0; i < childList.size(); i++) {
215:                    TreeChild child = (TreeChild) ((TreeObject)childList.get(i)).clone();
216:                    docType.appendChild(child);
217:                }
218:                 */
219:                // How I can created DTD from String??? - pretahat nodes z DTDdataObject
220:                //docType.setInternalDtdDecl(dtdString);
221:                return docType;
222:            }
223:
224:            /**
225:             * Test DTD builder.
226:             * Check missing attributes.
227:             */
228:            static void testDTDBuilder(String dtd) throws Exception {
229:                Iterator it;
230:
231:                TreeDTD tree = null;
232:
233:                it = tree.getChildNodes().iterator();
234:                while (it.hasNext()) {
235:                    System.out.println(">" + it.next());
236:                }
237:
238:                it = tree.getElementDeclarations().iterator();
239:                while (it.hasNext()) {
240:                    System.out.println("#" + ((TreeNode) it.next()).toString()); // NOI18N
241:                }
242:
243:                System.out.println("Listing Any attributes"); // NOI18N
244:
245:                //          TreeElementDecl elemDecl = tree.findElementDecl("Any"); // NOI18N
246:                //          it = elemDecl.getDeclAttrs();
247:                //          while (it.hasNext()) {
248:                //              TreeAttributeDecl next = (TreeAttributeDecl) it.next();
249:                //              System.out.println(next.toString());
250:                //          }
251:
252:                System.out.println("-------------------"); // NOI18N
253:                println(tree);
254:                TreeChild child = tree.getFirstChild();
255:                println(child);
256:                child = child.getNextSibling();
257:                println(child);
258:                System.out.println("==================="); // NOI18N
259:            }
260:
261:            /**
262:             * Try to merge two trees.
263:             * @param target repository resource prefix
264:             * @param src reource resource prefix
265:             * @param output file prefix
266:             */
267:            static void testMerge(String target, String src, String logg)
268:                    throws Exception {
269:            }
270:
271:            //
272:            // API tests
273:            //
274:
275:            /**
276:             */
277:            public static void println(TreeNode node) throws TreeException {
278:                System.out.println("###################"); // NOI18N
279:                System.out.println("node: " + node); // NOI18N
280:                System.out.println("node.ownerDocument: "
281:                        + node.getOwnerDocument()); // NOI18N
282:                System.out.println("-=#BEGIN#=-"); // NOI18N
283:                String string = XMLStringResult.toString(node);
284:                System.out.println(string);
285:                System.out.println("-=# END #=-"); // NOI18N
286:            }
287:
288:            /**
289:             */
290:            public static void testAttlistDecl() throws TreeException {
291:                TreeAttlistDecl attlistDecl = new TreeAttlistDecl("elemName"); // NOI18N
292:                attlistDecl
293:                        .setAttributeDef(new TreeAttlistDeclAttributeDef(
294:                                "attr1",
295:                                TreeAttlistDeclAttributeDef.TYPE_CDATA, null,
296:                                TreeAttlistDeclAttributeDef.DEFAULT_TYPE_FIXED,
297:                                "value")); // NOI18N
298:                attlistDecl
299:                        .setAttributeDef(new TreeAttlistDeclAttributeDef(
300:                                "attr2",
301:                                TreeAttlistDeclAttributeDef.TYPE_NOTATION,
302:                                new String[] { "abc", "def", "ghi" },
303:                                TreeAttlistDeclAttributeDef.DEFAULT_TYPE_IMPLIED,
304:                                null)); // NOI18N
305:                println(attlistDecl);
306:            }
307:
308:            /**
309:             */
310:            public static void testAttribute() throws TreeException {
311:                TreeAttribute attribute = new TreeAttribute("name", "value"); // NOI18N
312:                println(attribute);
313:            }
314:
315:            /**
316:             */
317:            public static void testCDATASection() throws TreeException {
318:                TreeCDATASection cdataSect = new TreeCDATASection(
319:                        "<cdata data>"); // NOI18N
320:                println(cdataSect);
321:            }
322:
323:            /**
324:             */
325:            public static void testCharacterReference() throws TreeException {
326:                TreeCharacterReference charRef = new TreeCharacterReference(
327:                        "#35"); // NOI18N
328:                println(charRef);
329:            }
330:
331:            /**
332:             */
333:            public static void testComment() throws TreeException {
334:                TreeComment comment = new TreeComment("komentar - komentar"); // NOI18N
335:                println(comment);
336:            }
337:
338:            /**
339:             */
340:            public static void testConditionalSection() throws TreeException {
341:                TreeConditionalSection condSect = new TreeConditionalSection(
342:                        true);
343:                println(condSect);
344:            }
345:
346:            /**
347:             */
348:            public static void testDTD() throws TreeException {
349:                TreeDTD dtd = new TreeDTD(null, null);
350:                println(dtd);
351:            }
352:
353:            /**
354:             */
355:            public static void testDocument() throws TreeException {
356:                TreeDocument document = new TreeDocument(null, null, null);
357:                println(document);
358:            }
359:
360:            /**
361:             */
362:            public static void testDocumentFragment() throws TreeException {
363:                TreeDocumentFragment docFrag = new TreeDocumentFragment(null,
364:                        null);
365:                println(docFrag);
366:            }
367:
368:            /**
369:             */
370:            public static void testDocumentType() throws TreeException {
371:                TreeDocumentType docType = new TreeDocumentType("element"); // NOI18N
372:                println(docType);
373:            }
374:
375:            /**
376:             */
377:            public static void testElement() throws TreeException {
378:                TreeElement element = new TreeElement("ns:element"); // NOI18N
379:                println(element);
380:            }
381:
382:            /**
383:             */
384:            public static void testElementDecl() throws TreeException {
385:                TreeElementDecl elemDecl = new TreeElementDecl("element",
386:                        new ANYType()); // NOI18N
387:                println(elemDecl);
388:            }
389:
390:            /**
391:             */
392:            public static void testEntityDecl() throws TreeException {
393:                TreeEntityDecl entDecl = new TreeEntityDecl("ent1", "text"); // NOI18N
394:                println(entDecl);
395:                entDecl = new TreeEntityDecl("ent2", "pub1", "sys1"); // NOI18N
396:                println(entDecl);
397:                entDecl = new TreeEntityDecl(TreeEntityDecl.PARAMETER_DECL,
398:                        "ent3", null, "sys2"); // NOI18N
399:                println(entDecl);
400:                entDecl = new TreeEntityDecl("ent4", "pub2", "sys3", "not1"); // NOI18N
401:                println(entDecl);
402:                entDecl = new TreeEntityDecl("ent5", "pub3", "sys4", null); // NOI18N
403:                println(entDecl);
404:            }
405:
406:            /**
407:             */
408:            public static void testGeneralEntityReference()
409:                    throws TreeException {
410:                TreeGeneralEntityReference geRef = new TreeGeneralEntityReference(
411:                        "ge-ref"); // NOI18N
412:                println(geRef);
413:            }
414:
415:            /**
416:             */
417:            public static void testNotationDecl() throws TreeException {
418:                TreeNotationDecl notDecl = new TreeNotationDecl("not1", "pub1",
419:                        "sys1"); // NOI18N
420:                println(notDecl);
421:                notDecl = new TreeNotationDecl("not2", "pub2", null); // NOI18N
422:                println(notDecl);
423:                notDecl = new TreeNotationDecl("not3", null, "sys2"); // NOI18N
424:                println(notDecl);
425:            }
426:
427:            /**
428:             */
429:            public static void testParameterEntityReference()
430:                    throws TreeException {
431:                TreeParameterEntityReference peRef = new TreeParameterEntityReference(
432:                        "pe-ref"); // NOI18N
433:                println(peRef);
434:            }
435:
436:            /**
437:             */
438:            public static void testProcessingInstruction() throws TreeException {
439:                TreeProcessingInstruction pi = new TreeProcessingInstruction(
440:                        "target", "pi-data"); // NOI18N
441:                println(pi);
442:            }
443:
444:            /**
445:             */
446:            public static void testText() throws TreeException {
447:                TreeText text = new TreeText("text"); // NOI18N
448:                println(text);
449:            }
450:
451:            /**
452:             */
453:            public static void testAllTree() throws ClassNotFoundException,
454:                    NoSuchMethodException {
455:                String[] methods = new String[] { "testAttlistDecl", // NOI18N
456:                        "testAttribute", // NOI18N
457:                        "testCDATASection", // NOI18N
458:                        "testCharacterReference", // NOI18N
459:                        "testComment", // NOI18N
460:                        "testConditionalSection", // NOI18N
461:                        "testDTD", // NOI18N
462:                        "testDocument", // NOI18N
463:                        "testDocumentFragment", // NOI18N
464:                        "testDocumentType", // NOI18N
465:                        "testElement", // NOI18N
466:                        "testElementDecl", // NOI18N
467:                        "testEntityDecl", // NOI18N
468:                        "testGeneralEntityReference", // NOI18N
469:                        "testNotationDecl", // NOI18N
470:                        "testParameterEntityReference", // NOI18N
471:                        "testProcessingInstruction", // NOI18N
472:                        "testText" // NOI18N
473:                };
474:                Class testsClass = Class.forName("org.netbeans.tax.Tests"); // NOI18N
475:                System.out.println("clazz = " + testsClass); // NOI18N
476:                for (int i = 0; i < methods.length; i++) {
477:                    Method testMethod = testsClass.getMethod(methods[i], null);
478:                    //              System.out.println ("    method = " + testMethod); // NOI18N
479:                    //              System.out.println ("<!-- v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v -->"); // NOI18N
480:                    try {
481:                        testMethod.invoke(null, null);
482:                    } catch (Exception exc) {
483:                        System.out
484:                                .println("<!--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!-->\n"); // NOI18N
485:                        System.out.println("Exception [ "
486:                                + exc.getClass().getName() + " ] : "
487:                                + exc.getMessage()); // NOI18N
488:                        exc.printStackTrace(System.out);
489:                    }
490:                    System.out
491:                            .println("<!--#######################################################################################-->"); // NOI18N
492:                    //              System.out.println ("<!-- ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ -->\n"); // NOI18N
493:                }
494:            }
495:
496:            public static void testUtilities() {
497:                System.out.println("\nTest TreeUtilities ...");
498:
499:                char[] PUBLIC_ID = "\n\r -'()+,./:=?;!*#@$_%0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
500:                        .toCharArray();
501:                char ac = (char) 0;
502:                for (int i = 0; i < PUBLIC_ID.length; i++) {
503:                    char nc = PUBLIC_ID[i];
504:                    if (ac > nc) {
505:                        System.out.println("    Precondiction failed: '" + ac
506:                                + "' > '" + nc + "' !!!");
507:                    }
508:                    if (UnicodeClasses.isXMLPubidLiteral(nc) == false) {
509:                        System.out.println("    Char '" + nc
510:                                + "' is not correct Pubid Literal !!!");
511:                    } else {
512:                        ac = nc;
513:                        continue;
514:                    }
515:                    break;
516:                }
517:            }
518:
519:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.