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.io;
012:
013: import java.util.Calendar;
014:
015: import junit.framework.Test;
016: import junit.framework.TestCase;
017: import junit.framework.TestSuite;
018:
019: /**
020: * File <code>VPFDateTest.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.VPFDateTest
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/io/VPFDateTest.java $
064: */
065: public class VPFDateTest extends TestCase {
066: /**
067: * Instance of tested class.
068: */
069: protected VPFDate varVPFDate;
070:
071: /**
072: * Public constructor for creating testing class.
073: */
074: public VPFDateTest(String name) {
075: super (name);
076: } // end of VPFDateTest(String name)
077:
078: /**
079: * This main method is used for run tests for this class only
080: * from command line.
081: */
082: public static void main(String[] args) {
083: junit.textui.TestRunner.run(suite());
084: } // end of main(Stringp[] args)
085:
086: protected String date = "20030129161055.00000";
087:
088: /**
089: * This method is called every time before particular test execution.
090: * It creates new instance of tested class and it can perform some more
091: * actions which are necessary for performs tests.
092: */
093: protected void setUp() {
094: byte[] bytes = new byte[date.length()];
095: for (int i = 0; i < bytes.length; i++) {
096: bytes[i] = (byte) date.charAt(i);
097: } // end of for (int i = 0; i < bytes.length; i++)
098: varVPFDate = new VPFDate(bytes);
099: }
100:
101: /**
102: * Returns all tests which should be performed for testing class.
103: * By default it returns only name of testing class. Instance of this
104: * is then created with its constructor.
105: */
106: public static Test suite() {
107: return new TestSuite(VPFDateTest.class);
108: } // end of suite()
109:
110: /**
111: * Method for testing original source method:
112: * java.util.Date getDate()
113: * from tested class
114: */
115: public void testGetDate() {
116: assertNotNull(
117: "Check if it is possible to parse date, corretness is "
118: + "checked in getCalendar method", varVPFDate
119: .getDate());
120: } // end of testGetDate()
121:
122: public void testGetCalendar() {
123: Calendar cal = varVPFDate.getCalendar();
124: assertEquals("Checking year", 2003, cal.get(Calendar.YEAR));
125: assertEquals("Checking month (Calendar numvers months from 0)",
126: 1, cal.get(Calendar.MONTH) + 1);
127: assertEquals("Checking day of month", 29, cal
128: .get(Calendar.DAY_OF_MONTH));
129: assertEquals("Checking hour", 16, cal.get(Calendar.HOUR_OF_DAY));
130: assertEquals("Checking minute", 10, cal.get(Calendar.MINUTE));
131: assertEquals("Checking second", 55, cal.get(Calendar.SECOND));
132: assertEquals("Checking zone", 0, cal.get(Calendar.ZONE_OFFSET));
133: }
134:
135: /**
136: * Method for testing original source method:
137: * java.lang.String toString()
138: * from tested class
139: */
140: public void testToString() {
141: assertEquals("Conversion to string", varVPFDate.toString(),
142: date);
143: } // end of testToString()
144:
145: } // end of VPFDateTest
|