-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MNG-8220] Add IT to check DI in extensions (#355)
* [MNG-8220] Add IT to check DI in extensions
- Loading branch information
Showing
9 changed files
with
203 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8220ExtensionWithDITest.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,55 @@ | ||
/* | ||
* 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.io.File; | ||
|
||
import org.apache.maven.shared.verifier.Verifier; | ||
import org.apache.maven.shared.verifier.util.ResourceExtractor; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-8220">MNG-8220</a>. | ||
*/ | ||
public class MavenITmng8220ExtensionWithDITest extends AbstractMavenIntegrationTestCase { | ||
public MavenITmng8220ExtensionWithDITest() { | ||
super("[4.0.0-beta-4,)"); | ||
} | ||
|
||
/** | ||
* Verify that the central url can be overridden by a user property. | ||
* | ||
* @throws Exception in case of failure | ||
*/ | ||
@Test | ||
public void testitModel() throws Exception { | ||
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-8220-extension-with-di"); | ||
|
||
Verifier verifier = newVerifier(new File(testDir, "extension").getAbsolutePath()); | ||
verifier.addCliArgument("install"); | ||
verifier.execute(); | ||
verifier.verifyErrorFreeLog(); | ||
|
||
verifier = newVerifier(new File(testDir, "test").getAbsolutePath()); | ||
verifier.addCliArgument("validate"); | ||
verifier.execute(); | ||
verifier.verifyErrorFreeLog(); | ||
verifier.verifyTextInLog("[MNG-8220] DumbModelParser Called from extension"); | ||
} | ||
} |
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
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
38 changes: 38 additions & 0 deletions
38
core-it-suite/src/test/resources/mng-8220-extension-with-di/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,38 @@ | ||
<?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.1.0"> | ||
<groupId>org.apache.maven.its.mng8220</groupId> | ||
<artifactId>extension</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-api-di</artifactId> | ||
<version>4.0.0-beta-3</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-api-impl</artifactId> | ||
<version>4.0.0-beta-3</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
54 changes: 54 additions & 0 deletions
54
...th-di/extension/src/main/java/org/apache/maven/its/mng8220/extension/DumbModelParser.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,54 @@ | ||
/* | ||
* 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.its.mng8220.extension; | ||
|
||
import java.nio.file.Path; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
import org.apache.maven.api.di.Inject; | ||
import org.apache.maven.api.di.Named; | ||
import org.apache.maven.api.di.Singleton; | ||
import org.apache.maven.api.model.Model; | ||
import org.apache.maven.api.services.Source; | ||
import org.apache.maven.api.spi.ModelParser; | ||
import org.apache.maven.api.spi.ModelParserException; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
@Singleton | ||
@Named | ||
final class DumbModelParser implements ModelParser { | ||
|
||
private final Logger logger = LoggerFactory.getLogger(getClass()); | ||
|
||
@Inject | ||
public DumbModelParser() {} | ||
|
||
@Override | ||
public Optional<Source> locate(Path dir) { | ||
logger.warn("[MNG-8220] DumbModelParser Called from extension"); | ||
return Optional.empty(); | ||
} | ||
|
||
@Override | ||
public Model parse(Source source, Map<String, ?> options) throws ModelParserException { | ||
return null; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...ension-with-di/extension/src/main/resources/META-INF/maven/org.apache.maven.api.di.Inject
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 @@ | ||
org.apache.maven.its.mng8220.extension.DumbModelParser |
7 changes: 7 additions & 0 deletions
7
core-it-suite/src/test/resources/mng-8220-extension-with-di/test/.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.mng8220</groupId> | ||
<artifactId>extension</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
</extension> | ||
</extensions> |
25 changes: 25 additions & 0 deletions
25
core-it-suite/src/test/resources/mng-8220-extension-with-di/test/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,25 @@ | ||
<?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.1.0"> | ||
<groupId>org.apache.maven.its.mng8220</groupId> | ||
<artifactId>extension</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
</project> |
21 changes: 21 additions & 0 deletions
21
...mng-8220-extension-with-di/test/src/main/java/org/apache/maven/its/mng8220/test/Dumb.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,21 @@ | ||
/* | ||
* 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.its.mng8220.test; | ||
|
||
public class Dumb {} |