├── junit4 ├── .gitignore └── src │ └── test │ ├── resources │ └── logging.properties │ └── java │ └── org │ └── jboss │ └── weld │ └── junit4 │ ├── bean │ ├── Foo.java │ ├── Bar.java │ ├── MockBeanWithQualifiersTest.java │ ├── extension │ │ └── GoodOldBean.java │ ├── Blue.java │ └── BlueToDiscover.java │ ├── resources │ ├── DummySessionBean.java │ ├── FooEjbs.java │ ├── FooResources.java │ └── FooJpa.java │ ├── contexts │ ├── RequestScopedProducer.java │ ├── InvalidScopeTest.java │ ├── Foo.java │ └── Oof.java │ ├── FooAlternative.java │ ├── Foo.java │ ├── ofpackage │ ├── Alpha.java │ └── Bravo.java │ ├── SimpleTest.java │ ├── classrule │ └── Charlie.java │ ├── BeanManagerTest.java │ ├── inject │ ├── IamDependent.java │ ├── MeatyStringObserver.java │ └── Meaty.java │ ├── event │ └── DummyObserver.java │ └── ContainerNotRunningTest.java ├── junit5 ├── .gitignore └── src │ ├── test │ ├── resources │ │ ├── logging.properties │ │ ├── META-INF │ │ │ └── services │ │ │ │ └── org.jboss.weld.junit5.WeldJunitEnricher │ │ └── junit-platform.properties │ └── java │ │ └── org │ │ └── jboss │ │ └── weld │ │ └── junit5 │ │ ├── initiator │ │ ├── bean │ │ │ ├── Bar.java │ │ │ └── Foo.java │ │ └── discovery │ │ │ ├── SubclassWithWeldInitiatorTest.java │ │ │ ├── SuperclassWithWeldInitiator.java │ │ │ ├── SuperclassWithPrivateWeldInitiator.java │ │ │ └── SuperclassWithProtectedWeldInitiator.java │ │ ├── basic │ │ ├── IFoo.java │ │ ├── SomeFoo.java │ │ ├── SomeIFoo.java │ │ ├── unsatisfied │ │ │ ├── SomeFooDeps.java │ │ │ ├── Baz.java │ │ │ └── FooDeps.java │ │ ├── EnableWeldTest.java │ │ ├── FooAlternative.java │ │ └── Foo.java │ │ ├── bean │ │ ├── Foo.java │ │ ├── Bar.java │ │ ├── MockBeanWithQualifiersTest.java │ │ ├── extension │ │ │ └── GoodOldBean.java │ │ ├── Blue.java │ │ └── BlueToDiscover.java │ │ ├── auto │ │ ├── beans │ │ │ ├── Engine.java │ │ │ ├── unsatisfied │ │ │ │ ├── InjectedV8NoAnnotation.java │ │ │ │ ├── ConstructedV8NoAnnotation.java │ │ │ │ └── V8NoAnnotation.java │ │ │ ├── V8.java │ │ │ └── V6.java │ │ ├── discovery │ │ │ ├── WithoutBeanDefiningAnnotation.java │ │ │ └── WithBeanDefiningAnnotation.java │ │ ├── InjectParameterizedTest.java │ │ ├── AddExtensionsTest.java │ │ ├── InjectInstanceTest.java │ │ ├── InjectParameterizedInstanceTest.java │ │ ├── InjectMethodParamTest.java │ │ ├── AddBeanClassesTest.java │ │ ├── AddPackagesTest.java │ │ ├── ParametersAutoConfigTest.java │ │ ├── ExcludeBeanTest.java │ │ ├── BasicAutoConfigTest.java │ │ ├── ExcludeBeanClassesTest.java │ │ ├── ExcludeBeanHierarchyTest.java │ │ ├── ProducesBeforeTest.java │ │ ├── ExcludeBeanDepsTest.java │ │ ├── ProducerMethodParametersScanningTest.java │ │ ├── ExcludeBeanClassesDepsTest.java │ │ ├── interceptorAndDecorator │ │ │ ├── DecoratedBeanInterface.java │ │ │ ├── InterceptedBean.java │ │ │ ├── DecoratedBean.java │ │ │ ├── TestInterceptorBinding.java │ │ │ ├── TestInterceptor.java │ │ │ └── TestDecorator.java │ │ ├── ExplicitParametersAutoConfigTest.java │ │ ├── alternatives │ │ │ ├── Foo.java │ │ │ └── FooAlternative.java │ │ ├── alternativeStereotype │ │ │ ├── Foo.java │ │ │ ├── FooAlternative.java │ │ │ └── SomeStereotype.java │ │ ├── SetDiscoveryModeAllTest.java │ │ ├── InheritedProducerFieldTest.java │ │ ├── InheritedProducerMethodTest.java │ │ └── extension │ │ │ └── AddedExtension.java │ │ ├── compat │ │ ├── JunitParameterResolverWeldTest.java │ │ ├── JunitParameterResolverAutoWeldTest.java │ │ └── JunitParameterResolverReferenceTest.java │ │ ├── resources │ │ ├── DummySessionBean.java │ │ ├── FooEjbs.java │ │ ├── FooResources.java │ │ └── FooJpa.java │ │ ├── nested │ │ └── MyBean.java │ │ ├── alternative │ │ ├── Fish.java │ │ └── AlternativeAsSoleBeanInSyntheticArchiveTest.java │ │ ├── explicitInjection │ │ ├── parameterizedTest │ │ │ └── Foo.java │ │ ├── Foo.java │ │ ├── BeanWithQualifier.java │ │ ├── Bar.java │ │ └── MyQualifier.java │ │ ├── contexts │ │ ├── RequestScopedProducer.java │ │ ├── SomeAnnotation.java │ │ ├── Foo.java │ │ └── Oof.java │ │ ├── testLifecycle │ │ ├── PerClassLifecycleChildTest.java │ │ └── PlainBean.java │ │ ├── extensionInjection │ │ ├── MapProducer.java │ │ ├── FooBean.java │ │ ├── SomeBean.java │ │ ├── BarBean.java │ │ └── MyQualifier.java │ │ ├── ofpackage │ │ ├── Alpha.java │ │ └── Bravo.java │ │ └── event │ │ └── DummyObserver.java │ └── main │ └── java │ └── org │ └── jboss │ └── weld │ └── junit5 │ ├── auto │ └── SetBeanDiscoveryMode.java │ └── WeldSetup.java ├── spock ├── .gitignore ├── src │ ├── test │ │ ├── resources │ │ │ ├── META-INF │ │ │ │ └── services │ │ │ │ │ └── org.jboss.weld.spock.WeldSpockEnricher │ │ │ ├── log4j2-test.xml │ │ │ └── SpockConfig.groovy │ │ └── groovy │ │ │ └── org │ │ │ └── jboss │ │ │ └── weld │ │ │ └── spock │ │ │ ├── initiator │ │ │ ├── bean │ │ │ │ └── Foo.groovy │ │ │ └── discovery │ │ │ │ ├── SuperclassWithWeldInitiatorTest.groovy │ │ │ │ ├── SuperclassWithProtectedWeldInitiator.groovy │ │ │ │ ├── SuperclassWithWeldInitiator.groovy │ │ │ │ └── ProtectedWeldInitiatorInSuperclassTest.groovy │ │ │ ├── basic │ │ │ ├── IFoo.groovy │ │ │ ├── SomeFoo.groovy │ │ │ ├── SomeIFoo.groovy │ │ │ ├── FooAlternative.groovy │ │ │ ├── unsatisfied │ │ │ │ ├── SomeFooDeps.groovy │ │ │ │ ├── FooDeps.groovy │ │ │ │ └── Baz.groovy │ │ │ ├── EnableWeldTest.groovy │ │ │ ├── Foo.groovy │ │ │ └── BeanManagerTest.groovy │ │ │ ├── bean │ │ │ ├── Foo.groovy │ │ │ ├── extension │ │ │ │ ├── GoodOldBean.groovy │ │ │ │ └── MyExtension.groovy │ │ │ ├── Blue.groovy │ │ │ ├── Bar.groovy │ │ │ └── BlueToDiscover.groovy │ │ │ ├── auto │ │ │ ├── beans │ │ │ │ ├── Engine.groovy │ │ │ │ ├── unsatisfied │ │ │ │ │ ├── InjectedV8NoAnnotation.groovy │ │ │ │ │ ├── ConstructedV8NoAnnotation.groovy │ │ │ │ │ └── V8NoAnnotation.groovy │ │ │ │ ├── V8.groovy │ │ │ │ └── V6.groovy │ │ │ ├── interceptorAndDecorator │ │ │ │ ├── DecoratedBeanInterface.groovy │ │ │ │ ├── InterceptedBean.groovy │ │ │ │ ├── DecoratedBean.groovy │ │ │ │ ├── TestInterceptor.groovy │ │ │ │ └── TestInterceptorBinding.groovy │ │ │ ├── alternatives │ │ │ │ ├── Foo.groovy │ │ │ │ └── FooAlternative.groovy │ │ │ ├── alternativeStereotype │ │ │ │ ├── Foo.groovy │ │ │ │ ├── FooAlternative.groovy │ │ │ │ └── SomeStereotype.groovy │ │ │ ├── AddExtensionsTest.groovy │ │ │ ├── extension │ │ │ │ └── AddedExtension.groovy │ │ │ ├── InjectParameterizedTest.groovy │ │ │ └── AddBeanClassesTest.groovy │ │ │ ├── scope │ │ │ └── PlainBean.groovy │ │ │ ├── resources │ │ │ ├── DummySessionBean.groovy │ │ │ ├── FooEjbs.groovy │ │ │ ├── FooResources.groovy │ │ │ └── FooJpa.groovy │ │ │ ├── explicitInjection │ │ │ ├── Foo.groovy │ │ │ ├── BeanWithQualifier.groovy │ │ │ └── Bar.groovy │ │ │ ├── contexts │ │ │ ├── SomeAnnotation.groovy │ │ │ ├── Foo.groovy │ │ │ ├── RequestScopedProducer.groovy │ │ │ └── Oof.groovy │ │ │ ├── extensionInjection │ │ │ ├── FooBean.groovy │ │ │ ├── SomeBean.groovy │ │ │ ├── BarBean.groovy │ │ │ └── MyQualifier.groovy │ │ │ ├── alternative │ │ │ └── Fish.groovy │ │ │ ├── ofpackage │ │ │ ├── Alpha.groovy │ │ │ └── Bravo.groovy │ │ │ └── event │ │ │ └── DummyObserver.groovy │ └── main │ │ ├── resources │ │ └── META-INF │ │ │ └── services │ │ │ └── org.spockframework.runtime.extension.IGlobalExtension │ │ └── java │ │ └── org │ │ └── jboss │ │ └── weld │ │ └── spock │ │ └── WeldSetup.java └── spotbugs-exclude.xml ├── junit-common ├── .gitignore └── pom.xml ├── .gitignore ├── .github ├── project.yml └── dependabot.yml └── dco.txt /junit4/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | /.classpath 4 | /.project 5 | /.idea 6 | *.iml 7 | -------------------------------------------------------------------------------- /junit5/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | /.classpath 4 | /.project 5 | /.idea 6 | *.iml 7 | -------------------------------------------------------------------------------- /spock/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | /.classpath 4 | /.project 5 | /.idea 6 | *.iml 7 | -------------------------------------------------------------------------------- /junit-common/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | /.classpath 4 | /.project 5 | /.idea 6 | *.iml 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.classpath 3 | /.project 4 | /.settings/ 5 | /.idea 6 | *.iml 7 | .cache 8 | 9 | -------------------------------------------------------------------------------- /.github/project.yml: -------------------------------------------------------------------------------- 1 | name: Weld Parent 2 | release: 3 | current-version: 5.0.3.Final 4 | next-version: 5.0.4-SNAPSHOT -------------------------------------------------------------------------------- /junit4/src/test/resources/logging.properties: -------------------------------------------------------------------------------- 1 | handlers = java.util.logging.ConsoleHandler 2 | org.jboss.weld.level = WARNING -------------------------------------------------------------------------------- /junit5/src/test/resources/logging.properties: -------------------------------------------------------------------------------- 1 | handlers = java.util.logging.ConsoleHandler 2 | org.jboss.weld.level = WARNING -------------------------------------------------------------------------------- /junit5/src/test/resources/META-INF/services/org.jboss.weld.junit5.WeldJunitEnricher: -------------------------------------------------------------------------------- 1 | org.jboss.weld.junit5.enricher.FooWeldJunitEnricher -------------------------------------------------------------------------------- /spock/src/test/resources/META-INF/services/org.jboss.weld.spock.WeldSpockEnricher: -------------------------------------------------------------------------------- 1 | org.jboss.weld.spock.enricher.FooWeldSpockEnricher 2 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/initiator/bean/Bar.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.initiator.bean; 2 | 3 | public class Bar { 4 | } 5 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/initiator/bean/Foo.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.initiator.bean; 2 | 3 | public class Foo { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/basic/IFoo.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.basic; 2 | 3 | public interface IFoo { 4 | 5 | String getBar(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /junit4/src/test/java/org/jboss/weld/junit4/bean/Foo.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit4.bean; 2 | 3 | public class Foo { 4 | public String ping() { 5 | return "foo"; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/bean/Foo.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.bean; 2 | 3 | public class Foo { 4 | 5 | public String ping() { 6 | return "foo"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /spock/src/main/resources/META-INF/services/org.spockframework.runtime.extension.IGlobalExtension: -------------------------------------------------------------------------------- 1 | org.jboss.weld.spock.impl.EnableWeldExtension 2 | org.jboss.weld.spock.impl.EagerExceptionRenderer 3 | -------------------------------------------------------------------------------- /junit5/src/test/resources/junit-platform.properties: -------------------------------------------------------------------------------- 1 | junit.jupiter.execution.parallel.enabled = true 2 | junit.jupiter.execution.parallel.mode.default = concurrent 3 | junit.jupiter.execution.parallel.mode.classes.default = concurrent 4 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/beans/Engine.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.auto.beans; 2 | 3 | public interface Engine { 4 | 5 | int getThrottle(); 6 | 7 | void setThrottle(int value); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/discovery/WithoutBeanDefiningAnnotation.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.auto.discovery; 2 | 3 | // intentionally doesn't have any bean defining annotation 4 | public class WithoutBeanDefiningAnnotation { 5 | } 6 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/discovery/WithBeanDefiningAnnotation.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.auto.discovery; 2 | 3 | import jakarta.enterprise.context.ApplicationScoped; 4 | 5 | @ApplicationScoped 6 | public class WithBeanDefiningAnnotation { 7 | } 8 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/compat/JunitParameterResolverWeldTest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.compat; 2 | 3 | import org.jboss.weld.junit5.EnableWeld; 4 | 5 | @EnableWeld 6 | class JunitParameterResolverWeldTest extends JunitParameterResolverReferenceTest { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /junit4/src/test/java/org/jboss/weld/junit4/resources/DummySessionBean.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit4.resources; 2 | 3 | public class DummySessionBean { 4 | 5 | final String id; 6 | 7 | public DummySessionBean(String id) { 8 | this.id = id; 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/resources/DummySessionBean.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.resources; 2 | 3 | public class DummySessionBean { 4 | 5 | final String id; 6 | 7 | public DummySessionBean(String id) { 8 | this.id = id; 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/compat/JunitParameterResolverAutoWeldTest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.compat; 2 | 3 | import org.jboss.weld.junit5.auto.EnableAutoWeld; 4 | 5 | @EnableAutoWeld 6 | class JunitParameterResolverAutoWeldTest extends JunitParameterResolverReferenceTest { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/basic/SomeFoo.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.basic; 2 | 3 | import jakarta.enterprise.context.ApplicationScoped; 4 | import jakarta.inject.Inject; 5 | 6 | @ApplicationScoped 7 | public class SomeFoo { 8 | 9 | @Inject 10 | private Foo foo; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/basic/SomeIFoo.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.basic; 2 | 3 | import jakarta.enterprise.context.ApplicationScoped; 4 | import jakarta.inject.Inject; 5 | 6 | @ApplicationScoped 7 | public class SomeIFoo { 8 | 9 | @Inject 10 | private IFoo foo; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/nested/MyBean.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.nested; 2 | 3 | import jakarta.enterprise.context.ApplicationScoped; 4 | 5 | @ApplicationScoped 6 | public class MyBean { 7 | 8 | public String ping() { 9 | return MyBean.class.getSimpleName(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: github-actions 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | open-pull-requests-limit: 15 8 | target-branch: master 9 | - package-ecosystem: maven 10 | directory: "/" 11 | schedule: 12 | interval: monthly 13 | open-pull-requests-limit: 10 14 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/basic/unsatisfied/SomeFooDeps.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.basic.unsatisfied; 2 | 3 | import jakarta.enterprise.context.ApplicationScoped; 4 | import jakarta.inject.Inject; 5 | 6 | @ApplicationScoped 7 | public class SomeFooDeps { 8 | 9 | @Inject 10 | private FooDeps fooDeps; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/alternative/Fish.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.alternative; 2 | 3 | public class Fish { 4 | 5 | private int legs; 6 | 7 | public Fish(int numberOfLegs) { 8 | this.legs = numberOfLegs; 9 | } 10 | 11 | public int getNumberOfLegs() { 12 | return legs; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/beans/unsatisfied/InjectedV8NoAnnotation.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.auto.beans.unsatisfied; 2 | 3 | import jakarta.enterprise.context.ApplicationScoped; 4 | import jakarta.inject.Inject; 5 | 6 | @ApplicationScoped 7 | public class InjectedV8NoAnnotation { 8 | 9 | @Inject 10 | V8NoAnnotation v8; 11 | } 12 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/explicitInjection/parameterizedTest/Foo.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.explicitInjection.parameterizedTest; 2 | 3 | import jakarta.enterprise.context.ApplicationScoped; 4 | import jakarta.enterprise.inject.Produces; 5 | 6 | @ApplicationScoped 7 | public class Foo { 8 | 9 | @Produces 10 | String s = "fooString"; 11 | 12 | String ping() { 13 | return Foo.class.getSimpleName(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /junit4/src/test/java/org/jboss/weld/junit4/contexts/RequestScopedProducer.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit4.contexts; 2 | 3 | import jakarta.enterprise.context.Dependent; 4 | import jakarta.enterprise.context.RequestScoped; 5 | import jakarta.enterprise.inject.Produces; 6 | 7 | @RequestScoped 8 | public class RequestScopedProducer { 9 | 10 | @Produces 11 | @Dependent 12 | public String produceDependentString() { 13 | return "foo"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/contexts/RequestScopedProducer.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.contexts; 2 | 3 | import jakarta.enterprise.context.Dependent; 4 | import jakarta.enterprise.context.RequestScoped; 5 | import jakarta.enterprise.inject.Produces; 6 | 7 | @RequestScoped 8 | public class RequestScopedProducer { 9 | 10 | @Produces 11 | @Dependent 12 | public String produceDependentString() { 13 | return "foo"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/basic/unsatisfied/Baz.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.basic.unsatisfied; 2 | 3 | import jakarta.enterprise.context.ApplicationScoped; 4 | import jakarta.inject.Inject; 5 | import jakarta.inject.Named; 6 | 7 | @ApplicationScoped 8 | public class Baz { 9 | 10 | @Inject 11 | @Named("bar-value") 12 | String bar; 13 | 14 | public Baz() { 15 | } 16 | 17 | public String getBar() { 18 | return bar; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/beans/unsatisfied/ConstructedV8NoAnnotation.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.auto.beans.unsatisfied; 2 | 3 | import jakarta.enterprise.context.ApplicationScoped; 4 | import jakarta.inject.Inject; 5 | 6 | @ApplicationScoped 7 | public class ConstructedV8NoAnnotation { 8 | 9 | private V8NoAnnotation engine; 10 | 11 | @Inject 12 | public ConstructedV8NoAnnotation(V8NoAnnotation engine) { 13 | this.engine = engine; 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/beans/V8.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.auto.beans; 2 | 3 | import java.io.Serializable; 4 | 5 | import jakarta.enterprise.context.Dependent; 6 | 7 | @Dependent 8 | public class V8 implements Engine, Serializable { 9 | 10 | private int throttle = 0; 11 | 12 | public int getThrottle() { 13 | return throttle; 14 | } 15 | 16 | @Override 17 | public void setThrottle(int throttle) { 18 | this.throttle = throttle; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/beans/V6.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.auto.beans; 2 | 3 | import java.io.Serializable; 4 | 5 | import jakarta.enterprise.context.ApplicationScoped; 6 | 7 | @ApplicationScoped 8 | public class V6 implements Engine, Serializable { 9 | 10 | private int throttle = 0; 11 | 12 | public int getThrottle() { 13 | return throttle; 14 | } 15 | 16 | @Override 17 | public void setThrottle(int throttle) { 18 | this.throttle = throttle; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /junit4/src/test/java/org/jboss/weld/junit4/bean/Bar.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit4.bean; 2 | 3 | import java.util.List; 4 | 5 | import jakarta.enterprise.context.ApplicationScoped; 6 | import jakarta.inject.Inject; 7 | 8 | @ApplicationScoped 9 | public class Bar { 10 | @Inject 11 | @Meaty 12 | private Foo foo; 13 | 14 | @Inject 15 | private List someList; 16 | 17 | public List getSomeList() { 18 | return someList; 19 | } 20 | 21 | public Foo getFoo() { 22 | return foo; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/bean/Bar.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.bean; 2 | 3 | import java.util.List; 4 | 5 | import jakarta.enterprise.context.ApplicationScoped; 6 | import jakarta.inject.Inject; 7 | 8 | @ApplicationScoped 9 | public class Bar { 10 | 11 | @Inject 12 | @Meaty 13 | private Foo foo; 14 | 15 | @Inject 16 | private List someList; 17 | 18 | public List getSomeList() { 19 | return someList; 20 | } 21 | 22 | public Foo getFoo() { 23 | return foo; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/initiator/discovery/SubclassWithWeldInitiatorTest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.initiator.discovery; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertNotNull; 4 | 5 | import org.jboss.weld.junit5.initiator.bean.Foo; 6 | import org.junit.jupiter.api.Test; 7 | 8 | public class SubclassWithWeldInitiatorTest extends SuperclassWithWeldInitiator { 9 | @Test 10 | public void testSuperclassWeldInit() { 11 | final Foo foo = weld.select(Foo.class).get(); 12 | assertNotNull(foo); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/InjectParameterizedTest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.auto; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertNotNull; 4 | 5 | import jakarta.enterprise.context.Dependent; 6 | import jakarta.inject.Inject; 7 | 8 | import org.junit.jupiter.api.Test; 9 | 10 | @EnableAutoWeld 11 | public class InjectParameterizedTest { 12 | 13 | @Dependent 14 | static class Foo { 15 | } 16 | 17 | @Inject 18 | Foo foo; 19 | 20 | @Test 21 | void test() { 22 | assertNotNull(foo); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/beans/unsatisfied/V8NoAnnotation.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.auto.beans.unsatisfied; 2 | 3 | import java.io.Serializable; 4 | 5 | import org.jboss.weld.junit5.auto.beans.Engine; 6 | 7 | // NOTE - deliberately missing bean defining annotation 8 | public class V8NoAnnotation implements Engine, Serializable { 9 | 10 | private int throttle = 0; 11 | 12 | public int getThrottle() { 13 | return throttle; 14 | } 15 | 16 | @Override 17 | public void setThrottle(int throttle) { 18 | this.throttle = throttle; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/AddExtensionsTest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.auto; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertTrue; 4 | 5 | import org.jboss.weld.junit5.auto.extension.AddedExtension; 6 | import org.junit.jupiter.api.DisplayName; 7 | import org.junit.jupiter.api.Test; 8 | 9 | @EnableAutoWeld 10 | @AddExtensions(AddedExtension.class) 11 | public class AddExtensionsTest { 12 | 13 | @Test 14 | @DisplayName("Test that @AddExtensions adds the specified extensions") 15 | void test() { 16 | assertTrue(AddedExtension.isEnabled()); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/testLifecycle/PerClassLifecycleChildTest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.testLifecycle; 2 | 3 | // all configuration is inherited, so are test methods 4 | // we should recognize this class as having per-class lifecycle and bootstrap Weld accordingly 5 | public class PerClassLifecycleChildTest extends PerClassLifecycleTest { 6 | 7 | static String childContainerId = null; 8 | 9 | @Override 10 | String getContainerId() { 11 | return childContainerId; 12 | } 13 | 14 | @Override 15 | void setContainerId(String id) { 16 | childContainerId = id; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/InjectInstanceTest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.auto; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertNotNull; 4 | 5 | import jakarta.enterprise.context.Dependent; 6 | import jakarta.enterprise.inject.Instance; 7 | import jakarta.inject.Inject; 8 | 9 | import org.junit.jupiter.api.Test; 10 | 11 | @EnableAutoWeld 12 | public class InjectInstanceTest { 13 | 14 | @Dependent 15 | static class Foo { 16 | } 17 | 18 | @Inject 19 | Instance fooInstance; 20 | 21 | @Test 22 | void test() { 23 | assertNotNull(fooInstance.get()); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/InjectParameterizedInstanceTest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.auto; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertNotNull; 4 | 5 | import jakarta.enterprise.context.Dependent; 6 | import jakarta.enterprise.inject.Instance; 7 | import jakarta.inject.Inject; 8 | 9 | import org.junit.jupiter.api.Test; 10 | 11 | @EnableAutoWeld 12 | public class InjectParameterizedInstanceTest { 13 | 14 | @Dependent 15 | static class Foo { 16 | } 17 | 18 | @Inject 19 | Instance> fooInstance; 20 | 21 | @Test 22 | void test() { 23 | assertNotNull(fooInstance.get()); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /spock/src/test/resources/log4j2-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | <%-35.35t> <%x> <%X> <%50.50c> %m}{TRACE = magenta}%n]]> 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/initiator/discovery/SuperclassWithWeldInitiator.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.initiator.discovery; 2 | 3 | import org.jboss.weld.environment.se.Weld; 4 | import org.jboss.weld.junit5.WeldInitiator; 5 | import org.jboss.weld.junit5.WeldJunit5Extension; 6 | import org.jboss.weld.junit5.WeldSetup; 7 | import org.jboss.weld.junit5.initiator.bean.Foo; 8 | import org.junit.jupiter.api.extension.ExtendWith; 9 | 10 | @ExtendWith(WeldJunit5Extension.class) 11 | public abstract class SuperclassWithWeldInitiator { 12 | @WeldSetup 13 | public WeldInitiator weld = WeldInitiator 14 | .of(new Weld() 15 | .addBeanClass(Foo.class)); 16 | } 17 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/extensionInjection/MapProducer.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.extensionInjection; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import jakarta.enterprise.context.ApplicationScoped; 7 | import jakarta.enterprise.context.Dependent; 8 | import jakarta.enterprise.inject.Produces; 9 | import jakarta.enterprise.inject.spi.InjectionPoint; 10 | 11 | @ApplicationScoped 12 | public class MapProducer { 13 | 14 | @Produces 15 | @Dependent 16 | public Map produceMap(InjectionPoint ip) { 17 | Map map = new HashMap<>(); 18 | map.put(ip.getType().getTypeName(), null); 19 | return map; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/InjectMethodParamTest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.auto; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertNotNull; 4 | 5 | import jakarta.enterprise.context.Dependent; 6 | import jakarta.inject.Inject; 7 | 8 | import org.junit.jupiter.api.Test; 9 | 10 | @EnableAutoWeld 11 | class InjectMethodParamTest { 12 | 13 | @Dependent 14 | static class Foo { 15 | } 16 | 17 | private Foo foo; 18 | 19 | @Inject 20 | private void setFoo(Foo foo) { 21 | this.foo = foo; 22 | } 23 | 24 | @Test 25 | void testInjectMethodParametersAreAddedToContainerWithNoConfiguration() { 26 | assertNotNull(foo); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/basic/EnableWeldTest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.basic; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertNotNull; 4 | 5 | import jakarta.enterprise.inject.spi.BeanManager; 6 | import jakarta.inject.Inject; 7 | 8 | import org.jboss.weld.junit5.EnableWeld; 9 | import org.junit.jupiter.api.DisplayName; 10 | import org.junit.jupiter.api.Test; 11 | 12 | @EnableWeld 13 | public class EnableWeldTest { 14 | 15 | @Inject 16 | BeanManager beanManager; 17 | 18 | @Test 19 | @DisplayName("@EnableWeld initializes the Weld CDI container") 20 | void enableWeldAnnotationInitializesTheWeldContainer() { 21 | assertNotNull(beanManager); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/AddBeanClassesTest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.auto; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertNotNull; 4 | 5 | import jakarta.inject.Inject; 6 | 7 | import org.jboss.weld.junit5.auto.beans.Engine; 8 | import org.jboss.weld.junit5.auto.beans.V8; 9 | import org.junit.jupiter.api.DisplayName; 10 | import org.junit.jupiter.api.Test; 11 | 12 | @EnableAutoWeld 13 | @AddBeanClasses(V8.class) 14 | public class AddBeanClassesTest { 15 | 16 | @Inject 17 | private Engine engine; 18 | 19 | @Test 20 | @DisplayName("Test that @AddBeanClasses pulls in V8 to fulfill the injected Engine interface") 21 | void test() { 22 | assertNotNull(engine); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/AddPackagesTest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.auto; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertNotNull; 4 | 5 | import jakarta.inject.Inject; 6 | 7 | import org.jboss.weld.junit5.auto.beans.Engine; 8 | import org.jboss.weld.junit5.auto.beans.V8; 9 | import org.junit.jupiter.api.DisplayName; 10 | import org.junit.jupiter.api.Test; 11 | 12 | @EnableAutoWeld 13 | @AddPackages(value = Engine.class, recursively = false) 14 | public class AddPackagesTest { 15 | 16 | @Inject 17 | private V8 engine; 18 | 19 | @Test 20 | @DisplayName("Test that @AddPackages pulls in V8 to fulfill the injected Engine interface") 21 | void test() { 22 | assertNotNull(engine); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/ParametersAutoConfigTest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.auto; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; 4 | import static org.junit.jupiter.api.Assertions.assertNotNull; 5 | 6 | import org.jboss.weld.junit5.basic.Foo; 7 | import org.jboss.weld.junit5.explicitInjection.Bar; 8 | import org.junit.jupiter.api.DisplayName; 9 | import org.junit.jupiter.api.Test; 10 | 11 | @EnableAutoWeld 12 | public class ParametersAutoConfigTest { 13 | 14 | @Test 15 | @DisplayName("Ensure the parameters Foo and Bar are automatically included in container with no configuration") 16 | void test(Foo foo, Bar bar) { 17 | assertNotNull(bar); 18 | assertEquals(Bar.class.getSimpleName(), bar.ping()); 19 | assertNotNull(foo); 20 | assertEquals(foo.getBar(), "baz"); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/ExcludeBeanTest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.auto; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; 4 | import static org.junit.jupiter.api.Assertions.assertNotNull; 5 | 6 | import jakarta.enterprise.inject.Produces; 7 | 8 | import org.jboss.weld.junit5.basic.Foo; 9 | import org.jboss.weld.junit5.basic.SomeFoo; 10 | import org.junit.jupiter.api.DisplayName; 11 | import org.junit.jupiter.api.Test; 12 | 13 | @EnableAutoWeld 14 | @AddBeanClasses(SomeFoo.class) 15 | class ExcludeBeanTest { 16 | 17 | @Produces 18 | @ExcludeBean 19 | Foo fakeFoo = new Foo("non-baz"); 20 | 21 | @Test 22 | @DisplayName("Ensure @ExcludeBean excludes the implied bean class") 23 | void test(Foo myFoo) { 24 | assertNotNull(myFoo); 25 | assertEquals(myFoo.getBar(), "non-baz"); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/BasicAutoConfigTest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.auto; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; 4 | import static org.junit.jupiter.api.Assertions.assertNotNull; 5 | 6 | import jakarta.inject.Inject; 7 | 8 | import org.jboss.weld.junit5.basic.Foo; 9 | import org.jboss.weld.junit5.explicitInjection.Bar; 10 | import org.junit.jupiter.api.DisplayName; 11 | import org.junit.jupiter.api.Test; 12 | 13 | @EnableAutoWeld 14 | class BasicAutoConfigTest { 15 | 16 | @Inject 17 | private Foo foo; 18 | 19 | @Inject 20 | private Bar bar; 21 | 22 | @Test 23 | @DisplayName("Ensure the injected Foo and Bar are automatically included in container with no configuration") 24 | void test() { 25 | assertNotNull(bar); 26 | assertNotNull(foo); 27 | assertEquals(foo.getBar(), "baz"); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /spock/spotbugs-exclude.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/ExcludeBeanClassesTest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.auto; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; 4 | import static org.junit.jupiter.api.Assertions.assertNotNull; 5 | 6 | import jakarta.enterprise.inject.Produces; 7 | 8 | import org.jboss.weld.junit5.basic.Foo; 9 | import org.jboss.weld.junit5.basic.SomeFoo; 10 | import org.junit.jupiter.api.DisplayName; 11 | import org.junit.jupiter.api.Test; 12 | 13 | @EnableAutoWeld 14 | @AddBeanClasses(SomeFoo.class) 15 | @ExcludeBeanClasses(Foo.class) 16 | class ExcludeBeanClassesTest { 17 | 18 | @Produces 19 | static Foo fakeFoo = new Foo("non-baz"); 20 | 21 | @Test 22 | @DisplayName("Ensure @ExcludeBeanClasses excludes the specified classes") 23 | void test(Foo myFoo) { 24 | assertNotNull(myFoo); 25 | assertEquals(myFoo.getBar(), "non-baz"); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /spock/src/test/resources/SpockConfig.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | runner { 19 | parallel { 20 | enabled true 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /junit4/src/test/java/org/jboss/weld/junit4/bean/MockBeanWithQualifiersTest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit4.bean; 2 | 3 | import jakarta.enterprise.inject.Any; 4 | 5 | import org.jboss.weld.junit.MockBean; 6 | import org.jboss.weld.junit4.WeldInitiator; 7 | import org.junit.Assert; 8 | import org.junit.Rule; 9 | import org.junit.Test; 10 | 11 | /** 12 | * Tests that {@link MockBean} with custom qualifiers has {@link Any} qualifier automatically added. 13 | */ 14 | public class MockBeanWithQualifiersTest { 15 | 16 | @Rule 17 | public WeldInitiator weld = WeldInitiator.from(MockBeanWithQualifiersTest.class) 18 | .addBeans(MockBean.builder().types(String.class).qualifiers(Meaty.Literal.INSTANCE).create(c -> "foo").build()) 19 | .build(); 20 | 21 | @Test 22 | public void testBeanHasDefaultQualifiersAdded() { 23 | Assert.assertEquals("foo", weld.select(String.class, Any.Literal.INSTANCE).get()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/ExcludeBeanHierarchyTest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.auto; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; 4 | import static org.junit.jupiter.api.Assertions.assertNotNull; 5 | 6 | import jakarta.enterprise.inject.Produces; 7 | 8 | import org.jboss.weld.junit5.basic.Foo; 9 | import org.jboss.weld.junit5.basic.IFoo; 10 | import org.jboss.weld.junit5.basic.SomeIFoo; 11 | import org.junit.jupiter.api.DisplayName; 12 | import org.junit.jupiter.api.Test; 13 | 14 | @EnableAutoWeld 15 | @AddBeanClasses(SomeIFoo.class) 16 | class ExcludeBeanHierarchyTest { 17 | 18 | @Produces 19 | @ExcludeBean 20 | IFoo fakeFoo = new Foo("non-baz"); 21 | 22 | @Test 23 | @DisplayName("Ensure @ExcludeBean excludes all beans in implied hierarchy") 24 | void test(IFoo myIFoo) { 25 | assertNotNull(myIFoo); 26 | assertEquals(myIFoo.getBar(), "non-baz"); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/initiator/bean/Foo.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.initiator.bean 19 | 20 | /** 21 | * @author Björn Kautler 22 | */ 23 | class Foo { 24 | } 25 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/basic/IFoo.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.basic 19 | 20 | /** 21 | * @author Björn Kautler 22 | */ 23 | interface IFoo { 24 | String getBar() 25 | } 26 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/ProducesBeforeTest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.auto; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertNotNull; 4 | 5 | import jakarta.enterprise.context.Dependent; 6 | import jakarta.enterprise.inject.Produces; 7 | import jakarta.inject.Named; 8 | 9 | import org.junit.jupiter.api.BeforeEach; 10 | import org.junit.jupiter.api.DisplayName; 11 | import org.junit.jupiter.api.Test; 12 | 13 | @EnableAutoWeld 14 | class ProducesBeforeTest { 15 | 16 | private Integer requiredValue; 17 | 18 | @BeforeEach 19 | void init() { 20 | requiredValue = 10; 21 | } 22 | 23 | @Produces 24 | @Dependent 25 | @Named("computed") 26 | Integer provideComputedValue() { 27 | return requiredValue * 10; 28 | } 29 | 30 | @Test 31 | @DisplayName("Ensure that @BeforeEach runs before any @Produces methods/fields are interrogated") 32 | void test(@Named("computed") Integer computed) { 33 | assertNotNull(computed); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/bean/Foo.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.bean 19 | 20 | /** 21 | * @author Björn Kautler 22 | */ 23 | class Foo { 24 | String ping() { 25 | 'foo' 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/bean/MockBeanWithQualifiersTest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.bean; 2 | 3 | import jakarta.enterprise.inject.Any; 4 | 5 | import org.jboss.weld.junit.MockBean; 6 | import org.jboss.weld.junit5.EnableWeld; 7 | import org.jboss.weld.junit5.WeldInitiator; 8 | import org.jboss.weld.junit5.WeldSetup; 9 | import org.junit.jupiter.api.Assertions; 10 | import org.junit.jupiter.api.Test; 11 | 12 | /** 13 | * Tests that {@link MockBean} with custom qualifiers has {@link Any} qualifier automatically added. 14 | */ 15 | @EnableWeld 16 | public class MockBeanWithQualifiersTest { 17 | 18 | @WeldSetup 19 | public WeldInitiator weld = WeldInitiator.from(AlternativeMockBeanTest.SimpleService.class) 20 | .addBeans(MockBean.builder().types(String.class).qualifiers(Meaty.Literal.INSTANCE).create(c -> "foo").build()) 21 | .build(); 22 | 23 | @Test 24 | public void testBeanHasDefaultQualifiersAdded() { 25 | Assertions.assertEquals("foo", weld.select(String.class, Any.Literal.INSTANCE).get()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/auto/beans/Engine.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.auto.beans 19 | 20 | /** 21 | * @author Björn Kautler 22 | */ 23 | interface Engine { 24 | int getThrottle() 25 | 26 | void setThrottle(int value) 27 | } 28 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/scope/PlainBean.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.scope 19 | 20 | import jakarta.enterprise.context.ApplicationScoped 21 | 22 | /** 23 | * @author Björn Kautler 24 | */ 25 | @ApplicationScoped 26 | class PlainBean { 27 | } 28 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/auto/interceptorAndDecorator/DecoratedBeanInterface.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.auto.interceptorAndDecorator 19 | 20 | /** 21 | * @author Björn Kautler 22 | */ 23 | interface DecoratedBeanInterface { 24 | String ping() 25 | } 26 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/bean/extension/GoodOldBean.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.bean.extension 19 | 20 | import jakarta.enterprise.context.ApplicationScoped 21 | 22 | /** 23 | * @author Björn Kautler 24 | */ 25 | @ApplicationScoped 26 | class GoodOldBean { 27 | } 28 | -------------------------------------------------------------------------------- /junit5/src/main/java/org/jboss/weld/junit5/auto/SetBeanDiscoveryMode.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.auto; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Inherited; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import org.jboss.weld.bootstrap.spi.BeanDiscoveryMode; 10 | 11 | /** 12 | * Sets discovery mode for Weld SE synthetic bean archive. Valid options are {@link BeanDiscoveryMode#ALL} and 13 | * {@link BeanDiscoveryMode#ANNOTATED}. 14 | *

15 | * Starting with Weld 5 (CDI 4), the default value is {@code ANNOTATED}. Applications can leverage this annotation to 16 | * enforce same behavior as older Weld versions where synthetic archives used discovery mode {@code ALL}. 17 | *

18 | * This annotation is equal to invocation of {@link org.jboss.weld.environment.se.Weld#setBeanDiscoveryMode(BeanDiscoveryMode)}. 19 | */ 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Target(ElementType.TYPE) 22 | @Inherited 23 | public @interface SetBeanDiscoveryMode { 24 | 25 | BeanDiscoveryMode value(); 26 | } 27 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/ExcludeBeanDepsTest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.auto; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertNotNull; 4 | 5 | import jakarta.enterprise.inject.Produces; 6 | 7 | import org.jboss.weld.junit5.basic.unsatisfied.FooDeps; 8 | import org.jboss.weld.junit5.basic.unsatisfied.SomeFooDeps; 9 | import org.junit.jupiter.api.DisplayName; 10 | import org.junit.jupiter.api.Test; 11 | 12 | @EnableAutoWeld 13 | @AddBeanClasses(SomeFooDeps.class) 14 | class ExcludeBeanDepsTest { 15 | 16 | /** 17 | * FooDeps injects the Baz bean which has an unsatisfied dependency "bar-value". Excluding FooDeps should ensure 18 | * that its specific dependencies are not included via scanning and therefore don't need to be provided for 19 | * testing. 20 | */ 21 | 22 | @Produces 23 | @ExcludeBean 24 | FooDeps fakeFooDeps = new FooDeps(); 25 | 26 | @Test 27 | @DisplayName("Ensure @ExcludeBean excludes any specific dependencies of the excluded class") 28 | void test(FooDeps myFooDeps) { 29 | assertNotNull(myFooDeps); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/ProducerMethodParametersScanningTest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.auto; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertNotNull; 4 | 5 | import jakarta.enterprise.context.Dependent; 6 | import jakarta.enterprise.inject.Produces; 7 | import jakarta.inject.Named; 8 | 9 | import org.jboss.weld.junit5.auto.beans.Engine; 10 | import org.jboss.weld.junit5.auto.beans.V6; 11 | import org.junit.jupiter.api.Test; 12 | 13 | @EnableAutoWeld 14 | public class ProducerMethodParametersScanningTest { 15 | 16 | @Produces 17 | @Named("custom") 18 | @Dependent 19 | Engine getEngine(V6 v6) { 20 | return new Engine() { 21 | @Override 22 | public int getThrottle() { 23 | return v6.getThrottle(); 24 | } 25 | 26 | @Override 27 | public void setThrottle(int value) { 28 | v6.setThrottle(value); 29 | } 30 | }; 31 | } 32 | 33 | @Test 34 | public void test(@Named("custom") Engine engine) { 35 | assertNotNull(engine); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /junit4/src/test/java/org/jboss/weld/junit4/resources/FooEjbs.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit4.resources; 18 | 19 | import jakarta.ejb.EJB; 20 | import jakarta.enterprise.context.Dependent; 21 | 22 | @Dependent 23 | public class FooEjbs { 24 | 25 | @EJB 26 | DummySessionBean dummySessionBean; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/resources/FooEjbs.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.resources; 18 | 19 | import jakarta.ejb.EJB; 20 | import jakarta.enterprise.context.Dependent; 21 | 22 | @Dependent 23 | public class FooEjbs { 24 | 25 | @EJB 26 | DummySessionBean dummySessionBean; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/resources/DummySessionBean.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.resources 19 | 20 | /** 21 | * @author Björn Kautler 22 | */ 23 | class DummySessionBean { 24 | final String id 25 | 26 | DummySessionBean(String id) { 27 | this.id = id 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/explicitInjection/Foo.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.explicitInjection 19 | 20 | import jakarta.enterprise.context.Dependent 21 | 22 | /** 23 | * @author Björn Kautler 24 | */ 25 | @Dependent 26 | class Foo { 27 | String ping() { 28 | return Foo.simpleName 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/ExcludeBeanClassesDepsTest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.auto; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertNotNull; 4 | 5 | import jakarta.enterprise.inject.Produces; 6 | 7 | import org.jboss.weld.junit5.basic.unsatisfied.FooDeps; 8 | import org.jboss.weld.junit5.basic.unsatisfied.SomeFooDeps; 9 | import org.junit.jupiter.api.DisplayName; 10 | import org.junit.jupiter.api.Test; 11 | 12 | @EnableAutoWeld 13 | @AddBeanClasses(SomeFooDeps.class) 14 | @ExcludeBeanClasses(FooDeps.class) 15 | class ExcludeBeanClassesDepsTest { 16 | 17 | /** 18 | * FooDeps injects the Baz bean which has an unsatisfied dependency "bar-value". Excluding FooDeps should ensure 19 | * that its specific dependencies are not included via scanning and therefore don't need to be provided for 20 | * testing. 21 | */ 22 | 23 | @Produces 24 | FooDeps fakeFooDeps = new FooDeps(); 25 | 26 | @Test 27 | @DisplayName("Ensure @ExcludeBeanClasses excludes any specific dependencies of the excluded classes") 28 | void test(FooDeps myFooDeps) { 29 | assertNotNull(myFooDeps); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/testLifecycle/PlainBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.testLifecycle; 18 | 19 | import jakarta.enterprise.context.ApplicationScoped; 20 | 21 | /** 22 | * 23 | * @author Matej Novotny 24 | */ 25 | @ApplicationScoped 26 | public class PlainBean { 27 | 28 | } 29 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/basic/SomeFoo.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.basic 19 | 20 | import jakarta.enterprise.context.ApplicationScoped 21 | import jakarta.inject.Inject 22 | 23 | /** 24 | * @author Björn Kautler 25 | */ 26 | @ApplicationScoped 27 | class SomeFoo { 28 | @Inject 29 | private Foo foo 30 | } 31 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/resources/FooEjbs.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.resources 19 | 20 | import jakarta.ejb.EJB 21 | import jakarta.enterprise.context.Dependent 22 | 23 | /** 24 | * @author Björn Kautler 25 | */ 26 | @Dependent 27 | class FooEjbs { 28 | @EJB 29 | DummySessionBean dummySessionBean 30 | } 31 | -------------------------------------------------------------------------------- /junit4/src/test/java/org/jboss/weld/junit4/FooAlternative.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit4; 18 | 19 | import jakarta.enterprise.inject.Alternative; 20 | 21 | @Alternative 22 | public class FooAlternative extends Foo { 23 | 24 | @Override 25 | public String getBar() { 26 | return super.getBar().toUpperCase(); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /junit4/src/test/java/org/jboss/weld/junit4/bean/extension/GoodOldBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2018, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit4.bean.extension; 18 | 19 | import jakarta.enterprise.context.ApplicationScoped; 20 | 21 | /** 22 | * 23 | * @author Matej Novotny 24 | */ 25 | @ApplicationScoped 26 | public class GoodOldBean { 27 | 28 | } 29 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/interceptorAndDecorator/DecoratedBeanInterface.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2018, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.auto.interceptorAndDecorator; 18 | 19 | /** 20 | * 21 | * @author Matej Novotny 22 | */ 23 | public interface DecoratedBeanInterface { 24 | 25 | public String ping(); 26 | } 27 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/bean/extension/GoodOldBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2018, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.bean.extension; 18 | 19 | import jakarta.enterprise.context.ApplicationScoped; 20 | 21 | /** 22 | * 23 | * @author Matej Novotny 24 | */ 25 | @ApplicationScoped 26 | public class GoodOldBean { 27 | 28 | } 29 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/auto/alternatives/Foo.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.auto.alternatives 19 | 20 | import jakarta.enterprise.context.ApplicationScoped 21 | 22 | /** 23 | * @author Björn Kautler 24 | */ 25 | @ApplicationScoped 26 | class Foo { 27 | String ping() { 28 | Foo.simpleName 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/basic/SomeIFoo.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.basic 19 | 20 | import jakarta.enterprise.context.ApplicationScoped 21 | import jakarta.inject.Inject 22 | 23 | /** 24 | * @author Björn Kautler 25 | */ 26 | @ApplicationScoped 27 | class SomeIFoo { 28 | @Inject 29 | private IFoo foo 30 | } 31 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/contexts/SomeAnnotation.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.contexts 19 | 20 | import java.lang.annotation.Retention 21 | 22 | import static java.lang.annotation.RetentionPolicy.RUNTIME 23 | 24 | /** 25 | * @author Björn Kautler 26 | */ 27 | @Retention(RUNTIME) 28 | @interface SomeAnnotation { 29 | } 30 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/extensionInjection/FooBean.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.extensionInjection 19 | 20 | import jakarta.enterprise.context.Dependent 21 | 22 | /** 23 | * @author Björn Kautler 24 | */ 25 | @Dependent 26 | class FooBean { 27 | String ping() { 28 | return FooBean.simpleName 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/basic/FooAlternative.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.basic; 18 | 19 | import jakarta.enterprise.inject.Alternative; 20 | 21 | @Alternative 22 | public class FooAlternative extends Foo { 23 | 24 | @Override 25 | public String getBar() { 26 | return super.getBar().toUpperCase(); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/auto/alternativeStereotype/Foo.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.auto.alternativeStereotype 19 | 20 | import jakarta.enterprise.context.ApplicationScoped 21 | 22 | /** 23 | * @author Björn Kautler 24 | */ 25 | @ApplicationScoped 26 | class Foo { 27 | String ping() { 28 | Foo.simpleName 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/alternative/Fish.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.alternative 19 | 20 | /** 21 | * @author Björn Kautler 22 | */ 23 | class Fish { 24 | private int legs 25 | 26 | Fish(int numberOfLegs) { 27 | legs = numberOfLegs 28 | } 29 | 30 | int getNumberOfLegs() { 31 | return legs 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/extensionInjection/SomeBean.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.extensionInjection 19 | 20 | import jakarta.enterprise.context.ApplicationScoped 21 | 22 | /** 23 | * @author Björn Kautler 24 | */ 25 | @ApplicationScoped 26 | class SomeBean { 27 | String ping() { 28 | return SomeBean.simpleName 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/basic/FooAlternative.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.basic 19 | 20 | import jakarta.enterprise.inject.Alternative 21 | 22 | /** 23 | * @author Björn Kautler 24 | */ 25 | @Alternative 26 | class FooAlternative extends Foo { 27 | @Override 28 | String getBar() { 29 | return super.bar.toUpperCase() 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/basic/unsatisfied/SomeFooDeps.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.basic.unsatisfied 19 | 20 | import jakarta.enterprise.context.ApplicationScoped 21 | import jakarta.inject.Inject 22 | 23 | /** 24 | * @author Björn Kautler 25 | */ 26 | @ApplicationScoped 27 | class SomeFooDeps { 28 | @Inject 29 | private FooDeps fooDeps 30 | } 31 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/extensionInjection/BarBean.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.extensionInjection 19 | 20 | import jakarta.enterprise.context.ApplicationScoped 21 | 22 | /** 23 | * @author Björn Kautler 24 | */ 25 | @ApplicationScoped 26 | @MyQualifier 27 | class BarBean { 28 | String ping() { 29 | return BarBean.simpleName 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/ExplicitParametersAutoConfigTest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.auto; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; 4 | import static org.junit.jupiter.api.Assertions.assertNotNull; 5 | 6 | import jakarta.enterprise.inject.Default; 7 | 8 | import org.jboss.weld.junit5.ExplicitParamInjection; 9 | import org.jboss.weld.junit5.basic.Foo; 10 | import org.jboss.weld.junit5.explicitInjection.Bar; 11 | import org.jboss.weld.junit5.explicitInjection.CustomExtension; 12 | import org.junit.jupiter.api.DisplayName; 13 | import org.junit.jupiter.api.Test; 14 | import org.junit.jupiter.api.extension.ExtendWith; 15 | 16 | @EnableAutoWeld 17 | @ExplicitParamInjection 18 | @ExtendWith(CustomExtension.class) 19 | public class ExplicitParametersAutoConfigTest { 20 | 21 | @Test 22 | @DisplayName("Ensure the parameter Foo is automatically included in container and that Bar comes from the CustomExtension") 23 | void test(@Default Foo foo, Bar bar) { 24 | assertNotNull(bar); 25 | assertEquals(bar.ping(), CustomExtension.class.getSimpleName()); 26 | assertNotNull(foo); 27 | assertEquals(foo.getBar(), "baz"); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/contexts/SomeAnnotation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.contexts; 18 | 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | 22 | /** 23 | * 24 | * @author Matej Novotny 25 | */ 26 | @Retention(RetentionPolicy.RUNTIME) 27 | public @interface SomeAnnotation { 28 | 29 | } 30 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/compat/JunitParameterResolverReferenceTest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.compat; 2 | 3 | import java.nio.file.Path; 4 | 5 | import org.junit.jupiter.api.Assertions; 6 | import org.junit.jupiter.api.RepeatedTest; 7 | import org.junit.jupiter.api.RepetitionInfo; 8 | import org.junit.jupiter.api.Test; 9 | import org.junit.jupiter.api.TestInfo; 10 | import org.junit.jupiter.api.TestReporter; 11 | import org.junit.jupiter.api.io.TempDir; 12 | 13 | /** 14 | * This test runs without CDI in order to demonstrate that it works with plain JUnit. 15 | */ 16 | class JunitParameterResolverReferenceTest { 17 | 18 | @Test 19 | void testResolveTestInfo(TestInfo testInfo) { 20 | Assertions.assertNotNull(testInfo); 21 | } 22 | 23 | @RepeatedTest(1) 24 | void testResolveRepetitionInfo(RepetitionInfo repetitionInfo) { 25 | Assertions.assertNotNull(repetitionInfo); 26 | } 27 | 28 | @Test 29 | void testResolveTestReporter(TestReporter testReporter) { 30 | Assertions.assertNotNull(testReporter); 31 | } 32 | 33 | @Test 34 | void testResolveTempDir(@TempDir Path tempDir) { 35 | Assertions.assertNotNull(tempDir); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/auto/beans/unsatisfied/InjectedV8NoAnnotation.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.auto.beans.unsatisfied 19 | 20 | import jakarta.enterprise.context.ApplicationScoped 21 | import jakarta.inject.Inject 22 | 23 | /** 24 | * @author Björn Kautler 25 | */ 26 | @ApplicationScoped 27 | class InjectedV8NoAnnotation { 28 | @Inject 29 | V8NoAnnotation v8 30 | } 31 | -------------------------------------------------------------------------------- /junit-common/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | Weld Testing Common Utilities 6 | 7 | 8 | org.jboss.weld 9 | weld-junit-parent 10 | 5.0.4-SNAPSHOT 11 | 12 | 13 | weld-junit-common 14 | jar 15 | 16 | 17 | 18 | 19 | org.jboss.weld.se 20 | weld-se-core 21 | 22 | 23 | 24 | jakarta.persistence 25 | jakarta.persistence-api 26 | 27 | 28 | 29 | com.github.spotbugs 30 | spotbugs-annotations 31 | ${version.spotbugs} 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/explicitInjection/Foo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.explicitInjection; 18 | 19 | import jakarta.enterprise.context.Dependent; 20 | 21 | /** 22 | * 23 | * @author Matej Novotny 24 | */ 25 | @Dependent 26 | public class Foo { 27 | 28 | public String ping() { 29 | return Foo.class.getSimpleName(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/explicitInjection/BeanWithQualifier.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.explicitInjection 19 | 20 | import jakarta.enterprise.context.ApplicationScoped 21 | 22 | /** 23 | * @author Björn Kautler 24 | */ 25 | @ApplicationScoped 26 | @MyQualifier 27 | class BeanWithQualifier { 28 | String ping() { 29 | return BeanWithQualifier.simpleName 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/auto/interceptorAndDecorator/InterceptedBean.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.auto.interceptorAndDecorator 19 | 20 | import jakarta.enterprise.context.Dependent 21 | 22 | /** 23 | * @author Björn Kautler 24 | */ 25 | @Dependent 26 | class InterceptedBean { 27 | @TestInterceptorBinding 28 | String ping() { 29 | InterceptedBean.toString() 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/alternatives/Foo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2018, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.auto.alternatives; 18 | 19 | import jakarta.enterprise.context.ApplicationScoped; 20 | 21 | /** 22 | * 23 | * @author Matej Novotny 24 | */ 25 | @ApplicationScoped 26 | public class Foo { 27 | 28 | public String ping() { 29 | return Foo.class.getSimpleName(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/extensionInjection/FooBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.extensionInjection; 18 | 19 | import jakarta.enterprise.context.Dependent; 20 | 21 | /** 22 | * 23 | * @author Matej Novotny 24 | */ 25 | @Dependent 26 | public class FooBean { 27 | 28 | public String ping() { 29 | return FooBean.class.getSimpleName(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/auto/alternativeStereotype/FooAlternative.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.auto.alternativeStereotype 19 | 20 | import jakarta.enterprise.context.ApplicationScoped 21 | 22 | /** 23 | * @author Björn Kautler 24 | */ 25 | @SomeStereotype 26 | @ApplicationScoped 27 | class FooAlternative extends Foo { 28 | String ping() { 29 | FooAlternative.simpleName 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/auto/interceptorAndDecorator/DecoratedBean.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.auto.interceptorAndDecorator 19 | 20 | import jakarta.enterprise.context.Dependent 21 | 22 | /** 23 | * @author Björn Kautler 24 | */ 25 | @Dependent 26 | class DecoratedBean implements DecoratedBeanInterface { 27 | @Override 28 | String ping() { 29 | DecoratedBean.toString() 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/alternativeStereotype/Foo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2018, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.auto.alternativeStereotype; 18 | 19 | import jakarta.enterprise.context.ApplicationScoped; 20 | 21 | /** 22 | * 23 | * @author Matej Novotny 24 | */ 25 | @ApplicationScoped 26 | public class Foo { 27 | 28 | public String ping() { 29 | return Foo.class.getSimpleName(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/extensionInjection/SomeBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.extensionInjection; 18 | 19 | import jakarta.enterprise.context.ApplicationScoped; 20 | 21 | /** 22 | * 23 | * @author Matej Novotny 24 | */ 25 | @ApplicationScoped 26 | public class SomeBean { 27 | 28 | public String ping() { 29 | return SomeBean.class.getSimpleName(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/bean/Blue.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.bean 19 | 20 | import jakarta.enterprise.context.ApplicationScoped 21 | import jakarta.inject.Inject 22 | 23 | /** 24 | * @author Björn Kautler 25 | */ 26 | @ApplicationScoped 27 | class Blue { 28 | @Inject 29 | @Meaty 30 | private List stringList 31 | 32 | List getStringList() { 33 | return stringList 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/basic/unsatisfied/FooDeps.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.basic.unsatisfied; 18 | 19 | import jakarta.enterprise.context.ApplicationScoped; 20 | import jakarta.inject.Inject; 21 | 22 | @ApplicationScoped 23 | public class FooDeps { 24 | 25 | @Inject 26 | Baz baz; 27 | 28 | public FooDeps() { 29 | } 30 | 31 | public String getBar() { 32 | return baz.getBar(); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/auto/alternatives/FooAlternative.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.auto.alternatives 19 | 20 | import jakarta.enterprise.context.ApplicationScoped 21 | import jakarta.enterprise.inject.Alternative 22 | 23 | /** 24 | * @author Björn Kautler 25 | */ 26 | @Alternative 27 | @ApplicationScoped 28 | class FooAlternative extends Foo { 29 | String ping() { 30 | FooAlternative.simpleName 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /junit4/src/test/java/org/jboss/weld/junit4/Foo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit4; 18 | 19 | import jakarta.annotation.PostConstruct; 20 | import jakarta.enterprise.context.ApplicationScoped; 21 | 22 | @ApplicationScoped 23 | public class Foo { 24 | 25 | private String bar; 26 | 27 | @PostConstruct 28 | public void init() { 29 | bar = "baz"; 30 | } 31 | 32 | public String getBar() { 33 | return bar; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /junit4/src/test/java/org/jboss/weld/junit4/bean/Blue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit4.bean; 18 | 19 | import java.util.List; 20 | 21 | import jakarta.enterprise.context.ApplicationScoped; 22 | import jakarta.inject.Inject; 23 | 24 | @ApplicationScoped 25 | public class Blue { 26 | 27 | @Inject 28 | @Meaty 29 | private List stringList; 30 | 31 | public List getStringList() { 32 | return stringList; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/bean/Blue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.bean; 18 | 19 | import java.util.List; 20 | 21 | import jakarta.enterprise.context.ApplicationScoped; 22 | import jakarta.inject.Inject; 23 | 24 | @ApplicationScoped 25 | public class Blue { 26 | 27 | @Inject 28 | @Meaty 29 | private List stringList; 30 | 31 | public List getStringList() { 32 | return stringList; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/extensionInjection/BarBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.extensionInjection; 18 | 19 | import jakarta.enterprise.context.ApplicationScoped; 20 | 21 | /** 22 | * 23 | * @author Matej Novotny 24 | */ 25 | @ApplicationScoped 26 | @MyQualifier 27 | public class BarBean { 28 | 29 | public String ping() { 30 | return BarBean.class.getSimpleName(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/basic/unsatisfied/FooDeps.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.basic.unsatisfied 19 | 20 | import jakarta.enterprise.context.ApplicationScoped 21 | import jakarta.inject.Inject 22 | 23 | /** 24 | * @author Björn Kautler 25 | */ 26 | @ApplicationScoped 27 | class FooDeps { 28 | @Inject 29 | Baz baz 30 | 31 | FooDeps() { 32 | } 33 | 34 | String getBar() { 35 | baz.bar 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /junit4/src/test/java/org/jboss/weld/junit4/resources/FooResources.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit4.resources; 18 | 19 | import jakarta.annotation.Resource; 20 | import jakarta.enterprise.context.Dependent; 21 | 22 | @Dependent 23 | public class FooResources { 24 | 25 | @Resource(lookup = "bar") 26 | String bar; 27 | 28 | String baz; 29 | 30 | @Resource(name = "baz") 31 | void setBaz(String baz) { 32 | this.baz = baz; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/resources/FooResources.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.resources; 18 | 19 | import jakarta.annotation.Resource; 20 | import jakarta.enterprise.context.Dependent; 21 | 22 | @Dependent 23 | public class FooResources { 24 | 25 | @Resource(lookup = "bar") 26 | String bar; 27 | 28 | String baz; 29 | 30 | @Resource(name = "baz") 31 | void setBaz(String baz) { 32 | this.baz = baz; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/SetDiscoveryModeAllTest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.auto; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertNotNull; 4 | import static org.junit.jupiter.api.Assertions.assertTrue; 5 | 6 | import jakarta.enterprise.inject.Instance; 7 | import jakarta.inject.Inject; 8 | 9 | import org.jboss.weld.bootstrap.spi.BeanDiscoveryMode; 10 | import org.jboss.weld.junit5.auto.discovery.WithBeanDefiningAnnotation; 11 | import org.jboss.weld.junit5.auto.discovery.WithoutBeanDefiningAnnotation; 12 | import org.junit.jupiter.api.Test; 13 | 14 | @EnableAutoWeld 15 | @AddPackages(value = WithBeanDefiningAnnotation.class, recursively = false) 16 | @SetBeanDiscoveryMode(BeanDiscoveryMode.ALL) 17 | public class SetDiscoveryModeAllTest { 18 | 19 | @Inject 20 | private WithBeanDefiningAnnotation standardBean; 21 | 22 | @Inject 23 | Instance instance; 24 | 25 | @Test 26 | void testDiscoveryModeWasChanged() { 27 | // bean with bean defining annotation is normally resolvable 28 | assertNotNull(standardBean); 29 | // bean without bean defining annotation is discovered as well because we set discovery to ALL 30 | assertTrue(instance.select(WithoutBeanDefiningAnnotation.class).isResolvable()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/explicitInjection/BeanWithQualifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.explicitInjection; 18 | 19 | import jakarta.enterprise.context.ApplicationScoped; 20 | 21 | /** 22 | * 23 | * @author Matej Novotny 24 | */ 25 | @ApplicationScoped 26 | @MyQualifier 27 | public class BeanWithQualifier { 28 | 29 | public String ping() { 30 | return BeanWithQualifier.class.getSimpleName(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/interceptorAndDecorator/InterceptedBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2018, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.auto.interceptorAndDecorator; 18 | 19 | import jakarta.enterprise.context.Dependent; 20 | 21 | /** 22 | * 23 | * @author Matej Novotny 24 | */ 25 | @TestInterceptorBinding 26 | @Dependent 27 | public class InterceptedBean { 28 | 29 | public String ping() { 30 | return InterceptedBean.class.toString(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /junit4/src/test/java/org/jboss/weld/junit4/contexts/InvalidScopeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit4.contexts; 18 | 19 | import org.jboss.weld.junit4.WeldInitiator; 20 | import org.junit.Rule; 21 | import org.junit.Test; 22 | 23 | /** 24 | * 25 | * @author Martin Kouba 26 | */ 27 | public class InvalidScopeTest { 28 | 29 | @Test(expected = IllegalArgumentException.class) 30 | public void testFoo() { 31 | WeldInitiator.from(Foo.class).activate(Rule.class); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/resources/FooResources.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.resources 19 | 20 | import jakarta.annotation.Resource 21 | import jakarta.enterprise.context.Dependent 22 | 23 | /** 24 | * @author Björn Kautler 25 | */ 26 | @Dependent 27 | class FooResources { 28 | @Resource(lookup = 'bar') 29 | String bar 30 | 31 | String baz 32 | 33 | @Resource(name = 'baz') 34 | void setBaz(String baz) { 35 | this.baz = baz 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/auto/beans/V8.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.auto.beans 19 | 20 | import jakarta.enterprise.context.Dependent 21 | 22 | /** 23 | * @author Björn Kautler 24 | */ 25 | @Dependent 26 | class V8 implements Engine, Serializable { 27 | private int throttle = 0 28 | 29 | int getThrottle() { 30 | return throttle 31 | } 32 | 33 | @Override 34 | void setThrottle(int throttle) { 35 | this.throttle = throttle 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/contexts/Foo.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.contexts 19 | 20 | import jakarta.annotation.PostConstruct 21 | import jakarta.enterprise.context.RequestScoped 22 | 23 | /** 24 | * @author Björn Kautler 25 | */ 26 | @RequestScoped 27 | class Foo { 28 | private String id 29 | 30 | @PostConstruct 31 | void init() { 32 | id = UUID.randomUUID().toString() 33 | } 34 | 35 | String getId() { 36 | return id 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/contexts/RequestScopedProducer.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.contexts 19 | 20 | import jakarta.enterprise.context.Dependent 21 | import jakarta.enterprise.context.RequestScoped 22 | import jakarta.enterprise.inject.Produces 23 | 24 | /** 25 | * @author Björn Kautler 26 | */ 27 | @RequestScoped 28 | class RequestScopedProducer { 29 | @Produces 30 | @Dependent 31 | String produceDependentString() { 32 | return 'foo' 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/explicitInjection/Bar.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.explicitInjection 19 | 20 | import jakarta.enterprise.context.ApplicationScoped 21 | 22 | /** 23 | * @author Björn Kautler 24 | */ 25 | @ApplicationScoped 26 | class Bar { 27 | private String someText 28 | 29 | Bar() { 30 | } 31 | 32 | Bar(String someText) { 33 | this.someText = someText 34 | } 35 | 36 | String ping() { 37 | return someText 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/initiator/discovery/SuperclassWithWeldInitiatorTest.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.initiator.discovery 19 | 20 | import org.jboss.weld.spock.initiator.bean.Foo 21 | 22 | /** 23 | * @author Björn Kautler 24 | */ 25 | class SuperclassWithWeldInitiatorTest extends SuperclassWithWeldInitiator { 26 | def 'Weld can be initialized from an initiator in a super spec'() { 27 | expect: 28 | weld.select(Foo).get() != null 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/alternativeStereotype/FooAlternative.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2018, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.auto.alternativeStereotype; 18 | 19 | import jakarta.enterprise.context.ApplicationScoped; 20 | 21 | /** 22 | * 23 | * @author Matej Novotny 24 | */ 25 | @SomeStereotype 26 | @ApplicationScoped 27 | public class FooAlternative extends Foo { 28 | 29 | public String ping() { 30 | return FooAlternative.class.getSimpleName(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/basic/unsatisfied/Baz.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.basic.unsatisfied 19 | 20 | import jakarta.enterprise.context.ApplicationScoped 21 | import jakarta.inject.Inject 22 | import jakarta.inject.Named 23 | 24 | /** 25 | * @author Björn Kautler 26 | */ 27 | @ApplicationScoped 28 | class Baz { 29 | @Inject 30 | @Named('bar-value') 31 | String bar 32 | 33 | Baz() { 34 | } 35 | 36 | String getBar() { 37 | bar 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /junit4/src/test/java/org/jboss/weld/junit4/ofpackage/Alpha.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit4.ofpackage; 18 | 19 | import jakarta.annotation.PostConstruct; 20 | import jakarta.enterprise.context.Dependent; 21 | 22 | @Dependent 23 | public class Alpha { 24 | 25 | private String value; 26 | 27 | @PostConstruct 28 | public void init() { 29 | value = this.getClass().getSimpleName().toLowerCase(); 30 | } 31 | 32 | public String getValue() { 33 | return value; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /junit4/src/test/java/org/jboss/weld/junit4/ofpackage/Bravo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit4.ofpackage; 18 | 19 | import jakarta.annotation.PostConstruct; 20 | import jakarta.enterprise.context.Dependent; 21 | 22 | @Dependent 23 | public class Bravo { 24 | 25 | private String value; 26 | 27 | @PostConstruct 28 | public void init() { 29 | value = this.getClass().getSimpleName().toLowerCase(); 30 | } 31 | 32 | public String getValue() { 33 | return value; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/interceptorAndDecorator/DecoratedBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2018, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.auto.interceptorAndDecorator; 18 | 19 | import jakarta.enterprise.context.Dependent; 20 | 21 | /** 22 | * 23 | * @author Matej Novotny 24 | */ 25 | @Dependent 26 | public class DecoratedBean implements DecoratedBeanInterface { 27 | 28 | @Override 29 | public String ping() { 30 | return DecoratedBean.class.toString(); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/ofpackage/Alpha.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.ofpackage; 18 | 19 | import jakarta.annotation.PostConstruct; 20 | import jakarta.enterprise.context.Dependent; 21 | 22 | @Dependent 23 | public class Alpha { 24 | 25 | private String value; 26 | 27 | @PostConstruct 28 | public void init() { 29 | value = this.getClass().getSimpleName().toLowerCase(); 30 | } 31 | 32 | public String getValue() { 33 | return value; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/ofpackage/Bravo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.ofpackage; 18 | 19 | import jakarta.annotation.PostConstruct; 20 | import jakarta.enterprise.context.Dependent; 21 | 22 | @Dependent 23 | public class Bravo { 24 | 25 | private String value; 26 | 27 | @PostConstruct 28 | public void init() { 29 | value = this.getClass().getSimpleName().toLowerCase(); 30 | } 31 | 32 | public String getValue() { 33 | return value; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /junit4/src/test/java/org/jboss/weld/junit4/contexts/Foo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit4.contexts; 18 | 19 | import java.util.UUID; 20 | 21 | import jakarta.annotation.PostConstruct; 22 | import jakarta.enterprise.context.RequestScoped; 23 | 24 | @RequestScoped 25 | public class Foo { 26 | 27 | private String id; 28 | 29 | @PostConstruct 30 | public void init() { 31 | id = UUID.randomUUID().toString(); 32 | } 33 | 34 | public String getId() { 35 | return id; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /junit5/src/main/java/org/jboss/weld/junit5/WeldSetup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5; 18 | 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | 22 | /** 23 | * An annotation used to denote a WeldInitiator field. This is then picked up by {@link WeldJunit5Extension} and used for 24 | * configuration. 25 | * 26 | * @author Matej Novotny 27 | */ 28 | @Retention(RetentionPolicy.RUNTIME) 29 | public @interface WeldSetup { 30 | 31 | } 32 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/contexts/Foo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.contexts; 18 | 19 | import java.util.UUID; 20 | 21 | import jakarta.annotation.PostConstruct; 22 | import jakarta.enterprise.context.RequestScoped; 23 | 24 | @RequestScoped 25 | public class Foo { 26 | 27 | private String id; 28 | 29 | @PostConstruct 30 | public void init() { 31 | id = UUID.randomUUID().toString(); 32 | } 33 | 34 | public String getId() { 35 | return id; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/auto/beans/V6.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.auto.beans 19 | 20 | import jakarta.enterprise.context.ApplicationScoped 21 | 22 | /** 23 | * @author Björn Kautler 24 | */ 25 | @ApplicationScoped 26 | class V6 implements Engine, Serializable { 27 | private int throttle = 0 28 | 29 | int getThrottle() { 30 | return throttle 31 | } 32 | 33 | @Override 34 | void setThrottle(int throttle) { 35 | this.throttle = throttle 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/contexts/Oof.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.contexts 19 | 20 | import jakarta.annotation.PostConstruct 21 | import jakarta.enterprise.context.SessionScoped 22 | 23 | /** 24 | * @author Björn Kautler 25 | */ 26 | @SessionScoped 27 | class Oof implements Serializable { 28 | private String id 29 | 30 | @PostConstruct 31 | void init() { 32 | id = UUID.randomUUID().toString() 33 | } 34 | 35 | String getId() { 36 | return id 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/ofpackage/Alpha.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.ofpackage 19 | 20 | import jakarta.annotation.PostConstruct 21 | import jakarta.enterprise.context.Dependent 22 | 23 | /** 24 | * @author Björn Kautler 25 | */ 26 | @Dependent 27 | class Alpha { 28 | private String value 29 | 30 | @PostConstruct 31 | void init() { 32 | value = this.getClass().simpleName.toLowerCase() 33 | } 34 | 35 | String getValue() { 36 | return value 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/ofpackage/Bravo.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.ofpackage 19 | 20 | import jakarta.annotation.PostConstruct 21 | import jakarta.enterprise.context.Dependent 22 | 23 | /** 24 | * @author Björn Kautler 25 | */ 26 | @Dependent 27 | class Bravo { 28 | private String value 29 | 30 | @PostConstruct 31 | void init() { 32 | value = this.getClass().simpleName.toLowerCase() 33 | } 34 | 35 | String getValue() { 36 | return value 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /junit4/src/test/java/org/jboss/weld/junit4/SimpleTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit4; 18 | 19 | import static org.junit.Assert.assertEquals; 20 | 21 | import org.junit.Rule; 22 | import org.junit.Test; 23 | 24 | /** 25 | * 26 | * @author Martin Kouba 27 | */ 28 | public class SimpleTest { 29 | 30 | @Rule 31 | public WeldInitiator weld = WeldInitiator.of(Foo.class); 32 | 33 | @Test 34 | public void testFoo() { 35 | assertEquals("baz", weld.select(Foo.class).get().getBar()); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/auto/beans/unsatisfied/ConstructedV8NoAnnotation.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.auto.beans.unsatisfied 19 | 20 | import jakarta.enterprise.context.ApplicationScoped 21 | import jakarta.inject.Inject 22 | 23 | /** 24 | * @author Björn Kautler 25 | */ 26 | @ApplicationScoped 27 | class ConstructedV8NoAnnotation { 28 | private V8NoAnnotation engine 29 | 30 | @Inject 31 | ConstructedV8NoAnnotation(V8NoAnnotation engine) { 32 | this.engine = engine 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/alternatives/FooAlternative.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2018, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.auto.alternatives; 18 | 19 | import jakarta.enterprise.context.ApplicationScoped; 20 | import jakarta.enterprise.inject.Alternative; 21 | 22 | /** 23 | * 24 | * @author Matej Novotny 25 | */ 26 | @Alternative 27 | @ApplicationScoped 28 | public class FooAlternative extends Foo { 29 | 30 | public String ping() { 31 | return FooAlternative.class.getSimpleName(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /junit4/src/test/java/org/jboss/weld/junit4/classrule/Charlie.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit4.classrule; 18 | 19 | import java.util.UUID; 20 | 21 | import jakarta.annotation.PostConstruct; 22 | import jakarta.enterprise.context.ApplicationScoped; 23 | 24 | @ApplicationScoped 25 | public class Charlie { 26 | 27 | private String id; 28 | 29 | @PostConstruct 30 | public void init() { 31 | this.id = UUID.randomUUID().toString(); 32 | } 33 | 34 | public String getId() { 35 | return id; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /junit4/src/test/java/org/jboss/weld/junit4/BeanManagerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit4; 18 | 19 | import static org.junit.Assert.assertEquals; 20 | 21 | import org.junit.Rule; 22 | import org.junit.Test; 23 | 24 | /** 25 | * 26 | * @author Martin Kouba 27 | */ 28 | public class BeanManagerTest { 29 | 30 | @Rule 31 | public WeldInitiator weld = WeldInitiator.of(Foo.class); 32 | 33 | @Test 34 | public void testFooBean() { 35 | assertEquals(1, weld.getBeanManager().getBeans(Foo.class).size()); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/InheritedProducerFieldTest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.auto; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; 4 | 5 | import jakarta.enterprise.context.Dependent; 6 | import jakarta.enterprise.inject.Produces; 7 | import jakarta.enterprise.inject.spi.BeanManager; 8 | import jakarta.inject.Inject; 9 | 10 | import org.junit.jupiter.api.Nested; 11 | import org.junit.jupiter.api.Test; 12 | 13 | @EnableAutoWeld 14 | public class InheritedProducerFieldTest { 15 | 16 | @Dependent 17 | static class Foo { 18 | } 19 | 20 | static class BaseClass { 21 | @Produces 22 | Foo baseFooProducer = new Foo(); 23 | } 24 | 25 | @Nested 26 | class DontAddBeanClassesInheritedFromTestBaseClassTest extends BaseClass { 27 | @Test 28 | void test(BeanManager beanManager) { 29 | assertEquals(0, beanManager.getBeans(Foo.class).size()); 30 | } 31 | } 32 | 33 | @Dependent 34 | static class SubClass extends BaseClass { 35 | } 36 | 37 | @Nested 38 | class DontAddBeanClassesInheritedFromBeanBaseClassTest { 39 | @Inject 40 | SubClass subClass; 41 | 42 | @Test 43 | void test(BeanManager beanManager) { 44 | assertEquals(0, beanManager.getBeans(Foo.class).size()); 45 | } 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/bean/Bar.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.bean 19 | 20 | import jakarta.enterprise.context.ApplicationScoped 21 | import jakarta.inject.Inject 22 | 23 | /** 24 | * @author Björn Kautler 25 | */ 26 | @ApplicationScoped 27 | class Bar { 28 | @Inject 29 | @Meaty 30 | private Foo foo 31 | 32 | @Inject 33 | private List someList 34 | 35 | List getSomeList() { 36 | return someList 37 | } 38 | 39 | Foo getFoo() { 40 | return foo 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /junit4/src/test/java/org/jboss/weld/junit4/resources/FooJpa.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit4.resources; 18 | 19 | import jakarta.enterprise.context.Dependent; 20 | import jakarta.persistence.EntityManager; 21 | import jakarta.persistence.EntityManagerFactory; 22 | import jakarta.persistence.PersistenceContext; 23 | import jakarta.persistence.PersistenceUnit; 24 | 25 | @Dependent 26 | public class FooJpa { 27 | 28 | @PersistenceContext 29 | EntityManager entityManager; 30 | 31 | @PersistenceUnit 32 | EntityManagerFactory entityManagerFactory; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/resources/FooJpa.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.resources; 18 | 19 | import jakarta.enterprise.context.Dependent; 20 | import jakarta.persistence.EntityManager; 21 | import jakarta.persistence.EntityManagerFactory; 22 | import jakarta.persistence.PersistenceContext; 23 | import jakarta.persistence.PersistenceUnit; 24 | 25 | @Dependent 26 | public class FooJpa { 27 | 28 | @PersistenceContext 29 | EntityManager entityManager; 30 | 31 | @PersistenceUnit 32 | EntityManagerFactory entityManagerFactory; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/auto/AddExtensionsTest.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.auto 19 | 20 | import org.jboss.weld.spock.EnableWeld 21 | import org.jboss.weld.spock.auto.extension.AddedExtension 22 | import spock.lang.Specification 23 | 24 | /** 25 | * @author Björn Kautler 26 | */ 27 | @EnableWeld(automagic = true) 28 | @AddExtensions(AddedExtension) 29 | class AddExtensionsTest extends Specification { 30 | def '@AddExtensions should add the specified extensions'() { 31 | expect: 32 | AddedExtension.enabled 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/bean/BlueToDiscover.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.bean 19 | 20 | import jakarta.annotation.PostConstruct 21 | import jakarta.enterprise.context.ApplicationScoped 22 | import jakarta.inject.Named 23 | 24 | /** 25 | * @author Björn Kautler 26 | */ 27 | @Named('blue') 28 | @ApplicationScoped 29 | class BlueToDiscover { 30 | private String id 31 | 32 | @PostConstruct 33 | void init() { 34 | this.id = UUID.randomUUID().toString() 35 | } 36 | 37 | String getId() { 38 | return id 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/auto/interceptorAndDecorator/TestInterceptor.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.auto.interceptorAndDecorator 19 | 20 | import jakarta.interceptor.AroundInvoke 21 | import jakarta.interceptor.Interceptor 22 | import jakarta.interceptor.InvocationContext 23 | 24 | /** 25 | * @author Björn Kautler 26 | */ 27 | @Interceptor 28 | @TestInterceptorBinding 29 | class TestInterceptor { 30 | @AroundInvoke 31 | Object intercept(InvocationContext ctx) throws Exception { 32 | TestInterceptor.toString() + ctx.proceed() 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /junit4/src/test/java/org/jboss/weld/junit4/bean/BlueToDiscover.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2018, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit4.bean; 18 | 19 | import java.util.UUID; 20 | 21 | import jakarta.annotation.PostConstruct; 22 | import jakarta.enterprise.context.ApplicationScoped; 23 | import jakarta.inject.Named; 24 | 25 | @Named("blue") 26 | @ApplicationScoped 27 | public class BlueToDiscover { 28 | 29 | private String id; 30 | 31 | @PostConstruct 32 | void init() { 33 | this.id = UUID.randomUUID().toString(); 34 | } 35 | 36 | public String getId() { 37 | return id; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /junit4/src/test/java/org/jboss/weld/junit4/inject/IamDependent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit4.inject; 18 | 19 | import java.util.concurrent.atomic.AtomicBoolean; 20 | 21 | import jakarta.annotation.PreDestroy; 22 | import jakarta.enterprise.context.Dependent; 23 | 24 | /** 25 | * 26 | * @author Martin Kouba 27 | */ 28 | @Dependent 29 | public class IamDependent { 30 | 31 | static final AtomicBoolean DESTROYED = new AtomicBoolean(false); 32 | 33 | void bang() { 34 | } 35 | 36 | @PreDestroy 37 | void destroy() { 38 | DESTROYED.set(true); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /junit4/src/test/java/org/jboss/weld/junit4/inject/MeatyStringObserver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit4.inject; 18 | 19 | import java.util.List; 20 | import java.util.concurrent.CopyOnWriteArrayList; 21 | 22 | import jakarta.enterprise.context.ApplicationScoped; 23 | import jakarta.enterprise.event.Observes; 24 | 25 | @ApplicationScoped 26 | public class MeatyStringObserver { 27 | 28 | static final List MESSAGES = new CopyOnWriteArrayList<>(); 29 | 30 | public void observeHelloMessage(@Observes @Meaty String message) { 31 | MESSAGES.add(message); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/bean/BlueToDiscover.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2018, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.bean; 18 | 19 | import java.util.UUID; 20 | 21 | import jakarta.annotation.PostConstruct; 22 | import jakarta.enterprise.context.ApplicationScoped; 23 | import jakarta.inject.Named; 24 | 25 | @Named("blue") 26 | @ApplicationScoped 27 | public class BlueToDiscover { 28 | 29 | private String id; 30 | 31 | @PostConstruct 32 | void init() { 33 | this.id = UUID.randomUUID().toString(); 34 | } 35 | 36 | public String getId() { 37 | return id; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/alternative/AlternativeAsSoleBeanInSyntheticArchiveTest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.alternative; 2 | 3 | import jakarta.enterprise.context.ApplicationScoped; 4 | import jakarta.enterprise.inject.spi.Bean; 5 | import jakarta.inject.Inject; 6 | 7 | import org.jboss.weld.junit.MockBean; 8 | import org.jboss.weld.junit5.EnableWeld; 9 | import org.jboss.weld.junit5.WeldInitiator; 10 | import org.jboss.weld.junit5.WeldSetup; 11 | import org.junit.jupiter.api.Assertions; 12 | import org.junit.jupiter.api.Test; 13 | 14 | /** 15 | * Tests that synthetic archive with only enabled alternative in it still works. 16 | * This mimics problems in issue 64, but without the need for discovery 17 | */ 18 | @EnableWeld 19 | public class AlternativeAsSoleBeanInSyntheticArchiveTest { 20 | 21 | @WeldSetup 22 | public WeldInitiator weld = WeldInitiator.from(WeldInitiator.createWeld()) 23 | .addBeans(createSelectedAlternativeBean()).build(); 24 | 25 | static Bean createSelectedAlternativeBean() { 26 | return MockBean.builder().types(Fish.class).scope(ApplicationScoped.class).selectedAlternative(Fish.class) 27 | .creating(new Fish(200)).build(); 28 | } 29 | 30 | @Inject 31 | Fish fish; 32 | 33 | @Test 34 | public void testAlternativeCanBeUsed() { 35 | Assertions.assertTrue(fish.getNumberOfLegs() == 200); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/InheritedProducerMethodTest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.junit5.auto; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; 4 | 5 | import jakarta.enterprise.context.Dependent; 6 | import jakarta.enterprise.inject.Produces; 7 | import jakarta.enterprise.inject.spi.BeanManager; 8 | import jakarta.inject.Inject; 9 | 10 | import org.junit.jupiter.api.Nested; 11 | import org.junit.jupiter.api.Test; 12 | 13 | @EnableAutoWeld 14 | public class InheritedProducerMethodTest { 15 | 16 | @Dependent 17 | static class Foo { 18 | } 19 | 20 | static class BaseClass { 21 | @Produces 22 | Foo baseFooProducer() { 23 | return new Foo(); 24 | } 25 | } 26 | 27 | @Nested 28 | class DontAddBeanClassesInheritedFromTestBaseClassTest extends BaseClass { 29 | @Test 30 | void test(BeanManager beanManager) { 31 | assertEquals(0, beanManager.getBeans(Foo.class).size()); 32 | } 33 | } 34 | 35 | @Dependent 36 | static class SubClass extends BaseClass { 37 | } 38 | 39 | @Nested 40 | class DontAddBeanClassesInheritedFromBeanBaseClassTest { 41 | @Inject 42 | SubClass subClass; 43 | 44 | @Test 45 | void test(BeanManager beanManager) { 46 | assertEquals(0, beanManager.getBeans(Foo.class).size()); 47 | } 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/auto/beans/unsatisfied/V8NoAnnotation.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.auto.beans.unsatisfied 19 | 20 | import org.jboss.weld.spock.auto.beans.Engine 21 | 22 | /** 23 | * @author Björn Kautler 24 | */ 25 | // NOTE - deliberately missing bean defining annotation 26 | class V8NoAnnotation implements Engine, Serializable { 27 | private int throttle = 0 28 | 29 | int getThrottle() { 30 | return throttle 31 | } 32 | 33 | @Override 34 | void setThrottle(int throttle) { 35 | this.throttle = throttle 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/basic/EnableWeldTest.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.basic 19 | 20 | import jakarta.enterprise.inject.spi.BeanManager 21 | import jakarta.inject.Inject 22 | import org.jboss.weld.spock.EnableWeld 23 | import spock.lang.Specification 24 | 25 | /** 26 | * @author Björn Kautler 27 | */ 28 | @EnableWeld 29 | class EnableWeldTest extends Specification { 30 | @Inject 31 | BeanManager beanManager 32 | 33 | def '@EnableWeld should initialize the Weld CDI container'() { 34 | expect: 35 | beanManager != null 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/resources/FooJpa.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.resources 19 | 20 | import jakarta.enterprise.context.Dependent 21 | import jakarta.persistence.EntityManager 22 | import jakarta.persistence.EntityManagerFactory 23 | import jakarta.persistence.PersistenceContext 24 | import jakarta.persistence.PersistenceUnit 25 | 26 | /** 27 | * @author Björn Kautler 28 | */ 29 | @Dependent 30 | class FooJpa { 31 | @PersistenceContext 32 | EntityManager entityManager 33 | 34 | @PersistenceUnit 35 | EntityManagerFactory entityManagerFactory 36 | } 37 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/basic/Foo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.basic; 18 | 19 | import jakarta.annotation.PostConstruct; 20 | import jakarta.enterprise.context.ApplicationScoped; 21 | 22 | @ApplicationScoped 23 | public class Foo implements IFoo { 24 | 25 | private String bar; 26 | 27 | public Foo() { 28 | } 29 | 30 | public Foo(String bar) { 31 | this.bar = bar; 32 | } 33 | 34 | @PostConstruct 35 | public void init() { 36 | bar = "baz"; 37 | } 38 | 39 | public String getBar() { 40 | return bar; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /junit4/src/test/java/org/jboss/weld/junit4/contexts/Oof.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit4.contexts; 18 | 19 | import java.io.Serializable; 20 | import java.util.UUID; 21 | 22 | import jakarta.annotation.PostConstruct; 23 | import jakarta.enterprise.context.SessionScoped; 24 | 25 | @SuppressWarnings("serial") 26 | @SessionScoped 27 | public class Oof implements Serializable { 28 | 29 | private String id; 30 | 31 | @PostConstruct 32 | public void init() { 33 | id = UUID.randomUUID().toString(); 34 | } 35 | 36 | public String getId() { 37 | return id; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/contexts/Oof.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.contexts; 18 | 19 | import java.io.Serializable; 20 | import java.util.UUID; 21 | 22 | import jakarta.annotation.PostConstruct; 23 | import jakarta.enterprise.context.SessionScoped; 24 | 25 | @SuppressWarnings("serial") 26 | @SessionScoped 27 | public class Oof implements Serializable { 28 | 29 | private String id; 30 | 31 | @PostConstruct 32 | public void init() { 33 | id = UUID.randomUUID().toString(); 34 | } 35 | 36 | public String getId() { 37 | return id; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/event/DummyObserver.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.event 19 | 20 | import java.util.concurrent.CopyOnWriteArrayList 21 | 22 | import jakarta.enterprise.context.ApplicationScoped 23 | import jakarta.enterprise.event.Observes 24 | import org.jboss.weld.spock.basic.Foo 25 | 26 | /** 27 | * @author Björn Kautler 28 | */ 29 | @ApplicationScoped 30 | class DummyObserver { 31 | static final List MESSAGES = new CopyOnWriteArrayList<>() 32 | 33 | void observeHelloMessage(@Observes Foo message) { 34 | MESSAGES.add(message) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/initiator/discovery/SuperclassWithProtectedWeldInitiator.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.initiator.discovery 19 | 20 | import org.jboss.weld.environment.se.Weld 21 | import org.jboss.weld.spock.WeldInitiator 22 | import org.jboss.weld.spock.WeldSetup 23 | import org.jboss.weld.spock.initiator.bean.Foo 24 | import spock.lang.Specification 25 | 26 | /** 27 | * @author Björn Kautler 28 | */ 29 | class SuperclassWithProtectedWeldInitiator extends Specification { 30 | @WeldSetup 31 | protected weld = WeldInitiator.of(new Weld().addBeanClass(Foo)) 32 | } 33 | -------------------------------------------------------------------------------- /junit4/src/test/java/org/jboss/weld/junit4/event/DummyObserver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit4.event; 18 | 19 | import java.util.List; 20 | import java.util.concurrent.CopyOnWriteArrayList; 21 | 22 | import jakarta.enterprise.context.ApplicationScoped; 23 | import jakarta.enterprise.event.Observes; 24 | 25 | import org.jboss.weld.junit4.Foo; 26 | 27 | @ApplicationScoped 28 | public class DummyObserver { 29 | 30 | static final List MESSAGES = new CopyOnWriteArrayList<>(); 31 | 32 | public void observeHelloMessage(@Observes Foo message) { 33 | MESSAGES.add(message); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/extension/AddedExtension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2018, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.auto.extension; 18 | 19 | import jakarta.enterprise.event.Observes; 20 | import jakarta.enterprise.inject.spi.AfterBeanDiscovery; 21 | import jakarta.enterprise.inject.spi.Extension; 22 | 23 | public class AddedExtension implements Extension { 24 | 25 | private static boolean enabled = false; 26 | 27 | public void observeABD(@Observes AfterBeanDiscovery abd) { 28 | enabled = true; 29 | } 30 | 31 | public static boolean isEnabled() { 32 | return enabled; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/basic/Foo.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.basic 19 | 20 | import jakarta.annotation.PostConstruct 21 | import jakarta.enterprise.context.ApplicationScoped 22 | 23 | /** 24 | * @author Björn Kautler 25 | */ 26 | @ApplicationScoped 27 | class Foo implements IFoo { 28 | 29 | private String bar 30 | 31 | Foo() { 32 | } 33 | 34 | Foo(String bar) { 35 | this.bar = bar 36 | } 37 | 38 | @PostConstruct 39 | void init() { 40 | bar = 'baz' 41 | } 42 | 43 | String getBar() { 44 | return bar 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/event/DummyObserver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.event; 18 | 19 | import java.util.List; 20 | import java.util.concurrent.CopyOnWriteArrayList; 21 | 22 | import jakarta.enterprise.context.ApplicationScoped; 23 | import jakarta.enterprise.event.Observes; 24 | 25 | import org.jboss.weld.junit5.basic.Foo; 26 | 27 | @ApplicationScoped 28 | public class DummyObserver { 29 | 30 | static final List MESSAGES = new CopyOnWriteArrayList<>(); 31 | 32 | public void observeHelloMessage(@Observes Foo message) { 33 | MESSAGES.add(message); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/auto/extension/AddedExtension.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.auto.extension 19 | 20 | import jakarta.enterprise.event.Observes 21 | import jakarta.enterprise.inject.spi.AfterBeanDiscovery 22 | import jakarta.enterprise.inject.spi.Extension 23 | 24 | /** 25 | * @author Björn Kautler 26 | */ 27 | class AddedExtension implements Extension { 28 | private static boolean enabled = false 29 | 30 | void observeABD(@Observes AfterBeanDiscovery abd) { 31 | enabled = true 32 | } 33 | 34 | static boolean isEnabled() { 35 | enabled 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/extensionInjection/MyQualifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.extensionInjection; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | import jakarta.inject.Qualifier; 25 | 26 | /** 27 | * 28 | * @author Matej Novotny 29 | */ 30 | @Qualifier 31 | @Target({ ElementType.FIELD, ElementType.PARAMETER, ElementType.TYPE }) 32 | @Retention(RetentionPolicy.RUNTIME) 33 | public @interface MyQualifier { 34 | 35 | } 36 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/auto/alternativeStereotype/SomeStereotype.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.auto.alternativeStereotype 19 | 20 | import java.lang.annotation.Retention 21 | import java.lang.annotation.Target 22 | 23 | import jakarta.enterprise.inject.Alternative 24 | import jakarta.enterprise.inject.Stereotype 25 | 26 | import static java.lang.annotation.ElementType.TYPE 27 | import static java.lang.annotation.RetentionPolicy.RUNTIME 28 | 29 | /** 30 | * @author Björn Kautler 31 | */ 32 | @Stereotype 33 | @Alternative 34 | @Retention(RUNTIME) 35 | @Target(TYPE) 36 | @interface SomeStereotype { 37 | } 38 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/basic/BeanManagerTest.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.basic 19 | 20 | import org.jboss.weld.spock.EnableWeld 21 | import org.jboss.weld.spock.WeldInitiator 22 | import org.jboss.weld.spock.WeldSetup 23 | import spock.lang.Specification 24 | 25 | /** 26 | * @author Björn Kautler 27 | */ 28 | @EnableWeld 29 | class BeanManagerTest extends Specification { 30 | 31 | @WeldSetup 32 | def weld = WeldInitiator.of(Foo) 33 | 34 | def 'BeanManager should be able to resolve added bean'() { 35 | expect: 36 | weld.beanManager.getBeans(Foo).size() == 1 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/explicitInjection/Bar.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.explicitInjection; 18 | 19 | import jakarta.enterprise.context.ApplicationScoped; 20 | 21 | /** 22 | * 23 | * @author Matej Novotny 24 | */ 25 | @ApplicationScoped 26 | public class Bar { 27 | 28 | private String someText = null; 29 | 30 | public Bar() { 31 | this.someText = Bar.class.getSimpleName(); 32 | } 33 | 34 | public Bar(String someText) { 35 | this.someText = someText; 36 | } 37 | 38 | public String ping() { 39 | return someText; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/bean/extension/MyExtension.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.bean.extension 19 | 20 | import jakarta.enterprise.event.Observes 21 | import jakarta.enterprise.inject.spi.Extension 22 | import jakarta.enterprise.inject.spi.ProcessAnnotatedType 23 | 24 | /** 25 | * @author Björn Kautler 26 | */ 27 | class MyExtension implements Extension { 28 | private boolean beanObserved = false 29 | 30 | void observePAT(@Observes ProcessAnnotatedType event) { 31 | beanObserved = true 32 | } 33 | 34 | boolean beanObserved() { 35 | return beanObserved 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/interceptorAndDecorator/TestInterceptorBinding.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2018, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.auto.interceptorAndDecorator; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | import jakarta.interceptor.InterceptorBinding; 25 | 26 | /** 27 | * 28 | * @author Matej Novotny 29 | */ 30 | @InterceptorBinding 31 | @Retention(RetentionPolicy.RUNTIME) 32 | @Target(ElementType.TYPE) 33 | public @interface TestInterceptorBinding { 34 | 35 | } 36 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/explicitInjection/MyQualifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.explicitInjection; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | import jakarta.inject.Qualifier; 25 | 26 | /** 27 | * 28 | * @author Matej Novotny 29 | */ 30 | @Qualifier 31 | @Retention(RetentionPolicy.RUNTIME) 32 | @Target({ ElementType.FIELD, ElementType.METHOD, ElementType.TYPE, ElementType.PARAMETER }) 33 | public @interface MyQualifier { 34 | 35 | } 36 | -------------------------------------------------------------------------------- /spock/src/main/java/org/jboss/weld/spock/WeldSetup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock; 19 | 20 | import static java.lang.annotation.ElementType.FIELD; 21 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 22 | 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.Target; 25 | 26 | /** 27 | * An annotation used to denote a field holding a {@link WeldInitiator}. This is then picked up by 28 | * {@link org.jboss.weld.spock.impl.EnableWeldManualInterceptor} and used for configuration. 29 | * 30 | * @author Björn Kautler 31 | */ 32 | @Retention(RUNTIME) 33 | @Target(FIELD) 34 | public @interface WeldSetup { 35 | } 36 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/initiator/discovery/SuperclassWithWeldInitiator.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.initiator.discovery 19 | 20 | import org.jboss.weld.environment.se.Weld 21 | import org.jboss.weld.spock.EnableWeld 22 | import org.jboss.weld.spock.WeldInitiator 23 | import org.jboss.weld.spock.WeldSetup 24 | import org.jboss.weld.spock.initiator.bean.Foo 25 | import spock.lang.Specification 26 | 27 | /** 28 | * @author Björn Kautler 29 | */ 30 | @EnableWeld 31 | abstract class SuperclassWithWeldInitiator extends Specification { 32 | @WeldSetup 33 | def weld = WeldInitiator.of(new Weld().addBeanClass(Foo)) 34 | } 35 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/interceptorAndDecorator/TestInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2018, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.auto.interceptorAndDecorator; 18 | 19 | import jakarta.interceptor.AroundInvoke; 20 | import jakarta.interceptor.Interceptor; 21 | import jakarta.interceptor.InvocationContext; 22 | 23 | /** 24 | * 25 | * @author Matej Novotny 26 | */ 27 | @Interceptor 28 | @TestInterceptorBinding 29 | public class TestInterceptor { 30 | 31 | @AroundInvoke 32 | public Object intercept(InvocationContext ctx) throws Exception { 33 | return TestInterceptor.class.toString() + ctx.proceed(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/auto/interceptorAndDecorator/TestInterceptorBinding.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.auto.interceptorAndDecorator 19 | 20 | import java.lang.annotation.Retention 21 | import java.lang.annotation.Target 22 | 23 | import jakarta.interceptor.InterceptorBinding 24 | 25 | import static java.lang.annotation.ElementType.METHOD 26 | import static java.lang.annotation.ElementType.TYPE 27 | import static java.lang.annotation.RetentionPolicy.RUNTIME 28 | 29 | /** 30 | * @author Björn Kautler 31 | */ 32 | @InterceptorBinding 33 | @Retention(RUNTIME) 34 | @Target([TYPE, METHOD]) 35 | @interface TestInterceptorBinding { 36 | } 37 | -------------------------------------------------------------------------------- /junit4/src/test/java/org/jboss/weld/junit4/inject/Meaty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit4.inject; 18 | 19 | import static java.lang.annotation.ElementType.FIELD; 20 | import static java.lang.annotation.ElementType.METHOD; 21 | import static java.lang.annotation.ElementType.PARAMETER; 22 | import static java.lang.annotation.ElementType.TYPE; 23 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 24 | 25 | import java.lang.annotation.Retention; 26 | import java.lang.annotation.Target; 27 | 28 | import jakarta.inject.Qualifier; 29 | 30 | @Qualifier 31 | @Target({ TYPE, METHOD, PARAMETER, FIELD }) 32 | @Retention(RUNTIME) 33 | public @interface Meaty { 34 | 35 | } 36 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/initiator/discovery/SuperclassWithPrivateWeldInitiator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2018, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.initiator.discovery; 18 | 19 | import org.jboss.weld.environment.se.Weld; 20 | import org.jboss.weld.junit5.WeldInitiator; 21 | import org.jboss.weld.junit5.WeldSetup; 22 | import org.jboss.weld.junit5.initiator.bean.Foo; 23 | 24 | /** 25 | * 26 | * @author Matej Novotny 27 | */ 28 | public class SuperclassWithPrivateWeldInitiator { 29 | 30 | @WeldSetup 31 | private WeldInitiator weld = WeldInitiator 32 | .of(new Weld() 33 | .addBeanClass(Foo.class)); 34 | } 35 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/extensionInjection/MyQualifier.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.extensionInjection 19 | 20 | import java.lang.annotation.Retention 21 | import java.lang.annotation.Target 22 | 23 | import jakarta.inject.Qualifier 24 | 25 | import static java.lang.annotation.ElementType.FIELD 26 | import static java.lang.annotation.ElementType.PARAMETER 27 | import static java.lang.annotation.ElementType.TYPE 28 | import static java.lang.annotation.RetentionPolicy.RUNTIME 29 | 30 | /** 31 | * @author Björn Kautler 32 | */ 33 | @Qualifier 34 | @Target([FIELD, PARAMETER, TYPE]) 35 | @Retention(RUNTIME) 36 | @interface MyQualifier { 37 | } 38 | -------------------------------------------------------------------------------- /dco.txt: -------------------------------------------------------------------------------- 1 | Developer Certificate of Origin 2 | Version 1.1 3 | 4 | Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 5 | 6 | Everyone is permitted to copy and distribute verbatim copies of this 7 | license document, but changing it is not allowed. 8 | 9 | 10 | Developer's Certificate of Origin 1.1 11 | 12 | By making a contribution to this project, I certify that: 13 | 14 | (a) The contribution was created in whole or in part by me and I 15 | have the right to submit it under the open source license 16 | indicated in the file; or 17 | 18 | (b) The contribution is based upon previous work that, to the best 19 | of my knowledge, is covered under an appropriate open source 20 | license and I have the right under that license to submit that 21 | work with modifications, whether created in whole or in part 22 | by me, under the same open source license (unless I am 23 | permitted to submit under a different license), as indicated 24 | in the file; or 25 | 26 | (c) The contribution was provided directly to me by some other 27 | person who certified (a), (b) or (c) and I have not modified 28 | it. 29 | 30 | (d) I understand and agree that this project and the contribution 31 | are public and that a record of the contribution (including all 32 | personal information I submit with it, including my sign-off) is 33 | maintained indefinitely and may be redistributed consistent with 34 | this project or the open source license(s) involved. 35 | 36 | -------------------------------------------------------------------------------- /junit4/src/test/java/org/jboss/weld/junit4/ContainerNotRunningTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit4; 18 | 19 | import org.junit.Rule; 20 | import org.junit.Test; 21 | 22 | /** 23 | * 24 | * @author Martin Kouba 25 | */ 26 | public class ContainerNotRunningTest { 27 | 28 | @Rule 29 | public WeldInitiator weld = WeldInitiator.of(WeldInitiator.createWeld().beanClasses(Foo.class)); 30 | 31 | @Test(expected = IllegalStateException.class) 32 | public void testFoo() { 33 | // Shutdown container manually 34 | weld.shutdown(); 35 | // This should throw IllegalStateException 36 | weld.select(Foo.class).get(); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/interceptorAndDecorator/TestDecorator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2018, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.auto.interceptorAndDecorator; 18 | 19 | import jakarta.decorator.Decorator; 20 | import jakarta.decorator.Delegate; 21 | import jakarta.inject.Inject; 22 | 23 | /** 24 | * 25 | * @author Matej Novotny 26 | */ 27 | @Decorator 28 | public class TestDecorator implements DecoratedBeanInterface { 29 | 30 | @Inject 31 | @Delegate 32 | DecoratedBeanInterface delegate; 33 | 34 | @Override 35 | public String ping() { 36 | return TestDecorator.class.toString() + delegate.ping(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/initiator/discovery/SuperclassWithProtectedWeldInitiator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2018, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.initiator.discovery; 18 | 19 | import org.jboss.weld.environment.se.Weld; 20 | import org.jboss.weld.junit5.WeldInitiator; 21 | import org.jboss.weld.junit5.WeldSetup; 22 | import org.jboss.weld.junit5.initiator.bean.Foo; 23 | 24 | /** 25 | * 26 | * @author Matej Novotny 27 | */ 28 | public class SuperclassWithProtectedWeldInitiator { 29 | 30 | @WeldSetup 31 | protected WeldInitiator weld = WeldInitiator 32 | .of(new Weld() 33 | .addBeanClass(Foo.class)); 34 | } 35 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/auto/InjectParameterizedTest.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.auto 19 | 20 | import jakarta.enterprise.context.Dependent 21 | import jakarta.inject.Inject 22 | import org.jboss.weld.spock.EnableWeld 23 | import spock.lang.Specification 24 | 25 | /** 26 | * @author Björn Kautler 27 | */ 28 | @EnableWeld(automagic = true) 29 | class InjectParameterizedTest extends Specification { 30 | @Dependent 31 | static class Foo { 32 | } 33 | 34 | @Inject 35 | Foo foo 36 | 37 | def 'injecting parameterized type should work properly'() { 38 | expect: 39 | foo != null 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /junit5/src/test/java/org/jboss/weld/junit5/auto/alternativeStereotype/SomeStereotype.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2018, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.junit5.auto.alternativeStereotype; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | import jakarta.enterprise.inject.Alternative; 25 | import jakarta.enterprise.inject.Stereotype; 26 | 27 | /** 28 | * 29 | * @author Matej Novotny 30 | */ 31 | @Stereotype 32 | @Alternative 33 | @Retention(RetentionPolicy.RUNTIME) 34 | @Target(ElementType.TYPE) 35 | public @interface SomeStereotype { 36 | 37 | } 38 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/initiator/discovery/ProtectedWeldInitiatorInSuperclassTest.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.initiator.discovery 19 | 20 | import org.jboss.weld.spock.EnableWeld 21 | import org.jboss.weld.spock.initiator.bean.Foo 22 | 23 | /** 24 | * Tests a case where WeldInitiator comes from a protected field in a superclass 25 | * 26 | * @author Björn Kautler 27 | */ 28 | @EnableWeld 29 | class ProtectedWeldInitiatorInSuperclassTest extends SuperclassWithProtectedWeldInitiator { 30 | def 'Weld can be initialized from an initiator in a protected field of a super spec'() { 31 | expect: 32 | weld.select(Foo).get() != null 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spock/src/test/groovy/org/jboss/weld/spock/auto/AddBeanClassesTest.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2022, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.spock.auto 19 | 20 | import jakarta.inject.Inject 21 | import org.jboss.weld.spock.EnableWeld 22 | import org.jboss.weld.spock.auto.beans.Engine 23 | import org.jboss.weld.spock.auto.beans.V8 24 | import spock.lang.Specification 25 | 26 | /** 27 | * @author Björn Kautler 28 | */ 29 | @EnableWeld(automagic = true) 30 | @AddBeanClasses(V8) 31 | class AddBeanClassesTest extends Specification { 32 | @Inject 33 | private Engine engine 34 | 35 | def '@AddBeanClasses should pull in V8 to fulfill the injected Engine interface'() { 36 | expect: 37 | engine != null 38 | } 39 | } 40 | --------------------------------------------------------------------------------