-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WELD-2758 Proxies for non-public class-based beans should reside in b…
…ean's package if possible
- Loading branch information
Showing
6 changed files
with
102 additions
and
1 deletion.
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
40 changes: 40 additions & 0 deletions
40
...jboss/weld/tests/classDefining/packPrivate/ProxyForInterceptedPackagePrivateBeanTest.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,40 @@ | ||
package org.jboss.weld.tests.classDefining.packPrivate; | ||
|
||
import jakarta.enterprise.inject.Instance; | ||
import jakarta.inject.Inject; | ||
|
||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.shrinkwrap.api.Archive; | ||
import org.jboss.shrinkwrap.api.BeanArchive; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.weld.test.util.Utils; | ||
import org.jboss.weld.tests.classDefining.packPrivate.api.Alpha; | ||
import org.jboss.weld.tests.classDefining.packPrivate.interceptor.MyInterceptor; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
/** | ||
* See WELD-2758 | ||
*/ | ||
@RunWith(Arquillian.class) | ||
public class ProxyForInterceptedPackagePrivateBeanTest { | ||
|
||
@Deployment | ||
public static Archive<?> deploy() { | ||
return ShrinkWrap | ||
.create(BeanArchive.class, Utils.getDeploymentNameAsHash(ProxyForInterceptedPackagePrivateBeanTest.class)) | ||
.addPackages(true, ProxyForInterceptedPackagePrivateBeanTest.class.getPackage()); | ||
} | ||
|
||
@Inject | ||
Instance<Object> instance; | ||
|
||
@Test | ||
public void testProxyCanBeCreated() { | ||
Instance<Alpha> select = instance.select(Alpha.class); | ||
Assert.assertTrue(select.isResolvable()); | ||
Assert.assertEquals(MyInterceptor.class.getSimpleName() + Alpha.class.getSimpleName(), select.get().ping()); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
tests-arquillian/src/test/java/org/jboss/weld/tests/classDefining/packPrivate/api/Alpha.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,6 @@ | ||
package org.jboss.weld.tests.classDefining.packPrivate.api; | ||
|
||
public interface Alpha { | ||
|
||
String ping(); | ||
} |
20 changes: 20 additions & 0 deletions
20
...quillian/src/test/java/org/jboss/weld/tests/classDefining/packPrivate/impl/AlphaImpl.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 org.jboss.weld.tests.classDefining.packPrivate.impl; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.enterprise.inject.Typed; | ||
|
||
import org.jboss.weld.tests.classDefining.packPrivate.api.Alpha; | ||
import org.jboss.weld.tests.classDefining.packPrivate.interceptor.SomeBinding; | ||
|
||
/** | ||
* Class is intentionally package private, @Typed to just the interface type and normal scoped to enforce client proxy | ||
*/ | ||
@ApplicationScoped | ||
@SomeBinding | ||
@Typed(Alpha.class) | ||
class AlphaImpl implements Alpha { | ||
@Override | ||
public String ping() { | ||
return Alpha.class.getSimpleName(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...c/test/java/org/jboss/weld/tests/classDefining/packPrivate/interceptor/MyInterceptor.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,17 @@ | ||
package org.jboss.weld.tests.classDefining.packPrivate.interceptor; | ||
|
||
import jakarta.annotation.Priority; | ||
import jakarta.interceptor.AroundInvoke; | ||
import jakarta.interceptor.Interceptor; | ||
import jakarta.interceptor.InvocationContext; | ||
|
||
@Interceptor | ||
@SomeBinding | ||
@Priority(Interceptor.Priority.APPLICATION) | ||
public class MyInterceptor { | ||
|
||
@AroundInvoke | ||
public Object intercept(InvocationContext context) throws Exception { | ||
return this.getClass().getSimpleName() + context.proceed(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...src/test/java/org/jboss/weld/tests/classDefining/packPrivate/interceptor/SomeBinding.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,11 @@ | ||
package org.jboss.weld.tests.classDefining.packPrivate.interceptor; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
|
||
import jakarta.interceptor.InterceptorBinding; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@InterceptorBinding | ||
public @interface SomeBinding { | ||
} |