Skip to content

Commit 873ebed

Browse files
committed
Add dependency to jakarta.annotation-api and more tests
1 parent 3fe1855 commit 873ebed

File tree

4 files changed

+68
-0
lines changed

4 files changed

+68
-0
lines changed

pom.xml

+8
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@
6262
<artifactId>guice</artifactId>
6363
<version>6.0.0</version>
6464
</dependency>
65+
<dependency>
66+
<groupId>jakarta.annotation</groupId>
67+
<artifactId>jakarta.annotation-api</artifactId>
68+
<version>2.1.1</version>
69+
<scope>provided</scope>
70+
<optional>true</optional>
71+
</dependency>
72+
6573
<dependency>
6674
<groupId>org.junit.jupiter</groupId>
6775
<artifactId>junit-jupiter-api</artifactId>

src/test/java/org/codehaus/plexus/testing/PlexusTestJakartaTest.java

+7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.junit.jupiter.api.Test;
2424

2525
import static org.junit.jupiter.api.Assertions.assertNotNull;
26+
import static org.junit.jupiter.api.Assertions.assertNull;
2627

2728
@PlexusTest
2829
class PlexusTestJakartaTest {
@@ -34,6 +35,12 @@ class PlexusTestJakartaTest {
3435
void dependencyShouldBeInjected() {
3536
assertNotNull(testJakartaComponent);
3637
assertNotNull(testJakartaComponent.getTestJakartaComponent2());
38+
assertNotNull(testJakartaComponent.getTestJakartaComponent3Named());
39+
assertNull(testJakartaComponent.getTestJakartaComponent3NullableJavax());
40+
assertNull(testJakartaComponent.getTestJakartaComponent3NullableJakarta());
41+
42+
assertNotNull(testJakartaComponent.getTestJavaxComponent2());
43+
assertNotNull(testJakartaComponent.getTestJavaxComponent2());
3744
assertNotNull(testJakartaComponent.getTestJavaxComponent2());
3845
}
3946
}

src/test/java/org/codehaus/plexus/testing/TestJakartaComponent.java

+28
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
* under the License.
2020
*/
2121

22+
import jakarta.annotation.Nonnull;
2223
import jakarta.inject.Inject;
2324
import jakarta.inject.Named;
2425

@@ -30,11 +31,38 @@ public class TestJakartaComponent {
3031
@Inject
3132
private TestJakartaComponent2 testJakartaComponent2;
3233

34+
@Inject
35+
@Nonnull
36+
@Named("someComponent")
37+
private TestJakartaComponent3 testJakartaComponent3Named;
38+
39+
@Inject
40+
@javax.annotation.Nullable
41+
@Named("someComponentNotExisting")
42+
private TestJakartaComponent3 testJakartaComponent3NullableJavax;
43+
44+
@Inject
45+
@jakarta.annotation.Nullable
46+
@Named("someComponentNotExisting")
47+
private TestJakartaComponent3 testJakartaComponent3NullableJakarta;
48+
3349
public TestJavaxComponent2 getTestJavaxComponent2() {
3450
return testJavaxComponent2;
3551
}
3652

3753
public TestJakartaComponent2 getTestJakartaComponent2() {
3854
return testJakartaComponent2;
3955
}
56+
57+
public TestJakartaComponent3 getTestJakartaComponent3Named() {
58+
return testJakartaComponent3Named;
59+
}
60+
61+
public TestJakartaComponent3 getTestJakartaComponent3NullableJavax() {
62+
return testJakartaComponent3NullableJavax;
63+
}
64+
65+
public TestJakartaComponent3 getTestJakartaComponent3NullableJakarta() {
66+
return testJakartaComponent3NullableJakarta;
67+
}
4068
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.codehaus.plexus.testing;
2+
3+
/*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing,
15+
* software distributed under the License is distributed on an
16+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
* KIND, either express or implied. See the License for the
18+
* specific language governing permissions and limitations
19+
* under the License.
20+
*/
21+
22+
import javax.inject.Named;
23+
24+
@Named("someComponent")
25+
public class TestJakartaComponent3 {}

0 commit comments

Comments
 (0)