Hi Felix

Thanks for your help. I am not quite sure what you mean it the "it classes" but 
anyhow I made some progress. I finally could create the launchpad-bundles 
(needed to set the packaging to war) and create the web application but when I 
try to run the tests Sling does not get deployed inside Cargo/Jetty. This is a 
snippet of my POM that handles the integration test:

        <profile>
            <!--
                Run the cargo-based integration tests.
            -->
            <id>cargoIntegrationTesting</id>
            <activation>
                <property>
                    <name>!maven.test.skip</name>
                </property>
            </activation>
            <build>
                <plugins>

                    <plugin>
                        <groupId>org.apache.sling</groupId>
                        <artifactId>maven-launchpad-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>prepare-launch-package</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>prepare-package</goal>
                                </goals>
                                <configuration>
                                    <defaultBundleList>
                                        <version>6-SNAPSHOT</version>
                                    </defaultBundleList>
                                    <packaging>war</packaging>

                                    <additionalBundles>
                                        <additionalBundle>
                                            <groupId>com.XXX.sn</groupId>
                                            
<artifactId>sling-service-web-bundle</artifactId>
                                            <version>1.0</version>
                                            <startLevel>0</startLevel>
                                        </additionalBundle>
                                    </additionalBundles>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <!--
                      Include sling-app launcher classes and resources, but no 
Sling
                      bundles (we want to specify our own versions)
                    -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-war-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>create-war</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>war</goal>
                                </goals>
                                <configuration>
                                    <webResources>
                                        <!-- the configuration resources -->
                                        <resource>
                                            <directory>
                                                
${project.build.directory}/launchpad-bundles
                                            </directory>
                                            <targetPath>WEB-INF</targetPath>
                                        </resource>
                                        <!-- Legal stuff -->
                                        <resource>
                                            <directory>${basedir}</directory>
                                            <targetPath>META-INF</targetPath>
                                            <includes>
                                                <include>LICENSE*</include>
                                                <include>NOTICE*</include>
                                                <include>DISCLAIMER</include>
                                            </includes>
                                        </resource>
                                    </webResources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>surefire-integration-test</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                                <configuration>
                                    <excludes>
                                        <exclude>none</exclude>
                                    </excludes>
                                    <includes>
                                        <include>
                                            
