Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

testing delete request

Posted on 2006-06-20
11
Medium Priority
?
333 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
 
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
The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

 
LVL 5

Accepted Solution

by:
tbboyett earned 500 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 500 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 500 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 500 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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
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:
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

670 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