This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/sling-feature-launcher-maven-plugin.git
commit ff9e77425431d6afe69a5d1e2526a9353ad3e35e Author: Robert Munteanu <[email protected]> AuthorDate: Thu Jun 25 13:40:23 2020 +0200 SLING-9526 - Allow launching feature model applications in external processes, non-blocking - update the IT to start Sling 12 (for now), validating the plugin - run the IT by default - remove the unit test, it did not work properly --- pom.xml | 69 ++++---- src/it/simple-it/pom.xml | 181 +++++++++++++++------ .../java/org/apache/sling/it/SlingRunningIT.java | 49 ++++++ .../maven/feature/launcher/StartMojoTest.java | 54 ------ src/test/resources/project-to-test/pom.xml | 56 ------- 5 files changed, 206 insertions(+), 203 deletions(-) diff --git a/pom.xml b/pom.xml index 3db716f..996b2fa 100644 --- a/pom.xml +++ b/pom.xml @@ -119,45 +119,36 @@ </execution> </executions> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-invoker-plugin</artifactId> + <configuration> + <debug>true</debug> + <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo> + <pomIncludes> + <pomInclude>*/pom.xml</pomInclude> + </pomIncludes> + <postBuildHookScript>verify</postBuildHookScript> + <!-- + <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath> + --> + <settingsFile>src/it/settings.xml</settingsFile> + <goals> + <goal>clean</goal> + <goal>verify</goal> + </goals> + </configuration> + <executions> + <execution> + <id>integration-test</id> + <goals> + <goal>install</goal> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> + </executions> + </plugin> </plugins> </build> - - <profiles> - <profile> - <id>run-its</id> - <build> - - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-invoker-plugin</artifactId> - <configuration> - <debug>true</debug> - <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo> - <pomIncludes> - <pomInclude>*/pom.xml</pomInclude> - </pomIncludes> - <postBuildHookScript>verify</postBuildHookScript> - <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath> - <settingsFile>src/it/settings.xml</settingsFile> - <goals> - <goal>clean</goal> - <goal>verify</goal> - </goals> - </configuration> - <executions> - <execution> - <id>integration-test</id> - <goals> - <goal>install</goal> - <goal>integration-test</goal> - <goal>verify</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - </profiles> </project> diff --git a/src/it/simple-it/pom.xml b/src/it/simple-it/pom.xml index e63422f..50edf83 100644 --- a/src/it/simple-it/pom.xml +++ b/src/it/simple-it/pom.xml @@ -1,61 +1,134 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at +<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor + license agreements. See the NOTICE file distributed with this work for additional + information regarding copyright ownership. The ASF licenses this file to + you under the Apache License, Version 2.0 (the "License"); you may not use + this file except in compliance with the License. You may obtain a copy of + the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required + by applicable law or agreed to in writing, software distributed under the + License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS + OF ANY KIND, either express or implied. See the License for the specific + language governing permissions and limitations under the License. --> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> - http://www.apache.org/licenses/LICENSE-2.0 + <groupId>org.apache.sling</groupId> + <artifactId>simple-it</artifactId> + <version>1.0-SNAPSHOT</version> - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> + <description>A simple IT verifying starting and stopping.</description> - <groupId>org.apache.sling</groupId> - <artifactId>simple-it</artifactId> - <version>1.0-SNAPSHOT</version> + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> - <description>A simple IT verifying the basic use case.</description> + <dependencies> + <dependency> + <groupId>org.apache.sling</groupId> + <artifactId>org.apache.sling.feature.launcher</artifactId> + <version>1.1.2</version> + </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-api</artifactId> + <version>5.6.2</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-engine</artifactId> + <version>5.6.2</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + <version>4.5.12</version> + <scope>test</scope> + </dependency> + </dependencies> - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - </properties> - - <build> - <plugins> - <plugin> - <groupId>@project.groupId@</groupId> - <artifactId>@project.artifactId@</artifactId> - <version>@project.version@</version> - <configuration> - <toLaunch> - <groupId>org.apache.sling</groupId> - <artifactId>org.apache.sling.starter</artifactId> - <version>12-SNAPSHOT</version> - <classifier>oak_tar</classifier> - <type>slingosgifeature</type> - </toLaunch> - </configuration> - <executions> - <execution> - <id>touch</id> - <goals> - <goal>start</goal> - <goal>stop</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> + <build> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>8</source> + <target>8</target> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <version>3.2.0</version> + <executions> + <execution> + <id>reserve-network-port</id> + <goals> + <goal>reserve-network-port</goal> + </goals> + <phase>process-resources</phase> + <configuration> + <portNames> + <portName>http.port</portName> + </portNames> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>@project.groupId@</groupId> + <artifactId>@project.artifactId@</artifactId> + <version>@project.version@</version> + <configuration> + <launches> + <launch> + <id>sling-12-oak-tar</id> + <feature> + <groupId>org.apache.sling</groupId> + <artifactId>org.apache.sling.starter</artifactId> + <version>12-SNAPSHOT</version> + <classifier>oak_tar</classifier> + <type>slingosgifeature</type> + </feature> + <launcherArguments> + <frameworkProperties> + <org.osgi.service.http.port>${http.port}</org.osgi.service.http.port> + </frameworkProperties> + </launcherArguments> + </launch> + </launches> + <toLaunch> + </toLaunch> + </configuration> + <executions> + <execution> + <goals> + <goal>start</goal> + <goal>stop</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-failsafe-plugin</artifactId> + <version>2.22.2</version> + <configuration> + <systemPropertyVariables> + <SLING_HTTP_PORT>${http.port}</SLING_HTTP_PORT> + </systemPropertyVariables> + </configuration> + <executions> + <execution> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> </project> diff --git a/src/it/simple-it/src/test/java/org/apache/sling/it/SlingRunningIT.java b/src/it/simple-it/src/test/java/org/apache/sling/it/SlingRunningIT.java new file mode 100644 index 0000000..4e0cb22 --- /dev/null +++ b/src/it/simple-it/src/test/java/org/apache/sling/it/SlingRunningIT.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package org.apache.sling.it; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; +import org.apache.http.impl.client.*; +import org.apache.http.client.methods.*; + +public class SlingRunningIT { + + @Test + public void slingIsUp() throws Exception { + + int port = Integer.getInteger("SLING_HTTP_PORT", 8080); + + try ( CloseableHttpClient httpclient = HttpClients.createDefault() ) { + HttpGet get = new HttpGet("http://localhost:" + port + "/"); + for ( int i = 0; i < 30; i++ ) { + try ( CloseableHttpResponse response = httpclient.execute(get) ) { + System.out.println("Status line = " + response.getStatusLine().toString()); + int statusCode = response.getStatusLine().getStatusCode(); + if ( (statusCode / 100 == 2) || (statusCode / 100 == 3) ) { + System.out.println("Sling is ready"); + return; + } + Thread.sleep(1000l); + } + } + + throw new RuntimeException("Sling is not yet ready, failing"); + } + } +} \ No newline at end of file diff --git a/src/test/java/org/apache/sling/maven/feature/launcher/StartMojoTest.java b/src/test/java/org/apache/sling/maven/feature/launcher/StartMojoTest.java deleted file mode 100644 index 859a706..0000000 --- a/src/test/java/org/apache/sling/maven/feature/launcher/StartMojoTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.sling.maven.feature.launcher; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.File; - -import org.apache.maven.plugin.testing.MojoRule; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; - -public class StartMojoTest { - @Rule - public MojoRule rule = new MojoRule(); - - @Test - @Ignore - // TODO - re-enable - public void startAndStop() throws Exception { - File pom = new File("target/test-classes/project-to-test/"); - assertNotNull(pom); - assertTrue(pom.exists()); - - StartMojo myMojo = (StartMojo) rule.lookupConfiguredMojo(pom, "start"); - assertNotNull(myMojo); - myMojo.execute(); - - File outputDirectory = (File) rule.getVariableValueFromObject(myMojo, "outputDirectory"); - assertNotNull(outputDirectory); - assertTrue(outputDirectory.exists()); - - File touch = new File(outputDirectory, "touch.txt"); - assertTrue(touch.exists()); - } -} diff --git a/src/test/resources/project-to-test/pom.xml b/src/test/resources/project-to-test/pom.xml deleted file mode 100644 index 3bf366c..0000000 --- a/src/test/resources/project-to-test/pom.xml +++ /dev/null @@ -1,56 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <groupId>org.apache.sling</groupId> - <artifactId>feature-launcher-maven-plugin</artifactId> - <version>1.0-SNAPSHOT</version> - <packaging>jar</packaging> - <name>Test StartMojo</name> - - <build> - <plugins> - <plugin> - <artifactId>maven-my-plugin</artifactId> - <version>1.0-SNAPSHOT</version> - <configuration> - <toLaunch> - <groupId>org.apache.sling</groupId> - <artifactId>org.apache.sling.starter</artifactId> - <version>12-SNAPSHOT</version> - <classifier>oak_tar</classifier> - <type>slingosgifeature</type> - </toLaunch> - </configuration> - <executions> - <execution> - <goals> - <goal>start</goal> - <goal>stop</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> -</project>
