-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
@ExplicitParameterInjection is now by default inherited for nested cl…
…asses
- Loading branch information
Showing
9 changed files
with
264 additions
and
26 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
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
98 changes: 98 additions & 0 deletions
98
...a/org/jboss/weld/junit5/explicitInjection/ExplicitParameterInjectionNestedClass2Test.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,98 @@ | ||
package org.jboss.weld.junit5.explicitInjection; | ||
|
||
import jakarta.enterprise.inject.Default; | ||
|
||
import org.jboss.weld.junit5.ExplicitParamInjection; | ||
import org.jboss.weld.junit5.WeldJunit5Extension; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Nested; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
|
||
@ExtendWith(WeldJunit5Extension.class) | ||
@ExplicitParamInjection(false) | ||
public class ExplicitParameterInjectionNestedClass2Test { | ||
|
||
@Test | ||
public void testParameterResolution(@Default Foo foo, Bar bar, @MyQualifier BeanWithQualifier bean) { | ||
// Bar should be resolved by Weld | ||
Assertions.assertNotNull(bar); | ||
Assertions.assertEquals(Bar.class.getSimpleName(), bar.ping()); | ||
// Foo should be resolved as usual | ||
Assertions.assertNotNull(foo); | ||
Assertions.assertEquals(Foo.class.getSimpleName(), foo.ping()); | ||
// BeanWithQualifier should be resolved | ||
Assertions.assertNotNull(bean); | ||
Assertions.assertEquals(BeanWithQualifier.class.getSimpleName(), bean.ping()); | ||
} | ||
|
||
@Nested | ||
class NestedTestClass { | ||
|
||
@Test | ||
public void testParameterResolution(@Default Foo foo, Bar bar, @MyQualifier BeanWithQualifier bean) { | ||
// Bar should be resolved by Weld | ||
Assertions.assertNotNull(bar); | ||
Assertions.assertEquals(Bar.class.getSimpleName(), bar.ping()); | ||
// Foo should be resolved as usual | ||
Assertions.assertNotNull(foo); | ||
Assertions.assertEquals(Foo.class.getSimpleName(), foo.ping()); | ||
// BeanWithQualifier should be resolved | ||
Assertions.assertNotNull(bean); | ||
Assertions.assertEquals(BeanWithQualifier.class.getSimpleName(), bean.ping()); | ||
} | ||
|
||
@Nested | ||
class TwiceNestedTestClass1 { | ||
|
||
@Test | ||
public void testParameterResolution(@Default Foo foo, Bar bar, @MyQualifier BeanWithQualifier bean) { | ||
// Bar should be resolved by Weld | ||
Assertions.assertNotNull(bar); | ||
Assertions.assertEquals(Bar.class.getSimpleName(), bar.ping()); | ||
// Foo should be resolved as usual | ||
Assertions.assertNotNull(foo); | ||
Assertions.assertEquals(Foo.class.getSimpleName(), foo.ping()); | ||
// BeanWithQualifier should be resolved | ||
Assertions.assertNotNull(bean); | ||
Assertions.assertEquals(BeanWithQualifier.class.getSimpleName(), bean.ping()); | ||
} | ||
} | ||
|
||
@Nested | ||
@ExplicitParamInjection(true) | ||
@ExtendWith(CustomExtension.class) // TwiceNestedTestClass2 and ThriceNestedClass will both use this | ||
class TwiceNestedTestClass2 { | ||
|
||
@Test | ||
public void testParameterResolution(@Default Foo foo, Bar bar, @MyQualifier BeanWithQualifier bean) { | ||
// Bar should be resolved by another extension | ||
Assertions.assertNotNull(bar); | ||
Assertions.assertEquals(CustomExtension.class.getSimpleName(), bar.ping()); | ||
// Foo should be resolved as usual | ||
Assertions.assertNotNull(foo); | ||
Assertions.assertEquals(Foo.class.getSimpleName(), foo.ping()); | ||
// BeanWithQualifier should be resolved | ||
Assertions.assertNotNull(bean); | ||
Assertions.assertEquals(BeanWithQualifier.class.getSimpleName(), bean.ping()); | ||
} | ||
|
||
@Nested | ||
class ThriceNestedClass { | ||
|
||
@Test | ||
public void testParameterResolution(@Default Foo foo, Bar bar, @MyQualifier BeanWithQualifier bean) { | ||
// Bar should be resolved by another extension | ||
Assertions.assertNotNull(bar); | ||
Assertions.assertEquals(CustomExtension.class.getSimpleName(), bar.ping()); | ||
// Foo should be resolved as usual | ||
Assertions.assertNotNull(foo); | ||
Assertions.assertEquals(Foo.class.getSimpleName(), foo.ping()); | ||
// BeanWithQualifier should be resolved | ||
Assertions.assertNotNull(bean); | ||
Assertions.assertEquals(BeanWithQualifier.class.getSimpleName(), bean.ping()); | ||
} | ||
} | ||
} | ||
} | ||
} |
102 changes: 102 additions & 0 deletions
102
...va/org/jboss/weld/junit5/explicitInjection/ExplicitParameterInjectionNestedClassTest.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,102 @@ | ||
package org.jboss.weld.junit5.explicitInjection; | ||
|
||
import jakarta.enterprise.inject.Default; | ||
|
||
import org.jboss.weld.junit5.ExplicitParamInjection; | ||
import org.jboss.weld.junit5.WeldJunit5Extension; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Nested; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
|
||
// Note that @ExtendWith(CustomExtension.class) has to be on each method separately. The inheritance of this would | ||
// otherwise cause failures for TwiceNestedTestClass2 and ThriceNestedClass where Weld claims all parameters. | ||
@ExtendWith(WeldJunit5Extension.class) | ||
@ExplicitParamInjection(true) | ||
public class ExplicitParameterInjectionNestedClassTest { | ||
|
||
@Test | ||
@ExtendWith(CustomExtension.class) | ||
public void testParameterResolution(@Default Foo foo, Bar bar, @MyQualifier BeanWithQualifier bean) { | ||
// Bar should be resolved by another extension | ||
Assertions.assertNotNull(bar); | ||
Assertions.assertEquals(CustomExtension.class.getSimpleName(), bar.ping()); | ||
// Foo should be resolved as usual | ||
Assertions.assertNotNull(foo); | ||
Assertions.assertEquals(Foo.class.getSimpleName(), foo.ping()); | ||
// BeanWithQualifier should be resolved | ||
Assertions.assertNotNull(bean); | ||
Assertions.assertEquals(BeanWithQualifier.class.getSimpleName(), bean.ping()); | ||
} | ||
|
||
@Nested | ||
class NestedTestClass { | ||
|
||
@Test | ||
@ExtendWith(CustomExtension.class) | ||
public void testParameterResolution(@Default Foo foo, Bar bar, @MyQualifier BeanWithQualifier bean) { | ||
// Bar should be resolved by another extension | ||
Assertions.assertNotNull(bar); | ||
Assertions.assertEquals(CustomExtension.class.getSimpleName(), bar.ping()); | ||
// Foo should be resolved as usual | ||
Assertions.assertNotNull(foo); | ||
Assertions.assertEquals(Foo.class.getSimpleName(), foo.ping()); | ||
// BeanWithQualifier should be resolved | ||
Assertions.assertNotNull(bean); | ||
Assertions.assertEquals(BeanWithQualifier.class.getSimpleName(), bean.ping()); | ||
} | ||
|
||
@Nested | ||
class TwiceNestedTestClass1 { | ||
|
||
@Test | ||
@ExtendWith(CustomExtension.class) | ||
public void testParameterResolution(@Default Foo foo, Bar bar, @MyQualifier BeanWithQualifier bean) { | ||
// Bar should be resolved by another extension | ||
Assertions.assertNotNull(bar); | ||
Assertions.assertEquals(CustomExtension.class.getSimpleName(), bar.ping()); | ||
// Foo should be resolved as usual | ||
Assertions.assertNotNull(foo); | ||
Assertions.assertEquals(Foo.class.getSimpleName(), foo.ping()); | ||
// BeanWithQualifier should be resolved | ||
Assertions.assertNotNull(bean); | ||
Assertions.assertEquals(BeanWithQualifier.class.getSimpleName(), bean.ping()); | ||
} | ||
} | ||
|
||
@Nested | ||
@ExplicitParamInjection(false) | ||
class TwiceNestedTestClass2 { | ||
|
||
@Test | ||
public void testParameterResolution(@Default Foo foo, Bar bar, @MyQualifier BeanWithQualifier bean) { | ||
// Bar should be resolved by Weld | ||
Assertions.assertNotNull(bar); | ||
Assertions.assertEquals(Bar.class.getSimpleName(), bar.ping()); | ||
// Foo should be resolved as usual | ||
Assertions.assertNotNull(foo); | ||
Assertions.assertEquals(Foo.class.getSimpleName(), foo.ping()); | ||
// BeanWithQualifier should be resolved | ||
Assertions.assertNotNull(bean); | ||
Assertions.assertEquals(BeanWithQualifier.class.getSimpleName(), bean.ping()); | ||
} | ||
|
||
@Nested | ||
class ThriceNestedClass { | ||
|
||
@Test | ||
public void testParameterResolution(@Default Foo foo, Bar bar, @MyQualifier BeanWithQualifier bean) { | ||
// Bar should be resolved by Weld | ||
Assertions.assertNotNull(bar); | ||
Assertions.assertEquals(Bar.class.getSimpleName(), bar.ping()); | ||
// Foo should be resolved as usual | ||
Assertions.assertNotNull(foo); | ||
Assertions.assertEquals(Foo.class.getSimpleName(), foo.ping()); | ||
// BeanWithQualifier should be resolved | ||
Assertions.assertNotNull(bean); | ||
Assertions.assertEquals(BeanWithQualifier.class.getSimpleName(), bean.ping()); | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.