Solved

testing delete request

Posted on 2006-06-20
11
326 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
 
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 30

Assisted Solution

by:mayankeagle
mayankeagle 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now