Source Code Cross Referenced for ResolutionSyntaxTest.java in  » Apache-Harmony-Java-SE » javax-package » javax » print » attribute » 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 » Apache Harmony Java SE » javax package » javax.print.attribute 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:        /** 
018:         * @author Elena V. Sayapina 
019:         * @version $Revision: 1.3 $ 
020:         */package javax.print.attribute;
021:
022:        import junit.framework.TestCase;
023:
024:        public class ResolutionSyntaxTest extends TestCase {
025:
026:            static {
027:                System.out.println("ResolutionSyntax testing...");
028:            }
029:
030:            public static void main(String[] args) {
031:                junit.textui.TestRunner.run(ResolutionSyntaxTest.class);
032:            }
033:
034:            resolutionSyntax rs1, rs2;
035:
036:            /*
037:             * ResolutionSyntax(int crossFeedResolution, int feedResolution, 
038:             * int units) constructor testing. 
039:             */
040:            public final void testResolutionSyntax() {
041:                try {
042:                    rs1 = new resolutionSyntax(1, 1, 0);
043:                    fail("ResolutionSyntax(int crossFeedResolution, "
044:                            + "int feedResolution, int units) doesn't throw "
045:                            + "IllegalArgumentException if units < 1");
046:                } catch (IllegalArgumentException e) {
047:                }
048:
049:                try {
050:                    rs1 = new resolutionSyntax(-1, 1, 1);
051:                    fail("ResolutionSyntax(int crossFeedResolution, "
052:                            + "int feedResolution, int units) doesn't throw "
053:                            + "IllegalArgumentException if "
054:                            + "crossFeedResolution < 1");
055:                } catch (IllegalArgumentException e) {
056:                }
057:                try {
058:                    rs1 = new resolutionSyntax(1, 0, 10);
059:                    fail("ResolutionSyntax(int crossFeedResolution, "
060:                            + "int feedResolution, int units) doesn't throw "
061:                            + "IllegalArgumentException if "
062:                            + "or feedResolution < 1");
063:                } catch (IllegalArgumentException e) {
064:                }
065:
066:                rs1 = new resolutionSyntax(10001, 1507, resolutionSyntax.DPI);
067:                assertEquals(10001, rs1
068:                        .getCrossFeedResolution(resolutionSyntax.DPI));
069:                assertEquals(1507, rs1.getFeedResolution(resolutionSyntax.DPI));
070:            }
071:
072:            /*
073:             * hashCode() method testing. Tests if two object aren't equal they should
074:             * have different hash codes.
075:             */
076:            public final void testHashCode() {
077:                rs1 = new resolutionSyntax(4444, 333, resolutionSyntax.DPCM);
078:                rs2 = new resolutionSyntax(333, 444, resolutionSyntax.DPCM);
079:                assertTrue(rs1.hashCode() != rs2.hashCode());
080:            }
081:
082:            /*
083:             * hashCode() method testing. Tests if two object are equal they must have
084:             * the same hash code.
085:             */
086:            public final void testHashCode1() {
087:                rs1 = new resolutionSyntax(1, 1, resolutionSyntax.DPCM);
088:                rs2 = new resolutionSyntax(1, 1, resolutionSyntax.DPCM);
089:                assertTrue(rs1.hashCode() == rs2.hashCode());
090:            }
091:
092:            /*
093:             * equals(Object object) method testing. Tests if two object are equal 
094:             * they must have the same hash code.
095:             */
096:            public final void testEqualsObject() {
097:                rs1 = new resolutionSyntax(1, 1, resolutionSyntax.DPCM);
098:                rs2 = new resolutionSyntax(1, 1, resolutionSyntax.DPCM);
099:                assertTrue(rs1.equals(rs2));
100:
101:                rs1 = new resolutionSyntax(1, 1, resolutionSyntax.DPCM);
102:                rs2 = new resolutionSyntax(1, 1, resolutionSyntax.DPI);
103:                assertFalse(rs1.equals(rs2));
104:
105:                rs1 = new resolutionSyntax(1000, 2000, resolutionSyntax.DPCM);
106:                rs2 = new resolutionSyntax(1000, 2000, resolutionSyntax.DPCM);
107:                assertTrue(rs1.equals(rs2));
108:
109:                rs1 = new resolutionSyntax(1000, 2000, resolutionSyntax.DPI);
110:                rs2 = new resolutionSyntax(1000, 2000 - 1,
111:                        resolutionSyntax.DPCM);
112:                assertFalse(rs1.equals(rs2));
113:
114:                rs2 = null;
115:                assertFalse("equals(object o) returns true if o is null", rs1
116:                        .equals(rs2));
117:            }
118:
119:            public final void testGetCrossFeedResolution() {
120:                rs1 = new resolutionSyntax(1000, 2000, 1);
121:                assertEquals(1000, rs1.getCrossFeedResolution(1));
122:                try {
123:                    rs1.getCrossFeedResolution(0);
124:                    fail("getCrossFeedResolution(int units) doesn't throw "
125:                            + "IllegalArgumentException if units < 1");
126:                } catch (IllegalArgumentException e) {
127:                }
128:            }
129:
130:            public final void testGetCrossFeedResolutionDphi() {
131:                rs1 = new resolutionSyntax(1000, 2000, 3);
132:                assertEquals(3000, rs1.getCrossFeedResolutionDphiEx());
133:                rs1 = new resolutionSyntax(1000, 2000, 1);
134:                assertEquals("bad rounding", 333, rs1.getCrossFeedResolution(3));
135:            }
136:
137:            public final void testGetFeedResolution() {
138:                rs1 = new resolutionSyntax(1000, 2000, 1);
139:                assertEquals(2000, rs1.getFeedResolution(1));
140:                try {
141:                    rs1.getFeedResolution(-100);
142:                    fail("getFeedResolution(int units) doesn't throw "
143:                            + "IllegalArgumentException if units < 1");
144:                } catch (IllegalArgumentException e) {
145:                }
146:            }
147:
148:            public final void testGetFeedResolutionDphi() {
149:                rs1 = new resolutionSyntax(1000, 2000, 3);
150:                assertEquals(6000, rs1.getFeedResolutionDphiEx());
151:                rs1 = new resolutionSyntax(1000, 500, 1);
152:                assertEquals("bad rounding", 63, rs1.getFeedResolution(8));
153:            }
154:
155:            public final void testGetResolution() {
156:                rs1 = new resolutionSyntax(1000, 2000, resolutionSyntax.DPCM);
157:                assertEquals(1000, rs1.getResolution(resolutionSyntax.DPCM)[0]);
158:                assertEquals(2000, rs1.getResolution(resolutionSyntax.DPCM)[1]);
159:                try {
160:                    rs1.getResolution(0);
161:                    fail("getResolution(int units) doesn't throw "
162:                            + "IllegalArgumentException if units < 1");
163:                } catch (IllegalArgumentException e) {
164:                }
165:            }
166:
167:            public final void testLessThanOrEquals() {
168:                rs1 = new resolutionSyntax(1000, 1000, 1);
169:                rs2 = new resolutionSyntax(999, 1000, 1);
170:                assertTrue(rs2.lessThanOrEquals(rs1));
171:
172:                rs1 = new resolutionSyntax(1, 1, resolutionSyntax.DPCM);
173:                rs2 = new resolutionSyntax(1, 2, resolutionSyntax.DPCM);
174:                assertFalse(rs2.lessThanOrEquals(rs1));
175:
176:                try {
177:                    rs2 = null;
178:                    rs1.lessThanOrEquals(rs2);
179:                    fail("lessThanOrEquals(ResolutionSyntax other) "
180:                            + "doesn't throw NullPointerException "
181:                            + "if other is null");
182:                } catch (NullPointerException e) {
183:                }
184:            }
185:
186:            public final void testToString() {
187:                rs1 = new resolutionSyntax(500, 50, 10);
188:                assertEquals("5000x500 dphi", rs1.toString());
189:                //System.out.println(rs1.toString());
190:            }
191:
192:            public final void testToStringintString() {
193:                rs1 = new resolutionSyntax(1024, 1034, 254);
194:                assertEquals("1024x1034 dpcm", rs1.toString(254, "dpcm"));
195:                //System.out.println(rs1.toString(254, "dpcm"));
196:            }
197:
198:            /*
199:             * Auxiliary class
200:             */
201:            public class resolutionSyntax extends ResolutionSyntax {
202:
203:                public resolutionSyntax(int a, int b, int c) {
204:                    super (a, b, c);
205:                }
206:
207:                public int getCrossFeedResolutionDphiEx() {
208:                    return getCrossFeedResolutionDphi();
209:                }
210:
211:                public int getFeedResolutionDphiEx() {
212:                    return getFeedResolutionDphi();
213:                }
214:            }
215:
216:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.