-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
235 additions
and
0 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
26 changes: 26 additions & 0 deletions
26
...cts/arc/tests/src/test/java17/io/quarkus/arc/test/java17/records/DependentRecordTest.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,26 @@ | ||
package io.quarkus.arc.test.java17.records; | ||
|
||
import io.quarkus.arc.Arc; | ||
import io.quarkus.arc.test.ArcTestContainer; | ||
import jakarta.enterprise.context.Dependent; | ||
import jakarta.enterprise.inject.spi.DeploymentException; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertInstanceOf; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class DependentRecordTest { | ||
@RegisterExtension | ||
public ArcTestContainer container = new ArcTestContainer(DependentRecord.class); | ||
|
||
@Test | ||
public void test() { | ||
assertNotNull(Arc.container().select(DependentRecord.class).get()); | ||
} | ||
|
||
@Dependent | ||
record DependentRecord() { | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
...s/arc/tests/src/test/java17/io/quarkus/arc/test/java17/records/InterceptedRecordTest.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,65 @@ | ||
package io.quarkus.arc.test.java17.records; | ||
|
||
import io.quarkus.arc.test.ArcTestContainer; | ||
import io.quarkus.arc.test.interceptors.targetclass.mixed.AroundInvokeOnTargetClassAndOutsideAndManySuperclassesWithOverridesTest; | ||
import jakarta.annotation.Priority; | ||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.enterprise.context.Dependent; | ||
import jakarta.enterprise.inject.spi.DeploymentException; | ||
import jakarta.interceptor.AroundInvoke; | ||
import jakarta.interceptor.Interceptor; | ||
import jakarta.interceptor.InterceptorBinding; | ||
import jakarta.interceptor.InvocationContext; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertInstanceOf; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class InterceptedRecordTest { | ||
@RegisterExtension | ||
public ArcTestContainer container = ArcTestContainer.builder() | ||
.beanClasses(DependentRecord.class, MyInterceptorBinding.class, MyInterceptor.class) | ||
.shouldFail() | ||
.build(); | ||
|
||
@Test | ||
public void trigger() { | ||
Throwable error = container.getFailure(); | ||
assertNotNull(error); | ||
assertInstanceOf(DeploymentException.class, error); | ||
assertTrue(error.getMessage().contains("records are always final")); | ||
} | ||
|
||
@Dependent | ||
record DependentRecord() { | ||
@MyInterceptorBinding | ||
String hello() { | ||
return "hello"; | ||
} | ||
} | ||
|
||
@Target({ ElementType.TYPE, ElementType.METHOD }) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Documented | ||
@InterceptorBinding | ||
@interface MyInterceptorBinding { | ||
} | ||
|
||
@MyInterceptorBinding | ||
@Interceptor | ||
@Priority(1) | ||
static class MyInterceptor { | ||
@AroundInvoke | ||
Object intercept(InvocationContext ctx) throws Exception { | ||
return "intercepted: " + ctx.proceed(); | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...ts/src/test/java17/io/quarkus/arc/test/java17/records/NormalScopedRecordProducerTest.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,41 @@ | ||
package io.quarkus.arc.test.java17.records; | ||
|
||
import io.quarkus.arc.test.ArcTestContainer; | ||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.enterprise.context.Dependent; | ||
import jakarta.enterprise.inject.Produces; | ||
import jakarta.enterprise.inject.spi.DeploymentException; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertInstanceOf; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class NormalScopedRecordProducerTest { | ||
@RegisterExtension | ||
public ArcTestContainer container = ArcTestContainer.builder() | ||
.beanClasses(Producer.class) | ||
.shouldFail() | ||
.build(); | ||
|
||
@Test | ||
public void trigger() { | ||
Throwable error = container.getFailure(); | ||
assertNotNull(error); | ||
assertInstanceOf(DeploymentException.class, error); | ||
assertTrue(error.getMessage().contains("records are always final")); | ||
} | ||
|
||
@Dependent | ||
static class Producer { | ||
@Produces | ||
@ApplicationScoped | ||
MyRecord produce() { | ||
return new MyRecord(); | ||
} | ||
} | ||
|
||
record MyRecord() { | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
.../arc/tests/src/test/java17/io/quarkus/arc/test/java17/records/NormalScopedRecordTest.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,31 @@ | ||
package io.quarkus.arc.test.java17.records; | ||
|
||
import io.quarkus.arc.test.ArcTestContainer; | ||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.enterprise.inject.spi.DeploymentException; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertInstanceOf; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class NormalScopedRecordTest { | ||
@RegisterExtension | ||
public ArcTestContainer container = ArcTestContainer.builder() | ||
.beanClasses(NormalScopedRecord.class) | ||
.shouldFail() | ||
.build(); | ||
|
||
@Test | ||
public void trigger() { | ||
Throwable error = container.getFailure(); | ||
assertNotNull(error); | ||
assertInstanceOf(DeploymentException.class, error); | ||
assertTrue(error.getMessage().contains("records are always final")); | ||
} | ||
|
||
@ApplicationScoped | ||
record NormalScopedRecord() { | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...tests/src/test/java17/io/quarkus/arc/test/java17/records/SingletonRecordProducerTest.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,37 @@ | ||
package io.quarkus.arc.test.java17.records; | ||
|
||
import io.quarkus.arc.Arc; | ||
import io.quarkus.arc.test.ArcTestContainer; | ||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.enterprise.context.Dependent; | ||
import jakarta.enterprise.inject.Produces; | ||
import jakarta.enterprise.inject.spi.DeploymentException; | ||
import jakarta.inject.Singleton; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertInstanceOf; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class SingletonRecordProducerTest { | ||
@RegisterExtension | ||
public ArcTestContainer container = new ArcTestContainer(Producer.class); | ||
|
||
@Test | ||
public void test() { | ||
assertNotNull(Arc.container().select(MyRecord.class).get()); | ||
} | ||
|
||
@Dependent | ||
static class Producer { | ||
@Produces | ||
@Singleton | ||
MyRecord produce() { | ||
return new MyRecord(); | ||
} | ||
} | ||
|
||
record MyRecord() { | ||
} | ||
} |