${integration.test.code.path}/**/*Test.java
                                        </include>
                                        <include>
                                            **/*Test.java
                                        </include>
                                    </includes>
                                    <systemProperties>
                                        <!--
                                            WARNING: make sure these URLs are 
consistent with the
                                            cargo-maven2-plugin settings: AFAIK 
Maven does not
                                            expand variables in the <value> 
element.
                                            And WARNING: these properties are 
duplicated somewhere in this
                                            POM with slightly different 
values...there must be a better way.
                                        -->
                                        <property>
                                            <name>
                                                launchpad.http.server.url
                                            </name>
                                            <value>
                                                
http://${test.host}:${http.port}/${project.build.finalName}
                                            </value>
                                        </property>
                                        <property>
                                            <name>
                                                launchpad.webdav.server.url
                                            </name>
                                            <value>
                                                
http://${test.host}:${http.port}/${project.build.finalName}/${webdav.workspace.path}
                                            </value>
                                        </property>

                                    </systemProperties>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.cargo</groupId>
                        <artifactId>cargo-maven2-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>start-container</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>stop-container</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <wait>${integration.test.wait}</wait>
                            <container>
                                <containerId>jetty6x</containerId>
                                <type>embedded</type>
                                <systemProperties>
                                    <sling.home>
                                         ${jetty.sling.home}
                                    </sling.home>
                                    <!--<sling.home>-->
                                        <!--${basedir}/target/it/sling-->
                                    <!--</sling.home>-->
                                </systemProperties>
                            </container>
                            <configuration>
                                <home>${project.build.directory}/cargo</home>
                                <properties>
                                    <cargo.servlet.port>
                                        ${http.port}
                                    </cargo.servlet.port>
                                    <!--
                                        <cargo.jvmargs>-Xdebug -Xnoagent 
-Xrunjdwp:transport=dt_socket,address=30333,server=y,suspend=y</cargo.jvmargs>
                                    -->
                                </properties>
                            </configuration>
                        </configuration>
                    </plugin>
                    <!--<plugin>-->
                        <!--<groupId>org.mortbay.jetty</groupId>-->
                        <!--<artifactId>maven-jetty-plugin</artifactId>-->
                        <!--<version>6.1.10</version>-->
                        <!--<configuration>-->
                            <!--<contextPath>/</contextPath>-->
                            <!--<scanIntervalSeconds>-->
                                <!--${jetty.scan.interval.seconds}-->
                            <!--</scanIntervalSeconds>-->

                            <!--<systemProperties>-->
                                <!--<systemProperty>-->
                                    <!--<name>sling.home</name>-->
                                    <!--<value>${jetty.sling.home}</value>-->
                                <!--</systemProperty>-->

                            <!--</systemProperties>-->

                            <!--<connectors>-->
                                <!--<connector 
implementation="org.mortbay.jetty.nio.SelectChannelConnector">-->
                                    <!--<port>${http.port}</port>-->
                                    <!--<maxIdleTime>60000</maxIdleTime>-->
                                <!--</connector>-->
                            <!--</connectors>-->

                            <!--&lt;!&ndash;-->
                                <!--Use target/... as the webapp source, as we 
unpack stuff there from the-->
                                <!--Sling launcher modules-->
                            <!--&ndash;&gt;-->
                            <!--<webAppSourceDirectory>-->
                                
<!--${basedir}/target/${artifactId}-${pom.version}-->
                            <!--</webAppSourceDirectory>-->
                        <!--</configuration>-->
                        <!--&lt;!&ndash;<configuration>&ndash;&gt;-->
                            
<!--&lt;!&ndash;<scanIntervalSeconds>10</scanIntervalSeconds>&ndash;&gt;-->
                            <!--&lt;!&ndash;<stopKey>foo</stopKey>&ndash;&gt;-->
                            
<!--&lt;!&ndash;<stopPort>9999</stopPort>&ndash;&gt;-->
                            <!--&lt;!&ndash;<connectors>&ndash;&gt;-->
                                <!--&lt;!&ndash;<connector 
implementation="org.mortbay.jetty.nio.SelectChannelConnector">&ndash;&gt;-->
                                    
<!--&lt;!&ndash;<port>8888</port>&ndash;&gt;-->
                                    
<!--&lt;!&ndash;<maxIdleTime>60000</maxIdleTime>&ndash;&gt;-->
                                <!--&lt;!&ndash;</connector>&ndash;&gt;-->
                            <!--&lt;!&ndash;</connectors>&ndash;&gt;-->
                        <!--&lt;!&ndash;</configuration>&ndash;&gt;-->
                        <!--<executions>-->
                            <!--<execution>-->
                                <!--<id>start-jetty</id>-->
                                <!--<phase>pre-integration-test</phase>-->
                                <!--<goals>-->
                                    <!--<goal>run</goal>-->
                                <!--</goals>-->
                                <!--<configuration>-->
                                    
<!--&lt;!&ndash;<scanIntervalSeconds>0</scanIntervalSeconds>&ndash;&gt;-->
                                    <!--<daemon>true</daemon>-->
                                <!--</configuration>-->
                            <!--</execution>-->
                            <!--<execution>-->
                                <!--<id>stop-jetty</id>-->
                                <!--<phase>post-integration-test</phase>-->
                                <!--<goals>-->
                                    <!--<goal>stop</goal>-->
                                <!--</goals>-->
                            <!--</execution>-->
                        <!--</executions>-->
                    <!--</plugin>-->
                </plugins>
            </build>
        </profile>

The plugin definition contain the Jetty plugin definition as in 
launchpad/testing POM. The important other plugins are moved into the 
integration profile to make them run during that profile.

If I fire up jetty (jetty:run) I noticed that sling is deployed into '_' rather 
than the artifactid-version.That is the output of Cargo when the plugin is 
executed:

INFO] [cargo:start {execution: start-container}]
[INFO] [beddedLocalContainer] Jetty 6.x Embedded starting...
2010-02-09 10:56:43.730::INFO:  Logging to STDERR via org.mortbay.log.StdErrLog
2010-02-09 10:56:43.771::INFO:  jetty-6.1.1rc1
2010-02-09 10:56:43.865::INFO:  Extract 
jar:file:/Users/schaefa/Development/XXX/svn/spikes/trunk/sn/sling-service-web-single/target/cargo/cargocpc.war!/
 to 
/var/folders/wJ/wJxmOwxZF5O6JZiH8XR7lU+++TI/-Tmp-/Jetty_0_0_0_0_8888_cargocpc.war__cargocpc__rw8xgv/webapp
log4j:WARN No appenders could be found for logger 
(org.apache.jasper.compiler.JspRuntimeContext).
log4j:WARN Please initialize the log4j system properly.
2010-02-09 10:56:44.616::INFO:  Started SelectChannelConnector @ 0.0.0.0:8888

For right now it seems that the bundle must be in its own Maven2 module in 
order to be deployed during the integration test phase.

-Andy

On Feb 9, 2010, at 12:05 AM, Felix Meschberger wrote:

> Hi,
> 
> I don't have such a POM set up.
> 
> A first approach I would test would be:
> 
>  * create your integration test classes in src/test/java
>  * exclude the it classes from unit testing
>  * package the it classes using the test-jar goal
>    excluding the regular unit test classes
> 
> In the integration test you would then include the generated test
> package for the tests to run ...
> 
> Regards
> Felix
> 
> On 09.02.2010 03:24, Andreas Schaefer wrote:
>> Hi
>> 
>> After getting my first Sling bundle deployed and tested with an integration 
>> test (more or less taken from what I found in the launchpad testing project) 
>> I was wondering if it would be possible to have the bundle code and its test 
>> code inside the same project / POM. Currently I need a second project in 
>> order to build the web test environment and to run it. For now I am stuck 
>> that the target/launchpad-bundles is not created.
>> 
>> Does anybody has a example POM to set that up if possible ?
>> 
>> Thanks - Andy Schaefer
>> 

Reply via email to