Java Doc for TestData.java in  » GIS » GeoTools-2.4.1 » org » geotools » test » 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.test 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.geotools.test.TestData

All known Subclasses:   org.geotools.TestData,
TestData
public class TestData implements Runnable(Code)
Provides access to test-data directories associated with JUnit tests.

We have chosen " test-data " to follow the javadoc " doc-files " convention of ensuring that data directories don't look anything like normal java packages.

Example:

 class MyClass {
 public void example() {
 Image testImage = new ImageIcon(TestData.url(this, "test.png")).getImage();
 Reader reader = TestData.openReader(this, "script.xml");
 // ... do some process
 reader.close();
 }
 }
 
Where the directory structure goes as bellow:
  • MyClass.java
  • test-data/test.png
  • test-data/script.xml

By convention you should try and locate test-data near the JUnit test cases that uses it. If you need an access to shared test data, import the org.geotools.TestData class from the sample-module instead of this one.
since:
   2.4
version:
   $Id: TestData.java 27862 2007-11-12 19:51:19Z desruisseaux $
author:
   James McGill
author:
   Simone Giannecchiin
author:
   Martin Desruisseaux



Field Summary
final public static  StringEXTENSIVE_TEST_KEY
     The key for more extensive test suite.
final public static  StringINTERACTIVE_TEST_KEY
     The key for interactive tests.

Constructor Summary
protected  TestData()
     Do not allow instantiation of this class, except for extending it.

Method Summary
protected static  voiddeleteOnExit(File file)
     Requests that the file or directory denoted by the specified pathname be deleted when the virtual machine terminates.
protected static  voiddeleteOnExit(File file, boolean force)
     Requests that the file or directory denoted by the specified pathname be deleted when the virtual machine terminates.
public static  Filefile(Object caller, String path)
     Access to (caller, path) as a non-null File .
public static  BufferedReadergetReader(Object caller, String name)
     Provides a java.io.BufferedReader for named test data. It is the caller responsability to close this reader after usage.
Parameters:
  caller - The class of the object associated with named data.
Parameters:
  name - of test data to load.
public static  URLgetResource(Object caller, String name)
     Locates named test-data resource for caller.
public static  booleanisBaseJavaPlatform()
     Returns true if the running Java virtual machine is 1.4.
public static  booleanisExtensiveTest()
     Returns true if system property is set to true .
public static  booleanisInteractiveTest()
     Returns true if system property is set to true .
public static  booleanisMediaLibAvailable()
     Returns true if JAI MediaLib acceleration is available.
public static  ReadableByteChannelopenChannel(Object caller, String name)
     Provides a channel for named test data.
public static  LineNumberReaderopenReader(Object caller, String name)
     Provides a BufferedReader for named test data.
public static  InputStreamopenStream(Object caller, String name)
     Provides a non-null InputStream for named test data. It is the caller responsability to close this stream after usage.
Parameters:
  caller - Calling class or object used to locate test-data .
Parameters:
  name - of test data to load.
public  voidrun()
     Deletes all temporary files.
public static  Filetemp(Object caller, String name)
     Creates a temporary file with the given name.
public static  voidunzipFile(Object caller, String name)
     Unzip a file in the test-data directory.
public static  URLurl(Object caller, String path)
     Access to (caller, path) as a non-null URL .

Field Detail
EXTENSIVE_TEST_KEY
final public static String EXTENSIVE_TEST_KEY(Code)
The key for more extensive test suite. The value for this key is returned by the TestData.isExtensiveTest method. Some test suites will perform more extensive test coverage if this property is set to true . The value for this property is typically defined on the command line as a -D =true option at Java or Maven starting time.



INTERACTIVE_TEST_KEY
final public static String INTERACTIVE_TEST_KEY(Code)
The key for interactive tests. The value for this key is returned by the TestData.isInteractiveTest method. Some test suites will show windows with maps and other artifacts related to testing if this property is set to true . The value for this property is typically defined on the command line as a -D =true option at Java or Maven starting time.




Constructor Detail
TestData
protected TestData()(Code)
Do not allow instantiation of this class, except for extending it.




Method Detail
deleteOnExit
protected static void deleteOnExit(File file)(Code)
Requests that the file or directory denoted by the specified pathname be deleted when the virtual machine terminates.



deleteOnExit
protected static void deleteOnExit(File file, boolean force)(Code)
Requests that the file or directory denoted by the specified pathname be deleted when the virtual machine terminates. This method can optionnaly delete the file only if it has been modified, thus giving a chance for test suites to copy their resources only once.
Parameters:
  file - The file to delete.
Parameters:
  force - If true , delete the file in all cases. If false ,delete the file if and only if it has been modified. The default valueif true .
since:
   2.4



file
public static File file(Object caller, String path) throws IOException(Code)
Access to (caller, path) as a non-null File . You can access the test-data directory with:
 TestData.file(MyClass.class, null);
 

Parameters:
  caller - Calling class or object used to locate test-data .
