This is an automated email from the ASF dual-hosted git repository. tibordigana pushed a commit to branch SUREFIRE-1570 in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
commit 48e839319da1a315c8cea071ffc005fc7a4b223e Author: tibordigana <tibordig...@apache.org> AuthorDate: Tue May 12 22:45:04 2020 +0200 [SUREFIRE-1570] Maven-fail-safe doesn't put testing JPMS module on module path --- .../resources/surefire-1570/com.foo.api/pom.xml | 51 +++++++++++ .../src/main/java/com/foo/api/SomeInterface.java | 28 ++++++ .../com.foo.api/src/main/java/module-info.java | 28 ++++++ .../resources/surefire-1570/com.foo.impl/pom.xml | 85 +++++++++++++++++ .../src/main/java/com/foo/impl/Bar.java | 51 +++++++++++ .../com.foo.impl/src/main/java/module-info.java | 26 ++++++ .../src/test/java/com/foo/impl/BarIT.java | 41 +++++++++ .../src/test/java/com/foo/impl/BarTest.java | 41 +++++++++ .../src/test/resources/surefire-1570/pom.xml | 101 +++++++++++++++++++++ 9 files changed, 452 insertions(+) diff --git a/surefire-its/src/test/resources/surefire-1570/com.foo.api/pom.xml b/surefire-its/src/test/resources/surefire-1570/com.foo.api/pom.xml new file mode 100644 index 0000000..6e1883c --- /dev/null +++ b/surefire-its/src/test/resources/surefire-1570/com.foo.api/pom.xml @@ -0,0 +1,51 @@ +<?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> + + <parent> + <groupId>com.foo</groupId> + <artifactId>com.foo</artifactId> + <version>1.0.0</version> + </parent> + + <artifactId>com.foo.api</artifactId> + + <dependencies> + <dependency> + <groupId>jakarta.persistence</groupId> + <artifactId>jakarta.persistence-api</artifactId> + </dependency> + <dependency> + <groupId>jakarta.ws.rs</groupId> + <artifactId>jakarta.ws.rs-api</artifactId> + </dependency> + <dependency> + <groupId>jakarta.xml.bind</groupId> + <artifactId>jakarta.xml.bind-api</artifactId> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + </dependency> + </dependencies> +</project> diff --git a/surefire-its/src/test/resources/surefire-1570/com.foo.api/src/main/java/com/foo/api/SomeInterface.java b/surefire-its/src/test/resources/surefire-1570/com.foo.api/src/main/java/com/foo/api/SomeInterface.java new file mode 100644 index 0000000..43ecf73 --- /dev/null +++ b/surefire-its/src/test/resources/surefire-1570/com.foo.api/src/main/java/com/foo/api/SomeInterface.java @@ -0,0 +1,28 @@ +package com.foo.api; + +/* + * 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. + */ + +/** + * + */ +public interface SomeInterface +{ + void doItNow( Class<?> observer ); +} diff --git a/surefire-its/src/test/resources/surefire-1570/com.foo.api/src/main/java/module-info.java b/surefire-its/src/test/resources/surefire-1570/com.foo.api/src/main/java/module-info.java new file mode 100644 index 0000000..95b05f7 --- /dev/null +++ b/surefire-its/src/test/resources/surefire-1570/com.foo.api/src/main/java/module-info.java @@ -0,0 +1,28 @@ +/* + * 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. + */ + +module com.foo.api +{ + exports com.foo.api; + requires org.slf4j; + requires java.persistence; + requires java.ws.rs; + requires java.xml.bind; + requires jakarta.activation; +} diff --git a/surefire-its/src/test/resources/surefire-1570/com.foo.impl/pom.xml b/surefire-its/src/test/resources/surefire-1570/com.foo.impl/pom.xml new file mode 100644 index 0000000..e151aff --- /dev/null +++ b/surefire-its/src/test/resources/surefire-1570/com.foo.impl/pom.xml @@ -0,0 +1,85 @@ +<?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> + + <parent> + <groupId>com.foo</groupId> + <artifactId>com.foo</artifactId> + <version>1.0.0</version> + </parent> + + <artifactId>com.foo.impl</artifactId> + + <dependencies> + <dependency> + <groupId>com.foo</groupId> + <artifactId>com.foo.api</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-simple</artifactId> + </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-api</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> +<!-- <multiReleaseOutput>true</multiReleaseOutput>--> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <configuration> + <archive> + <manifestEntries> +<!-- <Multi-Release>true</Multi-Release>--> + </manifestEntries> + </archive> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-failsafe-plugin</artifactId> + <executions> + <execution> + <id>integration-tests</id> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/surefire-its/src/test/resources/surefire-1570/com.foo.impl/src/main/java/com/foo/impl/Bar.java b/surefire-its/src/test/resources/surefire-1570/com.foo.impl/src/main/java/com/foo/impl/Bar.java new file mode 100644 index 0000000..50009e3 --- /dev/null +++ b/surefire-its/src/test/resources/surefire-1570/com.foo.impl/src/main/java/com/foo/impl/Bar.java @@ -0,0 +1,51 @@ +package com.foo.impl; + +/* + * 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. + */ + +import com.foo.api.SomeInterface; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + */ +public class Bar implements SomeInterface +{ + private static final Logger LOG = LoggerFactory.getLogger( Bar.class ); + + private boolean weAreAmongModules; + + @Override + public void doItNow( Class<?> observer ) + { + ModuleLayer.boot().modules().forEach( m -> { + if ( m == observer.getModule() || m == Bar.class.getModule() || m == Logger.class.getModule() ) + { + weAreAmongModules = true; + } + } ); + LOG.info( "" ); + LOG.info( "Let's see if I or SLF4J are among boot layer modules: {}", weAreAmongModules ); + if ( !weAreAmongModules ) + { + LOG.info( "Maybe we are in child layer? Or this is not module path?" ); + } + } +} diff --git a/surefire-its/src/test/resources/surefire-1570/com.foo.impl/src/main/java/module-info.java b/surefire-its/src/test/resources/surefire-1570/com.foo.impl/src/main/java/module-info.java new file mode 100644 index 0000000..af383c6 --- /dev/null +++ b/surefire-its/src/test/resources/surefire-1570/com.foo.impl/src/main/java/module-info.java @@ -0,0 +1,26 @@ +/* + * 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. + */ + +module com.foo.impl +{ + requires org.slf4j; + requires org.slf4j.simple; + opens com.foo.impl; + requires com.foo.api; +} diff --git a/surefire-its/src/test/resources/surefire-1570/com.foo.impl/src/test/java/com/foo/impl/BarIT.java b/surefire-its/src/test/resources/surefire-1570/com.foo.impl/src/test/java/com/foo/impl/BarIT.java new file mode 100644 index 0000000..43596b7 --- /dev/null +++ b/surefire-its/src/test/resources/surefire-1570/com.foo.impl/src/test/java/com/foo/impl/BarIT.java @@ -0,0 +1,41 @@ +package com.foo.impl; + +/* + * 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. + */ + +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + */ +public class BarIT +{ + private static final Logger LOG = LoggerFactory.getLogger( BarIT.class ); + + @Test + void shouldPrintModulePath() + { + Bar bar = new Bar(); + LOG.info( "======INTEGRATION TEST=======" ); + LOG.info( "Lets see JDKModulePath: {}", System.getProperty( "jdk.module.path" ) ); + bar.doItNow( getClass() ); + } +} diff --git a/surefire-its/src/test/resources/surefire-1570/com.foo.impl/src/test/java/com/foo/impl/BarTest.java b/surefire-its/src/test/resources/surefire-1570/com.foo.impl/src/test/java/com/foo/impl/BarTest.java new file mode 100644 index 0000000..6e392b6 --- /dev/null +++ b/surefire-its/src/test/resources/surefire-1570/com.foo.impl/src/test/java/com/foo/impl/BarTest.java @@ -0,0 +1,41 @@ +package com.foo.impl; + +/* + * 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. + */ + +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + */ +public class BarTest +{ + private static final Logger LOG = LoggerFactory.getLogger( BarTest.class ); + + @Test + void shouldPrintModulePath() + { + Bar bar = new Bar(); + LOG.info( "======UNIT TEST=======" ); + LOG.info( "Lets see JDKModulePath: {}", System.getProperty( "jdk.module.path" ) ); + bar.doItNow( getClass() ); + } +} diff --git a/surefire-its/src/test/resources/surefire-1570/pom.xml b/surefire-its/src/test/resources/surefire-1570/pom.xml new file mode 100644 index 0000000..0f6bc9a --- /dev/null +++ b/surefire-its/src/test/resources/surefire-1570/pom.xml @@ -0,0 +1,101 @@ +<?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>com.foo</groupId> + <artifactId>com.foo</artifactId> + <version>1.0.0</version> + <packaging>pom</packaging> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <maven.compiler.release>${java.specification.version}</maven.compiler.release> + </properties> + + <modules> + <module>com.foo.api</module> + <module>com.foo.impl</module> + </modules> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>jakarta.persistence</groupId> + <artifactId>jakarta.persistence-api</artifactId> + <version>2.2.3</version> + </dependency> + <dependency> + <groupId>jakarta.ws.rs</groupId> + <artifactId>jakarta.ws.rs-api</artifactId> + <version>2.1.6</version> + </dependency> + <dependency> + <groupId>jakarta.xml.bind</groupId> + <artifactId>jakarta.xml.bind-api</artifactId> + <version>2.3.2</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>1.8.0-beta2</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-simple</artifactId> + <version>1.8.0-beta2</version> + </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-api</artifactId> + <version>5.6.2</version> + </dependency> + </dependencies> + </dependencyManagement> + + <build> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.8.1</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>${surefire.version}</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>3.2.0</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-failsafe-plugin</artifactId> + <version>${surefire.version}</version> + </plugin> + </plugins> + </pluginManagement> + </build> +</project>