Skip to content

Commit be48bdd

Browse files
authored
Simplify JUnit dependency management (#11278)
1 parent e92746c commit be48bdd

File tree

7 files changed

+91
-114
lines changed

7 files changed

+91
-114
lines changed

its/core-it-suite/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ under the License.
100100
<dependencies>
101101
<dependency>
102102
<groupId>org.junit.jupiter</groupId>
103-
<artifactId>junit-jupiter</artifactId>
103+
<artifactId>junit-jupiter-api</artifactId>
104104
<!-- NOTE: Use compile scope for transitivity. -->
105105
</dependency>
106106
<dependency>

its/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/pom.xml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,15 @@ under the License.
2222

2323
<!-- We can't use the parent which has managed dependencies
2424
which make the tests using this plugin to fail -->
25-
<!-- <parent>-->
26-
<!-- <groupId>org.apache.maven.its.plugins</groupId>-->
27-
<!-- <artifactId>maven-it-plugins</artifactId>-->
28-
<!-- <version>2.1-SNAPSHOT</version>-->
29-
<!-- <relativePath>../../pom.xml</relativePath>-->
30-
<!-- </parent>-->
25+
<parent>
26+
<groupId>org.apache.maven.its.plugins</groupId>
27+
<artifactId>maven-it-plugins</artifactId>
28+
<version>2.1-SNAPSHOT</version>
29+
<relativePath>../../pom.xml</relativePath>
30+
</parent>
3131

3232
<groupId>org.apache.maven.its.plugins</groupId>
3333
<artifactId>maven-it-plugin-class-loader</artifactId>
34-
<version>2.1-SNAPSHOT</version>
3534
<packaging>maven-plugin</packaging>
3635

3736
<name>Maven IT Plugin :: Class Loader</name>
@@ -58,8 +57,7 @@ under the License.
5857
</dependency>
5958
<dependency>
6059
<groupId>org.junit.jupiter</groupId>
61-
<artifactId>junit-jupiter</artifactId>
62-
<version>5.13.4</version>
60+
<artifactId>junit-jupiter-api</artifactId>
6361
<scope>test</scope>
6462
</dependency>
6563
<!-- dedicated IT artifact that is surely not shadowed by the Maven core -->
Original file line numberDiff line numberDiff line change
@@ -1,3 +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+
*/
119
package org.apache.maven.plugin.coreit;
220

321
/*
@@ -34,107 +52,98 @@
3452
* @author Benjamin Bentmann
3553
*
3654
*/
37-
public class ExpressionUtilTest
38-
{
55+
public class ExpressionUtilTest {
3956

4057
@Test
41-
public void testEvaluate()
42-
{
43-
Object array = new String[]{ "one", "two", "three" };
44-
Object list = Arrays.asList( "0", "-1", "-2" );
45-
Object map = Collections.singletonMap( "some.key", "value" );
58+
public void testEvaluate() {
59+
Object array = new String[] {"one", "two", "three"};
60+
Object list = Arrays.asList("0", "-1", "-2");
61+
Object map = Collections.singletonMap("some.key", "value");
4662
Object bean = new BeanTwo();
4763

4864
Map<String, Object> contexts = new HashMap<>();
49-
contexts.put( "array", array );
50-
contexts.put( "list", list );
51-
contexts.put( "map", map );
52-
contexts.put( "bean", bean );
53-
54-
assertSame( array, evaluate( "array", contexts ) );
55-
assertSame( array, ExpressionUtil.evaluate( "array/", contexts ).get( "array" ) );
56-
assertSame( list, evaluate( "list", contexts ) );
57-
assertSame( map, evaluate( "map", contexts ) );
58-
assertSame( bean, evaluate( "bean", contexts ) );
59-
assertNull( evaluate( "no-root", contexts ) );
60-
61-
assertEquals( 3, evaluate( "array/length", contexts ) );
62-
assertEquals( "three", evaluate( "array/2", contexts ) );
63-
assertEquals( 5, evaluate( "array/2/length", contexts ) );
64-
assertNull( evaluate( "array/invalid", contexts ) );
65-
assertNull( evaluate( "array/-1", contexts ) );
66-
assertNull( evaluate( "array/999", contexts ) );
67-
assertEquals( 3, ExpressionUtil.evaluate( "array/*", contexts ).size() );
68-
assertEquals( "one", ExpressionUtil.evaluate( "array/*", contexts ).get( "array/0" ) );
69-
assertEquals( "two", ExpressionUtil.evaluate( "array/*", contexts ).get( "array/1" ) );
70-
assertEquals( "three", ExpressionUtil.evaluate( "array/*", contexts ).get( "array/2" ) );
71-
72-
assertEquals( 3, evaluate( "list/size", contexts ) );
73-
assertEquals( "-2", evaluate( "list/2", contexts ) );
74-
assertNull( evaluate( "list/invalid", contexts ) );
75-
assertNull( evaluate( "list/-1", contexts ) );
76-
assertNull( evaluate( "list/999", contexts ) );
77-
assertEquals( 3, ExpressionUtil.evaluate( "list/*", contexts ).size() );
78-
assertEquals( "0", ExpressionUtil.evaluate( "list/*", contexts ).get( "list/0" ) );
79-
assertEquals( "-1", ExpressionUtil.evaluate( "list/*", contexts ).get( "list/1" ) );
80-
assertEquals( "-2", ExpressionUtil.evaluate( "list/*", contexts ).get( "list/2" ) );
81-
82-
assertEquals( 1, evaluate( "map/size", contexts ) );
83-
assertEquals( "value", evaluate( "map/some.key", contexts ) );
84-
assertNull( evaluate( "map/invalid", contexts ) );
85-
86-
assertEquals( "field", evaluate( "bean/field", contexts ) );
87-
assertNull( evaluate( "bean/invalid", contexts ) );
88-
assertEquals( "prop", evaluate( "bean/bean/prop", contexts ) );
89-
assertEquals( "flag", evaluate( "bean/bean/flag", contexts ) );
90-
assertEquals( "arg", evaluate( "bean/bean/arg", contexts ) );
65+
contexts.put("array", array);
66+
contexts.put("list", list);
67+
contexts.put("map", map);
68+
contexts.put("bean", bean);
69+
70+
assertSame(array, evaluate("array", contexts));
71+
assertSame(array, ExpressionUtil.evaluate("array/", contexts).get("array"));
72+
assertSame(list, evaluate("list", contexts));
73+
assertSame(map, evaluate("map", contexts));
74+
assertSame(bean, evaluate("bean", contexts));
75+
assertNull(evaluate("no-root", contexts));
76+
77+
assertEquals(3, evaluate("array/length", contexts));
78+
assertEquals("three", evaluate("array/2", contexts));
79+
assertEquals(5, evaluate("array/2/length", contexts));
80+
assertNull(evaluate("array/invalid", contexts));
81+
assertNull(evaluate("array/-1", contexts));
82+
assertNull(evaluate("array/999", contexts));
83+
assertEquals(3, ExpressionUtil.evaluate("array/*", contexts).size());
84+
assertEquals("one", ExpressionUtil.evaluate("array/*", contexts).get("array/0"));
85+
assertEquals("two", ExpressionUtil.evaluate("array/*", contexts).get("array/1"));
86+
assertEquals("three", ExpressionUtil.evaluate("array/*", contexts).get("array/2"));
87+
88+
assertEquals(3, evaluate("list/size", contexts));
89+
assertEquals("-2", evaluate("list/2", contexts));
90+
assertNull(evaluate("list/invalid", contexts));
91+
assertNull(evaluate("list/-1", contexts));
92+
assertNull(evaluate("list/999", contexts));
93+
assertEquals(3, ExpressionUtil.evaluate("list/*", contexts).size());
94+
assertEquals("0", ExpressionUtil.evaluate("list/*", contexts).get("list/0"));
95+
assertEquals("-1", ExpressionUtil.evaluate("list/*", contexts).get("list/1"));
96+
assertEquals("-2", ExpressionUtil.evaluate("list/*", contexts).get("list/2"));
97+
98+
assertEquals(1, evaluate("map/size", contexts));
99+
assertEquals("value", evaluate("map/some.key", contexts));
100+
assertNull(evaluate("map/invalid", contexts));
101+
102+
assertEquals("field", evaluate("bean/field", contexts));
103+
assertNull(evaluate("bean/invalid", contexts));
104+
assertEquals("prop", evaluate("bean/bean/prop", contexts));
105+
assertEquals("flag", evaluate("bean/bean/flag", contexts));
106+
assertEquals("arg", evaluate("bean/bean/arg", contexts));
91107
}
92108

93-
private static Object evaluate( String expression, Object context )
94-
{
95-
return ExpressionUtil.evaluate( expression, context ).get( expression );
109+
private static Object evaluate(String expression, Object context) {
110+
return ExpressionUtil.evaluate(expression, context).get(expression);
96111
}
97112

98113
@Test
99-
public void testGetProperty()
100-
{
114+
public void testGetProperty() {
101115
BeanOne bean1 = new BeanOne();
102116
BeanTwo bean2 = new BeanTwo();
103117

104-
assertEquals( bean1.isFlag(), ExpressionUtil.getProperty( bean1, "flag" ) );
105-
assertEquals( bean1.getProp(), ExpressionUtil.getProperty( bean1, "prop" ) );
106-
assertEquals( bean1.get( "get" ), ExpressionUtil.getProperty( bean1, "get" ) );
118+
assertEquals(bean1.isFlag(), ExpressionUtil.getProperty(bean1, "flag"));
119+
assertEquals(bean1.getProp(), ExpressionUtil.getProperty(bean1, "prop"));
120+
assertEquals(bean1.get("get"), ExpressionUtil.getProperty(bean1, "get"));
107121

108-
assertNull( ExpressionUtil.getProperty( bean2, "invalid" ) );
109-
assertEquals( bean2.field, ExpressionUtil.getProperty( bean2, "field" ) );
110-
assertSame( bean2.bean, ExpressionUtil.getProperty( bean2, "bean" ) );
122+
assertNull(ExpressionUtil.getProperty(bean2, "invalid"));
123+
assertEquals(bean2.field, ExpressionUtil.getProperty(bean2, "field"));
124+
assertSame(bean2.bean, ExpressionUtil.getProperty(bean2, "bean"));
111125

112-
assertEquals( 0, ExpressionUtil.getProperty( new String[0], "length" ) );
126+
assertEquals(0, ExpressionUtil.getProperty(new String[0], "length"));
113127
}
114128

115-
public static class BeanOne
116-
{
117-
public String isFlag()
118-
{
129+
public static class BeanOne {
130+
public String isFlag() {
119131
return "flag";
120132
}
121133

122-
public String getProp()
123-
{
134+
public String getProp() {
124135
return "prop";
125136
}
126137

127-
public String get( String arg )
128-
{
138+
public String get(String arg) {
129139
return arg;
130140
}
131141
}
132142

133-
public static class BeanTwo
134-
{
143+
@SuppressWarnings("checkstyle:VisibilityModifier")
144+
public static class BeanTwo {
135145
public String field = "field";
136146

137147
public BeanOne bean = new BeanOne();
138-
139148
}
140149
}

its/core-it-support/core-it-plugins/maven-it-plugin-class-loader/pom.xml

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -37,29 +37,4 @@ under the License.
3737
<module>dep-b</module>
3838
<module>dep-c</module>
3939
</modules>
40-
41-
<build>
42-
<pluginManagement>
43-
<plugins>
44-
<plugin>
45-
<groupId>com.diffplug.spotless</groupId>
46-
<artifactId>spotless-maven-plugin</artifactId>
47-
<configuration>
48-
<java>
49-
<includes>
50-
<include>src/main/java/**/*.java</include>
51-
<include>maven-it-plugin-class-loader/src/main/java/**/*.java</include>
52-
</includes>
53-
</java>
54-
<pom>
55-
<includes>
56-
<include>pom.xml</include>
57-
<include>maven-it-plugin-class-loader/pom.xml</include>
58-
</includes>
59-
</pom>
60-
</configuration>
61-
</plugin>
62-
</plugins>
63-
</pluginManagement>
64-
</build>
6540
</project>

its/core-it-support/core-it-plugins/maven-it-plugin-expression/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ under the License.
4747
</dependency>
4848
<dependency>
4949
<groupId>org.junit.jupiter</groupId>
50-
<artifactId>junit-jupiter</artifactId>
50+
<artifactId>junit-jupiter-api</artifactId>
5151
<scope>test</scope>
5252
</dependency>
5353
</dependencies>

its/core-it-support/maven-it-helper/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ under the License.
4949
</dependency>
5050
<dependency>
5151
<groupId>org.junit.jupiter</groupId>
52-
<artifactId>junit-jupiter</artifactId>
52+
<artifactId>junit-jupiter-api</artifactId>
5353
</dependency>
5454
</dependencies>
5555

its/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,6 @@ under the License.
252252
<artifactId>maven-verifier</artifactId>
253253
<version>2.0.0-M1</version>
254254
</dependency>
255-
<dependency>
256-
<groupId>org.junit.jupiter</groupId>
257-
<artifactId>junit-jupiter</artifactId>
258-
<version>5.13.4</version>
259-
</dependency>
260255
<dependency>
261256
<groupId>org.apache.maven.plugin-tools</groupId>
262257
<artifactId>maven-plugin-tools-java</artifactId>

0 commit comments

Comments
 (0)