forked from quarkusio/quarkus
-
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.
ArC - producers - change the client proxy class package
- use the package of the return type/field type - previously, the package of the declaring class was used - resolves quarkusio#22815
- Loading branch information
Showing
9 changed files
with
154 additions
and
10 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
...o/quarkus/arc/test/unproxyable/ProducerReturnTypePackagePrivateNoArgsConstructorTest.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,51 @@ | ||
package io.quarkus.arc.test.unproxyable; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.io.IOException; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.enterprise.inject.Instance; | ||
import javax.enterprise.inject.Produces; | ||
import javax.inject.Inject; | ||
import javax.inject.Singleton; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.arc.test.unproxyable.some.Resource; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class ProducerReturnTypePackagePrivateNoArgsConstructorTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot(root -> root | ||
.addClasses(ProducerReturnTypePackagePrivateNoArgsConstructorTest.class, ResourceProducer.class, | ||
Resource.class)); | ||
|
||
@Inject | ||
Instance<Resource> instance; | ||
|
||
@Test | ||
public void testProducer() throws IOException { | ||
assertTrue(instance.isResolvable()); | ||
assertEquals(5, instance.get().ping()); | ||
} | ||
|
||
@Singleton | ||
static class ResourceProducer { | ||
|
||
protected ResourceProducer() { | ||
} | ||
|
||
@ApplicationScoped | ||
@Produces | ||
Resource resource() { | ||
return Resource.from(5); | ||
} | ||
|
||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
extensions/arc/deployment/src/test/java/io/quarkus/arc/test/unproxyable/some/Resource.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,20 @@ | ||
package io.quarkus.arc.test.unproxyable.some; | ||
|
||
public abstract class Resource { | ||
|
||
Resource() { | ||
} | ||
|
||
public static Resource from(int ping) { | ||
return new Resource() { | ||
|
||
@Override | ||
public int ping() { | ||
return ping; | ||
} | ||
}; | ||
} | ||
|
||
public abstract int ping(); | ||
|
||
} |
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
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
42 changes: 42 additions & 0 deletions
42
...c/test/clientproxy/constructor/ProducerReturnTypePackagePrivateNoArgsConstructorTest.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,42 @@ | ||
package io.quarkus.arc.test.clientproxy.constructor; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import io.quarkus.arc.Arc; | ||
import io.quarkus.arc.ClientProxy; | ||
import io.quarkus.arc.test.ArcTestContainer; | ||
import io.quarkus.arc.test.clientproxy.constructor.some.Resource; | ||
import java.io.IOException; | ||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.enterprise.inject.Produces; | ||
import javax.inject.Singleton; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
public class ProducerReturnTypePackagePrivateNoArgsConstructorTest { | ||
|
||
@RegisterExtension | ||
public ArcTestContainer container = new ArcTestContainer(ResourceProducer.class); | ||
|
||
@Test | ||
public void testProducer() throws IOException { | ||
Resource res = Arc.container().instance(Resource.class).get(); | ||
assertNotNull(res); | ||
assertTrue(res instanceof ClientProxy); | ||
assertEquals(5, res.ping()); | ||
} | ||
|
||
@Singleton | ||
static class ResourceProducer { | ||
|
||
@ApplicationScoped | ||
@Produces | ||
Resource resource() { | ||
return Resource.from(5); | ||
} | ||
|
||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
...ts/arc/tests/src/test/java/io/quarkus/arc/test/clientproxy/constructor/some/Resource.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,20 @@ | ||
package io.quarkus.arc.test.clientproxy.constructor.some; | ||
|
||
public abstract class Resource { | ||
|
||
Resource() { | ||
} | ||
|
||
public static Resource from(int ping) { | ||
return new Resource() { | ||
|
||
@Override | ||
public int ping() { | ||
return ping; | ||
} | ||
}; | ||
} | ||
|
||
public abstract int ping(); | ||
|
||
} |