From 873ebeda51f4355dd3a19c1e326befc61710dbcb Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Tue, 30 Jan 2024 20:39:54 +0100 Subject: [PATCH] Add dependency to jakarta.annotation-api and more tests --- pom.xml | 8 ++++++ .../plexus/testing/PlexusTestJakartaTest.java | 7 +++++ .../plexus/testing/TestJakartaComponent.java | 28 +++++++++++++++++++ .../plexus/testing/TestJakartaComponent3.java | 25 +++++++++++++++++ 4 files changed, 68 insertions(+) create mode 100644 src/test/java/org/codehaus/plexus/testing/TestJakartaComponent3.java diff --git a/pom.xml b/pom.xml index 98ac317..fd2517d 100644 --- a/pom.xml +++ b/pom.xml @@ -62,6 +62,14 @@ guice 6.0.0 + + jakarta.annotation + jakarta.annotation-api + 2.1.1 + provided + true + + org.junit.jupiter junit-jupiter-api diff --git a/src/test/java/org/codehaus/plexus/testing/PlexusTestJakartaTest.java b/src/test/java/org/codehaus/plexus/testing/PlexusTestJakartaTest.java index 0da3636..c9ae806 100644 --- a/src/test/java/org/codehaus/plexus/testing/PlexusTestJakartaTest.java +++ b/src/test/java/org/codehaus/plexus/testing/PlexusTestJakartaTest.java @@ -23,6 +23,7 @@ import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; @PlexusTest class PlexusTestJakartaTest { @@ -34,6 +35,12 @@ class PlexusTestJakartaTest { void dependencyShouldBeInjected() { assertNotNull(testJakartaComponent); assertNotNull(testJakartaComponent.getTestJakartaComponent2()); + assertNotNull(testJakartaComponent.getTestJakartaComponent3Named()); + assertNull(testJakartaComponent.getTestJakartaComponent3NullableJavax()); + assertNull(testJakartaComponent.getTestJakartaComponent3NullableJakarta()); + + assertNotNull(testJakartaComponent.getTestJavaxComponent2()); + assertNotNull(testJakartaComponent.getTestJavaxComponent2()); assertNotNull(testJakartaComponent.getTestJavaxComponent2()); } } diff --git a/src/test/java/org/codehaus/plexus/testing/TestJakartaComponent.java b/src/test/java/org/codehaus/plexus/testing/TestJakartaComponent.java index ac71e40..64e9e10 100644 --- a/src/test/java/org/codehaus/plexus/testing/TestJakartaComponent.java +++ b/src/test/java/org/codehaus/plexus/testing/TestJakartaComponent.java @@ -19,6 +19,7 @@ * under the License. */ +import jakarta.annotation.Nonnull; import jakarta.inject.Inject; import jakarta.inject.Named; @@ -30,6 +31,21 @@ public class TestJakartaComponent { @Inject private TestJakartaComponent2 testJakartaComponent2; + @Inject + @Nonnull + @Named("someComponent") + private TestJakartaComponent3 testJakartaComponent3Named; + + @Inject + @javax.annotation.Nullable + @Named("someComponentNotExisting") + private TestJakartaComponent3 testJakartaComponent3NullableJavax; + + @Inject + @jakarta.annotation.Nullable + @Named("someComponentNotExisting") + private TestJakartaComponent3 testJakartaComponent3NullableJakarta; + public TestJavaxComponent2 getTestJavaxComponent2() { return testJavaxComponent2; } @@ -37,4 +53,16 @@ public TestJavaxComponent2 getTestJavaxComponent2() { public TestJakartaComponent2 getTestJakartaComponent2() { return testJakartaComponent2; } + + public TestJakartaComponent3 getTestJakartaComponent3Named() { + return testJakartaComponent3Named; + } + + public TestJakartaComponent3 getTestJakartaComponent3NullableJavax() { + return testJakartaComponent3NullableJavax; + } + + public TestJakartaComponent3 getTestJakartaComponent3NullableJakarta() { + return testJakartaComponent3NullableJakarta; + } } diff --git a/src/test/java/org/codehaus/plexus/testing/TestJakartaComponent3.java b/src/test/java/org/codehaus/plexus/testing/TestJakartaComponent3.java new file mode 100644 index 0000000..1bf0e49 --- /dev/null +++ b/src/test/java/org/codehaus/plexus/testing/TestJakartaComponent3.java @@ -0,0 +1,25 @@ +package org.codehaus.plexus.testing; + +/* + * 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. + */ + +import javax.inject.Named; + +@Named("someComponent") +public class TestJakartaComponent3 {}