Source Code Cross Referenced for PrintIconTest.java in  » IDE-Netbeans » nbbuild » org » netbeans » nbbuild » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » nbbuild » org.netbeans.nbbuild 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * Portions Copyrighted 2007 Sun Microsystems, Inc.
027:         */
028:
029:        package org.netbeans.nbbuild;
030:
031:        import junit.framework.TestCase;
032:        import org.apache.tools.ant.types.FileSet;
033:        import org.netbeans.junit.NbTestCase;
034:
035:        /**
036:         *
037:         * @author Jaroslav Tulach
038:         */
039:        public class PrintIconTest extends NbTestCase {
040:
041:            public PrintIconTest(String testName) {
042:                super (testName);
043:            }
044:
045:            protected void setUp() throws Exception {
046:                clearWorkDir();
047:                super .setUp();
048:            }
049:
050:            protected void tearDown() throws Exception {
051:                super .tearDown();
052:            }
053:
054:            public void testPrintOutSameIcons() throws Exception {
055:                java.io.File img = PublicPackagesInProjectizedXMLTest
056:                        .extractResource("data/instanceBroken.gif");
057:                java.io.File img2 = PublicPackagesInProjectizedXMLTest
058:                        .extractResource("data/instanceObject.gif");
059:                java.io.File img3 = PublicPackagesInProjectizedXMLTest
060:                        .extractResource("data/instanceBroken.gif");
061:                java.io.File out = PublicPackagesInProjectizedXMLTest
062:                        .extractString("");
063:                out.delete();
064:
065:                java.io.File f = PublicPackagesInProjectizedXMLTest
066:                        .extractString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
067:                                + "<project name=\"Test Arch\" basedir=\".\" default=\"all\" >"
068:                                + "  <taskdef name=\"printicon\" classname=\"org.netbeans.nbbuild.PrintIcon\" classpath=\"${nb_all}/nbbuild/nbantext.jar\"/>"
069:                                + "<target name=\"all\" >"
070:                                + "  <printicon duplicates='"
071:                                + out
072:                                + "'>"
073:                                + "    <firstpool dir='"
074:                                + img.getParent()
075:                                + "'>"
076:                                + "       <include name='"
077:                                + img.getName()
078:                                + "'/>"
079:                                + "       <include name='"
080:                                + img2.getName()
081:                                + "'/>"
082:                                + "    </firstpool>"
083:                                + "    <secondpool dir='"
084:                                + img3.getParent()
085:                                + "'>"
086:                                + "       <include name='"
087:                                + img3.getName()
088:                                + "'/>"
089:                                + "    </secondpool>"
090:                                + "  </printicon>" + "</target>" + "</project>");
091:                PublicPackagesInProjectizedXMLTest.execute(f,
092:                        new String[] { "-verbose" });
093:
094:                assertTrue("Exists: " + out, out.canRead());
095:
096:                String file = PublicPackagesInProjectizedXMLTest.readFile(out);
097:
098:                String[] threeParts = file.split("( |\n)+");
099:                assertEquals(file, 6, threeParts.length);
100:
101:                {
102:                    long hash = Long.parseLong(threeParts[0], 16);
103:                    assertEquals("Hash code is ee2ab8d3:\n" + file,
104:                            0xee2ab8d3L, hash);
105:                    assertEquals("Name is from img:\n" + file, img.getName(),
106:                            threeParts[1]);
107:                    assertEquals("Full name is img:\n" + file, img.toURL()
108:                            .toExternalForm(), threeParts[2]);
109:                }
110:
111:                {
112:                    long hash = Long.parseLong(threeParts[3], 16);
113:                    assertEquals("Hash code is ee2ab8d3:\n" + file,
114:                            0xee2ab8d3L, hash);
115:                    assertEquals("Name is from img:\n" + file, img3.getName(),
116:                            threeParts[4]);
117:                    assertEquals("Full name is img:\n" + file, img3.toURL()
118:                            .toExternalForm(), threeParts[5]);
119:                }
120:
121:            }
122:
123:            public void testDuplicatesFromTheSameSet() throws Exception {
124:                java.io.File img = PublicPackagesInProjectizedXMLTest
125:                        .extractResource("data/instanceBroken.gif");
126:                java.io.File img2 = PublicPackagesInProjectizedXMLTest
127:                        .extractResource("data/instanceObject.gif");
128:                java.io.File img3 = PublicPackagesInProjectizedXMLTest
129:                        .extractResource("data/instanceBroken.gif");
130:                java.io.File out = PublicPackagesInProjectizedXMLTest
131:                        .extractString("");
132:                out.delete();
133:
134:                java.io.File f = PublicPackagesInProjectizedXMLTest
135:                        .extractString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
136:                                + "<project name=\"Test Arch\" basedir=\".\" default=\"all\" >"
137:                                + "  <taskdef name=\"printicon\" classname=\"org.netbeans.nbbuild.PrintIcon\" classpath=\"${nb_all}/nbbuild/nbantext.jar\"/>"
138:                                + "<target name=\"all\" >"
139:                                + "  <printicon duplicates='"
140:                                + out
141:                                + "'>"
142:                                + "    <firstpool dir='"
143:                                + img.getParent()
144:                                + "'>"
145:                                + "       <include name='"
146:                                + img.getName()
147:                                + "'/>"
148:                                + "       <include name='"
149:                                + img2.getName()
150:                                + "'/>"
151:                                + "       <include name='"
152:                                + img3.getName()
153:                                + "'/>"
154:                                + "    </firstpool>"
155:                                + "  </printicon>" + "</target>" + "</project>");
156:                PublicPackagesInProjectizedXMLTest.execute(f,
157:                        new String[] { "-verbose" });
158:
159:                assertTrue("Exists: " + out, out.canRead());
160:
161:                String file = PublicPackagesInProjectizedXMLTest.readFile(out);
162:
163:                String[] threeParts = file.split("( |\n)+");
164:                assertEquals(file, 6, threeParts.length);
165:
166:                {
167:                    long hash = Long.parseLong(threeParts[0], 16);
168:                    assertEquals("Hash code is ee2ab8d3:\n" + file,
169:                            0xee2ab8d3L, hash);
170:                    assertEquals("Name is from img:\n" + file, img.getName(),
171:                            threeParts[1]);
172:                    assertEquals("Full name is img:\n" + file, img.toURL()
173:                            .toExternalForm(), threeParts[2]);
174:                }
175:
176:                {
177:                    long hash = Long.parseLong(threeParts[3], 16);
178:                    assertEquals("Hash code is ee2ab8d3:\n" + file,
179:                            0xee2ab8d3L, hash);
180:                    assertEquals("Name is from img:\n" + file, img3.getName(),
181:                            threeParts[4]);
182:                    assertEquals("Full name is img:\n" + file, img3.toURL()
183:                            .toExternalForm(), threeParts[5]);
184:                }
185:
186:            }
187:
188:            public void testBrokenImageThatCould() throws Exception {
189:                doBrokenImageTest("data/columnIndex.gif");
190:            }
191:
192:            public void testBrokenImageThatCoul2() throws Exception {
193:                doBrokenImageTest("data/Category.png");
194:            }
195:
196:            private void doBrokenImageTest(String res) throws Exception {
197:                java.io.File img = PublicPackagesInProjectizedXMLTest
198:                        .extractResource(res);
199:                java.io.File img2 = PublicPackagesInProjectizedXMLTest
200:                        .extractResource("data/instanceObject.gif");
201:                java.io.File img3 = PublicPackagesInProjectizedXMLTest
202:                        .extractResource(res);
203:                java.io.File out = PublicPackagesInProjectizedXMLTest
204:                        .extractString("");
205:                out.delete();
206:
207:                java.io.File f = PublicPackagesInProjectizedXMLTest
208:                        .extractString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
209:                                + "<project name=\"Test Arch\" basedir=\".\" default=\"all\" >"
210:                                + "  <taskdef name=\"printicon\" classname=\"org.netbeans.nbbuild.PrintIcon\" classpath=\"${nb_all}/nbbuild/nbantext.jar\"/>"
211:                                + "<target name=\"all\" >"
212:                                + "  <printicon duplicates='"
213:                                + out
214:                                + "'>"
215:                                + "    <firstpool dir='"
216:                                + img.getParent()
217:                                + "'>"
218:                                + "       <include name='"
219:                                + img.getName()
220:                                + "'/>"
221:                                + "       <include name='"
222:                                + img2.getName()
223:                                + "'/>"
224:                                + "       <include name='"
225:                                + img3.getName()
226:                                + "'/>"
227:                                + "    </firstpool>"
228:                                + "  </printicon>" + "</target>" + "</project>");
229:                PublicPackagesInProjectizedXMLTest.execute(f,
230:                        new String[] { "-verbose" });
231:
232:                assertTrue("Exists: " + out, out.canRead());
233:
234:                String file = PublicPackagesInProjectizedXMLTest.readFile(out);
235:
236:                String[] threeParts = file.split("( |\n)+");
237:                assertEquals(file, 6, threeParts.length);
238:
239:                long prevHash;
240:                {
241:                    prevHash = Long.parseLong(threeParts[0], 16);
242:                    assertEquals("Name is from img:\n" + file, img.getName(),
243:                            threeParts[1]);
244:                    assertEquals("Full name is img:\n" + file, img.toURL()
245:                            .toExternalForm(), threeParts[2]);
246:                }
247:
248:                {
249:                    long hash = Long.parseLong(threeParts[3], 16);
250:                    assertEquals("Hash code is the same:\n" + file, prevHash,
251:                            hash);
252:                    assertEquals("Name is from img:\n" + file, img3.getName(),
253:                            threeParts[4]);
254:                    assertEquals("Full name is img:\n" + file, img3.toURL()
255:                            .toExternalForm(), threeParts[5]);
256:                }
257:
258:            }
259:
260:            public void testPrintExtra() throws Exception {
261:                java.io.File img = PublicPackagesInProjectizedXMLTest
262:                        .extractResource("data/instanceBroken.gif");
263:                java.io.File img2 = PublicPackagesInProjectizedXMLTest
264:                        .extractResource("data/instanceObject.gif");
265:                java.io.File img3 = PublicPackagesInProjectizedXMLTest
266:                        .extractResource("data/instanceBroken.gif");
267:                java.io.File out = PublicPackagesInProjectizedXMLTest
268:                        .extractString("");
269:                out.delete();
270:
271:                java.io.File f = PublicPackagesInProjectizedXMLTest
272:                        .extractString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
273:                                + "<project name=\"Test Arch\" basedir=\".\" default=\"all\" >"
274:                                + "  <taskdef name=\"printicon\" classname=\"org.netbeans.nbbuild.PrintIcon\" classpath=\"${nb_all}/nbbuild/nbantext.jar\"/>"
275:                                + "<target name=\"all\" >"
276:                                + "  <printicon difference='"
277:                                + out
278:                                + "'>"
279:                                + "    <firstpool dir='"
280:                                + img.getParent()
281:                                + "'>"
282:                                + "       <include name='"
283:                                + img.getName()
284:                                + "'/>"
285:                                + "       <include name='"
286:                                + img2.getName()
287:                                + "'/>"
288:                                + "    </firstpool>"
289:                                + "    <secondpool dir='"
290:                                + img3.getParent()
291:                                + "'>"
292:                                + "       <include name='"
293:                                + img3.getName()
294:                                + "'/>"
295:                                + "    </secondpool>"
296:                                + "  </printicon>" + "</target>" + "</project>");
297:                PublicPackagesInProjectizedXMLTest.execute(f,
298:                        new String[] { "-verbose" });
299:
300:                assertTrue("Exists: " + out, out.canRead());
301:
302:                String file = PublicPackagesInProjectizedXMLTest.readFile(out);
303:
304:                if (!file.startsWith("-")) {
305:                    fail("Should start with - as one icon is missing in new version:\n"
306:                            + file);
307:                } else {
308:                    file = file.substring(1);
309:                }
310:
311:                String[] threeParts = file.split("( |\n)+");
312:                assertEquals(file, 3, threeParts.length);
313:
314:                long hash = Long.parseLong(threeParts[0], 16);
315:                assertEquals("Hash code is 10ba4f25:\n" + file, 0x10ba4f25L,
316:                        hash);
317:                assertEquals("Name is from img2:\n" + file, img2.getName(),
318:                        threeParts[1]);
319:                assertEquals("Full name is img2:\n" + file, img2.toURL()
320:                        .toExternalForm(), threeParts[2]);
321:            }
322:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.