Source Code Cross Referenced for TestXMLPrinter.java in  » Code-Analyzer » DependencyFinder » com » jeantessier » dependency » 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 » Code Analyzer » DependencyFinder » com.jeantessier.dependency 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         *  Copyright (c) 2001-2007, Jean Tessier
0003:         *  All rights reserved.
0004:         *  
0005:         *  Redistribution and use in source and binary forms, with or without
0006:         *  modification, are permitted provided that the following conditions
0007:         *  are met:
0008:         *  
0009:         *      * Redistributions of source code must retain the above copyright
0010:         *        notice, this list of conditions and the following disclaimer.
0011:         *  
0012:         *      * Redistributions in binary form must reproduce the above copyright
0013:         *        notice, this list of conditions and the following disclaimer in the
0014:         *        documentation and/or other materials provided with the distribution.
0015:         *  
0016:         *      * Neither the name of Jean Tessier nor the names of his contributors
0017:         *        may be used to endorse or promote products derived from this software
0018:         *        without specific prior written permission.
0019:         *  
0020:         *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0021:         *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0022:         *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0023:         *  A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR
0024:         *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
0025:         *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
0026:         *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
0027:         *  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
0028:         *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
0029:         *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
0030:         *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0031:         */
0032:
0033:        package com.jeantessier.dependency;
0034:
0035:        import java.io.*;
0036:        import javax.xml.parsers.*;
0037:
0038:        import junit.framework.*;
0039:        import org.apache.oro.text.perl.*;
0040:        import org.xml.sax.*;
0041:
0042:        public class TestXMLPrinter extends TestCase implements  ErrorHandler {
0043:            private static final String SPECIFIC_ENCODING = "iso-latin-1";
0044:            private static final String SPECIFIC_DTD_PREFIX = "./etc";
0045:
0046:            private XMLReader reader;
0047:            private Perl5Util perl;
0048:            private NodeFactory factory;
0049:            private StringWriter out;
0050:
0051:            protected void setUp() throws Exception {
0052:                reader = SAXParserFactory.newInstance().newSAXParser()
0053:                        .getXMLReader();
0054:                reader.setFeature("http://xml.org/sax/features/validation",
0055:                        true);
0056:                reader
0057:                        .setFeature(
0058:                                "http://apache.org/xml/features/nonvalidating/load-external-dtd",
0059:                                true);
0060:                reader.setErrorHandler(this );
0061:
0062:                perl = new Perl5Util();
0063:
0064:                factory = new NodeFactory();
0065:                out = new StringWriter();
0066:            }
0067:
0068:            public void testDefaultDTDPrefix() {
0069:                XMLPrinter printer = new XMLPrinter(new PrintWriter(out));
0070:
0071:                String xmlDocument = out.toString();
0072:                assertTrue(xmlDocument + "Missing DTD", perl.match(
0073:                        "/DOCTYPE \\S+ SYSTEM \"(.*)\"/", xmlDocument));
0074:                assertTrue("DTD \"" + perl.group(1)
0075:                        + "\" does not have prefix \""
0076:                        + XMLPrinter.DEFAULT_DTD_PREFIX + "\"", perl.group(1)
0077:                        .startsWith(XMLPrinter.DEFAULT_DTD_PREFIX));
0078:
0079:                try {
0080:                    reader
0081:                            .parse(new InputSource(
0082:                                    new StringReader(xmlDocument)));
0083:                    fail("Parsed non-existant document\n" + xmlDocument);
0084:                } catch (SAXException ex) {
0085:                    // Ignore
0086:                } catch (IOException ex) {
0087:                    fail("Could not read XML Document: " + ex.getMessage()
0088:                            + "\n" + xmlDocument);
0089:                }
0090:            }
0091:
0092:            public void testSpecificDTDPrefix() {
0093:                XMLPrinter printer = new XMLPrinter(new PrintWriter(out),
0094:                        XMLPrinter.DEFAULT_ENCODING, SPECIFIC_DTD_PREFIX);
0095:
0096:                String xmlDocument = out.toString();
0097:                assertTrue(xmlDocument + "Missing DTD", perl.match(
0098:                        "/DOCTYPE \\S+ SYSTEM \"(.*)\"/", xmlDocument));
0099:                assertTrue("DTD \"" + perl.group(1)
0100:                        + "\" does not have prefix \"./etc\"", perl.group(1)
0101:                        .startsWith(SPECIFIC_DTD_PREFIX));
0102:
0103:                try {
0104:                    reader
0105:                            .parse(new InputSource(
0106:                                    new StringReader(xmlDocument)));
0107:                    fail("Parsed non-existant document\n" + xmlDocument);
0108:                } catch (SAXException ex) {
0109:                    // Ignore
0110:                } catch (IOException ex) {
0111:                    fail("Could not read XML Document: " + ex.getMessage()
0112:                            + "\n" + xmlDocument);
0113:                }
0114:            }
0115:
0116:            public void testDefaultEncoding() {
0117:                XMLPrinter printer = new XMLPrinter(new PrintWriter(out));
0118:
0119:                String xmlDocument = out.toString();
0120:                assertTrue(xmlDocument + "Missing encoding", perl.match(
0121:                        "/encoding=\"([^\"]*)\"/", xmlDocument));
0122:                assertEquals("Encoding", XMLPrinter.DEFAULT_ENCODING, perl
0123:                        .group(1));
0124:
0125:                try {
0126:                    reader
0127:                            .parse(new InputSource(
0128:                                    new StringReader(xmlDocument)));
0129:                    fail("Parsed non-existant document\n" + xmlDocument);
0130:                } catch (SAXException ex) {
0131:                    // Ignore
0132:                } catch (IOException ex) {
0133:                    fail("Could not read XML Document: " + ex.getMessage()
0134:                            + "\n" + xmlDocument);
0135:                }
0136:            }
0137:
0138:            public void testSpecificEncoding() {
0139:                XMLPrinter printer = new XMLPrinter(new PrintWriter(out),
0140:                        SPECIFIC_ENCODING, XMLPrinter.DEFAULT_DTD_PREFIX);
0141:
0142:                String xmlDocument = out.toString();
0143:                assertTrue(xmlDocument + "Missing encoding", perl.match(
0144:                        "/encoding=\"([^\"]*)\"/", xmlDocument));
0145:                assertEquals("Encoding", SPECIFIC_ENCODING, perl.group(1));
0146:
0147:                try {
0148:                    reader
0149:                            .parse(new InputSource(
0150:                                    new StringReader(xmlDocument)));
0151:                    fail("Parsed non-existant document\n" + xmlDocument);
0152:                } catch (SAXException ex) {
0153:                    // Ignore
0154:                } catch (IOException ex) {
0155:                    fail("Could not read XML Document: " + ex.getMessage()
0156:                            + "\n" + xmlDocument);
0157:                }
0158:            }
0159:
0160:            public void testShowInboundsPackageTrue() throws IOException {
0161:                factory.createPackage("outbound").addDependency(
0162:                        factory.createPackage("inbound"));
0163:                factory.createPackage("empty");
0164:
0165:                XMLPrinter printer = new XMLPrinter(new PrintWriter(out),
0166:                        XMLPrinter.DEFAULT_ENCODING, SPECIFIC_DTD_PREFIX);
0167:                printer.setShowInbounds(true);
0168:                printer.setShowOutbounds(false);
0169:
0170:                printer.traverseNodes(factory.getPackages().values());
0171:
0172:                int lineNumber = 0;
0173:                BufferedReader in = new BufferedReader(new StringReader(out
0174:                        .toString()));
0175:
0176:                assertEquals("line " + ++lineNumber,
0177:                        "<?xml version=\"1.0\" encoding=\"utf-8\" ?>", in
0178:                                .readLine());
0179:                assertEquals("line " + ++lineNumber, "", in.readLine());
0180:                assertEquals(
0181:                        "line " + ++lineNumber,
0182:                        "<!DOCTYPE dependencies SYSTEM \"./etc/dependencies.dtd\">",
0183:                        in.readLine());
0184:                assertEquals("line " + ++lineNumber, "", in.readLine());
0185:                assertEquals("line " + ++lineNumber, "<dependencies>", in
0186:                        .readLine());
0187:                assertEquals("line " + ++lineNumber,
0188:                        "    <package confirmed=\"no\">", in.readLine());
0189:                assertEquals("line " + ++lineNumber,
0190:                        "        <name>empty</name>", in.readLine());
0191:                assertEquals("line " + ++lineNumber, "    </package>", in
0192:                        .readLine());
0193:                assertEquals("line " + ++lineNumber,
0194:                        "    <package confirmed=\"no\">", in.readLine());
0195:                assertEquals("line " + ++lineNumber,
0196:                        "        <name>inbound</name>", in.readLine());
0197:                assertEquals(
0198:                        "line " + ++lineNumber,
0199:                        "        <inbound type=\"package\" confirmed=\"no\">outbound</inbound>",
0200:                        in.readLine());
0201:                assertEquals("line " + ++lineNumber, "    </package>", in
0202:                        .readLine());
0203:                assertEquals("line " + ++lineNumber,
0204:                        "    <package confirmed=\"no\">", in.readLine());
0205:                assertEquals("line " + ++lineNumber,
0206:                        "        <name>outbound</name>", in.readLine());
0207:                assertEquals("line " + ++lineNumber, "    </package>", in
0208:                        .readLine());
0209:                assertEquals("line " + ++lineNumber, "</dependencies>", in
0210:                        .readLine());
0211:
0212:                assertEquals("End of file", null, in.readLine());
0213:            }
0214:
0215:            public void testShowInboundsPackageFalse() throws IOException {
0216:                factory.createPackage("outbound").addDependency(
0217:                        factory.createPackage("inbound"));
0218:                factory.createPackage("empty");
0219:
0220:                XMLPrinter printer = new XMLPrinter(new PrintWriter(out),
0221:                        XMLPrinter.DEFAULT_ENCODING, SPECIFIC_DTD_PREFIX);
0222:                printer.setShowInbounds(false);
0223:                printer.setShowOutbounds(false);
0224:
0225:                printer.traverseNodes(factory.getPackages().values());
0226:
0227:                int lineNumber = 0;
0228:                BufferedReader in = new BufferedReader(new StringReader(out
0229:                        .toString()));
0230:
0231:                assertEquals("line " + ++lineNumber,
0232:                        "<?xml version=\"1.0\" encoding=\"utf-8\" ?>", in
0233:                                .readLine());
0234:                assertEquals("line " + ++lineNumber, "", in.readLine());
0235:                assertEquals(
0236:                        "line " + ++lineNumber,
0237:                        "<!DOCTYPE dependencies SYSTEM \"./etc/dependencies.dtd\">",
0238:                        in.readLine());
0239:                assertEquals("line " + ++lineNumber, "", in.readLine());
0240:                assertEquals("line " + ++lineNumber, "<dependencies>", in
0241:                        .readLine());
0242:                assertEquals("line " + ++lineNumber,
0243:                        "    <package confirmed=\"no\">", in.readLine());
0244:                assertEquals("line " + ++lineNumber,
0245:                        "        <name>empty</name>", in.readLine());
0246:                assertEquals("line " + ++lineNumber, "    </package>", in
0247:                        .readLine());
0248:                assertEquals("line " + ++lineNumber,
0249:                        "    <package confirmed=\"no\">", in.readLine());
0250:                assertEquals("line " + ++lineNumber,
0251:                        "        <name>inbound</name>", in.readLine());
0252:                assertEquals("line " + ++lineNumber, "    </package>", in
0253:                        .readLine());
0254:                assertEquals("line " + ++lineNumber,
0255:                        "    <package confirmed=\"no\">", in.readLine());
0256:                assertEquals("line " + ++lineNumber,
0257:                        "        <name>outbound</name>", in.readLine());
0258:                assertEquals("line " + ++lineNumber, "    </package>", in
0259:                        .readLine());
0260:                assertEquals("line " + ++lineNumber, "</dependencies>", in
0261:                        .readLine());
0262:
0263:                assertEquals("End of file", null, in.readLine());
0264:            }
0265:
0266:            public void testShowInboundsClassTrue() throws IOException {
0267:                factory.createClass("outbound.Outbound").addDependency(
0268:                        factory.createClass("inbound.Inbound"));
0269:                factory.createClass("empty.Empty");
0270:
0271:                XMLPrinter printer = new XMLPrinter(new PrintWriter(out),
0272:                        XMLPrinter.DEFAULT_ENCODING, SPECIFIC_DTD_PREFIX);
0273:                printer.setShowInbounds(true);
0274:                printer.setShowOutbounds(false);
0275:
0276:                printer.traverseNodes(factory.getPackages().values());
0277:
0278:                int lineNumber = 0;
0279:                BufferedReader in = new BufferedReader(new StringReader(out
0280:                        .toString()));
0281:
0282:                assertEquals("line " + ++lineNumber,
0283:                        "<?xml version=\"1.0\" encoding=\"utf-8\" ?>", in
0284:                                .readLine());
0285:                assertEquals("line " + ++lineNumber, "", in.readLine());
0286:                assertEquals(
0287:                        "line " + ++lineNumber,
0288:                        "<!DOCTYPE dependencies SYSTEM \"./etc/dependencies.dtd\">",
0289:                        in.readLine());
0290:                assertEquals("line " + ++lineNumber, "", in.readLine());
0291:                assertEquals("line " + ++lineNumber, "<dependencies>", in
0292:                        .readLine());
0293:                assertEquals("line " + ++lineNumber,
0294:                        "    <package confirmed=\"no\">", in.readLine());
0295:                assertEquals("line " + ++lineNumber,
0296:                        "        <name>empty</name>", in.readLine());
0297:                assertEquals("line " + ++lineNumber,
0298:                        "        <class confirmed=\"no\">", in.readLine());
0299:                assertEquals("line " + ++lineNumber,
0300:                        "            <name>empty.Empty</name>", in.readLine());
0301:                assertEquals("line " + ++lineNumber, "        </class>", in
0302:                        .readLine());
0303:                assertEquals("line " + ++lineNumber, "    </package>", in
0304:                        .readLine());
0305:                assertEquals("line " + ++lineNumber,
0306:                        "    <package confirmed=\"no\">", in.readLine());
0307:                assertEquals("line " + ++lineNumber,
0308:                        "        <name>inbound</name>", in.readLine());
0309:                assertEquals("line " + ++lineNumber,
0310:                        "        <class confirmed=\"no\">", in.readLine());
0311:                assertEquals("line " + ++lineNumber,
0312:                        "            <name>inbound.Inbound</name>", in
0313:                                .readLine());
0314:                assertEquals(
0315:                        "line " + ++lineNumber,
0316:                        "            <inbound type=\"class\" confirmed=\"no\">outbound.Outbound</inbound>",
0317:                        in.readLine());
0318:                assertEquals("line " + ++lineNumber, "        </class>", in
0319:                        .readLine());
0320:                assertEquals("line " + ++lineNumber, "    </package>", in
0321:                        .readLine());
0322:                assertEquals("line " + ++lineNumber,
0323:                        "    <package confirmed=\"no\">", in.readLine());
0324:                assertEquals("line " + ++lineNumber,
0325:                        "        <name>outbound</name>", in.readLine());
0326:                assertEquals("line " + ++lineNumber,
0327:                        "        <class confirmed=\"no\">", in.readLine());
0328:                assertEquals("line " + ++lineNumber,
0329:                        "            <name>outbound.Outbound</name>", in
0330:                                .readLine());
0331:                assertEquals("line " + ++lineNumber, "        </class>", in
0332:                        .readLine());
0333:                assertEquals("line " + ++lineNumber, "    </package>", in
0334:                        .readLine());
0335:                assertEquals("line " + ++lineNumber, "</dependencies>", in
0336:                        .readLine());
0337:
0338:                assertEquals("End of file", null, in.readLine());
0339:            }
0340:
0341:            public void testShowInboundsClassFalse() throws IOException {
0342:                factory.createClass("outbound.Outbound").addDependency(
0343:                        factory.createClass("inbound.Inbound"));
0344:                factory.createClass("empty.Empty");
0345:
0346:                XMLPrinter printer = new XMLPrinter(new PrintWriter(out),
0347:                        XMLPrinter.DEFAULT_ENCODING, SPECIFIC_DTD_PREFIX);
0348:                printer.setShowInbounds(false);
0349:                printer.setShowOutbounds(false);
0350:
0351:                printer.traverseNodes(factory.getPackages().values());
0352:
0353:                int lineNumber = 0;
0354:                BufferedReader in = new BufferedReader(new StringReader(out
0355:                        .toString()));
0356:
0357:                assertEquals("line " + ++lineNumber,
0358:                        "<?xml version=\"1.0\" encoding=\"utf-8\" ?>", in
0359:                                .readLine());
0360:                assertEquals("line " + ++lineNumber, "", in.readLine());
0361:                assertEquals(
0362:                        "line " + ++lineNumber,
0363:                        "<!DOCTYPE dependencies SYSTEM \"./etc/dependencies.dtd\">",
0364:                        in.readLine());
0365:                assertEquals("line " + ++lineNumber, "", in.readLine());
0366:                assertEquals("line " + ++lineNumber, "<dependencies>", in
0367:                        .readLine());
0368:                assertEquals("line " + ++lineNumber,
0369:                        "    <package confirmed=\"no\">", in.readLine());
0370:                assertEquals("line " + ++lineNumber,
0371:                        "        <name>empty</name>", in.readLine());
0372:                assertEquals("line " + ++lineNumber,
0373:                        "        <class confirmed=\"no\">", in.readLine());
0374:                assertEquals("line " + ++lineNumber,
0375:                        "            <name>empty.Empty</name>", in.readLine());
0376:                assertEquals("line " + ++lineNumber, "        </class>", in
0377:                        .readLine());
0378:                assertEquals("line " + ++lineNumber, "    </package>", in
0379:                        .readLine());
0380:                assertEquals("line " + ++lineNumber,
0381:                        "    <package confirmed=\"no\">", in.readLine());
0382:                assertEquals("line " + ++lineNumber,
0383:                        "        <name>inbound</name>", in.readLine());
0384:                assertEquals("line " + ++lineNumber,
0385:                        "        <class confirmed=\"no\">", in.readLine());
0386:                assertEquals("line " + ++lineNumber,
0387:                        "            <name>inbound.Inbound</name>", in
0388:                                .readLine());
0389:                assertEquals("line " + ++lineNumber, "        </class>", in
0390:                        .readLine());
0391:                assertEquals("line " + ++lineNumber, "    </package>", in
0392:                        .readLine());
0393:                assertEquals("line " + ++lineNumber,
0394:                        "    <package confirmed=\"no\">", in.readLine());
0395:                assertEquals("line " + ++lineNumber,
0396:                        "        <name>outbound</name>", in.readLine());
0397:                assertEquals("line " + ++lineNumber,
0398:                        "        <class confirmed=\"no\">", in.readLine());
0399:                assertEquals("line " + ++lineNumber,
0400:                        "            <name>outbound.Outbound</name>", in
0401:                                .readLine());
0402:                assertEquals("line " + ++lineNumber, "        </class>", in
0403:                        .readLine());
0404:                assertEquals("line " + ++lineNumber, "    </package>", in
0405:                        .readLine());
0406:                assertEquals("line " + ++lineNumber, "</dependencies>", in
0407:                        .readLine());
0408:
0409:                assertEquals("End of file", null, in.readLine());
0410:            }
0411:
0412:            public void testShowInboundsFeatureTrue() throws IOException {
0413:                factory
0414:                        .createFeature("outbound.Outbound.outbound()")
0415:                        .addDependency(
0416:                                factory
0417:                                        .createFeature("inbound.Inbound.inbound()"));
0418:                factory.createFeature("empty.Empty.empty()");
0419:
0420:                XMLPrinter printer = new XMLPrinter(new PrintWriter(out),
0421:                        XMLPrinter.DEFAULT_ENCODING, SPECIFIC_DTD_PREFIX);
0422:                printer.setShowInbounds(true);
0423:                printer.setShowOutbounds(false);
0424:
0425:                printer.traverseNodes(factory.getPackages().values());
0426:
0427:                int lineNumber = 0;
0428:                BufferedReader in = new BufferedReader(new StringReader(out
0429:                        .toString()));
0430:
0431:                assertEquals("line " + ++lineNumber,
0432:                        "<?xml version=\"1.0\" encoding=\"utf-8\" ?>", in
0433:                                .readLine());
0434:                assertEquals("line " + ++lineNumber, "", in.readLine());
0435:                assertEquals(
0436:                        "line " + ++lineNumber,
0437:                        "<!DOCTYPE dependencies SYSTEM \"./etc/dependencies.dtd\">",
0438:                        in.readLine());
0439:                assertEquals("line " + ++lineNumber, "", in.readLine());
0440:                assertEquals("line " + ++lineNumber, "<dependencies>", in
0441:                        .readLine());
0442:                assertEquals("line " + ++lineNumber,
0443:                        "    <package confirmed=\"no\">", in.readLine());
0444:                assertEquals("line " + ++lineNumber,
0445:                        "        <name>empty</name>", in.readLine());
0446:                assertEquals("line " + ++lineNumber,
0447:                        "        <class confirmed=\"no\">", in.readLine());
0448:                assertEquals("line " + ++lineNumber,
0449:                        "            <name>empty.Empty</name>", in.readLine());
0450:                assertEquals("line " + ++lineNumber,
0451:                        "            <feature confirmed=\"no\">", in.readLine());
0452:                assertEquals("line " + ++lineNumber,
0453:                        "                <name>empty.Empty.empty()</name>", in
0454:                                .readLine());
0455:                assertEquals("line " + ++lineNumber, "            </feature>",
0456:                        in.readLine());
0457:                assertEquals("line " + ++lineNumber, "        </class>", in
0458:                        .readLine());
0459:                assertEquals("line " + ++lineNumber, "    </package>", in
0460:                        .readLine());
0461:                assertEquals("line " + ++lineNumber,
0462:                        "    <package confirmed=\"no\">", in.readLine());
0463:                assertEquals("line " + ++lineNumber,
0464:                        "        <name>inbound</name>", in.readLine());
0465:                assertEquals("line " + ++lineNumber,
0466:                        "        <class confirmed=\"no\">", in.readLine());
0467:                assertEquals("line " + ++lineNumber,
0468:                        "            <name>inbound.Inbound</name>", in
0469:                                .readLine());
0470:                assertEquals("line " + ++lineNumber,
0471:                        "            <feature confirmed=\"no\">", in.readLine());
0472:                assertEquals(
0473:                        "line " + ++lineNumber,
0474:                        "                <name>inbound.Inbound.inbound()</name>",
0475:                        in.readLine());
0476:                assertEquals(
0477:                        "line " + ++lineNumber,
0478:                        "                <inbound type=\"feature\" confirmed=\"no\">outbound.Outbound.outbound()</inbound>",
0479:                        in.readLine());
0480:                assertEquals("line " + ++lineNumber, "            </feature>",
0481:                        in.readLine());
0482:                assertEquals("line " + ++lineNumber, "        </class>", in
0483:                        .readLine());
0484:                assertEquals("line " + ++lineNumber, "    </package>", in
0485:                        .readLine());
0486:                assertEquals("line " + ++lineNumber,
0487:                        "    <package confirmed=\"no\">", in.readLine());
0488:                assertEquals("line " + ++lineNumber,
0489:                        "        <name>outbound</name>", in.readLine());
0490:                assertEquals("line " + ++lineNumber,
0491:                        "        <class confirmed=\"no\">", in.readLine());
0492:                assertEquals("line " + ++lineNumber,
0493:                        "            <name>outbound.Outbound</name>", in
0494:                                .readLine());
0495:                assertEquals("line " + ++lineNumber,
0496:                        "            <feature confirmed=\"no\">", in.readLine());
0497:                assertEquals(
0498:                        "line " + ++lineNumber,
0499:                        "                <name>outbound.Outbound.outbound()</name>",
0500:                        in.readLine());
0501:                assertEquals("line " + ++lineNumber, "            </feature>",
0502:                        in.readLine());
0503:                assertEquals("line " + ++lineNumber, "        </class>", in
0504:                        .readLine());
0505:                assertEquals("line " + ++lineNumber, "    </package>", in
0506:                        .readLine());
0507:                assertEquals("line " + ++lineNumber, "</dependencies>", in
0508:                        .readLine());
0509:
0510:                assertEquals("End of file", null, in.readLine());
0511:            }
0512:
0513:            public void testShowInboundsFeatureFalse() throws IOException {
0514:                factory
0515:                        .createFeature("outbound.Outbound.outbound()")
0516:                        .addDependency(
0517:                                factory
0518:                                        .createFeature("inbound.Inbound.inbound()"));
0519:                factory.createFeature("empty.Empty.empty()");
0520:
0521:                XMLPrinter printer = new XMLPrinter(new PrintWriter(out),
0522:                        XMLPrinter.DEFAULT_ENCODING, SPECIFIC_DTD_PREFIX);
0523:                printer.setShowInbounds(false);
0524:                printer.setShowOutbounds(false);
0525:
0526:                printer.traverseNodes(factory.getPackages().values());
0527:
0528:                int lineNumber = 0;
0529:                BufferedReader in = new BufferedReader(new StringReader(out
0530:                        .toString()));
0531:
0532:                assertEquals("line " + ++lineNumber,
0533:                        "<?xml version=\"1.0\" encoding=\"utf-8\" ?>", in
0534:                                .readLine());
0535:                assertEquals("line " + ++lineNumber, "", in.readLine());
0536:                assertEquals(
0537:                        "line " + ++lineNumber,
0538:                        "<!DOCTYPE dependencies SYSTEM \"./etc/dependencies.dtd\">",
0539:                        in.readLine());
0540:                assertEquals("line " + ++lineNumber, "", in.readLine());
0541:                assertEquals("line " + ++lineNumber, "<dependencies>", in
0542:                        .readLine());
0543:                assertEquals("line " + ++lineNumber,
0544:                        "    <package confirmed=\"no\">", in.readLine());
0545:                assertEquals("line " + ++lineNumber,
0546:                        "        <name>empty</name>", in.readLine());
0547:                assertEquals("line " + ++lineNumber,
0548:                        "        <class confirmed=\"no\">", in.readLine());
0549:                assertEquals("line " + ++lineNumber,
0550:                        "            <name>empty.Empty</name>", in.readLine());
0551:                assertEquals("line " + ++lineNumber,
0552:                        "            <feature confirmed=\"no\">", in.readLine());
0553:                assertEquals("line " + ++lineNumber,
0554:                        "                <name>empty.Empty.empty()</name>", in
0555:                                .readLine());
0556:                assertEquals("line " + ++lineNumber, "            </feature>",
0557:                        in.readLine());
0558:                assertEquals("line " + ++lineNumber, "        </class>", in
0559:                        .readLine());
0560:                assertEquals("line " + ++lineNumber, "    </package>", in
0561:                        .readLine());
0562:                assertEquals("line " + ++lineNumber,
0563:                        "    <package confirmed=\"no\">", in.readLine());
0564:                assertEquals("line " + ++lineNumber,
0565:                        "        <name>inbound</name>", in.readLine());
0566:                assertEquals("line " + ++lineNumber,
0567:                        "        <class confirmed=\"no\">", in.readLine());
0568:                assertEquals("line " + ++lineNumber,
0569:                        "            <name>inbound.Inbound</name>", in
0570:                                .readLine());
0571:                assertEquals("line " + ++lineNumber,
0572:                        "            <feature confirmed=\"no\">", in.readLine());
0573:                assertEquals(
0574:                        "line " + ++lineNumber,
0575:                        "                <name>inbound.Inbound.inbound()</name>",
0576:                        in.readLine());
0577:                assertEquals("line " + ++lineNumber, "            </feature>",
0578:                        in.readLine());
0579:                assertEquals("line " + ++lineNumber, "        </class>", in
0580:                        .readLine());
0581:                assertEquals("line " + ++lineNumber, "    </package>", in
0582:                        .readLine());
0583:                assertEquals("line " + ++lineNumber,
0584:                        "    <package confirmed=\"no\">", in.readLine());
0585:                assertEquals("line " + ++lineNumber,
0586:                        "        <name>outbound</name>", in.readLine());
0587:                assertEquals("line " + ++lineNumber,
0588:                        "        <class confirmed=\"no\">", in.readLine());
0589:                assertEquals("line " + ++lineNumber,
0590:                        "            <name>outbound.Outbound</name>", in
0591:                                .readLine());
0592:                assertEquals("line " + ++lineNumber,
0593:                        "            <feature confirmed=\"no\">", in.readLine());
0594:                assertEquals(
0595:                        "line " + ++lineNumber,
0596:                        "                <name>outbound.Outbound.outbound()</name>",
0597:                        in.readLine());
0598:                assertEquals("line " + ++lineNumber, "            </feature>",
0599:                        in.readLine());
0600:                assertEquals("line " + ++lineNumber, "        </class>", in
0601:                        .readLine());
0602:                assertEquals("line " + ++lineNumber, "    </package>", in
0603:                        .readLine());
0604:                assertEquals("line " + ++lineNumber, "</dependencies>", in
0605:                        .readLine());
0606:
0607:                assertEquals("End of file", null, in.readLine());
0608:            }
0609:
0610:            public void testShowOutboundsPackageTrue() throws IOException {
0611:                factory.createPackage("outbound").addDependency(
0612:                        factory.createPackage("inbound"));
0613:                factory.createPackage("empty");
0614:
0615:                XMLPrinter printer = new XMLPrinter(new PrintWriter(out),
0616:                        XMLPrinter.DEFAULT_ENCODING, SPECIFIC_DTD_PREFIX);
0617:                printer.setShowInbounds(false);
0618:                printer.setShowOutbounds(true);
0619:
0620:                printer.traverseNodes(factory.getPackages().values());
0621:
0622:                int lineNumber = 0;
0623:                BufferedReader in = new BufferedReader(new StringReader(out
0624:                        .toString()));
0625:
0626:                assertEquals("line " + ++lineNumber,
0627:                        "<?xml version=\"1.0\" encoding=\"utf-8\" ?>", in
0628:                                .readLine());
0629:                assertEquals("line " + ++lineNumber, "", in.readLine());
0630:                assertEquals(
0631:                        "line " + ++lineNumber,
0632:                        "<!DOCTYPE dependencies SYSTEM \"./etc/dependencies.dtd\">",
0633:                        in.readLine());
0634:                assertEquals("line " + ++lineNumber, "", in.readLine());
0635:                assertEquals("line " + ++lineNumber, "<dependencies>", in
0636:                        .readLine());
0637:                assertEquals("line " + ++lineNumber,
0638:                        "    <package confirmed=\"no\">", in.readLine());
0639:                assertEquals("line " + ++lineNumber,
0640:                        "        <name>empty</name>", in.readLine());
0641:                assertEquals("line " + ++lineNumber, "    </package>", in
0642:                        .readLine());
0643:                assertEquals("line " + ++lineNumber,
0644:                        "    <package confirmed=\"no\">", in.readLine());
0645:                assertEquals("line " + ++lineNumber,
0646:                        "        <name>inbound</name>", in.readLine());
0647:                assertEquals("line " + ++lineNumber, "    </package>", in
0648:                        .readLine());
0649:                assertEquals("line " + ++lineNumber,
0650:                        "    <package confirmed=\"no\">", in.readLine());
0651:                assertEquals("line " + ++lineNumber,
0652:                        "        <name>outbound</name>", in.readLine());
0653:                assertEquals(
0654:                        "line " + ++lineNumber,
0655:                        "        <outbound type=\"package\" confirmed=\"no\">inbound</outbound>",
0656:                        in.readLine());
0657:                assertEquals("line " + ++lineNumber, "    </package>", in
0658:                        .readLine());
0659:                assertEquals("line " + ++lineNumber, "</dependencies>", in
0660:                        .readLine());
0661:
0662:                assertEquals("End of file", null, in.readLine());
0663:            }
0664:
0665:            public void testShowOutboundsPackageFalse() throws IOException {
0666:                factory.createPackage("outbound").addDependency(
0667:                        factory.createPackage("inbound"));
0668:                factory.createPackage("empty");
0669:
0670:                XMLPrinter printer = new XMLPrinter(new PrintWriter(out),
0671:                        XMLPrinter.DEFAULT_ENCODING, SPECIFIC_DTD_PREFIX);
0672:                printer.setShowInbounds(false);
0673:                printer.setShowOutbounds(false);
0674:
0675:                printer.traverseNodes(factory.getPackages().values());
0676:
0677:                int lineNumber = 0;
0678:                BufferedReader in = new BufferedReader(new StringReader(out
0679:                        .toString()));
0680:
0681:                assertEquals("line " + ++lineNumber,
0682:                        "<?xml version=\"1.0\" encoding=\"utf-8\" ?>", in
0683:                                .readLine());
0684:                assertEquals("line " + ++lineNumber, "", in.readLine());
0685:                assertEquals(
0686:                        "line " + ++lineNumber,
0687:                        "<!DOCTYPE dependencies SYSTEM \"./etc/dependencies.dtd\">",
0688:                        in.readLine());
0689:                assertEquals("line " + ++lineNumber, "", in.readLine());
0690:                assertEquals("line " + ++lineNumber, "<dependencies>", in
0691:                        .readLine());
0692:                assertEquals("line " + ++lineNumber,
0693:                        "    <package confirmed=\"no\">", in.readLine());
0694:                assertEquals("line " + ++lineNumber,
0695:                        "        <name>empty</name>", in.readLine());
0696:                assertEquals("line " + ++lineNumber, "    </package>", in
0697:                        .readLine());
0698:                assertEquals("line " + ++lineNumber,
0699:                        "    <package confirmed=\"no\">", in.readLine());
0700:                assertEquals("line " + ++lineNumber,
0701:                        "        <name>inbound</name>", in.readLine());
0702:                assertEquals("line " + ++lineNumber, "    </package>", in
0703:                        .readLine());
0704:                assertEquals("line " + ++lineNumber,
0705:                        "    <package confirmed=\"no\">", in.readLine());
0706:                assertEquals("line " + ++lineNumber,
0707:                        "        <name>outbound</name>", in.readLine());
0708:                assertEquals("line " + ++lineNumber, "    </package>", in
0709:                        .readLine());
0710:                assertEquals("line " + ++lineNumber, "</dependencies>", in
0711:                        .readLine());
0712:
0713:                assertEquals("End of file", null, in.readLine());
0714:            }
0715:
0716:            public void testShowOutboundsClassTrue() throws IOException {
0717:                factory.createClass("outbound.Outbound").addDependency(
0718:                        factory.createClass("inbound.Inbound"));
0719:                factory.createClass("empty.Empty");
0720:
0721:                XMLPrinter printer = new XMLPrinter(new PrintWriter(out),
0722:                        XMLPrinter.DEFAULT_ENCODING, SPECIFIC_DTD_PREFIX);
0723:                printer.setShowInbounds(false);
0724:                printer.setShowOutbounds(true);
0725:
0726:                printer.traverseNodes(factory.getPackages().values());
0727:
0728:                int lineNumber = 0;
0729:                BufferedReader in = new BufferedReader(new StringReader(out
0730:                        .toString()));
0731:
0732:                assertEquals("line " + ++lineNumber,
0733:                        "<?xml version=\"1.0\" encoding=\"utf-8\" ?>", in
0734:                                .readLine());
0735:                assertEquals("line " + ++lineNumber, "", in.readLine());
0736:                assertEquals(
0737:                        "line " + ++lineNumber,
0738:                        "<!DOCTYPE dependencies SYSTEM \"./etc/dependencies.dtd\">",
0739:                        in.readLine());
0740:                assertEquals("line " + ++lineNumber, "", in.readLine());
0741:                assertEquals("line " + ++lineNumber, "<dependencies>", in
0742:                        .readLine());
0743:                assertEquals("line " + ++lineNumber,
0744:                        "    <package confirmed=\"no\">", in.readLine());
0745:                assertEquals("line " + ++lineNumber,
0746:                        "        <name>empty</name>", in.readLine());
0747:                assertEquals("line " + ++lineNumber,
0748:                        "        <class confirmed=\"no\">", in.readLine());
0749:                assertEquals("line " + ++lineNumber,
0750:                        "            <name>empty.Empty</name>", in.readLine());
0751:                assertEquals("line " + ++lineNumber, "        </class>", in
0752:                        .readLine());
0753:                assertEquals("line " + ++lineNumber, "    </package>", in
0754:                        .readLine());
0755:                assertEquals("line " + ++lineNumber,
0756:                        "    <package confirmed=\"no\">", in.readLine());
0757:                assertEquals("line " + ++lineNumber,
0758:                        "        <name>inbound</name>", in.readLine());
0759:                assertEquals("line " + ++lineNumber,
0760:                        "        <class confirmed=\"no\">", in.readLine());
0761:                assertEquals("line " + ++lineNumber,
0762:                        "            <name>inbound.Inbound</name>", in
0763:                                .readLine());
0764:                assertEquals("line " + ++lineNumber, "        </class>", in
0765:                        .readLine());
0766:                assertEquals("line " + ++lineNumber, "    </package>", in
0767:                        .readLine());
0768:                assertEquals("line " + ++lineNumber,
0769:                        "    <package confirmed=\"no\">", in.readLine());
0770:                assertEquals("line " + ++lineNumber,
0771:                        "        <name>outbound</name>", in.readLine());
0772:                assertEquals("line " + ++lineNumber,
0773:                        "        <class confirmed=\"no\">", in.readLine());
0774:                assertEquals("line " + ++lineNumber,
0775:                        "            <name>outbound.Outbound</name>", in
0776:                                .readLine());
0777:                assertEquals(
0778:                        "line " + ++lineNumber,
0779:                        "            <outbound type=\"class\" confirmed=\"no\">inbound.Inbound</outbound>",
0780:                        in.readLine());
0781:                assertEquals("line " + ++lineNumber, "        </class>", in
0782:                        .readLine());
0783:                assertEquals("line " + ++lineNumber, "    </package>", in
0784:                        .readLine());
0785:                assertEquals("line " + ++lineNumber, "</dependencies>", in
0786:                        .readLine());
0787:
0788:                assertEquals("End of file", null, in.readLine());
0789:            }
0790:
0791:            public void testShowOutboundsClassFalse() throws IOException {
0792:                factory.createClass("outbound.Outbound").addDependency(
0793:                        factory.createClass("inbound.Inbound"));
0794:                factory.createClass("empty.Empty");
0795:
0796:                XMLPrinter printer = new XMLPrinter(new PrintWriter(out),
0797:                        XMLPrinter.DEFAULT_ENCODING, SPECIFIC_DTD_PREFIX);
0798:                printer.setShowInbounds(false);
0799:                printer.setShowOutbounds(false);
0800:
0801:                printer.traverseNodes(factory.getPackages().values());
0802:
0803:                int lineNumber = 0;
0804:                BufferedReader in = new BufferedReader(new StringReader(out
0805:                        .toString()));
0806:
0807:                assertEquals("line " + ++lineNumber,
0808:                        "<?xml version=\"1.0\" encoding=\"utf-8\" ?>", in
0809:                                .readLine());
0810:                assertEquals("line " + ++lineNumber, "", in.readLine());
0811:                assertEquals(
0812:                        "line " + ++lineNumber,
0813:                        "<!DOCTYPE dependencies SYSTEM \"./etc/dependencies.dtd\">",
0814:                        in.readLine());
0815:                assertEquals("line " + ++lineNumber, "", in.readLine());
0816:                assertEquals("line " + ++lineNumber, "<dependencies>", in
0817:                        .readLine());
0818:                assertEquals("line " + ++lineNumber,
0819:                        "    <package confirmed=\"no\">", in.readLine());
0820:                assertEquals("line " + ++lineNumber,
0821:                        "        <name>empty</name>", in.readLine());
0822:                assertEquals("line " + ++lineNumber,
0823:                        "        <class confirmed=\"no\">", in.readLine());
0824:                assertEquals("line " + ++lineNumber,
0825:                        "            <name>empty.Empty</name>", in.readLine());
0826:                assertEquals("line " + ++lineNumber, "        </class>", in
0827:                        .readLine());
0828:                assertEquals("line " + ++lineNumber, "    </package>", in
0829:                        .readLine());
0830:                assertEquals("line " + ++lineNumber,
0831:                        "    <package confirmed=\"no\">", in.readLine());
0832:                assertEquals("line " + ++lineNumber,
0833:                        "        <name>inbound</name>", in.readLine());
0834:                assertEquals("line " + ++lineNumber,
0835:                        "        <class confirmed=\"no\">", in.readLine());
0836:                assertEquals("line " + ++lineNumber,
0837:                        "            <name>inbound.Inbound</name>", in
0838:                                .readLine());
0839:                assertEquals("line " + ++lineNumber, "        </class>", in
0840:                        .readLine());
0841:                assertEquals("line " + ++lineNumber, "    </package>", in
0842:                        .readLine());
0843:                assertEquals("line " + ++lineNumber,
0844:                        "    <package confirmed=\"no\">", in.readLine());
0845:                assertEquals("line " + ++lineNumber,
0846:                        "        <name>outbound</name>", in.readLine());
0847:                assertEquals("line " + ++lineNumber,
0848:                        "        <class confirmed=\"no\">", in.readLine());
0849:                assertEquals("line " + ++lineNumber,
0850:                        "            <name>outbound.Outbound</name>", in
0851:                                .readLine());
0852:                assertEquals("line " + ++lineNumber, "        </class>", in
0853:                        .readLine());
0854:                assertEquals("line " + ++lineNumber, "    </package>", in
0855:                        .readLine());
0856:                assertEquals("line " + ++lineNumber, "</dependencies>", in
0857:                        .readLine());
0858:
0859:                assertEquals("End of file", null, in.readLine());
0860:            }
0861:
0862:            public void testShowOutboundsFeatureTrue() throws IOException {
0863:                factory
0864:                        .createFeature("outbound.Outbound.outbound()")
0865:                        .addDependency(
0866:                                factory
0867:                                        .createFeature("inbound.Inbound.inbound()"));
0868:                factory.createFeature("empty.Empty.empty()");
0869:
0870:                XMLPrinter printer = new XMLPrinter(new PrintWriter(out),
0871:                        XMLPrinter.DEFAULT_ENCODING, SPECIFIC_DTD_PREFIX);
0872:                printer.setShowInbounds(false);
0873:                printer.setShowOutbounds(true);
0874:
0875:                printer.traverseNodes(factory.getPackages().values());
0876:
0877:                int lineNumber = 0;
0878:                BufferedReader in = new BufferedReader(new StringReader(out
0879:                        .toString()));
0880:
0881:                assertEquals("line " + ++lineNumber,
0882:                        "<?xml version=\"1.0\" encoding=\"utf-8\" ?>", in
0883:                                .readLine());
0884:                assertEquals("line " + ++lineNumber, "", in.readLine());
0885:                assertEquals(
0886:                        "line " + ++lineNumber,
0887:                        "<!DOCTYPE dependencies SYSTEM \"./etc/dependencies.dtd\">",
0888:                        in.readLine());
0889:                assertEquals("line " + ++lineNumber, "", in.readLine());
0890:                assertEquals("line " + ++lineNumber, "<dependencies>", in
0891:                        .readLine());
0892:                assertEquals("line " + ++lineNumber,
0893:                        "    <package confirmed=\"no\">", in.readLine());
0894:                assertEquals("line " + ++lineNumber,
0895:                        "        <name>empty</name>", in.readLine());
0896:                assertEquals("line " + ++lineNumber,
0897:                        "        <class confirmed=\"no\">", in.readLine());
0898:                assertEquals("line " + ++lineNumber,
0899:                        "            <name>empty.Empty</name>", in.readLine());
0900:                assertEquals("line " + ++lineNumber,
0901:                        "            <feature confirmed=\"no\">", in.readLine());
0902:                assertEquals("line " + ++lineNumber,
0903:                        "                <name>empty.Empty.empty()</name>", in
0904:                                .readLine());
0905:                assertEquals("line " + ++lineNumber, "            </feature>",
0906:                        in.readLine());
0907:                assertEquals("line " + ++lineNumber, "        </class>", in
0908:                        .readLine());
0909:                assertEquals("line " + ++lineNumber, "    </package>", in
0910:                        .readLine());
0911:                assertEquals("line " + ++lineNumber,
0912:                        "    <package confirmed=\"no\">", in.readLine());
0913:                assertEquals("line " + ++lineNumber,
0914:                        "        <name>inbound</name>", in.readLine());
0915:                assertEquals("line " + ++lineNumber,
0916:                        "        <class confirmed=\"no\">", in.readLine());
0917:                assertEquals("line " + ++lineNumber,
0918:                        "            <name>inbound.Inbound</name>", in
0919:                                .readLine());
0920:                assertEquals("line " + ++lineNumber,
0921:                        "            <feature confirmed=\"no\">", in.readLine());
0922:                assertEquals(
0923:                        "line " + ++lineNumber,
0924:                        "                <name>inbound.Inbound.inbound()</name>",
0925:                        in.readLine());
0926:                assertEquals("line " + ++lineNumber, "            </feature>",
0927:                        in.readLine());
0928:                assertEquals("line " + ++lineNumber, "        </class>", in
0929:                        .readLine());
0930:                assertEquals("line " + ++lineNumber, "    </package>", in
0931:                        .readLine());
0932:                assertEquals("line " + ++lineNumber,
0933:                        "    <package confirmed=\"no\">", in.readLine());
0934:                assertEquals("line " + ++lineNumber,
0935:                        "        <name>outbound</name>", in.readLine());
0936:                assertEquals("line " + ++lineNumber,
0937:                        "        <class confirmed=\"no\">", in.readLine());
0938:                assertEquals("line " + ++lineNumber,
0939:                        "            <name>outbound.Outbound</name>", in
0940:                                .readLine());
0941:                assertEquals("line " + ++lineNumber,
0942:                        "            <feature confirmed=\"no\">", in.readLine());
0943:                assertEquals(
0944:                        "line " + ++lineNumber,
0945:                        "                <name>outbound.Outbound.outbound()</name>",
0946:                        in.readLine());
0947:                assertEquals(
0948:                        "line " + ++lineNumber,
0949:                        "                <outbound type=\"feature\" confirmed=\"no\">inbound.Inbound.inbound()</outbound>",
0950:                        in.readLine());
0951:                assertEquals("line " + ++lineNumber, "            </feature>",
0952:                        in.readLine());
0953:                assertEquals("line " + ++lineNumber, "        </class>", in
0954:                        .readLine());
0955:                assertEquals("line " + ++lineNumber, "    </package>", in
0956:                        .readLine());
0957:                assertEquals("line " + ++lineNumber, "</dependencies>", in
0958:                        .readLine());
0959:
0960:                assertEquals("End of file", null, in.readLine());
0961:            }
0962:
0963:            public void testShowOutboundsFeatureFalse() throws IOException {
0964:                factory
0965:                        .createFeature("outbound.Outbound.outbound()")
0966:                        .addDependency(
0967:                                factory
0968:                                        .createFeature("inbound.Inbound.inbound()"));
0969:                factory.createFeature("empty.Empty.empty()");
0970:
0971:                XMLPrinter printer = new XMLPrinter(new PrintWriter(out),
0972:                        XMLPrinter.DEFAULT_ENCODING, SPECIFIC_DTD_PREFIX);
0973:                printer.setShowInbounds(false);
0974:                printer.setShowOutbounds(false);
0975:
0976:                printer.traverseNodes(factory.getPackages().values());
0977:
0978:                int lineNumber = 0;
0979:                BufferedReader in = new BufferedReader(new StringReader(out
0980:                        .toString()));
0981:
0982:                assertEquals("line " + ++lineNumber,
0983:                        "<?xml version=\"1.0\" encoding=\"utf-8\" ?>", in
0984:                                .readLine());
0985:                assertEquals("line " + ++lineNumber, "", in.readLine());
0986:                assertEquals(
0987:                        "line " + ++lineNumber,
0988:                        "<!DOCTYPE dependencies SYSTEM \"./etc/dependencies.dtd\">",
0989:                        in.readLine());
0990:                assertEquals("line " + ++lineNumber, "", in.readLine());
0991:                assertEquals("line " + ++lineNumber, "<dependencies>", in
0992:                        .readLine());
0993:                assertEquals("line " + ++lineNumber,
0994:                        "    <package confirmed=\"no\">", in.readLine());
0995:                assertEquals("line " + ++lineNumber,
0996:                        "        <name>empty</name>", in.readLine());
0997:                assertEquals("line " + ++lineNumber,
0998:                        "        <class confirmed=\"no\">", in.readLine());
0999:                assertEquals("line " + ++lineNumber,
1000:                        "            <name>empty.Empty</name>", in.readLine());
1001:                assertEquals("line " + ++lineNumber,
1002:                        "            <feature confirmed=\"no\">", in.readLine());
1003:                assertEquals("line " + ++lineNumber,
1004:                        "                <name>empty.Empty.empty()</name>", in
1005:                                .readLine());
1006:                assertEquals("line " + ++lineNumber, "            </feature>",
1007:                        in.readLine());
1008:                assertEquals("line " + ++lineNumber, "        </class>", in
1009:                        .readLine());
1010:                assertEquals("line " + ++lineNumber, "    </package>", in
1011:                        .readLine());
1012:                assertEquals("line " + ++lineNumber,
1013:                        "    <package confirmed=\"no\">", in.readLine());
1014:                assertEquals("line " + ++lineNumber,
1015:                        "        <name>inbound</name>", in.readLine());
1016:                assertEquals("line " + ++lineNumber,
1017:                        "        <class confirmed=\"no\">", in.readLine());
1018:                assertEquals("line " + ++lineNumber,
1019:                        "            <name>inbound.Inbound</name>", in
1020:                                .readLine());
1021:                assertEquals("line " + ++lineNumber,
1022:                        "            <feature confirmed=\"no\">", in.readLine());
1023:                assertEquals(
1024:                        "line " + ++lineNumber,
1025:                        "                <name>inbound.Inbound.inbound()</name>",
1026:                        in.readLine());
1027:                assertEquals("line " + ++lineNumber, "            </feature>",
1028:                        in.readLine());
1029:                assertEquals("line " + ++lineNumber, "        </class>", in
1030:                        .readLine());
1031:                assertEquals("line " + ++lineNumber, "    </package>", in
1032:                        .readLine());
1033:                assertEquals("line " + ++lineNumber,
1034:                        "    <package confirmed=\"no\">", in.readLine());
1035:                assertEquals("line " + ++lineNumber,
1036:                        "        <name>outbound</name>", in.readLine());
1037:                assertEquals("line " + ++lineNumber,
1038:                        "        <class confirmed=\"no\">", in.readLine());
1039:                assertEquals("line " + ++lineNumber,
1040:                        "            <name>outbound.Outbound</name>", in
1041:                                .readLine());
1042:                assertEquals("line " + ++lineNumber,
1043:                        "            <feature confirmed=\"no\">", in.readLine());
1044:                assertEquals(
1045:                        "line " + ++lineNumber,
1046:                        "                <name>outbound.Outbound.outbound()</name>",
1047:                        in.readLine());
1048:                assertEquals("line " + ++lineNumber, "            </feature>",
1049:                        in.readLine());
1050:                assertEquals("line " + ++lineNumber, "        </class>", in
1051:                        .readLine());
1052:                assertEquals("line " + ++lineNumber, "    </package>", in
1053:                        .readLine());
1054:                assertEquals("line " + ++lineNumber, "</dependencies>", in
1055:                        .readLine());
1056:
1057:                assertEquals("End of file", null, in.readLine());
1058:            }
1059:
1060:            public void testShowEmptyPackageTrue() throws IOException {
1061:                factory.createPackage("outbound").addDependency(
1062:                        factory.createPackage("inbound"));
1063:                factory.createClass("outbound.Outbound").addDependency(
1064:                        factory.createClass("inbound.Inbound"));
1065:                factory
1066:                        .createFeature("outbound.Outbound.outbound()")
1067:                        .addDependency(
1068:                                factory
1069:                                        .createFeature("inbound.Inbound.inbound()"));
1070:                factory.createPackage("empty");
1071:
1072:                XMLPrinter printer = new XMLPrinter(new PrintWriter(out),
1073:                        XMLPrinter.DEFAULT_ENCODING, SPECIFIC_DTD_PREFIX);
1074:                printer.setShowEmptyNodes(true);
1075:
1076:                printer.traverseNodes(factory.getPackages().values());
1077:
1078:                int lineNumber = 0;
1079:                BufferedReader in = new BufferedReader(new StringReader(out
1080:                        .toString()));
1081:
1082:                assertEquals("line " + ++lineNumber,
1083:                        "<?xml version=\"1.0\" encoding=\"utf-8\" ?>", in
1084:                                .readLine());
1085:                assertEquals("line " + ++lineNumber, "", in.readLine());
1086:                assertEquals(
1087:                        "line " + ++lineNumber,
1088:                        "<!DOCTYPE dependencies SYSTEM \"./etc/dependencies.dtd\">",
1089:                        in.readLine());
1090:                assertEquals("line " + ++lineNumber, "", in.readLine());
1091:                assertEquals("line " + ++lineNumber, "<dependencies>", in
1092:                        .readLine());
1093:                assertEquals("line " + ++lineNumber,
1094:                        "    <package confirmed=\"no\">", in.readLine());
1095:                assertEquals("line " + ++lineNumber,
1096:                        "        <name>empty</name>", in.readLine());
1097:                assertEquals("line " + ++lineNumber, "    </package>", in
1098:                        .readLine());
1099:                assertEquals("line " + ++lineNumber,
1100:                        "    <package confirmed=\"no\">", in.readLine());
1101:                assertEquals("line " + ++lineNumber,
1102:                        "        <name>inbound</name>", in.readLine());
1103:                assertEquals(
1104:                        "line " + ++lineNumber,
1105:                        "        <inbound type=\"package\" confirmed=\"no\">outbound</inbound>",
1106:                        in.readLine());
1107:                assertEquals("line " + ++lineNumber,
1108:                        "        <class confirmed=\"no\">", in.readLine());
1109:                assertEquals("line " + ++lineNumber,
1110:                        "            <name>inbound.Inbound</name>", in
1111:                                .readLine());
1112:                assertEquals(
1113:                        "line " + ++lineNumber,
1114:                        "            <inbound type=\"class\" confirmed=\"no\">outbound.Outbound</inbound>",
1115:                        in.readLine());
1116:                assertEquals("line " + ++lineNumber,
1117:                        "            <feature confirmed=\"no\">", in.readLine());
1118:                assertEquals(
1119:                        "line " + ++lineNumber,
1120:                        "                <name>inbound.Inbound.inbound()</name>",
1121:                        in.readLine());
1122:                assertEquals(
1123:                        "line " + ++lineNumber,
1124:                        "                <inbound type=\"feature\" confirmed=\"no\">outbound.Outbound.outbound()</inbound>",
1125:                        in.readLine());
1126:                assertEquals("line " + ++lineNumber, "            </feature>",
1127:                        in.readLine());
1128:                assertEquals("line " + ++lineNumber, "        </class>", in
1129:                        .readLine());
1130:                assertEquals("line " + ++lineNumber, "    </package>", in
1131:                        .readLine());
1132:                assertEquals("line " + ++lineNumber,
1133:                        "    <package confirmed=\"no\">", in.readLine());
1134:                assertEquals("line " + ++lineNumber,
1135:                        "        <name>outbound</name>", in.readLine());
1136:                assertEquals(
1137:                        "line " + ++lineNumber,
1138:                        "        <outbound type=\"package\" confirmed=\"no\">inbound</outbound>",
1139:                        in.readLine());
1140:                assertEquals("line " + ++lineNumber,
1141:                        "        <class confirmed=\"no\">", in.readLine());
1142:                assertEquals("line " + ++lineNumber,
1143:                        "            <name>outbound.Outbound</name>", in
1144:                                .readLine());
1145:                assertEquals(
1146:                        "line " + ++lineNumber,
1147:                        "            <outbound type=\"class\" confirmed=\"no\">inbound.Inbound</outbound>",
1148:                        in.readLine());
1149:                assertEquals("line " + ++lineNumber,
1150:                        "            <feature confirmed=\"no\">", in.readLine());
1151:                assertEquals(
1152:                        "line " + ++lineNumber,
1153:                        "                <name>outbound.Outbound.outbound()</name>",
1154:                        in.readLine());
1155:                assertEquals(
1156:                        "line " + ++lineNumber,
1157:                        "                <outbound type=\"feature\" confirmed=\"no\">inbound.Inbound.inbound()</outbound>",
1158:                        in.readLine());
1159:                assertEquals("line " + ++lineNumber, "            </feature>",
1160:                        in.readLine());
1161:                assertEquals("line " + ++lineNumber, "        </class>", in
1162:                        .readLine());
1163:                assertEquals("line " + ++lineNumber, "    </package>", in
1164:                        .readLine());
1165:                assertEquals("line " + ++lineNumber, "</dependencies>", in
1166:                        .readLine());
1167:
1168:                assertEquals("End of file", null, in.readLine());
1169:            }
1170:
1171:            public void testShowEmptyPackageTrueWithConfirmed()
1172:                    throws IOException {
1173:                factory.createPackage("outbound", true).addDependency(
1174:                        factory.createPackage("inbound", true));
1175:                factory.createClass("outbound.Outbound", true).addDependency(
1176:                        factory.createClass("inbound.Inbound", true));
1177:                factory.createFeature("outbound.Outbound.outbound()", true)
1178:                        .addDependency(
1179:                                factory.createFeature(
1180:                                        "inbound.Inbound.inbound()", true));
1181:                factory.createPackage("empty", true);
1182:
1183:                XMLPrinter printer = new XMLPrinter(new PrintWriter(out),
1184:                        XMLPrinter.DEFAULT_ENCODING, SPECIFIC_DTD_PREFIX);
1185:                printer.setShowEmptyNodes(true);
1186:
1187:                printer.traverseNodes(factory.getPackages().values());
1188:
1189:                int lineNumber = 0;
1190:                BufferedReader in = new BufferedReader(new StringReader(out
1191:                        .toString()));
1192:
1193:                assertEquals("line " + ++lineNumber,
1194:                        "<?xml version=\"1.0\" encoding=\"utf-8\" ?>", in
1195:                                .readLine());
1196:                assertEquals("line " + ++lineNumber, "", in.readLine());
1197:                assertEquals(
1198:                        "line " + ++lineNumber,
1199:                        "<!DOCTYPE dependencies SYSTEM \"./etc/dependencies.dtd\">",
1200:                        in.readLine());
1201:                assertEquals("line " + ++lineNumber, "", in.readLine());
1202:                assertEquals("line " + ++lineNumber, "<dependencies>", in
1203:                        .readLine());
1204:                assertEquals("line " + ++lineNumber,
1205:                        "    <package confirmed=\"yes\">", in.readLine());
1206:                assertEquals("line " + ++lineNumber,
1207:                        "        <name>empty</name>", in.readLine());
1208:                assertEquals("line " + ++lineNumber, "    </package>", in
1209:                        .readLine());
1210:                assertEquals("line " + ++lineNumber,
1211:                        "    <package confirmed=\"yes\">", in.readLine());
1212:                assertEquals("line " + ++lineNumber,
1213:                        "        <name>inbound</name>", in.readLine());
1214:                assertEquals(
1215:                        "line " + ++lineNumber,
1216:                        "        <inbound type=\"package\" confirmed=\"yes\">outbound</inbound>",
1217:                        in.readLine());
1218:                assertEquals("line " + ++lineNumber,
1219:                        "        <class confirmed=\"yes\">", in.readLine());
1220:                assertEquals("line " + ++lineNumber,
1221:                        "            <name>inbound.Inbound</name>", in
1222:                                .readLine());
1223:                assertEquals(
1224:                        "line " + ++lineNumber,
1225:                        "            <inbound type=\"class\" confirmed=\"yes\">outbound.Outbound</inbound>",
1226:                        in.readLine());
1227:                assertEquals("line " + ++lineNumber,
1228:                        "            <feature confirmed=\"yes\">", in
1229:                                .readLine());
1230:                assertEquals(
1231:                        "line " + ++lineNumber,
1232:                        "                <name>inbound.Inbound.inbound()</name>",
1233:                        in.readLine());
1234:                assertEquals(
1235:                        "line " + ++lineNumber,
1236:                        "                <inbound type=\"feature\" confirmed=\"yes\">outbound.Outbound.outbound()</inbound>",
1237:                        in.readLine());
1238:                assertEquals("line " + ++lineNumber, "            </feature>",
1239:                        in.readLine());
1240:                assertEquals("line " + ++lineNumber, "        </class>", in
1241:                        .readLine());
1242:                assertEquals("line " + ++lineNumber, "    </package>", in
1243:                        .readLine());
1244:                assertEquals("line " + ++lineNumber,
1245:                        "    <package confirmed=\"yes\">", in.readLine());
1246:                assertEquals("line " + ++lineNumber,
1247:                        "        <name>outbound</name>", in.readLine());
1248:                assertEquals(
1249:                        "line " + ++lineNumber,
1250:                        "        <outbound type=\"package\" confirmed=\"yes\">inbound</outbound>",
1251:                        in.readLine());
1252:                assertEquals("line " + ++lineNumber,
1253:                        "        <class confirmed=\"yes\">", in.readLine());
1254:                assertEquals("line " + ++lineNumber,
1255:                        "            <name>outbound.Outbound</name>", in
1256:                                .readLine());
1257:                assertEquals(
1258:                        "line " + ++lineNumber,
1259:                        "            <outbound type=\"class\" confirmed=\"yes\">inbound.Inbound</outbound>",
1260:                        in.readLine());
1261:                assertEquals("line " + ++lineNumber,
1262:                        "            <feature confirmed=\"yes\">", in
1263:                                .readLine());
1264:                assertEquals(
1265:                        "line " + ++lineNumber,
1266:                        "                <name>outbound.Outbound.outbound()</name>",
1267:                        in.readLine());
1268:                assertEquals(
1269:                        "line " + ++lineNumber,
1270:                        "                <outbound type=\"feature\" confirmed=\"yes\">inbound.Inbound.inbound()</outbound>",
1271:                        in.readLine());
1272:                assertEquals("line " + ++lineNumber, "            </feature>",
1273:                        in.readLine());
1274:                assertEquals("line " + ++lineNumber, "        </class>", in
1275:                        .readLine());
1276:                assertEquals("line " + ++lineNumber, "    </package>", in
1277:                        .readLine());
1278:                assertEquals("line " + ++lineNumber, "</dependencies>", in
1279:                        .readLine());
1280:
1281:                assertEquals("End of file", null, in.readLine());
1282:            }
1283:
1284:            public void testShowEmptyPackageFalse() throws IOException {
1285:                factory.createPackage("outbound").addDependency(
1286:                        factory.createPackage("inbound"));
1287:                factory.createClass("outbound.Outbound").addDependency(
1288:                        factory.createClass("inbound.Inbound"));
1289:                factory
1290:                        .createFeature("outbound.Outbound.outbound()")
1291:                        .addDependency(
1292:                                factory
1293:                                        .createFeature("inbound.Inbound.inbound()"));
1294:                factory.createPackage("empty");
1295:
1296:                XMLPrinter printer = new XMLPrinter(new PrintWriter(out),
1297:                        XMLPrinter.DEFAULT_ENCODING, SPECIFIC_DTD_PREFIX);
1298:                printer.setShowEmptyNodes(false);
1299:
1300:                printer.traverseNodes(factory.getPackages().values());
1301:
1302:                int lineNumber = 0;
1303:                BufferedReader in = new BufferedReader(new StringReader(out
1304:                        .toString()));
1305:
1306:                assertEquals("line " + ++lineNumber,
1307:                        "<?xml version=\"1.0\" encoding=\"utf-8\" ?>", in
1308:                                .readLine());
1309:                assertEquals("line " + ++lineNumber, "", in.readLine());
1310:                assertEquals(
1311:                        "line " + ++lineNumber,
1312:                        "<!DOCTYPE dependencies SYSTEM \"./etc/dependencies.dtd\">",
1313:                        in.readLine());
1314:                assertEquals("line " + ++lineNumber, "", in.readLine());
1315:                assertEquals("line " + ++lineNumber, "<dependencies>", in
1316:                        .readLine());
1317:                assertEquals("line " + ++lineNumber,
1318:                        "    <package confirmed=\"no\">", in.readLine());
1319:                assertEquals("line " + ++lineNumber,
1320:                        "        <name>inbound</name>", in.readLine());
1321:                assertEquals(
1322:                        "line " + ++lineNumber,
1323:                        "        <inbound type=\"package\" confirmed=\"no\">outbound</inbound>",
1324:                        in.readLine());
1325:                assertEquals("line " + ++lineNumber,
1326:                        "        <class confirmed=\"no\">", in.readLine());
1327:                assertEquals("line " + ++lineNumber,
1328:                        "            <name>inbound.Inbound</name>", in
1329:                                .readLine());
1330:                assertEquals(
1331:                        "line " + ++lineNumber,
1332:                        "            <inbound type=\"class\" confirmed=\"no\">outbound.Outbound</inbound>",
1333:                        in.readLine());
1334:                assertEquals("line " + ++lineNumber,
1335:                        "            <feature confirmed=\"no\">", in.readLine());
1336:                assertEquals(
1337:                        "line " + ++lineNumber,
1338:                        "                <name>inbound.Inbound.inbound()</name>",
1339:                        in.readLine());
1340:                assertEquals(
1341:                        "line " + ++lineNumber,
1342:                        "                <inbound type=\"feature\" confirmed=\"no\">outbound.Outbound.outbound()</inbound>",
1343:                        in.readLine());
1344:                assertEquals("line " + ++lineNumber, "            </feature>",
1345:                        in.readLine());
1346:                assertEquals("line " + ++lineNumber, "        </class>", in
1347:                        .readLine());
1348:                assertEquals("line " + ++lineNumber, "    </package>", in
1349:                        .readLine());
1350:                assertEquals("line " + ++lineNumber,
1351:                        "    <package confirmed=\"no\">", in.readLine());
1352:                assertEquals("line " + ++lineNumber,
1353:                        "        <name>outbound</name>", in.readLine());
1354:                assertEquals(
1355:                        "line " + ++lineNumber,
1356:                        "        <outbound type=\"package\" confirmed=\"no\">inbound</outbound>",
1357:                        in.readLine());
1358:                assertEquals("line " + ++lineNumber,
1359:                        "        <class confirmed=\"no\">", in.readLine());
1360:                assertEquals("line " + ++lineNumber,
1361:                        "            <name>outbound.Outbound</name>", in
1362:                                .readLine());
1363:                assertEquals(
1364:                        "line " + ++lineNumber,
1365:                        "            <outbound type=\"class\" confirmed=\"no\">inbound.Inbound</outbound>",
1366:                        in.readLine());
1367:                assertEquals("line " + ++lineNumber,
1368:                        "            <feature confirmed=\"no\">", in.readLine());
1369:                assertEquals(
1370:                        "line " + ++lineNumber,
1371:                        "                <name>outbound.Outbound.outbound()</name>",
1372:                        in.readLine());
1373:                assertEquals(
1374:                        "line " + ++lineNumber,
1375:                        "                <outbound type=\"feature\" confirmed=\"no\">inbound.Inbound.inbound()</outbound>",
1376:                        in.readLine());
1377:                assertEquals("line " + ++lineNumber, "            </feature>",
1378:                        in.readLine());
1379:                assertEquals("line " + ++lineNumber, "        </class>", in
1380:                        .readLine());
1381:                assertEquals("line " + ++lineNumber, "    </package>", in
1382:                        .readLine());
1383:                assertEquals("line " + ++lineNumber, "</dependencies>", in
1384:                        .readLine());
1385:
1386:                assertEquals("End of file", null, in.readLine());
1387:            }
1388:
1389:            public void testShowEmptyClassTrue() throws IOException {
1390:                factory.createClass("outbound.Outbound").addDependency(
1391:                        factory.createClass("inbound.Inbound"));
1392:                factory
1393:                        .createFeature("outbound.Outbound.outbound()")
1394:                        .addDependency(
1395:                                factory
1396:                                        .createFeature("inbound.Inbound.inbound()"));
1397:                factory.createClass("empty.Empty");
1398:
1399:                XMLPrinter printer = new XMLPrinter(new PrintWriter(out),
1400:                        XMLPrinter.DEFAULT_ENCODING, SPECIFIC_DTD_PREFIX);
1401:                printer.setShowEmptyNodes(true);
1402:
1403:                printer.traverseNodes(factory.getPackages().values());
1404:
1405:                int lineNumber = 0;
1406:                BufferedReader in = new BufferedReader(new StringReader(out
1407:                        .toString()));
1408:
1409:                assertEquals("line " + ++lineNumber,
1410:                        "<?xml version=\"1.0\" encoding=\"utf-8\" ?>", in
1411:                                .readLine());
1412:                assertEquals("line " + ++lineNumber, "", in.readLine());
1413:                assertEquals(
1414:                        "line " + ++lineNumber,
1415:                        "<!DOCTYPE dependencies SYSTEM \"./etc/dependencies.dtd\">",
1416:                        in.readLine());
1417:                assertEquals("line " + ++lineNumber, "", in.readLine());
1418:                assertEquals("line " + ++lineNumber, "<dependencies>", in
1419:                        .readLine());
1420:                assertEquals("line " + ++lineNumber,
1421:                        "    <package confirmed=\"no\">", in.readLine());
1422:                assertEquals("line " + ++lineNumber,
1423:                        "        <name>empty</name>", in.readLine());
1424:                assertEquals("line " + ++lineNumber,
1425:                        "        <class confirmed=\"no\">", in.readLine());
1426:                assertEquals("line " + ++lineNumber,
1427:                        "            <name>empty.Empty</name>", in.readLine());
1428:                assertEquals("line " + ++lineNumber, "        </class>", in
1429:                        .readLine());
1430:                assertEquals("line " + ++lineNumber, "    </package>", in
1431:                        .readLine());
1432:                assertEquals("line " + ++lineNumber,
1433:                        "    <package confirmed=\"no\">", in.readLine());
1434:                assertEquals("line " + ++lineNumber,
1435:                        "        <name>inbound</name>", in.readLine());
1436:                assertEquals("line " + ++lineNumber,
1437:                        "        <class confirmed=\"no\">", in.readLine());
1438:                assertEquals("line " + ++lineNumber,
1439:                        "            <name>inbound.Inbound</name>", in
1440:                                .readLine());
1441:                assertEquals(
1442:                        "line " + ++lineNumber,
1443:                        "            <inbound type=\"class\" confirmed=\"no\">outbound.Outbound</inbound>",
1444:                        in.readLine());
1445:                assertEquals("line " + ++lineNumber,
1446:                        "            <feature confirmed=\"no\">", in.readLine());
1447:                assertEquals(
1448:                        "line " + ++lineNumber,
1449:                        "                <name>inbound.Inbound.inbound()</name>",
1450:                        in.readLine());
1451:                assertEquals(
1452:                        "line " + ++lineNumber,
1453:                        "                <inbound type=\"feature\" confirmed=\"no\">outbound.Outbound.outbound()</inbound>",
1454:                        in.readLine());
1455:                assertEquals("line " + ++lineNumber, "            </feature>",
1456:                        in.readLine());
1457:                assertEquals("line " + ++lineNumber, "        </class>", in
1458:                        .readLine());
1459:                assertEquals("line " + ++lineNumber, "    </package>", in
1460:                        .readLine());
1461:                assertEquals("line " + ++lineNumber,
1462:                        "    <package confirmed=\"no\">", in.readLine());
1463:                assertEquals("line " + ++lineNumber,
1464:                        "        <name>outbound</name>", in.readLine());
1465:                assertEquals("line " + ++lineNumber,
1466:                        "        <class confirmed=\"no\">", in.readLine());
1467:                assertEquals("line " + ++lineNumber,
1468:                        "            <name>outbound.Outbound</name>", in
1469:                                .readLine());
1470:                assertEquals(
1471:                        "line " + ++lineNumber,
1472:                        "            <outbound type=\"class\" confirmed=\"no\">inbound.Inbound</outbound>",
1473:                        in.readLine());
1474:                assertEquals("line " + ++lineNumber,
1475:                        "            <feature confirmed=\"no\">", in.readLine());
1476:                assertEquals(
1477:                        "line " + ++lineNumber,
1478:                        "                <name>outbound.Outbound.outbound()</name>",
1479:                        in.readLine());
1480:                assertEquals(
1481:                        "line " + ++lineNumber,
1482:                        "                <outbound type=\"feature\" confirmed=\"no\">inbound.Inbound.inbound()</outbound>",
1483:                        in.readLine());
1484:                assertEquals("line " + ++lineNumber, "            </feature>",
1485:                        in.readLine());
1486:                assertEquals("line " + ++lineNumber, "        </class>", in
1487:                        .readLine());
1488:                assertEquals("line " + ++lineNumber, "    </package>", in
1489:                        .readLine());
1490:                assertEquals("line " + ++lineNumber, "</dependencies>", in
1491:                        .readLine());
1492:
1493:                assertEquals("End of file", null, in.readLine());
1494:            }
1495:
1496:            public void testShowEmptyClassFalse() throws IOException {
1497:                factory.createClass("outbound.Outbound").addDependency(
1498:                        factory.createClass("inbound.Inbound"));
1499:                factory
1500:                        .createFeature("outbound.Outbound.outbound()")
1501:                        .addDependency(
1502:                                factory
1503:                                        .createFeature("inbound.Inbound.inbound()"));
1504:                factory.createClass("empty.Empty");
1505:
1506:                XMLPrinter printer = new XMLPrinter(new PrintWriter(out),
1507:                        XMLPrinter.DEFAULT_ENCODING, SPECIFIC_DTD_PREFIX);
1508:                printer.setShowEmptyNodes(false);
1509:
1510:                printer.traverseNodes(factory.getPackages().values());
1511:
1512:                int lineNumber = 0;
1513:                BufferedReader in = new BufferedReader(new StringReader(out
1514:                        .toString()));
1515:
1516:                assertEquals("line " + ++lineNumber,
1517:                        "<?xml version=\"1.0\" encoding=\"utf-8\" ?>", in
1518:                                .readLine());
1519:                assertEquals("line " + ++lineNumber, "", in.readLine());
1520:                assertEquals(
1521:                        "line " + ++lineNumber,
1522:                        "<!DOCTYPE dependencies SYSTEM \"./etc/dependencies.dtd\">",
1523:                        in.readLine());
1524:                assertEquals("line " + ++lineNumber, "", in.readLine());
1525:                assertEquals("line " + ++lineNumber, "<dependencies>", in
1526:                        .readLine());
1527:                assertEquals("line " + ++lineNumber,
1528:                        "    <package confirmed=\"no\">", in.readLine());
1529:                assertEquals("line " + ++lineNumber,
1530:                        "        <name>inbound</name>", in.readLine());
1531:                assertEquals("line " + ++lineNumber,
1532:                        "        <class confirmed=\"no\">", in.readLine());
1533:                assertEquals("line " + ++lineNumber,
1534:                        "            <name>inbound.Inbound</name>", in
1535:                                .readLine());
1536:                assertEquals(
1537:                        "line " + ++lineNumber,
1538:                        "            <inbound type=\"class\" confirmed=\"no\">outbound.Outbound</inbound>",
1539:                        in.readLine());
1540:                assertEquals("line " + ++lineNumber,
1541:                        "            <feature confirmed=\"no\">", in.readLine());
1542:                assertEquals(
1543:                        "line " + ++lineNumber,
1544:                        "                <name>inbound.Inbound.inbound()</name>",
1545:                        in.readLine());
1546:                assertEquals(
1547:                        "line " + ++lineNumber,
1548:                        "                <inbound type=\"feature\" confirmed=\"no\">outbound.Outbound.outbound()</inbound>",
1549:                        in.readLine());
1550:                assertEquals("line " + ++lineNumber, "            </feature>",
1551:                        in.readLine());
1552:                assertEquals("line " + ++lineNumber, "        </class>", in
1553:                        .readLine());
1554:                assertEquals("line " + ++lineNumber, "    </package>", in
1555:                        .readLine());
1556:                assertEquals("line " + ++lineNumber,
1557:                        "    <package confirmed=\"no\">", in.readLine());
1558:                assertEquals("line " + ++lineNumber,
1559:                        "        <name>outbound</name>", in.readLine());
1560:                assertEquals("line " + ++lineNumber,
1561:                        "        <class confirmed=\"no\">", in.readLine());
1562:                assertEquals("line " + ++lineNumber,
1563:                        "            <name>outbound.Outbound</name>", in
1564:                                .readLine());
1565:                assertEquals(
1566:                        "line " + ++lineNumber,
1567:                        "            <outbound type=\"class\" confirmed=\"no\">inbound.Inbound</outbound>",
1568:                        in.readLine());
1569:                assertEquals("line " + ++lineNumber,
1570:                        "            <feature confirmed=\"no\">", in.readLine());
1571:                assertEquals(
1572:                        "line " + ++lineNumber,
1573:                        "                <name>outbound.Outbound.outbound()</name>",
1574:                        in.readLine());
1575:                assertEquals(
1576:                        "line " + ++lineNumber,
1577:                        "                <outbound type=\"feature\" confirmed=\"no\">inbound.Inbound.inbound()</outbound>",
1578:                        in.readLine());
1579:                assertEquals("line " + ++lineNumber, "            </feature>",
1580:                        in.readLine());
1581:                assertEquals("line " + ++lineNumber, "        </class>", in
1582:                        .readLine());
1583:                assertEquals("line " + ++lineNumber, "    </package>", in
1584:                        .readLine());
1585:                assertEquals("line " + ++lineNumber, "</dependencies>", in
1586:                        .readLine());
1587:
1588:                assertEquals("End of file", null, in.readLine());
1589:            }
1590:
1591:            public void testShowEmptyFeatureTrue() throws IOException {
1592:                factory
1593:                        .createFeature("outbound.Outbound.outbound()")
1594:                        .addDependency(
1595:                                factory
1596:                                        .createFeature("inbound.Inbound.inbound()"));
1597:                factory.createFeature("empty.Empty.empty()");
1598:
1599:                XMLPrinter printer = new XMLPrinter(new PrintWriter(out),
1600:                        XMLPrinter.DEFAULT_ENCODING, SPECIFIC_DTD_PREFIX);
1601:                printer.setShowEmptyNodes(true);
1602:
1603:                printer.traverseNodes(factory.getPackages().values());
1604:
1605:                int lineNumber = 0;
1606:                BufferedReader in = new BufferedReader(new StringReader(out
1607:                        .toString()));
1608:
1609:                assertEquals("line " + ++lineNumber,
1610:                        "<?xml version=\"1.0\" encoding=\"utf-8\" ?>", in
1611:                                .readLine());
1612:                assertEquals("line " + ++lineNumber, "", in.readLine());
1613:                assertEquals(
1614:                        "line " + ++lineNumber,
1615:                        "<!DOCTYPE dependencies SYSTEM \"./etc/dependencies.dtd\">",
1616:                        in.readLine());
1617:                assertEquals("line " + ++lineNumber, "", in.readLine());
1618:                assertEquals("line " + ++lineNumber, "<dependencies>", in
1619:                        .readLine());
1620:                assertEquals("line " + ++lineNumber,
1621:                        "    <package confirmed=\"no\">", in.readLine());
1622:                assertEquals("line " + ++lineNumber,
1623:                        "        <name>empty</name>", in.readLine());
1624:                assertEquals("line " + ++lineNumber,
1625:                        "        <class confirmed=\"no\">", in.readLine());
1626:                assertEquals("line " + ++lineNumber,
1627:                        "            <name>empty.Empty</name>", in.readLine());
1628:                assertEquals("line " + ++lineNumber,
1629:                        "            <feature confirmed=\"no\">", in.readLine());
1630:                assertEquals("line " + ++lineNumber,
1631:                        "                <name>empty.Empty.empty()</name>", in
1632:                                .readLine());
1633:                assertEquals("line " + ++lineNumber, "            </feature>",
1634:                        in.readLine());
1635:                assertEquals("line " + ++lineNumber, "        </class>", in
1636:                        .readLine());
1637:                assertEquals("line " + ++lineNumber, "    </package>", in
1638:                        .readLine());
1639:                assertEquals("line " + ++lineNumber,
1640:                        "    <package confirmed=\"no\">", in.readLine());
1641:                assertEquals("line " + ++lineNumber,
1642:                        "        <name>inbound</name>", in.readLine());
1643:                assertEquals("line " + ++lineNumber,
1644:                        "        <class confirmed=\"no\">", in.readLine());
1645:                assertEquals("line " + ++lineNumber,
1646:                        "            <name>inbound.Inbound</name>", in
1647:                                .readLine());
1648:                assertEquals("line " + ++lineNumber,
1649:                        "            <feature confirmed=\"no\">", in.readLine());
1650:                assertEquals(
1651:                        "line " + ++lineNumber,
1652:                        "                <name>inbound.Inbound.inbound()</name>",
1653:                        in.readLine());
1654:                assertEquals(
1655:                        "line " + ++lineNumber,
1656:                        "                <inbound type=\"feature\" confirmed=\"no\">outbound.Outbound.outbound()</inbound>",
1657:                        in.readLine());
1658:                assertEquals("line " + ++lineNumber, "            </feature>",
1659:                        in.readLine());
1660:                assertEquals("line " + ++lineNumber, "        </class>", in
1661:                        .readLine());
1662:                assertEquals("line " + ++lineNumber, "    </package>", in
1663:                        .readLine());
1664:                assertEquals("line " + ++lineNumber,
1665:                        "    <package confirmed=\"no\">", in.readLine());
1666:                assertEquals("line " + ++lineNumber,
1667:                        "        <name>outbound</name>", in.readLine());
1668:                assertEquals("line " + ++lineNumber,
1669:                        "        <class confirmed=\"no\">", in.readLine());
1670:                assertEquals("line " + ++lineNumber,
1671:                        "            <name>outbound.Outbound</name>", in
1672:                                .readLine());
1673:                assertEquals("line " + ++lineNumber,
1674:                        "            <feature confirmed=\"no\">", in.readLine());
1675:                assertEquals(
1676:                        "line " + ++lineNumber,
1677:                        "                <name>outbound.Outbound.outbound()</name>",
1678:                        in.readLine());
1679:                assertEquals(
1680:                        "line " + ++lineNumber,
1681:                        "                <outbound type=\"feature\" confirmed=\"no\">inbound.Inbound.inbound()</outbound>",
1682:                        in.readLine());
1683:                assertEquals("line " + ++lineNumber, "            </feature>",
1684:                        in.readLine());
1685:                assertEquals("line " + ++lineNumber, "        </class>", in
1686:                        .readLine());
1687:                assertEquals("line " + ++lineNumber, "    </package>", in
1688:                        .readLine());
1689:                assertEquals("line " + ++lineNumber, "</dependencies>", in
1690:                        .readLine());
1691:
1692:                assertEquals("End of file", null, in.readLine());
1693:            }
1694:
1695:            public void testShowEmptyFeatureFalse() throws IOException {
1696:                factory
1697:                        .createFeature("outbound.Outbound.outbound()")
1698:                        .addDependency(
1699:                                factory
1700:                                        .createFeature("inbound.Inbound.inbound()"));
1701:                factory.createFeature("empty.Empty.empty()");
1702:
1703:                XMLPrinter printer = new XMLPrinter(new PrintWriter(out),
1704:                        XMLPrinter.DEFAULT_ENCODING, SPECIFIC_DTD_PREFIX);
1705:                printer.setShowEmptyNodes(false);
1706:
1707:                printer.traverseNodes(factory.getPackages().values());
1708:
1709:                int lineNumber = 0;
1710:                BufferedReader in = new BufferedReader(new StringReader(out
1711:                        .toString()));
1712:
1713:                assertEquals("line " + ++lineNumber,
1714:                        "<?xml version=\"1.0\" encoding=\"utf-8\" ?>", in
1715:                                .readLine());
1716:                assertEquals("line " + ++lineNumber, "", in.readLine());
1717:                assertEquals(
1718:                        "line " + ++lineNumber,
1719:                        "<!DOCTYPE dependencies SYSTEM \"./etc/dependencies.dtd\">",
1720:                        in.readLine());
1721:                assertEquals("line " + ++lineNumber, "", in.readLine());
1722:                assertEquals("line " + ++lineNumber, "<dependencies>", in
1723:                        .readLine());
1724:                assertEquals("line " + ++lineNumber,
1725:                        "    <package confirmed=\"no\">", in.readLine());
1726:                assertEquals("line " + ++lineNumber,
1727:                        "        <name>inbound</name>", in.readLine());
1728:                assertEquals("line " + ++lineNumber,
1729:                        "        <class confirmed=\"no\">", in.readLine());
1730:                assertEquals("line " + ++lineNumber,
1731:                        "            <name>inbound.Inbound</name>", in
1732:                                .readLine());
1733:                assertEquals("line " + ++lineNumber,
1734:                        "            <feature confirmed=\"no\">", in.readLine());
1735:                assertEquals(
1736:                        "line " + ++lineNumber,
1737:                        "                <name>inbound.Inbound.inbound()</name>",
1738:                        in.readLine());
1739:                assertEquals(
1740:                        "line " + ++lineNumber,
1741:                        "                <inbound type=\"feature\" confirmed=\"no\">outbound.Outbound.outbound()</inbound>",
1742:                        in.readLine());
1743:                assertEquals("line " + ++lineNumber, "            </feature>",
1744:                        in.readLine());
1745:                assertEquals("line " + ++lineNumber, "        </class>", in
1746:                        .readLine());
1747:                assertEquals("line " + ++lineNumber, "    </package>", in
1748:                        .readLine());
1749:                assertEquals("line " + ++lineNumber,
1750:                        "    <package confirmed=\"no\">", in.readLine());
1751:                assertEquals("line " + ++lineNumber,
1752:                        "        <name>outbound</name>", in.readLine());
1753:                assertEquals("line " + ++lineNumber,
1754:                        "        <class confirmed=\"no\">", in.readLine());
1755:                assertEquals("line " + ++lineNumber,
1756:                        "            <name>outbound.Outbound</name>", in
1757:                                .readLine());
1758:                assertEquals("line " + ++lineNumber,
1759:                        "            <feature confirmed=\"no\">", in.readLine());
1760:                assertEquals(
1761:                        "line " + ++lineNumber,
1762:                        "                <name>outbound.Outbound.outbound()</name>",
1763:                        in.readLine());
1764:                assertEquals(
1765:                        "line " + ++lineNumber,
1766:                        "                <outbound type=\"feature\" confirmed=\"no\">inbound.Inbound.inbound()</outbound>",
1767:                        in.readLine());
1768:                assertEquals("line " + ++lineNumber, "            </feature>",
1769:                        in.readLine());
1770:                assertEquals("line " + ++lineNumber, "        </class>", in
1771:                        .readLine());
1772:                assertEquals("line " + ++lineNumber, "    </package>", in
1773:                        .readLine());
1774:                assertEquals("line " + ++lineNumber, "</dependencies>", in
1775:                        .readLine());
1776:
1777:                assertEquals("End of file", null, in.readLine());
1778:            }
1779:
1780:            public void error(SAXParseException ex) {
1781:                // Ignore
1782:            }
1783:
1784:            public void fatalError(SAXParseException ex) {
1785:                // Ignore
1786:            }
1787:
1788:            public void warning(SAXParseException ex) {
1789:                // Ignore
1790:            }
1791:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.