Source Code Cross Referenced for DescriptorUtilTest.java in  » 6.0-JDK-Modules » Java-Advanced-Imaging » ca » forklabs » media » jai » Java Source Code / Java DocumentationJava Source Code and Java Documentation

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


001:        /*
002:         * @(#) $Header: /cvs/jai-operators/src/tests/ca/forklabs/media/jai/DescriptorUtilTest.java,v 1.2 2007/06/11 22:00:53 forklabs Exp $
003:         *
004:         * Copyright (C) 2007  Forklabs Daniel Léonard
005:         *
006:         * This program is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU General Public License
008:         * as published by the Free Software Foundation; either version 2
009:         * of the License, or (at your option) any later version.
010:         *
011:         * This program is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:         * GNU General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * along with this program; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
019:         */
020:
021:        package ca.forklabs.media.jai;
022:
023:        import java.awt.image.renderable.ParameterBlock;
024:        import java.util.Arrays;
025:        import java.util.Collection;
026:        import java.util.Iterator;
027:        import java.util.LinkedList;
028:        import javax.media.jai.registry.CollectionRegistryMode;
029:        import javax.media.jai.registry.RenderableCollectionRegistryMode;
030:        import javax.media.jai.registry.RenderableRegistryMode;
031:        import javax.media.jai.registry.RenderedRegistryMode;
032:        import junit.framework.TestCase;
033:        import ca.forklabs.media.jai.mock.MockRenderableImage;
034:        import ca.forklabs.media.jai.mock.MockRenderedImage;
035:
036:        /**
037:         * Class {@code DescriptorUtilTest} tests class {@link DescriptorUtil}.
038:         *
039:         * @author   <a href="mailto:forklabs at dev.java.net?subject=ca.forklabs.media.jai.DescriptorUtilTest">Daniel Léonard</a>
040:         * @version $Revision: 1.2 $
041:         */
042:        @SuppressWarnings("nls")
043:        public class DescriptorUtilTest extends TestCase {
044:
045:            //---------------------------
046:            // Constructors
047:            //---------------------------
048:
049:            /**
050:             * Constructor.
051:             * @param   name   the name of this test.
052:             */
053:            public DescriptorUtilTest(String name) {
054:                super (name);
055:            }
056:
057:            //---------------------------
058:            // Test methods
059:            //---------------------------
060:
061:            /**
062:             * Tests {@link DescriptorUtil#isRenderedMode(String)}.
063:             */
064:            public void testIsRenderedMode() {
065:                assertTrue(DescriptorUtil.isRenderedMode("rendered"));
066:                assertTrue(DescriptorUtil.isRenderedMode("ReNdErEd"));
067:                assertTrue(DescriptorUtil
068:                        .isRenderedMode(RenderedRegistryMode.MODE_NAME));
069:                assertFalse(DescriptorUtil.isRenderedMode("foo"));
070:            }
071:
072:            /**
073:             * Tests {@link DescriptorUtil#isRenderableMode(String)}.
074:             */
075:            public void testIsRenderableMode() {
076:                assertTrue(DescriptorUtil.isRenderableMode("renderable"));
077:                assertTrue(DescriptorUtil.isRenderableMode("rEnDeRaBlE"));
078:                assertTrue(DescriptorUtil
079:                        .isRenderableMode(RenderableRegistryMode.MODE_NAME));
080:                assertFalse(DescriptorUtil.isRenderableMode("foo"));
081:            }
082:
083:            /**
084:             * Tests {@link DescriptorUtil#isCollectionMode(String)}.
085:             */
086:            public void testIsCollectionMode() {
087:                assertTrue(DescriptorUtil.isCollectionMode("collection"));
088:                assertTrue(DescriptorUtil.isCollectionMode("CoLLectioN"));
089:                assertTrue(DescriptorUtil
090:                        .isCollectionMode(CollectionRegistryMode.MODE_NAME));
091:                assertFalse(DescriptorUtil.isCollectionMode("foo"));
092:            }
093:
094:            /**
095:             * Tests {@link DescriptorUtil#isRenderableCollectionMode(String)}.
096:             */
097:            public void testIsRenderableCollectionMode() {
098:                assertTrue(DescriptorUtil
099:                        .isRenderableCollectionMode("renderableCollection"));
100:                assertTrue(DescriptorUtil
101:                        .isRenderableCollectionMode("ReNdErAbLeCoLlEcTiOn"));
102:                assertTrue(DescriptorUtil
103:                        .isRenderableCollectionMode(RenderableCollectionRegistryMode.MODE_NAME));
104:                assertFalse(DescriptorUtil.isRenderableCollectionMode("foo"));
105:            }
106:
107:            /**
108:             * Tests {@link DescriptorUtil#isSourceRendered(Object)}.
109:             */
110:            public void testIsSourceRendered() {
111:                assertTrue(DescriptorUtil
112:                        .isSourceRendered(new MockRenderedImage()));
113:                assertFalse(DescriptorUtil.isSourceRendered("foo"));
114:            }
115:
116:            /**
117:             * Tests {@link DescriptorUtil#isSourceRenderable(Object)}.
118:             */
119:            public void testIsSourceRenderable() {
120:                assertTrue(DescriptorUtil
121:                        .isSourceRenderable(new MockRenderableImage()));
122:                assertFalse(DescriptorUtil.isSourceRenderable("foo"));
123:            }
124:
125:            /**
126:             * Tests {@link DescriptorUtil#isSourceCollection(Object)}.
127:             */
128:            public void testIsSourceCollection() {
129:                assertTrue(DescriptorUtil.isSourceCollection(Arrays.asList()));
130:                assertFalse(DescriptorUtil.isSourceCollection("foo"));
131:            }
132:
133:            /**
134:             * Tests {@link DescriptorUtil#areAllSourceRendered(Iterable)}.
135:             */
136:            @SuppressWarnings("unchecked")
137:            public void testAreAllSourceRendered() {
138:                Collection sources = new LinkedList();
139:                sources.add(new MockRenderedImage());
140:                sources.add(new MockRenderedImage());
141:
142:                assertTrue(DescriptorUtil.areAllSourceRendered(sources));
143:
144:                sources.add(new MockRenderableImage());
145:
146:                assertFalse(DescriptorUtil.areAllSourceRendered(sources));
147:            }
148:
149:            /**
150:             * Tests {@link DescriptorUtil#areAllSourceRenderable(Iterable)}.
151:             */
152:            @SuppressWarnings("unchecked")
153:            public void testAreAllSourceRenderable() {
154:                Collection sources = new LinkedList();
155:                sources.add(new MockRenderableImage());
156:                sources.add(new MockRenderableImage());
157:
158:                assertTrue(DescriptorUtil.areAllSourceRenderable(sources));
159:
160:                sources.add(new MockRenderedImage());
161:
162:                assertFalse(DescriptorUtil.areAllSourceRenderable(sources));
163:            }
164:
165:            /**
166:             * Tests {@link DescriptorUtil#collateSources(ParameterBlock)}.
167:             */
168:            @SuppressWarnings("unchecked")
169:            public void testCollateSources() {
170:                Object o1 = new Object();
171:                Object o2 = new Object();
172:                Object o3 = new Object();
173:                Object o4 = new Object();
174:                Object o5 = new Object();
175:                Object o6 = new Object();
176:                Object o7 = new Object();
177:
178:                ParameterBlock pb = new ParameterBlock().addSource(o1)
179:                        .addSource(Arrays.asList(o2, o3)).addSource(o4)
180:                        .addSource(o5).addSource(new Object[] { o6, o7, });
181:
182:                DescriptorUtil.collateSources(pb);
183:
184:                assertEquals(1, pb.getNumSources());
185:
186:                Collection sources = (Collection) pb.getSource(0);
187:
188:                assertEquals(7, sources.size());
189:
190:                Iterator iterator = sources.iterator();
191:
192:                assertSame(o1, iterator.next());
193:                assertSame(o2, iterator.next());
194:                assertSame(o3, iterator.next());
195:                assertSame(o4, iterator.next());
196:                assertSame(o5, iterator.next());
197:                assertSame(o6, iterator.next());
198:                assertSame(o7, iterator.next());
199:            }
200:
201:            //---------------------------
202:            // Class methods
203:            //---------------------------
204:
205:            /**
206:             * Runs only this test.
207:             * @param   args   ignored.
208:             */
209:            public static void main(String... args) {
210:                junit.swingui.TestRunner.run(DescriptorUtilTest.class);
211:            }
212:
213:        }
214:
215:        /*
216:         * $Log: DescriptorUtilTest.java,v $
217:         * Revision 1.2  2007/06/11 22:00:53  forklabs
218:         * Source collation now takes array and treats them as collection.
219:         *
220:         * Revision 1.1  2007/06/07 21:44:31  forklabs
221:         * Utilities for help descriptor validation.
222:         *
223:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.