Skip to content

Commit

Permalink
Add dependency to jakarta.annotation-api and more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
slachiewicz committed May 14, 2024
1 parent ae72f9b commit 5205012
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@
<artifactId>guice</artifactId>
<version>6.0.0</version>
</dependency>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>2.1.1</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* under the License.
*/

import jakarta.annotation.Nonnull;
import jakarta.inject.Inject;
import jakarta.inject.Named;

Expand All @@ -30,11 +31,38 @@ 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;
}

public TestJakartaComponent2 getTestJakartaComponent2() {
return testJakartaComponent2;
}

public TestJakartaComponent3 getTestJakartaComponent3Named() {
return testJakartaComponent3Named;
}

public TestJakartaComponent3 getTestJakartaComponent3NullableJavax() {
return testJakartaComponent3NullableJavax;
}

public TestJakartaComponent3 getTestJakartaComponent3NullableJakarta() {
return testJakartaComponent3NullableJakarta;
}
}
Original file line number Diff line number Diff line change
@@ -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 {}

0 comments on commit 5205012

Please sign in to comment.