@Valid is not working in unit test cases

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

@Valid is not working in unit test cases

gnanapandithan
This post was updated on .
I am using TomEE 7.0.2 and developed simple JAX-RS web service . it is working good. I did unit test using  TestNG and Arquillian. In Arquillian @Deployment ( testable= false ) and  WARArchive deployment. I am using Jersey Restclient  to  invoke my rest service in unit test case . checking response status and response object. it is working good. test case passed.

I have added @valid ( javax.validation) to validate my restful request object variable @NotNull. It is working good and throwing exception when I do real time ( WAR deployed in TomEE and tested via postman restclient) if the variable is null.

But When I tried with unit test case ( passing request object with null variable ), my request is not being validated by @valid .  please guide me how to enable @Valid in unit test case.


I am using TomEE 7.0.2. Test NG, Arquillian and @Valid. doing black box testing.

I will appreciate if you share any example code for my scenario  


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: @Valid is not working in unit test cases

Romain Manni-Bucau
Hi

nothing special is needed - this test uses it for instance
https://github.com/apache/tomee/blob/master/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/AutoBValTest.java

how do you write your test?


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://blog-rmannibucau.rhcloud.com> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2017-06-29 23:48 GMT+02:00 gnanapandithan <[hidden email]>:

> I am using TomEE 7.0.2 and developed simple JAX-RS web service . it is
> working good. I did unit test using  TestNG and Arquillian. In Arquillian
> @Deployment ( testable= false ) and  WARArchive deployment. using
> Restclient
> ( Jersy) I am invoking my service in unit test case and checking response
> status and response object. it is working good. I have added @valid (
> javax.validation) to validate my restful request. It is working good and
> throwing exception when I do real time ( WAR deployed in TomEE and tested
> via postman restclient)
>
> *But When I tried with unit test case , my request is not being validated
> by
> @valid.  please guide me how to enable @Valid in unit test case.
> *
>
> *I am using TomEE 7.0.2. Test NG, Arquillian and @Valid.
>
> I will appreciate if you share any example code for my scenario  *
>
>
>
>
>
> --
> View this message in context: http://tomee-openejb.979440.
> n4.nabble.com/Valid-is-not-working-in-unit-test-cases-tp4681995.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: @Valid is not working in unit test cases

gnanapandithan
This post has NOT been accepted by the mailing list yet.
I am not using ApplicationComposer. I am using Arquillian. please help me with Arquillian
Loading...