Skip to content

Commit ea0b4e5

Browse files
authored
[MNG-8220] Add IT to check DI in extensions (#355)
* [MNG-8220] Add IT to check DI in extensions
1 parent 92734d4 commit ea0b4e5

File tree

9 files changed

+203
-0
lines changed

9 files changed

+203
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.maven.it;
20+
21+
import java.io.File;
22+
23+
import org.apache.maven.shared.verifier.Verifier;
24+
import org.apache.maven.shared.verifier.util.ResourceExtractor;
25+
import org.junit.jupiter.api.Test;
26+
27+
/**
28+
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-8220">MNG-8220</a>.
29+
*/
30+
public class MavenITmng8220ExtensionWithDITest extends AbstractMavenIntegrationTestCase {
31+
public MavenITmng8220ExtensionWithDITest() {
32+
super("[4.0.0-beta-4,)");
33+
}
34+
35+
/**
36+
* Verify that the central url can be overridden by a user property.
37+
*
38+
* @throws Exception in case of failure
39+
*/
40+
@Test
41+
public void testitModel() throws Exception {
42+
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-8220-extension-with-di");
43+
44+
Verifier verifier = newVerifier(new File(testDir, "extension").getAbsolutePath());
45+
verifier.addCliArgument("install");
46+
verifier.execute();
47+
verifier.verifyErrorFreeLog();
48+
49+
verifier = newVerifier(new File(testDir, "test").getAbsolutePath());
50+
verifier.addCliArgument("validate");
51+
verifier.execute();
52+
verifier.verifyErrorFreeLog();
53+
verifier.verifyTextInLog("[MNG-8220] DumbModelParser Called from extension");
54+
}
55+
}

core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ public TestSuiteOrdering() {
120120
* the tests are to finishing. Newer tests are also more likely to fail, so this is
121121
* a fail fast technique as well.
122122
*/
123+
suite.addTestSuite(MavenITmng8220ExtensionWithDITest.class);
123124
suite.addTestSuite(MavenITmng8181CentralRepoTest.class);
124125
suite.addTestSuite(MavenITmng8123BuildCacheTest.class);
125126
suite.addTestSuite(MavenITmng8106OverlappingDirectoryRolesTest.class);

core-it-suite/src/test/resources-filtered/bootstrap.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ org.apache.commons:commons-text:1.10.0
1919
org.apache.geronimo.specs:geronimo-jcdi_2.0_spec:1.3
2020
org.apache.groovy:groovy-ant:4.0.15
2121
org.apache.groovy:groovy:4.0.15
22+
org.apache.maven:maven-api-impl:4.0.0-beta-3
2223
org.apache.maven:maven-api-spi:4.0.0-alpha-8
2324
org.apache.maven:maven-api-model:mdo:4.0.0-alpha-8
2425
org.apache.maven.extensions:maven-extensions:pom:41
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
-->
20+
<project xmlns="http://maven.apache.org/POM/4.1.0">
21+
<groupId>org.apache.maven.its.mng8220</groupId>
22+
<artifactId>extension</artifactId>
23+
<version>1.0-SNAPSHOT</version>
24+
<packaging>jar</packaging>
25+
26+
<dependencies>
27+
<dependency>
28+
<groupId>org.apache.maven</groupId>
29+
<artifactId>maven-api-di</artifactId>
30+
<version>4.0.0-beta-3</version>
31+
</dependency>
32+
<dependency>
33+
<groupId>org.apache.maven</groupId>
34+
<artifactId>maven-api-impl</artifactId>
35+
<version>4.0.0-beta-3</version>
36+
</dependency>
37+
</dependencies>
38+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.maven.its.mng8220.extension;
20+
21+
import java.nio.file.Path;
22+
import java.util.Map;
23+
import java.util.Optional;
24+
25+
import org.apache.maven.api.di.Inject;
26+
import org.apache.maven.api.di.Named;
27+
import org.apache.maven.api.di.Singleton;
28+
import org.apache.maven.api.model.Model;
29+
import org.apache.maven.api.services.Source;
30+
import org.apache.maven.api.spi.ModelParser;
31+
import org.apache.maven.api.spi.ModelParserException;
32+
import org.slf4j.Logger;
33+
import org.slf4j.LoggerFactory;
34+
35+
@Singleton
36+
@Named
37+
final class DumbModelParser implements ModelParser {
38+
39+
private final Logger logger = LoggerFactory.getLogger(getClass());
40+
41+
@Inject
42+
public DumbModelParser() {}
43+
44+
@Override
45+
public Optional<Source> locate(Path dir) {
46+
logger.warn("[MNG-8220] DumbModelParser Called from extension");
47+
return Optional.empty();
48+
}
49+
50+
@Override
51+
public Model parse(Source source, Map<String, ?> options) throws ModelParserException {
52+
return null;
53+
}
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.apache.maven.its.mng8220.extension.DumbModelParser
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<extensions>
2+
<extension>
3+
<groupId>org.apache.maven.its.mng8220</groupId>
4+
<artifactId>extension</artifactId>
5+
<version>1.0-SNAPSHOT</version>
6+
</extension>
7+
</extensions>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
-->
20+
<project xmlns="http://maven.apache.org/POM/4.1.0">
21+
<groupId>org.apache.maven.its.mng8220</groupId>
22+
<artifactId>extension</artifactId>
23+
<version>1.0-SNAPSHOT</version>
24+
<packaging>jar</packaging>
25+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.maven.its.mng8220.test;
20+
21+
public class Dumb {}

0 commit comments

Comments
 (0)