wood burning stoves 2.0*
The moose likes Testing and the fly likes Java.lang.ClassCastException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Java.lang.ClassCastException" Watch "Java.lang.ClassCastException" New topic
Author

Java.lang.ClassCastException

Awet Haddis
Greenhorn

Joined: Jan 25, 2011
Posts: 11
Background: I am testing a class that will allow a user to upload data. I am using the Apache Commons FileUpload library.




I believe the compiler is having a problem with this statement:



Is there a way to specify the path to a FileItem so I don't have to cast a file as a FileItem? Thanks in advance.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Awet Haddis wrote:Is there a way to specify the path to a FileItem so I don't have to cast a file as a FileItem? Thanks in advance.


Well, no you can't take just anything and cast it to a FileItem. If you want to simulate what the file upload would have produced, you're going to have to produce a mock version of FileItem and have it wrap your File, or something like that.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java.lang.ClassCastException
 
Similar Threads
jmock query
problem with upload file using common file upload servlet
Apache Commons FileUpload with Zip Files
How to redirect from servlet to JSP/Servlet with out executing the below code
JMock with singleton object