users@jersey.java.net

Re: [Jersey] jersey test framework modularity

From: Pavel Bucek <Pavel.Bucek_at_Sun.COM>
Date: Mon, 15 Feb 2010 09:45:49 +0100

Paul Sandoz wrote:
> Hi Pavel,
>
> Perhaps for now with the samples we do not need to define multiple
> profiles and we can stick to explicitly using a single test framework
> module implementation dependency, as appropriate to the test
> implementation. (In any case not all framework implementations will
> work with all test setups.) Currently some use the low-level grizzly
> container, others use the grizzly servlet container etc.
If I understood it correctly, you are suggesting to have just single
dependency (on actually used test framework module). I don't think we
can do it, because that would disallow testing on external container,
which is used by others (and actually we use that too, when testing with
"external" glassfish). I guess we don't need specify all containers in
every sample (because it definitely won't work for some combination) but
I don't want to make it "worse" than it is now (in sense of modularity).

We need somehow add "dynamic" dependencies and maven allows that only
through profiles (correct me if I'm wrong) so we just have to use them..

>
> Jakub knows a lot more than I on the limitations of profiles in maven.
> IIRC he and Naresh has some similar issues. So i would tend to avoid
> complicating matters and keeping things simple.
agreed.

Pavel
>
>
> Paul.
>
> On Feb 12, 2010, at 3:12 PM, Pavel Bucek wrote:
>
>> Hello,
>>
>> I was able to modularize jersey-test-framework (jersey-test-framework
>> depends only on jersey-client, jersey-server and javax.servlet),
>> introduced several new modules (one for each container).
>>
>> The problem I'm having now is correctly define dependencies in
>> samples or to be more precise - how to define dependency on default
>> or specified test container. I wanted to do this centrally - somehow
>> in jersey-test-framework pom or anywhere else BUT it doesn't seem
>> possible. Maven has limited profile inheritance and it looks like its
>> not really stable (discovered various bug reports).
>>
>> Currently I have to define everything in every samples pom file. Not
>> really convenient but probably the safest way.
>>
>> I'm playing with helloworld sample in
>> jersey-test-framework-modularization branch and current state is:
>>
>> when you execute *mvn clean install*, project will be tested using
>> grizzly web container. If you want to use different one, you need to run
>> *mvn clean install
>> -Djersey.test.containerFactory=com.sun.jersey.test.framework.spi.container.inmemory.InMemoryTestContainerFactory*
>> (or different factory). No further action needed, profile should be
>> selected according to this single property.
>>
>> dependencies:
>>
>> <dependencies>
>> <dependency>
>> <groupId>com.sun.jersey</groupId>
>> <artifactId>jersey-server</artifactId>
>> <version>${project.version}</version>
>> </dependency> <dependency>
>> <groupId>com.sun.jersey</groupId>
>> <artifactId>jersey-test-framework</artifactId>
>> <version>${project.version}</version>
>> <scope>test</scope>
>> </dependency>
>> <dependency>
>> <groupId>com.sun.grizzly</groupId>
>> <artifactId>grizzly-servlet-webserver</artifactId>
>> <version>1.9.8</version>
>> </dependency>
>> </dependencies>
>>
>> profiles (not complete yet):
>>
>> <profile>
>> <id>JDK 1.5</id>
>> <activation>
>> <jdk>1.5</jdk>
>> </activation>
>> <dependencies>
>> <dependency>
>> <groupId>com.sun.jersey</groupId>
>> <artifactId>jersey-test-framework-grizzly</artifactId>
>> <version>${project.version}</version>
>> </dependency>
>> <dependency> <!-- enabling WADL support -->
>> <groupId>com.sun.xml.bind</groupId>
>> <artifactId>jaxb-impl</artifactId>
>> <version>2.1</version>
>> </dependency>
>> </dependencies>
>> </profile>
>>
>>
>> <profile>
>> <id>Grizzly Default</id>
>> <activation>
>> <property>
>> <name>!jersey.test.containerFactory</name>
>> </property>
>> </activation>
>> <dependencies>
>> <dependency>
>> <groupId>com.sun.jersey</groupId>
>> <artifactId>jersey-test-framework-grizzly</artifactId>
>> <version>${project.version}</version>
>> </dependency>
>> <dependency> <!-- enabling WADL support -->
>> <groupId>com.sun.xml.bind</groupId>
>> <artifactId>jaxb-impl</artifactId>
>> <version>2.1</version>
>> </dependency>
>> </dependencies>
>> </profile>
>>
>> <profile>
>> <id>Grizzly</id>
>> <activation>
>> <property>
>> <name>jersey.test.containerFactory</name>
>>
>> <value>com.sun.jersey.test.framework.spi.container.grizzly.web.GrizzlyWebTestContainerFactory</value>
>>
>> </property>
>> </activation>
>> <dependencies>
>> <dependency>
>> <groupId>com.sun.jersey</groupId>
>> <artifactId>jersey-test-framework-grizzly</artifactId>
>> <version>${project.version}</version>
>> </dependency>
>> </dependencies>
>> </profile>
>>
>> <profile>
>> <id>Grizzly Light</id>
>> <activation>
>> <property>
>> <name>jersey.test.containerFactory</name>
>>
>> <value>com.sun.jersey.test.framework.spi.container.grizzly.GrizzlyTestContainerFactory</value>
>>
>> </property>
>> </activation>
>> <dependencies>
>> <dependency>
>> <groupId>com.sun.jersey</groupId>
>> <artifactId>jersey-test-framework-grizzly</artifactId>
>> <version>${project.version}</version>
>> </dependency>
>> </dependencies>
>> </profile>
>>
>> <profile>
>> <id>InMemory</id>
>> <activation>
>> <property>
>> <name>jersey.test.containerFactory</name>
>>
>> <value>com.sun.jersey.test.framework.spi.container.inmemory.InMemoryTestContainerFactory</value>
>>
>> </property>
>> </activation>
>> <dependencies>
>> <dependency>
>> <groupId>com.sun.jersey</groupId>
>> <artifactId>jersey-test-framework-inmemory</artifactId>
>> <version>${project.version}</version>
>> </dependency>
>> </dependencies>
>> </profile>
>>
>> ... (others)
>>
>>
>> I would like to have feedback from you so if you see some possible
>> issue or if you have any suggestions, please let me know.
>>
>> Thanks,
>> Pavel
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>