-
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-2763 Correct how Weld chooses proxy package for EJB beans using @…
- Loading branch information
Showing
6 changed files
with
112 additions
and
5 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
53 changes: 53 additions & 0 deletions
53
...rc/test/java/org/jboss/weld/tests/classDefining/ejb/TestProxyCreationForEjbLocalBean.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,53 @@ | ||
package org.jboss.weld.tests.classDefining.ejb; | ||
|
||
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.category.Integration; | ||
import org.jboss.weld.tests.classDefining.ejb.ifaces.LocalInterface1; | ||
import org.jboss.weld.tests.classDefining.ejb.ifaces.NotImplementedButDeclaredInterface; | ||
import org.jboss.weld.tests.classDefining.ejb.impl.StatelessLocalBean; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
import org.junit.runner.RunWith; | ||
|
||
@Category(Integration.class) | ||
@RunWith(Arquillian.class) | ||
public class TestProxyCreationForEjbLocalBean { | ||
|
||
@Deployment | ||
public static Archive<?> deploy() { | ||
return ShrinkWrap.create(BeanArchive.class, Utils.getDeploymentNameAsHash(TestProxyCreationForEjbLocalBean.class)) | ||
.addPackage(TestProxyCreationForEjbLocalBean.class.getPackage()) | ||
.addPackage(StatelessLocalBean.class.getPackage()) | ||
.addPackage(LocalInterface1.class.getPackage()); | ||
} | ||
|
||
@Inject | ||
StatelessLocalBean bean1; | ||
|
||
@Inject | ||
NotImplementedButDeclaredInterface bean2; | ||
|
||
@Test | ||
public void testProxyPackageMatchesTheClass() { | ||
// sanity check of the testing setup | ||
Assert.assertEquals(LocalInterface1.class.getSimpleName(), bean1.ping1()); | ||
|
||
// also assert invoking the method from the interface bean doesn't implement directly | ||
Assert.assertEquals(NotImplementedButDeclaredInterface.class.getSimpleName(), bean2.ping3()); | ||
|
||
// The assertion is based solely on inspecting the proxy format - expected package and first mentioned class | ||
// We cannot rely on verifying that the class can be defined because this runs on WFLY which directly uses | ||
// ClassLoader#defineClass in which case it's a non-issue. The mismatch only shows when using MethodHandles.Lookup | ||
// see https://github.com/jakartaee/platform-tck/issues/1194 for more information | ||
Assert.assertEquals(StatelessLocalBean.class.getPackage(), bean1.getClass().getPackage()); | ||
Assert.assertTrue(bean1.getClass().getName().startsWith(StatelessLocalBean.class.getName())); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...quillian/src/test/java/org/jboss/weld/tests/classDefining/ejb/ifaces/LocalInterface1.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,5 @@ | ||
package org.jboss.weld.tests.classDefining.ejb.ifaces; | ||
|
||
public interface LocalInterface1 { | ||
String ping1(); | ||
} |
5 changes: 5 additions & 0 deletions
5
...quillian/src/test/java/org/jboss/weld/tests/classDefining/ejb/ifaces/LocalInterface2.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,5 @@ | ||
package org.jboss.weld.tests.classDefining.ejb.ifaces; | ||
|
||
public interface LocalInterface2 { | ||
String ping2(); | ||
} |
8 changes: 8 additions & 0 deletions
8
...ava/org/jboss/weld/tests/classDefining/ejb/ifaces/NotImplementedButDeclaredInterface.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,8 @@ | ||
package org.jboss.weld.tests.classDefining.ejb.ifaces; | ||
|
||
import jakarta.ejb.Local; | ||
|
||
@Local | ||
public interface NotImplementedButDeclaredInterface extends LocalInterface1 { | ||
String ping3(); | ||
} |
31 changes: 31 additions & 0 deletions
31
...uillian/src/test/java/org/jboss/weld/tests/classDefining/ejb/impl/StatelessLocalBean.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 org.jboss.weld.tests.classDefining.ejb.impl; | ||
|
||
import jakarta.ejb.Local; | ||
import jakarta.ejb.LocalBean; | ||
import jakarta.ejb.Stateless; | ||
|
||
import org.jboss.weld.tests.classDefining.ejb.ifaces.LocalInterface1; | ||
import org.jboss.weld.tests.classDefining.ejb.ifaces.LocalInterface2; | ||
import org.jboss.weld.tests.classDefining.ejb.ifaces.NotImplementedButDeclaredInterface; | ||
|
||
// NOTE: the bean intentionally declares NotImplementedButDeclaredInterface but does *not* implement it directly | ||
@Stateless | ||
@LocalBean | ||
@Local({ LocalInterface1.class, LocalInterface2.class, | ||
NotImplementedButDeclaredInterface.class }) | ||
public class StatelessLocalBean implements LocalInterface1, LocalInterface2 { | ||
|
||
@Override | ||
public String ping1() { | ||
return LocalInterface1.class.getSimpleName(); | ||
} | ||
|
||
@Override | ||
public String ping2() { | ||
return LocalInterface2.class.getSimpleName(); | ||
} | ||
|
||
public String ping3() { | ||
return NotImplementedButDeclaredInterface.class.getSimpleName(); | ||
} | ||
} |