Solved

testing delete request

Posted on 2006-06-20
11
330 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
Industry Leaders: 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!

 
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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Adding multiple JVM environments to RedHat 6 7 69
Java: The Public Class Main 4 45
Is there a simpler dropbox system? 10 44
Netbeans and org.apache.commons.lang3 issue 3 25
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 had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to implement Singleton Design Pattern in Java.

749 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