Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dependency to jakarta.annotation-api and more tests #63

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {}