This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/openwebbeans.git
commit 7b170d0dadcf4e613bd19ae0ba8755bb38785900 Author: Romain Manni-Bucau <rmannibu...@gmail.com> AuthorDate: Sun Jun 14 20:49:14 2020 +0200 [OWB-1331] @Scopes junit5 extension to veto or start scopes --- .../org/apache/openwebbeans/junit5/Scopes.java | 43 ++++++ .../junit5/internal/ScopesExtension.java | 116 ++++++++++++++++ .../org/apache/openwebbeans/junit5/ScopesTest.java | 118 ++++++++++++++++ .../openwebbeans/junit5/extension/DummyScoped.java | 31 +++++ .../openwebbeans/junit5/extension/MyScope.java | 55 ++++++++ .../junit5/parameter/ParameterResolutionTest.java | 22 ++- .../junit5/perclass/PerMethodTest.java | 148 ++++++++++++++------- .../services/javax.enterprise.inject.spi.Extension | 17 +++ 8 files changed, 490 insertions(+), 60 deletions(-) diff --git a/webbeans-junit5/src/main/java/org/apache/openwebbeans/junit5/Scopes.java b/webbeans-junit5/src/main/java/org/apache/openwebbeans/junit5/Scopes.java new file mode 100644 index 0000000..804d510 --- /dev/null +++ b/webbeans-junit5/src/main/java/org/apache/openwebbeans/junit5/Scopes.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openwebbeans.junit5; + +import org.apache.openwebbeans.junit5.internal.ScopesExtension; +import org.junit.jupiter.api.extension.ExtendWith; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * Activates CDI scopes on a running OWB instance - you can use @{@link Cdi} for that. + */ +@Target({TYPE, METHOD}) +@Retention(RUNTIME) +@ExtendWith(ScopesExtension.class) +public @interface Scopes +{ + /** + * @return classes to deploy. + */ + Class<?>[] value() default {}; +} diff --git a/webbeans-junit5/src/main/java/org/apache/openwebbeans/junit5/internal/ScopesExtension.java b/webbeans-junit5/src/main/java/org/apache/openwebbeans/junit5/internal/ScopesExtension.java new file mode 100644 index 0000000..fd54b20 --- /dev/null +++ b/webbeans-junit5/src/main/java/org/apache/openwebbeans/junit5/internal/ScopesExtension.java @@ -0,0 +1,116 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openwebbeans.junit5.internal; + +import org.apache.openwebbeans.junit5.Scopes; +import org.apache.webbeans.config.WebBeansContext; +import org.apache.webbeans.spi.ContextsService; +import org.junit.jupiter.api.extension.AfterAllCallback; +import org.junit.jupiter.api.extension.AfterEachCallback; +import org.junit.jupiter.api.extension.BeforeAllCallback; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.platform.commons.util.AnnotationUtils; + +import javax.enterprise.context.ConversationScoped; +import javax.enterprise.context.RequestScoped; +import javax.enterprise.context.SessionScoped; +import javax.enterprise.context.spi.Context; +import java.lang.annotation.Annotation; +import java.util.stream.Stream; + +public class ScopesExtension implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback +{ + private Runnable[] classCallbacks; + private Runnable[] methodCallbacks; + + @Override + public void afterAll(final ExtensionContext context) + { + stop(classCallbacks); + } + + @Override + public void afterEach(final ExtensionContext context) + { + stop(methodCallbacks); + } + + @Override + public void beforeAll(final ExtensionContext context) + { + classCallbacks = start(context, true); + } + + @Override + public void beforeEach(final ExtensionContext context) + { + methodCallbacks = start(context, false); + } + + private Runnable[] start(final ExtensionContext context, final boolean canVetoScopes) + { + final Class<?>[] scopes = AnnotationUtils.findAnnotation(context.getElement(), Scopes.class) + .map(Scopes::value) + .orElse(null); + if (scopes == null || scopes.length == 0) + { + return null; + } + final WebBeansContext webBeansContext = WebBeansContext.currentInstance(); + final ContextsService contextsService = webBeansContext.getContextsService(); + if (canVetoScopes) + { + stopIfNeeded(scopes, contextsService, RequestScoped.class); + stopIfNeeded(scopes, contextsService, SessionScoped.class); + if (webBeansContext.getOpenWebBeansConfiguration().supportsConversation()) + { + stopIfNeeded(scopes, contextsService, ConversationScoped.class); + } + } + return Stream.of(scopes) + .map(scope -> { + // todo: endParam support, not needed in standalone but can be in web? + final Class<? extends Annotation> scopeAnnot = (Class<? extends Annotation>) scope; + contextsService.startContext(scopeAnnot, null); + return (Runnable) () -> contextsService.endContext(scopeAnnot, null); + }) + .toArray(Runnable[]::new); + } + + private void stopIfNeeded(final Class<?>[] scopes, final ContextsService contextsService, final Class<? extends Annotation> scope) + { + if (Stream.of(scopes).noneMatch(it -> it == scope)) + { + final Context currentReqScope = contextsService.getCurrentContext(scope); + if (currentReqScope != null && currentReqScope.isActive()) + { + contextsService.endContext(scope, null); + } + } + } + + private void stop(final Runnable[] destroyers) + { + if (destroyers != null) + { + Stream.of(destroyers).forEach(Runnable::run); + } + } +} diff --git a/webbeans-junit5/src/test/java/org/apache/openwebbeans/junit5/ScopesTest.java b/webbeans-junit5/src/test/java/org/apache/openwebbeans/junit5/ScopesTest.java new file mode 100644 index 0000000..3c4ccee --- /dev/null +++ b/webbeans-junit5/src/test/java/org/apache/openwebbeans/junit5/ScopesTest.java @@ -0,0 +1,118 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openwebbeans.junit5; + +import org.apache.openwebbeans.junit5.extension.DummyScoped; +import org.apache.openwebbeans.junit5.extension.MyScope; +import org.apache.webbeans.config.WebBeansContext; +import org.apache.webbeans.context.AbstractContext; +import org.apache.webbeans.corespi.se.StandaloneContextsService; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; + +import javax.enterprise.context.ContextException; +import javax.enterprise.context.ContextNotActiveException; +import javax.enterprise.context.RequestScoped; +import javax.enterprise.context.SessionScoped; +import javax.enterprise.inject.spi.BeanManager; +import javax.inject.Inject; +import java.lang.annotation.Annotation; + +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +@Cdi(disableDiscovery = true, properties = + @Cdi.Property( + name = "org.apache.webbeans.spi.ContextsService", + value = "org.apache.openwebbeans.junit5.ScopesTest$ContextsService")) +@Scopes(SessionScoped.class) +class ScopesTest +{ + @Inject + private BeanManager beanManager; + private static BeanManager beanManagerRef; + + @AfterEach + void captureBm() { + beanManagerRef = beanManager; + } + + @AfterAll + static void after() { + assertThrows(ContextNotActiveException.class, () -> beanManagerRef.getContext(DummyScoped.class).isActive()); + } + + @Test + void classScopeStarted() + { + assertThrows(ContextNotActiveException.class, () -> beanManager.getContext(RequestScoped.class).isActive()); + assertThrows(ContextNotActiveException.class, () -> beanManager.getContext(DummyScoped.class).isActive()); + assertTrue(beanManager.getContext(SessionScoped.class).isActive()); + } + + @Test + @Scopes(DummyScoped.class) + void methodScopeStarted() + { + assertThrows(ContextNotActiveException.class, () -> beanManager.getContext(RequestScoped.class).isActive()); + assertTrue(beanManager.getContext(SessionScoped.class).isActive()); + assertTrue(beanManager.getContext(DummyScoped.class).isActive()); + } + + // not required but enables to control the activation as any built-in scope so good enough for this test + public static class ContextsService extends StandaloneContextsService + { + public ContextsService(final WebBeansContext webBeansContext) + { + super(webBeansContext); + } + + private AbstractContext getDummyScope() + { + return webBeansContext.getBeanManagerImpl().getExtension(MyScope.class).getScope(); + } + + @Override + public void endContext(final Class<? extends Annotation> scopeType, final Object endParameters) + { + if (scopeType == DummyScoped.class) + { + getDummyScope().setActive(false); + } + else + { + super.endContext(scopeType, endParameters); + } + } + + @Override + public void startContext(final Class<? extends Annotation> scopeType, final Object startParameter) throws ContextException + { + if (scopeType == DummyScoped.class) + { + getDummyScope().setActive(true); + } + else + { + super.startContext(scopeType, startParameter); + } + } + } +} diff --git a/webbeans-junit5/src/test/java/org/apache/openwebbeans/junit5/extension/DummyScoped.java b/webbeans-junit5/src/test/java/org/apache/openwebbeans/junit5/extension/DummyScoped.java new file mode 100644 index 0000000..66b5147 --- /dev/null +++ b/webbeans-junit5/src/test/java/org/apache/openwebbeans/junit5/extension/DummyScoped.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openwebbeans.junit5.extension; + +import javax.enterprise.context.NormalScope; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@NormalScope +public @interface DummyScoped { +} diff --git a/webbeans-junit5/src/test/java/org/apache/openwebbeans/junit5/extension/MyScope.java b/webbeans-junit5/src/test/java/org/apache/openwebbeans/junit5/extension/MyScope.java new file mode 100644 index 0000000..cf4649a --- /dev/null +++ b/webbeans-junit5/src/test/java/org/apache/openwebbeans/junit5/extension/MyScope.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openwebbeans.junit5.extension; + +import org.apache.webbeans.context.AbstractContext; + +import javax.enterprise.event.Observes; +import javax.enterprise.inject.spi.AfterBeanDiscovery; +import javax.enterprise.inject.spi.BeforeBeanDiscovery; +import javax.enterprise.inject.spi.Extension; +import java.util.concurrent.ConcurrentHashMap; + +// register a custom scope we can manipulate injecting the extension (getScope()) +public class MyScope implements Extension +{ + private AbstractContext scope; + + public AbstractContext getScope() + { + return scope; + } + + void addScope(@Observes final BeforeBeanDiscovery beforeBeanDiscovery) + { + beforeBeanDiscovery.addScope(DummyScoped.class, true, true); + } + + void addScope(@Observes final AfterBeanDiscovery afterBeanDiscovery) + { + afterBeanDiscovery.addContext(scope = new AbstractContext(DummyScoped.class) + { + @Override + protected void setComponentInstanceMap() + { + componentInstanceMap = new ConcurrentHashMap<>(); + } + }); + } +} diff --git a/webbeans-junit5/src/test/java/org/apache/openwebbeans/junit5/parameter/ParameterResolutionTest.java b/webbeans-junit5/src/test/java/org/apache/openwebbeans/junit5/parameter/ParameterResolutionTest.java index fa0071c..6593846 100644 --- a/webbeans-junit5/src/test/java/org/apache/openwebbeans/junit5/parameter/ParameterResolutionTest.java +++ b/webbeans-junit5/src/test/java/org/apache/openwebbeans/junit5/parameter/ParameterResolutionTest.java @@ -18,18 +18,8 @@ */ package org.apache.openwebbeans.junit5.parameter; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertSame; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import javax.inject.Inject; -import javax.inject.Qualifier; import org.apache.openwebbeans.junit5.Cdi; +import org.apache.openwebbeans.junit5.SkipInject; import org.apache.openwebbeans.junit5.bean.MyService; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -38,6 +28,12 @@ import org.junit.jupiter.api.extension.ParameterContext; import org.junit.jupiter.api.extension.ParameterResolutionException; import org.junit.jupiter.api.extension.ParameterResolver; +import javax.inject.Inject; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; + @Cdi(classes = MyService.class) class ParameterResolutionTest { @@ -72,14 +68,14 @@ class ParameterResolutionTest @Test @ExtendWith(OnlyFirstParameterResolver.class) - void testThatParameterDoesNotGetInjectedWithDontInject(@Cdi.DontInject MyService service) + void testThatParameterDoesNotGetInjectedWithDontInject(@SkipInject MyService service) { assertNull(service); // OnlyFirstParameterResolver.resolveParameter resolves service to null } @Test @ExtendWith(OnlyFirstParameterResolver.class) - void testMixedCdiAndOtherParameterResolver(@Cdi.DontInject MyService service1, MyService service2) + void testMixedCdiAndOtherParameterResolver(@SkipInject MyService service1, MyService service2) { // OnlyFirstParameterResolver.resolveParameter resolves service1 to null assertNull(service1); diff --git a/webbeans-junit5/src/test/java/org/apache/openwebbeans/junit5/perclass/PerMethodTest.java b/webbeans-junit5/src/test/java/org/apache/openwebbeans/junit5/perclass/PerMethodTest.java index 98aa912..a5c70b7 100644 --- a/webbeans-junit5/src/test/java/org/apache/openwebbeans/junit5/perclass/PerMethodTest.java +++ b/webbeans-junit5/src/test/java/org/apache/openwebbeans/junit5/perclass/PerMethodTest.java @@ -46,13 +46,15 @@ import static org.junit.jupiter.api.Assertions.fail; import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; @TestInstance(PER_CLASS) -class PerMethodTest { +class PerMethodTest +{ private BeanManager bm1; @Test @Order(1) @ExtendWith(CustomExtension.class) - void cdiRuns() { + void cdiRuns() + { bm1 = CDI.current().getBeanManager(); assertNotNull(bm1); } @@ -60,7 +62,8 @@ class PerMethodTest { @Test @Order(2) @ExtendWith(CustomExtension.class) - void cdiReRuns() { + void cdiReRuns() + { final BeanManager bm2 = CDI.current().getBeanManager(); assertNotNull(bm2); assertNotEquals(bm1, bm2); @@ -68,13 +71,17 @@ class PerMethodTest { } private BeanManager getRealBm(final BeanManager wrapper) { - try { + try + { final Field bm = InjectableBeanManager.class.getDeclaredField("bm"); - if (!bm.isAccessible()) { + if (!bm.isAccessible()) + { bm.setAccessible(true); } return BeanManager.class.cast(bm.get(wrapper)); - } catch (final Exception e) { + } + catch (final Exception e) + { return fail(e); } } @@ -83,15 +90,21 @@ class PerMethodTest { // here we just virtually set @Cdi on the method and move the class lifecycle to the method // note 1: in real, this kind of impl is not "inline" but this tests the use case more than the impl // note 2: by itself this use case is not terrible but sometimes requires by another jupiter extension - public static class CustomExtension extends CdiExtension { + public static class CustomExtension extends CdiExtension + { @Override - public void beforeEach(final ExtensionContext extensionContext) { - super.beforeAll(new ExtensionContext() { + public void beforeEach(final ExtensionContext extensionContext) + { + super.beforeAll(new ExtensionContext() + { @Override - public Optional<AnnotatedElement> getElement() { - return of(new AnnotatedElement() { + public Optional<AnnotatedElement> getElement() + { + return of(new AnnotatedElement() + { @Override - public <T extends Annotation> T getAnnotation(final Class<T> annotationClass) { + public <T extends Annotation> T getAnnotation(final Class<T> annotationClass) + { return Stream.of(getAnnotations()) .filter(it -> it.annotationType() == annotationClass) .map(annotationClass::cast) @@ -99,66 +112,86 @@ class PerMethodTest { } @Override - public Annotation[] getAnnotations() { + public Annotation[] getAnnotations() + { return getDeclaredAnnotations(); } @Override - public Annotation[] getDeclaredAnnotations() { - return new Annotation[]{ + public Annotation[] getDeclaredAnnotations() + { + return new Annotation[] + { new Cdi() { @Override - public Class<? extends Annotation> annotationType() { + public Class<? extends Annotation> annotationType() + { return Cdi.class; } @Override - public Class<?>[] classes() { + public Class<?>[] classes() + { return new Class[0]; } @Override - public Class<?>[] decorators() { + public Class<?>[] decorators() + { return new Class[0]; } @Override - public Class<?>[] interceptors() { + public Class<?>[] interceptors() + { return new Class[0]; } @Override - public Class<?>[] alternatives() { + public Class<?>[] alternatives() + { return new Class[0]; } @Override - public Class<? extends Annotation>[] alternativeStereotypes() { + public Class<? extends Annotation>[] alternativeStereotypes() + { return new Class[0]; } @Override - public Class<?>[] packages() { + public Class<?>[] packages() + { return new Class[0]; } @Override - public Class<?>[] recursivePackages() { + public Class<?>[] recursivePackages() + { return new Class[0]; } @Override - public boolean disableDiscovery() { + public Property[] properties() + { + return new Property[0]; + } + + @Override + public boolean disableDiscovery() + { return false; } @Override - public Class<? extends OnStart>[] onStarts() { + public Class<? extends OnStart>[] onStarts() + { return new Class[0]; } @Override - public boolean reusable() { + public boolean reusable() + { return false; } } @@ -168,102 +201,122 @@ class PerMethodTest { } @Override - public Optional<ExtensionContext> getParent() { + public Optional<ExtensionContext> getParent() + { return extensionContext.getParent(); } @Override - public ExtensionContext getRoot() { + public ExtensionContext getRoot() + { return extensionContext.getRoot(); } @Override - public String getUniqueId() { + public String getUniqueId() + { return extensionContext.getUniqueId(); } @Override - public String getDisplayName() { + public String getDisplayName() + { return extensionContext.getDisplayName(); } @Override - public Set<String> getTags() { + public Set<String> getTags() + { return extensionContext.getTags(); } @Override - public Optional<Class<?>> getTestClass() { + public Optional<Class<?>> getTestClass() + { return extensionContext.getTestClass(); } @Override - public Class<?> getRequiredTestClass() { + public Class<?> getRequiredTestClass() + { return extensionContext.getRequiredTestClass(); } @Override - public Optional<TestInstance.Lifecycle> getTestInstanceLifecycle() { + public Optional<TestInstance.Lifecycle> getTestInstanceLifecycle() + { return extensionContext.getTestInstanceLifecycle(); } @Override - public Optional<Object> getTestInstance() { + public Optional<Object> getTestInstance() + { return extensionContext.getTestInstance(); } @Override - public Object getRequiredTestInstance() { + public Object getRequiredTestInstance() + { return extensionContext.getRequiredTestInstance(); } @Override - public Optional<TestInstances> getTestInstances() { + public Optional<TestInstances> getTestInstances() + { return extensionContext.getTestInstances(); } @Override - public TestInstances getRequiredTestInstances() { + public TestInstances getRequiredTestInstances() + { return extensionContext.getRequiredTestInstances(); } @Override - public Optional<Method> getTestMethod() { + public Optional<Method> getTestMethod() + { return extensionContext.getTestMethod(); } @Override - public Method getRequiredTestMethod() { + public Method getRequiredTestMethod() + { return extensionContext.getRequiredTestMethod(); } @Override - public Optional<Throwable> getExecutionException() { + public Optional<Throwable> getExecutionException() + { return extensionContext.getExecutionException(); } @Override - public Optional<String> getConfigurationParameter(final String key) { + public Optional<String> getConfigurationParameter(final String key) + { return extensionContext.getConfigurationParameter(key); } @Override - public void publishReportEntry(final Map<String, String> map) { + public void publishReportEntry(final Map<String, String> map) + { extensionContext.publishReportEntry(map); } @Override - public void publishReportEntry(final String key, final String value) { + public void publishReportEntry(final String key, final String value) + { extensionContext.publishReportEntry(key, value); } @Override - public void publishReportEntry(final String value) { + public void publishReportEntry(final String value) + { extensionContext.publishReportEntry(value); } @Override - public Store getStore(final Namespace namespace) { + public Store getStore(final Namespace namespace) + { return extensionContext.getStore(namespace); } }); @@ -271,7 +324,8 @@ class PerMethodTest { } @Override - public void afterEach(final ExtensionContext extensionContext) { + public void afterEach(final ExtensionContext extensionContext) + { super.afterEach(extensionContext); super.afterAll(extensionContext); } diff --git a/webbeans-junit5/src/test/resources/META-INF/services/javax.enterprise.inject.spi.Extension b/webbeans-junit5/src/test/resources/META-INF/services/javax.enterprise.inject.spi.Extension new file mode 100644 index 0000000..d7f1887 --- /dev/null +++ b/webbeans-junit5/src/test/resources/META-INF/services/javax.enterprise.inject.spi.Extension @@ -0,0 +1,17 @@ +#Licensed to the Apache Software Foundation (ASF) under one +#or more contributor license agreements. See the NOTICE file +#distributed with this work for additional information +#regarding copyright ownership. The ASF licenses this file +#to you under the Apache License, Version 2.0 (the +#"License"); you may not use this file except in compliance +#with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +#Unless required by applicable law or agreed to in writing, +#software distributed under the License is distributed on an +#"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +#KIND, either express or implied. See the License for the +#specific language governing permissions and limitations +#under the License. +org.apache.openwebbeans.junit5.extension.MyScope