Source Code Cross Referenced for DataUtilsTest.java in  » GIS » GeoTools-2.4.1 » org » geotools » data » vpf » util » 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 » GIS » GeoTools 2.4.1 » org.geotools.data.vpf.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * File is generated by 'Unit Tests Generator' developed under
003:         * 'Web Test Tools' project at http://sf.net/projects/wttools/
004:         * Copyright (C) 2001 "Artur Hefczyc" <kobit@users.sourceforge.net>
005:         * to all 'Web Test Tools' subprojects.
006:         *
007:         * No rigths to files and no responsibility for code generated
008:         * by this tool are belonged to author of 'unittestsgen' utility.
009:         *
010:         */
011:        package org.geotools.data.vpf.util;
012:
013:        import junit.framework.Test;
014:        import junit.framework.TestCase;
015:        import junit.framework.TestSuite;
016:
017:        import org.geotools.data.vpf.ifc.DataTypesDefinition;
018:
019:        /**
020:         * File <code>DataUtilsTest.java</code> is automaticaly generated by
021:         * 'unittestsgen' application. Code generator is created for java
022:         * sources and for 'junit' package by "Artur Hefczyc"
023:         * <kobit@users.sourceforge.net><br/>
024:         * You should fulfil test methods with proper code for testing
025:         * purpose. All methods where you should put your code are below and
026:         * their names starts with 'test'.<br/>
027:         * You can run unit tests in many ways, however prefered are:
028:         * <ul>
029:         *   <li>Run tests for one class only, for example for this class you
030:         *       can run tests with command:
031:         *     <pre>
032:         *       java -cp "jar/thisjarfile.jar;lib/junit.jar" org.geotools.vpf.util.DataUtilsTest
033:         *     </pre>
034:         *   </li>
035:         *   <li>Run tests for all classes in one command call. Code generator
036:         *       creates also <code>TestAll.class</code> which runs all
037:         *       available tests:
038:         *     <pre>
039:         *       java -cp "jar/thisjarfile.jar;lib/junit.jar" TestAll
040:         *     </pre>
041:         *   </li>
042:         *   <li>But the most prefered way is to run all tests from
043:         *     <em>Ant</em> just after compilation process finished.<br/>
044:         *     To do it. You need:
045:         *     <ol>
046:         *       <li>Ant package from
047:         *         <a href="http://jakarta.apache.org/">Ant</a>
048:         *       </li>
049:         *       <li>JUnit package from
050:         *         <a href="http://www.junit.org/">JUnit</a>
051:         *       </li>
052:         *       <li>Put some code in your <code>build.xml</code> file
053:         *         to tell Ant how to test your package. Sample code for
054:         *         Ant's <code>build.xml</code> you can find in created file:
055:         *         <code>sample-junit-build.xml</code>. And remember to have
056:         *         <code>junit.jar</code> in CLASSPATH <b>before</b> you run Ant.
057:         *         To generate reports by ant you must have <code>xalan.jar</code>
058:         *         in your <code>ANT_HOME/lib/</code> directory.
059:         *       </li>
060:         *     </ol>
061:         *   </li>
062:         * </ul>
063:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/unsupported/vpf/src/test/java/org/geotools/data/vpf/util/DataUtilsTest.java $
064:         */
065:        public class DataUtilsTest extends TestCase implements 
066:                DataTypesDefinition {
067:            /**
068:             * Instance of tested class.
069:             */
070:            protected DataUtils varDataUtils;
071:
072:            /**
073:             * Public constructor for creating testing class.
074:             */
075:            public DataUtilsTest(String name) {
076:                super (name);
077:            } // end of DataUtilsTest(String name)
078:
079:            /**
080:             * This main method is used for run tests for this class only
081:             * from command line.
082:             */
083:            public static void main(String[] args) {
084:                junit.textui.TestRunner.run(suite());
085:            } // end of main(Stringp[] args)
086:
087:            /**
088:             * This method is called every time before particular test execution.
089:             * It creates new instance of tested class and it can perform some more
090:             * actions which are necessary for performs tests.
091:             */
092:            protected void setUp() {
093:                varDataUtils = new org.geotools.data.vpf.util.DataUtils();
094:            } // end of setUp()
095:
096:            /**
097:             * Returns all tests which should be performed for testing class.
098:             * By default it returns only name of testing class. Instance of this
099:             * is then created with its constructor.
100:             */
101:            public static Test suite() {
102:                return new TestSuite(DataUtilsTest.class);
103:            } // end of suite()
104:
105:            public static final byte[][] TEST_SAMPLES = { { 0, 0, 0, 1 },
106:                    { 1, 0, 0, 0 }, { 0, 0, 0, (byte) 0xFF },
107:                    { (byte) 0xFF, 0, 0, 0 },
108:                    { 0, 0, (byte) 0x0F, (byte) 0xF0 },
109:                    { (byte) 0xF0, (byte) 0x0F, 0, 0 } };
110:
111:            public static final int[][] TEST_RESULTS = {
112:                    //      Expected results
113:                    //  BigEndian     LittleEndian
114:                    { 1, 16777216 }, { 16777216, 1 }, { 255, -16777216 },
115:                    { -16777216, 255 }, { 4080, -267452416 },
116:                    { -267452416, 4080 } };
117:
118:            /**
119:             * Method for testing original source method:
120:             * int littleEndianToInt(byte[])
121:             * from tested class
122:             */
123:            //   public void testLittleEndianToInt1374008726()
124:            //   {
125:            // 	for (int i = 0; i < TEST_SAMPLES.length; i++)
126:            // 	{
127:            // 	  assertEquals("Testing little endian converions from bytes to java int",
128:            // 				   TEST_RESULTS[i][1],
129:            // 				   DataUtils.littleEndianToInt(TEST_SAMPLES[i]));
130:            // 	} // end of for (int i = 0; i < TEST_SAMPLES.length; i++)
131:            //   } // end of testLittleEndianToInt1374008726(byte[])
132:            /**
133:             * Method for testing original source method:
134:             * byte[] toBigEndian(byte[])
135:             * from tested class
136:             */
137:            public void testToBigEndian1374008726() {
138:                byte[] testData = DataUtils.toBigEndian(TEST_SAMPLES[0]);
139:                for (int i = 0; i < testData.length; i++) {
140:                    assertEquals(
141:                            "Checking translation little endian bytes order to bin "
142:                                    + "endian bytes order", testData[i],
143:                            TEST_SAMPLES[1][i]);
144:                } // end of for (int i = 0; i < testData.length; i++)
145:                testData = DataUtils.toBigEndian(TEST_SAMPLES[1]);
146:                for (int i = 0; i < testData.length; i++) {
147:                    assertEquals(
148:                            "Checking translation little endian bytes order to bin "
149:                                    + "endian bytes order", testData[i],
150:                            TEST_SAMPLES[0][i]);
151:                } // end of for (int i = 0; i < testData.length; i++)	
152:                testData = DataUtils.toBigEndian(TEST_SAMPLES[2]);
153:                for (int i = 0; i < testData.length; i++) {
154:                    assertEquals(
155:                            "Checking translation little endian bytes order to bin "
156:                                    + "endian bytes order", testData[i],
157:                            TEST_SAMPLES[3][i]);
158:                } // end of for (int i = 0; i < testData.length; i++)	
159:                testData = DataUtils.toBigEndian(TEST_SAMPLES[3]);
160:                for (int i = 0; i < testData.length; i++) {
161:                    assertEquals(
162:                            "Checking translation little endian bytes order to bin "
163:                                    + "endian bytes order", testData[i],
164:                            TEST_SAMPLES[2][i]);
165:                } // end of for (int i = 0; i < testData.length; i++)	
166:                testData = DataUtils.toBigEndian(TEST_SAMPLES[4]);
167:                for (int i = 0; i < testData.length; i++) {
168:                    assertEquals(
169:                            "Checking translation little endian bytes order to bin "
170:                                    + "endian bytes order", testData[i],
171:                            TEST_SAMPLES[5][i]);
172:                } // end of for (int i = 0; i < testData.length; i++)	
173:                testData = DataUtils.toBigEndian(TEST_SAMPLES[5]);
174:                for (int i = 0; i < testData.length; i++) {
175:                    assertEquals(
176:                            "Checking translation little endian bytes order to bin "
177:                                    + "endian bytes order", testData[i],
178:                            TEST_SAMPLES[4][i]);
179:                } // end of for (int i = 0; i < testData.length; i++)	
180:            } // end of testToBigEndian1374008726(byte[])
181:
182:            public static final char[] TEST_TYPES = { DATA_TEXT,
183:                    DATA_LEVEL1_TEXT, DATA_LEVEL2_TEXT, DATA_LEVEL3_TEXT,
184:                    DATA_SHORT_FLOAT, DATA_LONG_FLOAT, DATA_SHORT_INTEGER,
185:                    DATA_LONG_INTEGER,
186:                    //DATA_2_COORD_F,
187:                    //DATA_2_COORD_R,
188:                    //DATA_3_COORD_F,
189:                    //DATA_3_COORD_R,
190:                    DATA_DATE_TIME, DATA_NULL_FIELD, DATA_TRIPLET_ID, };
191:
192:            public static final Class[] RESULT_TYPES = {
193:                    java.lang.String.class, java.lang.String.class,
194:                    java.lang.String.class, java.lang.String.class,
195:                    java.lang.Float.class, java.lang.Double.class,
196:                    java.lang.Short.class, java.lang.Integer.class,
197:                    //org.geotools.data.vpf.io.Coordinate2DFloat.class,
198:                    //org.geotools.data.vpf.io.Coordinate2DDouble.class,
199:                    //org.geotools.data.vpf.io.Coordinate3DFloat.class,
200:                    //org.geotools.data.vpf.io.Coordinate3DDouble.class,
201:                    org.geotools.data.vpf.io.VPFDate.class, null, null };
202:
203:            /**
204:             * Method for testing original source method:
205:             * java.lang.Object decodeData(byte[], char)
206:             * from tested class
207:             */
208:            public void testDecodeData13740087263052374() {
209:                byte[] testData = new byte[] { 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
210:                        1, 0, 1, 0, 1 };
211:                for (int i = 0; i < TEST_TYPES.length; i++) {
212:                    Object result = DataUtils.decodeData(testData,
213:                            TEST_TYPES[i]);
214:                    if (i < TEST_TYPES.length - 2) {
215:                        assertTrue("Incorrect type "
216:                                + RESULT_TYPES[i].getName()
217:                                + " detected for data for VPF type: "
218:                                + TEST_TYPES[i], RESULT_TYPES[i]
219:                                .isInstance(result));
220:                    } // end of if (i < TEST_TYPES.length - 2)
221:                    else {
222:                        assertNull("for this type: " + RESULT_TYPES[i]
223:                                + " NULL should be returned", result);
224:                    } // end of else
225:                } // end of for (int i = 0; i < TEST_TYPES.length; i++)
226:            } // end of testDecodeData13740087263052374(byte[], char)
227:
228:            /**
229:             * Method for testing original source method:
230:             * double decodeDouble(byte[])
231:             * from tested class
232:             */
233:            public void testDecodeDouble1374008726() {
234:                assertEquals("Decoding double from bytes stream", 4.9E-324d,
235:                        DataUtils.decodeDouble(new byte[] { 0, 0, 0, 0, 0, 0,
236:                                0, 1 }), 0);
237:                assertEquals("Decoding double from bytes stream", 1.26E-321d,
238:                        DataUtils.decodeDouble(new byte[] { 0, 0, 0, 0, 0, 0,
239:                                0, (byte) 0xFF }), 0);
240:                assertEquals("Decoding double from bytes stream",
241:                        3.22526E-319d, DataUtils.decodeDouble(new byte[] { 0,
242:                                0, 0, 0, 0, 0, (byte) 0xFF, 0 }), 0);
243:                assertEquals("Decoding double from bytes stream",
244:                        8.256667E-317d, DataUtils.decodeDouble(new byte[] { 0,
245:                                0, 0, 0, 0, (byte) 0xFF, 0, 0 }), 0);
246:                assertEquals("Decoding double from bytes stream",
247:                        2.113706745E-314d, DataUtils.decodeDouble(new byte[] {
248:                                0, 0, 0, 0, (byte) 0xFF, 0, 0, 0 }), 0);
249:                assertEquals("Decoding double from bytes stream",
250:                        5.41108926696E-312d, DataUtils.decodeDouble(new byte[] {
251:                                0, 0, 0, (byte) 0xFF, 0, 0, 0, 0 }), 0);
252:                assertEquals("Decoding double from bytes stream",
253:                        1.38523885234213E-309d, DataUtils
254:                                .decodeDouble(new byte[] { 0, 0, (byte) 0xFF,
255:                                        0, 0, 0, 0, 0 }), 0);
256:                assertEquals("Decoding double from bytes stream",
257:                        7.06327445644526E-304d, DataUtils
258:                                .decodeDouble(new byte[] { 0, (byte) 0xFF, 0,
259:                                        0, 0, 0, 0, 0 }), 0);
260:                assertEquals("Decoding double from bytes stream",
261:                        -5.4861240687936887E303d, DataUtils
262:                                .decodeDouble(new byte[] { (byte) 0xFF, 0, 0,
263:                                        0, 0, 0, 0, 0 }), 0);
264:            } // end of testDecodeDouble1374008726(byte[])
265:
266:            /**
267:             * Method for testing original source method:
268:             * float decodeFloat(byte[])
269:             * from tested class
270:             */
271:            public void testDecodeFloat1374008726() {
272:                assertEquals("Decoding float from bytes stream", 1.4E-45f,
273:                        DataUtils.decodeFloat(new byte[] { 0, 0, 0, 1 }), 0);
274:                assertEquals(
275:                        "Decoding float from bytes stream",
276:                        3.57E-43f,
277:                        DataUtils
278:                                .decodeFloat(new byte[] { 0, 0, 0, (byte) 0xFF }),
279:                        0);
280:                assertEquals(
281:                        "Decoding float from bytes stream",
282:                        9.147676375112406E-41f,
283:                        DataUtils
284:                                .decodeFloat(new byte[] { 0, 0, (byte) 0xFF, 0 }),
285:                        0);
286:                assertEquals("Decoding float from bytes stream",
287:                        2.3418052E-38f, DataUtils.decodeFloat(new byte[] { 0,
288:                                (byte) 0xFF, 0, 0 }), 0);
289:                assertEquals("Decoding float from bytes stream",
290:                        -1.7014118E38f, DataUtils.decodeFloat(new byte[] {
291:                                (byte) 0xFF, 0, 0, 0 }), 0);
292:            } // end of testDecodeFloat1374008726(byte[])
293:
294:            /**
295:             * Method for testing original source method:
296:             * int decodeInt(byte[])
297:             * from tested class
298:             */
299:            public void testDecodeInt1374008726() {
300:                assertEquals("Decoding short from bytes stream", 255, DataUtils
301:                        .decodeInt(new byte[] { 0, 0, 0, (byte) 0xFF }));
302:                assertEquals("Decoding short from bytes stream", 65280,
303:                        DataUtils
304:                                .decodeInt(new byte[] { 0, 0, (byte) 0xFF, 0 }));
305:                assertEquals("Decoding short from bytes stream", 16711680,
306:                        DataUtils
307:                                .decodeInt(new byte[] { 0, (byte) 0xFF, 0, 0 }));
308:                assertEquals("Decoding short from bytes stream", -16777216,
309:                        DataUtils
310:                                .decodeInt(new byte[] { (byte) 0xFF, 0, 0, 0 }));
311:            } // end of testDecodeInt1374008726(byte[])
312:
313:            /**
314:             * Method for testing original source method:
315:             * short decodeShort(byte[])
316:             * from tested class
317:             */
318:            public void testDecodeShort1374008726() {
319:                assertEquals("Decoding short from bytes stream", 255, DataUtils
320:                        .decodeShort(new byte[] { 0, (byte) 0xFF }));
321:                assertEquals("Decoding short from bytes stream", -256,
322:                        DataUtils.decodeShort(new byte[] { (byte) 0xFF, 0 }));
323:            } // end of testDecodeShort1374008726(byte[])
324:
325:            /**
326:             * Method for testing original source method:
327:             * int unsigByteToInt(byte)
328:             * from tested class
329:             */
330:            public void testUnsigByteToInt3039496() {
331:                assertEquals("Is negative byte converted correcly:", 255,
332:                        DataUtils.unsigByteToInt((byte) 0xFF));
333:                assertEquals("Is negative byte converted correcly:", (int) 1,
334:                        DataUtils.unsigByteToInt((byte) 1));
335:            } // end of testUnsigByteToInt3039496(byte)
336:
337:        } // end of DataUtilsTest
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.