forked from helidon-io/helidon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Dmitry Aleksandrov <dmitry.aleksandrov@oracle.com>
- Loading branch information
1 parent
77936c6
commit ec3b0db
Showing
10 changed files
with
279 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...profile/testing/junit5/src/main/java/io/helidon/microprofile/testing/junit5/AddJaxRs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright (c) 2023 Oracle and/or its affiliates. | ||
* | ||
* Licensed 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. | ||
*/ | ||
package io.helidon.microprofile.testing.junit5; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Add JaxRS support for Request-scoped beans. | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.TYPE, ElementType.METHOD}) | ||
public @interface AddJaxRs { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...profile/testing/testng/src/main/java/io/helidon/microprofile/testing/testng/AddJaxRs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright (c) 2023 Oracle and/or its affiliates. | ||
* | ||
* Licensed 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. | ||
*/ | ||
package io.helidon.microprofile.testing.testng; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Add JaxRS support for Request-scoped beans. | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.TYPE, ElementType.METHOD}) | ||
public @interface AddJaxRs { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...test/java/io/helidon/microprofile/tests/testing/junit5/TestReqScopeDisabledDiscovery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package io.helidon.microprofile.tests.testing.junit5; | ||
|
||
import io.helidon.microprofile.server.JaxRsCdiExtension; | ||
import io.helidon.microprofile.server.ServerCdiExtension; | ||
import io.helidon.microprofile.testing.junit5.*; | ||
import jakarta.enterprise.context.RequestScoped; | ||
import jakarta.inject.Inject; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.client.WebTarget; | ||
import jakarta.ws.rs.core.Response; | ||
import org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
@HelidonTest | ||
@DisableDiscovery | ||
@AddExtension(ServerCdiExtension.class) | ||
@AddExtension(JaxRsCdiExtension.class) | ||
@AddExtension(CdiComponentProvider.class) | ||
|
||
// JAX-RS Request scope | ||
@AddJaxRs | ||
@AddBean(TestReqScopeDisabledDiscovery.MyController.class) | ||
public class TestReqScopeDisabledDiscovery { | ||
@Inject | ||
private WebTarget target; | ||
|
||
@Test | ||
void testGet() { | ||
assertEquals("Hallo!", target | ||
.path("/greeting") | ||
.request() | ||
.get(String.class)); | ||
} | ||
|
||
@Path("/greeting") | ||
@RequestScoped | ||
public static class MyController { | ||
@GET | ||
public Response get() { | ||
return Response.ok("Hallo!").build(); | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...test/java/io/helidon/microprofile/tests/testing/testng/TestReqScopeDisabledDiscovery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package io.helidon.microprofile.tests.testing.testng; | ||
|
||
|
||
import io.helidon.microprofile.server.JaxRsCdiExtension; | ||
import io.helidon.microprofile.server.ServerCdiExtension; | ||
import io.helidon.microprofile.testing.testng.*; | ||
import jakarta.enterprise.context.RequestScoped; | ||
import jakarta.inject.Inject; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.client.WebTarget; | ||
import jakarta.ws.rs.core.Response; | ||
import org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider; | ||
import org.testng.annotations.Test; | ||
|
||
import static org.testng.AssertJUnit.assertEquals; | ||
|
||
@HelidonTest | ||
@DisableDiscovery | ||
@AddExtension(ServerCdiExtension.class) | ||
@AddExtension(JaxRsCdiExtension.class) | ||
@AddExtension(CdiComponentProvider.class) | ||
|
||
// JAX-RS Request scope | ||
@AddJaxRs | ||
@AddBean(TestReqScopeDisabledDiscovery.MyController.class) | ||
public class TestReqScopeDisabledDiscovery { | ||
|
||
@Inject | ||
private WebTarget target; | ||
|
||
//@Test | ||
void testGet() { | ||
assertEquals("Hallo!", target | ||
.path("/greeting") | ||
.request() | ||
.get(String.class)); | ||
} | ||
|
||
@Path("/greeting") | ||
@RequestScoped | ||
public static class MyController { | ||
@GET | ||
public Response get() { | ||
return Response.ok("Hallo!").build(); | ||
} | ||
} | ||
} |