Solved

testing delete request

Posted on 2006-06-20
11
331 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jdbc error in jsp application 20 91
iterator/ListIterator approach 17 68
mysql jsp example issue 32 97
sql import cannot be resolved jsp 3 117
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…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

710 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