-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce tests for BeanContainer#getContexts
- Loading branch information
Showing
7 changed files
with
155 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
impl/src/main/java/org/jboss/cdi/tck/tests/beanContainer/ContextRegisteringExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.jboss.cdi.tck.tests.beanContainer; | ||
|
||
import jakarta.enterprise.inject.build.compatible.spi.BuildCompatibleExtension; | ||
import jakarta.enterprise.inject.build.compatible.spi.Discovery; | ||
import jakarta.enterprise.inject.build.compatible.spi.MetaAnnotations; | ||
|
||
public class ContextRegisteringExtension implements BuildCompatibleExtension { | ||
|
||
@Discovery | ||
public void discovery(MetaAnnotations metaAnnotations) { | ||
metaAnnotations.addContext(CustomScoped.class, CustomContextImpl1.class); | ||
metaAnnotations.addContext(CustomScoped.class, CustomContextImpl2.class); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
impl/src/main/java/org/jboss/cdi/tck/tests/beanContainer/CustomContextImpl1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.jboss.cdi.tck.tests.beanContainer; | ||
|
||
import jakarta.enterprise.context.spi.AlterableContext; | ||
import jakarta.enterprise.context.spi.Contextual; | ||
import jakarta.enterprise.context.spi.CreationalContext; | ||
|
||
import java.lang.annotation.Annotation; | ||
|
||
// dummy context, always active | ||
public class CustomContextImpl1 implements AlterableContext { | ||
|
||
@Override | ||
public void destroy(Contextual<?> contextual) { | ||
} | ||
|
||
@Override | ||
public Class<? extends Annotation> getScope() { | ||
return CustomScoped.class; | ||
} | ||
|
||
@Override | ||
public <T> T get(Contextual<T> contextual, CreationalContext<T> creationalContext) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public <T> T get(Contextual<T> contextual) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean isActive() { | ||
return true; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
impl/src/main/java/org/jboss/cdi/tck/tests/beanContainer/CustomContextImpl2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.jboss.cdi.tck.tests.beanContainer; | ||
|
||
import jakarta.enterprise.context.spi.AlterableContext; | ||
import jakarta.enterprise.context.spi.Contextual; | ||
import jakarta.enterprise.context.spi.CreationalContext; | ||
|
||
import java.lang.annotation.Annotation; | ||
|
||
// dummy context, never active | ||
public class CustomContextImpl2 implements AlterableContext { | ||
|
||
@Override | ||
public void destroy(Contextual<?> contextual) { | ||
} | ||
|
||
@Override | ||
public Class<? extends Annotation> getScope() { | ||
return CustomScoped.class; | ||
} | ||
|
||
@Override | ||
public <T> T get(Contextual<T> contextual, CreationalContext<T> creationalContext) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public <T> T get(Contextual<T> contextual) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean isActive() { | ||
return false; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
impl/src/main/java/org/jboss/cdi/tck/tests/beanContainer/CustomScoped.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.jboss.cdi.tck.tests.beanContainer; | ||
|
||
import static java.lang.annotation.ElementType.FIELD; | ||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.ElementType.TYPE; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
import jakarta.enterprise.context.NormalScope; | ||
|
||
import java.lang.annotation.Inherited; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
@NormalScope | ||
@Inherited | ||
@Target({ TYPE, METHOD, FIELD }) | ||
@Retention(RUNTIME) | ||
public @interface CustomScoped { | ||
} |
20 changes: 20 additions & 0 deletions
20
impl/src/main/java/org/jboss/cdi/tck/tests/beanContainer/NoImplScope.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.jboss.cdi.tck.tests.beanContainer; | ||
|
||
import static java.lang.annotation.ElementType.FIELD; | ||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.ElementType.TYPE; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
import jakarta.enterprise.context.NormalScope; | ||
|
||
import java.lang.annotation.Inherited; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
// This scope has no context implementing it | ||
@NormalScope | ||
@Inherited | ||
@Target({ TYPE, METHOD, FIELD }) | ||
@Retention(RUNTIME) | ||
public @interface NoImplScope { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters