You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Arulazi Dhesiaseelan <ar...@gmail.com> on 2009/12/17 03:18:00 UTC

Re: Practical to write unit tests that can simulate the container and verify XML/JSON data?

Yes, it is practical and I have done it before.

You could use the embedded Jetty server to deploy your resources (start your
server in your setup()) and then you can invoke the resources in the test
and then finally dispose the server in teardown.

-Arul

On Wed, Dec 16, 2009 at 7:01 PM, KARR, DAVID (ATTCINW) <dk...@att.com>wrote:

> Is it practical to write unit tests that can simulate the container,
> call the jax-rs server with a REST query, and verify the XML/JSON
> response that it gets?  This would all be in a standalone container.
>



-- 
http://aruld.info

Re: Practical to write unit tests that can simulate the container and verify XML/JSON data?

Posted by Daniel Kulp <dk...@apache.org>.

Looks like his pom.xml in the example isn't properly configuring the compiler 
plugin.    Add:

<build>
        <pluginManagement>
<plugins>
               <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.0.2</version>
                    <configuration>
                        <source>1.5</source>
                        <target>1.5</target>
 </configuration>
                </plugin>
 </plugins>
        </pluginManagement>
    </build>


Dan



On Thu December 17 2009 12:34:27 pm KARR, DAVID (ATTCINW) wrote:
> That fails with errors like this:
> 
> 
> 
> Entries.java:[7,1] annotations are not supported in -source 1.3
> 
> (try -source 1.5 to enable annotations)
> 
> @XmlRootElement
> 
> 
> 
> From: Arulazi Dhesiaseelan [mailto:aruld.info@gmail.com]
> Sent: Wednesday, December 16, 2009 8:08 PM
> To: users@cxf.apache.org
> Subject: Re: Practical to write unit tests that can simulate the
> container and verify XML/JSON data?
> 
> 
> 
> Attaching a simple maven project to get you started. You should you be
> able to run the tests directly from an IDE.
> 
> I had blogged [1] about this example a while ago.
> 
> -Arul
> 
> [1] http://aruld.info/cxf-22-in-action-services-design-simplified/
> 
> On Wed, Dec 16, 2009 at 8:36 PM, KARR, DAVID (ATTCINW) <dk...@att.com>
> 
> wrote:
> > -----Original Message-----
> > From: Johan Edstrom [mailto:seijoed@gmail.com] On Behalf Of Johan
> > Edstrom
> > Sent: Wednesday, December 16, 2009 6:54 PM
> > To: users@cxf.apache.org
> > Subject: Re: Practical to write unit tests that can simulate the
> > container and verify XML/JSON data?
> >
> > It is quite practical for integration testing, I do it quite often on
> > the SOAP side.
> >
> > On Dec 16, 2009, at 7:18 PM, Arulazi Dhesiaseelan wrote:
> > > Yes, it is practical and I have done it before.
> > >
> > > You could use the embedded Jetty server to deploy your resources
> >
> > (start your
> >
> > > server in your setup()) and then you can invoke the resources in the
> >
> > test
> >
> > > and then finally dispose the server in teardown.
> 
> Ok, then I guess I'll add to my question.
> 
> Can either of you map out more details about how I would do this?  Any
> links to concise descriptions of pieces of this would be fine also.
> 
> > > On Wed, Dec 16, 2009 at 7:01 PM, KARR, DAVID (ATTCINW)
> >
> > <dk...@att.com>wrote:
> > >> Is it practical to write unit tests that can simulate the
> 
> container,
> 
> > >> call the jax-rs server with a REST query, and verify the XML/JSON
> > >> response that it gets?  This would all be in a standalone
> 
> container.
> 
> > > --
> > > http://aruld.info
> >
> > Johan Edstrom
> >
> > joed@opennms.org
> >
> > They that can give up essential liberty to purchase a little temporary
> > safety, deserve neither liberty nor safety.
> >
> > Benjamin Franklin, Historical Review of Pennsylvania, 1759
> 

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

Re: Practical to write unit tests that can simulate the container and verify XML/JSON data?

Posted by Arulazi Dhesiaseelan <ar...@gmail.com>.
It should work in JDK 6 as JAXB is part of the JDK. If you want to use in
JDK5, you may want to add maven dependency for JAXB:

-Arul

On Thu, Dec 17, 2009 at 10:34 AM, KARR, DAVID (ATTCINW) <dk...@att.com>wrote:

> That fails with errors like this:
>
>
>
> Entries.java:[7,1] annotations are not supported in -source 1.3
>
> (try -source 1.5 to enable annotations)
>
> @XmlRootElement
>
>
>
> From: Arulazi Dhesiaseelan [mailto:aruld.info@gmail.com]
> Sent: Wednesday, December 16, 2009 8:08 PM
> To: users@cxf.apache.org
> Subject: Re: Practical to write unit tests that can simulate the
> container and verify XML/JSON data?
>
>
>
> Attaching a simple maven project to get you started. You should you be
> able to run the tests directly from an IDE.
>
> I had blogged [1] about this example a while ago.
>
> -Arul
>
> [1] http://aruld.info/cxf-22-in-action-services-design-simplified/
>
> On Wed, Dec 16, 2009 at 8:36 PM, KARR, DAVID (ATTCINW) <dk...@att.com>
> wrote:
>
> > -----Original Message-----
> > From: Johan Edstrom [mailto:seijoed@gmail.com] On Behalf Of Johan
> > Edstrom
> > Sent: Wednesday, December 16, 2009 6:54 PM
> > To: users@cxf.apache.org
> > Subject: Re: Practical to write unit tests that can simulate the
> > container and verify XML/JSON data?
> >
> > It is quite practical for integration testing, I do it quite often on
> > the SOAP side.
> >
>
> > On Dec 16, 2009, at 7:18 PM, Arulazi Dhesiaseelan wrote:
> >
> > > Yes, it is practical and I have done it before.
> > >
> > > You could use the embedded Jetty server to deploy your resources
> > (start your
> > > server in your setup()) and then you can invoke the resources in the
> > test
> > > and then finally dispose the server in teardown.
>
> Ok, then I guess I'll add to my question.
>
> Can either of you map out more details about how I would do this?  Any
> links to concise descriptions of pieces of this would be fine also.
>
>
> > > On Wed, Dec 16, 2009 at 7:01 PM, KARR, DAVID (ATTCINW)
> > <dk...@att.com>wrote:
> > >
> > >> Is it practical to write unit tests that can simulate the
> container,
> > >> call the jax-rs server with a REST query, and verify the XML/JSON
> > >> response that it gets?  This would all be in a standalone
> container.
> > >>
> > >
> > >
> > >
> > > --
> > > http://aruld.info
> >
> > Johan Edstrom
> >
> > joed@opennms.org
> >
> > They that can give up essential liberty to purchase a little temporary
> > safety, deserve neither liberty nor safety.
> >
> > Benjamin Franklin, Historical Review of Pennsylvania, 1759
> >
> >
> >
> >
>
>
>
>
> --
> http://aruld.info
>
>


-- 
http://aruld.info

RE: Practical to write unit tests that can simulate the container and verify XML/JSON data?

Posted by "KARR, DAVID (ATTCINW)" <dk...@att.com>.
That fails with errors like this:

 

Entries.java:[7,1] annotations are not supported in -source 1.3

(try -source 1.5 to enable annotations)

@XmlRootElement

 

From: Arulazi Dhesiaseelan [mailto:aruld.info@gmail.com] 
Sent: Wednesday, December 16, 2009 8:08 PM
To: users@cxf.apache.org
Subject: Re: Practical to write unit tests that can simulate the
container and verify XML/JSON data?

 

Attaching a simple maven project to get you started. You should you be
able to run the tests directly from an IDE.

I had blogged [1] about this example a while ago.

-Arul

[1] http://aruld.info/cxf-22-in-action-services-design-simplified/

On Wed, Dec 16, 2009 at 8:36 PM, KARR, DAVID (ATTCINW) <dk...@att.com>
wrote:

> -----Original Message-----
> From: Johan Edstrom [mailto:seijoed@gmail.com] On Behalf Of Johan
> Edstrom
> Sent: Wednesday, December 16, 2009 6:54 PM
> To: users@cxf.apache.org
> Subject: Re: Practical to write unit tests that can simulate the
> container and verify XML/JSON data?
>
> It is quite practical for integration testing, I do it quite often on
> the SOAP side.
>

> On Dec 16, 2009, at 7:18 PM, Arulazi Dhesiaseelan wrote:
>
> > Yes, it is practical and I have done it before.
> >
> > You could use the embedded Jetty server to deploy your resources
> (start your
> > server in your setup()) and then you can invoke the resources in the
> test
> > and then finally dispose the server in teardown.

Ok, then I guess I'll add to my question.

Can either of you map out more details about how I would do this?  Any
links to concise descriptions of pieces of this would be fine also.


> > On Wed, Dec 16, 2009 at 7:01 PM, KARR, DAVID (ATTCINW)
> <dk...@att.com>wrote:
> >
> >> Is it practical to write unit tests that can simulate the
container,
> >> call the jax-rs server with a REST query, and verify the XML/JSON
> >> response that it gets?  This would all be in a standalone
container.
> >>
> >
> >
> >
> > --
> > http://aruld.info
>
> Johan Edstrom
>
> joed@opennms.org
>
> They that can give up essential liberty to purchase a little temporary
> safety, deserve neither liberty nor safety.
>
> Benjamin Franklin, Historical Review of Pennsylvania, 1759
>
>
>
>




-- 
http://aruld.info


Re: Practical to write unit tests that can simulate the container and verify XML/JSON data?

Posted by Arulazi Dhesiaseelan <ar...@gmail.com>.
Attaching a simple maven project to get you started. You should you be able
to run the tests directly from an IDE.

I had blogged [1] about this example a while ago.

-Arul

[1] http://aruld.info/cxf-22-in-action-services-design-simplified/

On Wed, Dec 16, 2009 at 8:36 PM, KARR, DAVID (ATTCINW) <dk...@att.com>wrote:

> > -----Original Message-----
> > From: Johan Edstrom [mailto:seijoed@gmail.com] On Behalf Of Johan
> > Edstrom
> > Sent: Wednesday, December 16, 2009 6:54 PM
> > To: users@cxf.apache.org
> > Subject: Re: Practical to write unit tests that can simulate the
> > container and verify XML/JSON data?
> >
> > It is quite practical for integration testing, I do it quite often on
> > the SOAP side.
> >
> > On Dec 16, 2009, at 7:18 PM, Arulazi Dhesiaseelan wrote:
> >
> > > Yes, it is practical and I have done it before.
> > >
> > > You could use the embedded Jetty server to deploy your resources
> > (start your
> > > server in your setup()) and then you can invoke the resources in the
> > test
> > > and then finally dispose the server in teardown.
>
> Ok, then I guess I'll add to my question.
>
> Can either of you map out more details about how I would do this?  Any
> links to concise descriptions of pieces of this would be fine also.
>
> > > On Wed, Dec 16, 2009 at 7:01 PM, KARR, DAVID (ATTCINW)
> > <dk...@att.com>wrote:
> > >
> > >> Is it practical to write unit tests that can simulate the
> container,
> > >> call the jax-rs server with a REST query, and verify the XML/JSON
> > >> response that it gets?  This would all be in a standalone
> container.
> > >>
> > >
> > >
> > >
> > > --
> > > http://aruld.info
> >
> > Johan Edstrom
> >
> > joed@opennms.org
> >
> > They that can give up essential liberty to purchase a little temporary
> > safety, deserve neither liberty nor safety.
> >
> > Benjamin Franklin, Historical Review of Pennsylvania, 1759
> >
> >
> >
> >
>
>


-- 
http://aruld.info

RE: Practical to write unit tests that can simulate the container and verify XML/JSON data?

Posted by "KARR, DAVID (ATTCINW)" <dk...@att.com>.
> -----Original Message-----
> From: Johan Edstrom [mailto:seijoed@gmail.com] On Behalf Of Johan
> Edstrom
> Sent: Wednesday, December 16, 2009 6:54 PM
> To: users@cxf.apache.org
> Subject: Re: Practical to write unit tests that can simulate the
> container and verify XML/JSON data?
> 
> It is quite practical for integration testing, I do it quite often on
> the SOAP side.
> 
> On Dec 16, 2009, at 7:18 PM, Arulazi Dhesiaseelan wrote:
> 
> > Yes, it is practical and I have done it before.
> >
> > You could use the embedded Jetty server to deploy your resources
> (start your
> > server in your setup()) and then you can invoke the resources in the
> test
> > and then finally dispose the server in teardown.

Ok, then I guess I'll add to my question.

Can either of you map out more details about how I would do this?  Any
links to concise descriptions of pieces of this would be fine also.

> > On Wed, Dec 16, 2009 at 7:01 PM, KARR, DAVID (ATTCINW)
> <dk...@att.com>wrote:
> >
> >> Is it practical to write unit tests that can simulate the
container,
> >> call the jax-rs server with a REST query, and verify the XML/JSON
> >> response that it gets?  This would all be in a standalone
container.
> >>
> >
> >
> >
> > --
> > http://aruld.info
> 
> Johan Edstrom
> 
> joed@opennms.org
> 
> They that can give up essential liberty to purchase a little temporary
> safety, deserve neither liberty nor safety.
> 
> Benjamin Franklin, Historical Review of Pennsylvania, 1759
> 
> 
> 
> 


Re: Practical to write unit tests that can simulate the container and verify XML/JSON data?

Posted by Johan Edstrom <jo...@opennms.org>.
It is quite practical for integration testing, I do it quite often on the SOAP side.

/je

On Dec 16, 2009, at 7:18 PM, Arulazi Dhesiaseelan wrote:

> Yes, it is practical and I have done it before.
> 
> You could use the embedded Jetty server to deploy your resources (start your
> server in your setup()) and then you can invoke the resources in the test
> and then finally dispose the server in teardown.
> 
> -Arul
> 
> On Wed, Dec 16, 2009 at 7:01 PM, KARR, DAVID (ATTCINW) <dk...@att.com>wrote:
> 
>> Is it practical to write unit tests that can simulate the container,
>> call the jax-rs server with a REST query, and verify the XML/JSON
>> response that it gets?  This would all be in a standalone container.
>> 
> 
> 
> 
> -- 
> http://aruld.info

Johan Edstrom

joed@opennms.org

They that can give up essential liberty to purchase a little temporary safety, deserve neither liberty nor safety.

Benjamin Franklin, Historical Review of Pennsylvania, 1759