-
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.
Merge pull request #25552 from mkouba/arc-client-proxies-context-not-…
…active ArC - improved message for some occurrences of ContextNotActiveException
- Loading branch information
Showing
9 changed files
with
109 additions
and
14 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
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
21 changes: 21 additions & 0 deletions
21
independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/Beans.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,21 @@ | ||
package io.quarkus.arc.impl; | ||
|
||
import io.quarkus.arc.InjectableBean; | ||
|
||
public class Beans { | ||
|
||
private Beans() { | ||
} | ||
|
||
public static String toString(InjectableBean<?> bean) { | ||
return new StringBuilder() | ||
.append(bean.getKind()) | ||
.append(" bean [class=") | ||
.append(bean.getBeanClass().getName()) | ||
.append(", id=") | ||
.append(bean.getIdentifier()) | ||
.append("]") | ||
.toString(); | ||
} | ||
|
||
} |
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
34 changes: 34 additions & 0 deletions
34
...ava/io/quarkus/arc/test/clientproxy/contextnotactive/ClientProxyContextNotActiveTest.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,34 @@ | ||
package io.quarkus.arc.test.clientproxy.contextnotactive; | ||
|
||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType; | ||
|
||
import io.quarkus.arc.Arc; | ||
import io.quarkus.arc.test.ArcTestContainer; | ||
import javax.enterprise.context.ContextNotActiveException; | ||
import javax.enterprise.context.RequestScoped; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
public class ClientProxyContextNotActiveTest { | ||
|
||
@RegisterExtension | ||
public ArcTestContainer container = new ArcTestContainer(RequestFoo.class); | ||
|
||
@Test | ||
public void testToStringIsDelegated() { | ||
RequestFoo foo = Arc.container().instance(RequestFoo.class).get(); | ||
assertThatExceptionOfType(ContextNotActiveException.class).isThrownBy(() -> foo.ping()) | ||
.withMessageContaining( | ||
"RequestScoped context was not active when trying to obtain a bean instance for a client proxy of CLASS bean [class=io.quarkus.arc.test.clientproxy.contextnotactive.ClientProxyContextNotActiveTest$RequestFoo, id=3e5a77b35b0824bc957993f6db95a37e766e929e]") | ||
.withMessageContaining( | ||
"you can activate the request context for a specific method using the @ActivateRequestContext interceptor binding"); | ||
} | ||
|
||
@RequestScoped | ||
static class RequestFoo { | ||
|
||
void ping() { | ||
} | ||
|
||
} | ||
} |