-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Integrate the reproducer into ITs. --- https://issues.apache.org/jira/browse/MNG-8461
- Loading branch information
Showing
7 changed files
with
214 additions
and
0 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8461SpySettingsEventTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* 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.maven.it; | ||
|
||
import java.nio.file.Path; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-8461">MNG-8461</a>. | ||
*/ | ||
class MavenITmng8461SpySettingsEventTest extends AbstractMavenIntegrationTestCase { | ||
|
||
MavenITmng8461SpySettingsEventTest() { | ||
super("[4.0.0-rc-3-SNAPSHOT,)"); | ||
} | ||
|
||
/** | ||
* Verify that settings building event is emitted. | ||
*/ | ||
@Test | ||
void testIt() throws Exception { | ||
Path basedir = extractResources("/mng-8461").getAbsoluteFile().toPath(); | ||
Verifier verifier; | ||
|
||
Path extension = basedir.resolve("extension"); | ||
verifier = newVerifier(extension.toString()); | ||
verifier.setAutoclean(false); | ||
verifier.addCliArgument("install"); | ||
verifier.execute(); | ||
verifier.verifyErrorFreeLog(); | ||
|
||
Path project = basedir.resolve("project"); | ||
verifier = newVerifier(project.toString()); | ||
verifier.setAutoclean(false); | ||
verifier.setForkJvm(true); | ||
verifier.addCliArgument("-X"); | ||
verifier.addCliArgument("validate"); | ||
verifier.execute(); | ||
verifier.verifyErrorFreeLog(); | ||
|
||
verifier.verifyTextInLog("Initializing Simple Event Spy"); | ||
verifier.verifyTextInLog("SettingsBuilderRequest event is present"); | ||
verifier.verifyTextInLog("SettingsBuilderResult event is present"); | ||
verifier.verifyTextInLog("ToolchainsBuilderRequest event is present"); | ||
verifier.verifyTextInLog("ToolchainsBuilderResult event is present"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
its/core-it-suite/src/test/resources/mng-8461/extension/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Simple reproducer for SettingsBuilderRequest not emitted | ||
|
||
- Build this small extension | ||
`./mvnw clean install` | ||
- Use this extension in a project by `.mvn/extensions.xml`: | ||
```xml | ||
<extensions> | ||
<extension> | ||
<groupId>org.example</groupId> | ||
<artifactId>maven4-reproducer</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
</extension> | ||
</extensions> | ||
``` | ||
- Run a build with Maven 4 rc-2: | ||
`[INFO] [stdout] Closing Simple Event Spy, checking SettingsBuilderRequest event` => all good | ||
- Run a build with Maven 4 latest rc-3 snapshot: | ||
`[WARNING] Failed to close spy org.example.SimpleEventSpy: No value present` => the SettingsBuilderRequest event is not there |
50 changes: 50 additions & 0 deletions
50
its/core-it-suite/src/test/resources/mng-8461/extension/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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.maven.its.mng8461</groupId> | ||
<artifactId>reproducer</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<maven.compiler.source>17</maven.compiler.source> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-core</artifactId> | ||
<version>4.0.0-rc-2</version> | ||
<scope>provided</scope> | ||
<!-- always provided by the Maven Core Classloader --> | ||
</dependency> | ||
<!-- dependency for JSR 330 annotation --> | ||
<dependency> | ||
<groupId>javax.inject</groupId> | ||
<artifactId>javax.inject</artifactId> | ||
<version>1</version> | ||
<scope>provided</scope> | ||
<!-- always provided by the Maven Core Classloader --> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.eclipse.sisu</groupId> | ||
<artifactId>sisu-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>index-project</id> | ||
<goals> | ||
<goal>main-index</goal> | ||
<goal>test-index</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
64 changes: 64 additions & 0 deletions
64
...suite/src/test/resources/mng-8461/extension/src/main/java/org/example/SimpleEventSpy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* 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.example; | ||
|
||
import javax.inject.Named; | ||
import javax.inject.Singleton; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.apache.maven.api.services.SettingsBuilderRequest; | ||
import org.apache.maven.api.services.SettingsBuilderResult; | ||
import org.apache.maven.api.services.ToolchainsBuilderRequest; | ||
import org.apache.maven.api.services.ToolchainsBuilderResult; | ||
import org.apache.maven.eventspy.EventSpy; | ||
|
||
@Named("simple") | ||
@Singleton | ||
public class SimpleEventSpy implements EventSpy { | ||
private final List<Object> events = new ArrayList<>(); | ||
|
||
@Override | ||
public void init(Context context) throws Exception { | ||
System.out.println("Initializing Simple Event Spy"); | ||
} | ||
|
||
@Override | ||
public void onEvent(Object o) throws Exception { | ||
events.add(o); | ||
} | ||
|
||
@Override | ||
public void close() throws Exception { | ||
System.out.println("Closing Simple Event Spy, checking events"); | ||
checkEvent(SettingsBuilderRequest.class); | ||
checkEvent(SettingsBuilderResult.class); | ||
checkEvent(ToolchainsBuilderRequest.class); | ||
checkEvent(ToolchainsBuilderResult.class); | ||
} | ||
|
||
private void checkEvent(Class<?> clazz) { | ||
if (!events.stream().anyMatch(e -> clazz.isAssignableFrom(e.getClass()))) { | ||
System.out.println(clazz.getSimpleName() + " event is absent"); | ||
} else { | ||
System.out.println(clazz.getSimpleName() + " event is present"); | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
its/core-it-suite/src/test/resources/mng-8461/project/.mvn/extensions.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<extensions> | ||
<extension> | ||
<groupId>org.apache.maven.its.mng8461</groupId> | ||
<artifactId>reproducer</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
</extension> | ||
</extensions> |
10 changes: 10 additions & 0 deletions
10
its/core-it-suite/src/test/resources/mng-8461/project/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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 https://maven.apache.org/maven-v4_0_0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.apache.maven.its.mng8461</groupId> | ||
<artifactId>project</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
|
||
</project> |