Parameters:
  path - Path to file in test-data . The file to the test-data resource.
throws:
  FileNotFoundException - if the file is not found.
throws:
  IOException - if the resource can't be fetched for an other reason.



getReader
public static BufferedReader getReader(Object caller, String name) throws IOException(Code)
Provides a java.io.BufferedReader for named test data. It is the caller responsability to close this reader after usage.
Parameters:
  caller - The class of the object associated with named data.
Parameters:
  name - of test data to load. The reader, or null if the named test data are not found.
throws:
  IOException - if an error occurs during an input operation.TestData.openReader openReader NullPointerException openReader



getResource
public static URL getResource(Object caller, String name)(Code)
Locates named test-data resource for caller. Note: Consider using the TestData.url url (caller, name) method instead if the resource should always exists.
Parameters:
  caller - Calling class or object used to locate test-data .
Parameters:
  name - resource name in test-data directory. URL or null if the named test-data could not be found.
See Also:   TestData.url



isBaseJavaPlatform
public static boolean isBaseJavaPlatform()(Code)
Returns true if the running Java virtual machine is 1.4. This is the lowest Java version currently supported by Geotools. This version will increase in future Geotools version.

This method is used for some broken JUnit test that are know to run on JSE 1.4 but not on JSE 1.6 for example.




isExtensiveTest
public static boolean isExtensiveTest()(Code)
Returns true if system property is set to true . Test suites should check this value before to perform lengthly tests.



isInteractiveTest
public static boolean isInteractiveTest()(Code)
Returns true if system property is set to true . Test suites should check this value before showing any kind of graphical window to the user.



isMediaLibAvailable
public static boolean isMediaLibAvailable()(Code)
Returns true if JAI MediaLib acceleration is available.

This method is used to disable some checks in unit tests that fail when JAI is run in pure java mode.




openChannel
public static ReadableByteChannel openChannel(Object caller, String name) throws IOException(Code)
Provides a channel for named test data. It is the caller responsability to close this chanel after usage.
Parameters:
  caller - The class of the object associated with named data.
Parameters:
  name - of test data to load. The chanel.
throws:
  FileNotFoundException - if the resource is not found.
throws:
  IOException - if an error occurs during an input operation.
since:
   2.2



openReader
public static LineNumberReader openReader(Object caller, String name) throws IOException(Code)
Provides a BufferedReader for named test data. The buffered reader is provided as an LineNumberReader instance, which is useful for displaying line numbers where error occur. It is the caller responsability to close this reader after usage.
Parameters:
  caller - The class of the object associated with named data.
Parameters:
  name - of test data to load. The buffered reader.
throws:
  FileNotFoundException - if the resource is not found.
throws:
  IOException - if an error occurs during an input operation.
since:
   2.2



openStream
public static InputStream openStream(Object caller, String name) throws IOException(Code)
Provides a non-null InputStream for named test data. It is the caller responsability to close this stream after usage.
Parameters:
  caller - Calling class or object used to locate test-data .
Parameters:
  name - of test data to load. The input stream.
throws:
  FileNotFoundException - if the resource is not found.
throws:
  IOException - if an error occurs during an input operation.
since:
   2.2



run
public void run()(Code)
Deletes all temporary files. This method is invoked automatically at shutdown time and should not be invoked directly. It is public only as an implementation side effect.



temp
public static File temp(Object caller, String name) throws IOException(Code)
Creates a temporary file with the given name. The file will be created in the test-data directory and will be deleted on exit.
Parameters:
  caller - Calling class or object used to locate test-data .
Parameters:
  A - base name for the temporary file. The temporary file in the test-data directory.
throws:
  IOException - if the file can't be created.



unzipFile
public static void unzipFile(Object caller, String name) throws IOException(Code)
Unzip a file in the test-data directory. The zip file content is inflated in place, i.e. inflated files are written in the same test-data directory. If a file to be inflated already exists in the test-data directory, then the existing file is left untouched and the corresponding ZIP entry is silently skipped. This approach avoid the overhead of inflating the same files many time if this unzipFile method is invoked before every tests.

Inflated files will be automatically if and only if they have been modified. Callers don't need to worry about cleanup, because the files are inflated in the target/.../test-data directory, which is not versionned by SVN and is cleaned by Maven on mvn clean execution.
Parameters:
  caller - The class of the object associated with named data.
Parameters:
  name - The file name to unzip in place.
throws:
  FileNotFoundException - if the specified zip file is not found.
throws:
  IOException - if an error occurs during an input or output operation.
since:
   2.2




url
public static URL url(Object caller, String path) throws FileNotFoundException(Code)
Access to (caller, path) as a non-null URL . At the difference of getResource , this method throws an exception if the resource is not found. This provides a more explicit explanation about the failure reason than the infamous NullPointerException .
Parameters:
  caller - Calling class or object used to locate test-data .
Parameters:
  path - Path to file in test-data . The URL to the test-data resource.
throws:
  FileNotFoundException - if the resource is not found.
since:
   2.2



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.