Solved

testing delete request

Posted on 2006-06-20
11
328 Views
Last Modified: 2012-05-05
In my HttpServlet I have overriden the method doDelete(HttpServletRequest, HttpServletResponse). I need to write unit tests for that code. I am using HttpUnit for testing the get and post request. However, I couldn't find anything in httpunit regarding testing delete requests. Any one knows how it should be done?

If not, is there any other unit testing package that can handle delete requests in addition to get and post?
0
Comment
Question by:salmasri
  • 3
  • 2
  • 2
  • +2
11 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 16946338
What is a 'delete request'?
0
 

Author Comment

by:salmasri
ID: 16947237
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16947256
Oh i see - as in the opposite of PUT. That and DELETE are uncommonly implemented or supported
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 5

Accepted Solution

by:
tbboyett earned 125 total points
ID: 16947577
I'm not real familiar with it but you could check and see if junit would help
http://junit.sourceforge.net/README.html

and a link that covers how to use it:
http://today.java.net/pub/a/today/2003/08/06/multithreadedTests.html

Hope this helps
0
 
LVL 30

Assisted Solution

by:Mayank S
Mayank S earned 125 total points
ID: 16948780
>> That and DELETE are uncommonly implemented or supported

Yes the default implementation reports an HTTP BAD_REQUEST error. That's because in most of the cases you would not want to remove something from the server if one client requests for it (other clients might need it).
0
 
LVL 92

Assisted Solution

by:objects
objects earned 125 total points
ID: 16948821
> In my HttpServlet I have overriden the method doDelete(HttpServletRequest, HttpServletResponse).

Unless you have a specific reason to do this then you shouldn't.

> If not, is there any other unit testing package that can handle delete requests in addition to get and post?

You could test the servlet in isolation. ie. not through the container.
0
 

Author Comment

by:salmasri
ID: 16950324
>> In my HttpServlet I have overriden the method doDelete(HttpServletRequest, HttpServletResponse).

>Unless you have a specific reason to do this then you shouldn't.

Why not? I need to serve a delete request. If I didn't do it this way then I will just have to create a seperate "DeleteServlet" and in its doPost() I would do the deletion. But I think it would be cleaner to just override doDelete(), no?
0
 
LVL 92

Expert Comment

by:objects
ID: 16950350
> I need to serve a delete request.

What do you mean by a delete request?
The DELETE method requests that the origin server delete the resource identified by the Request-URI. If this is what you want then it is a "specific reason", if it is a more general delete request then a seperate interface may be more appropriate.
0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 125 total points
ID: 16950352
>>Why not? I need to serve a delete request.

If you implement DELETE you also should implement PUT. DELETE will remove the named resource and PUT will create it
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question