You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2018/11/29 21:53:57 UTC

[06/15] tomee git commit: TOMEE-2278 - improve test to include SafeguardInterceptor

TOMEE-2278 - improve test to include SafeguardInterceptor

Signed-off-by: brunobat <br...@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/37bc867f
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/37bc867f
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/37bc867f

Branch: refs/heads/master
Commit: 37bc867f956b90df89e481b06c7766ff2f6d9f91
Parents: ec92720
Author: brunobat <br...@gmail.com>
Authored: Mon Nov 19 14:03:03 2018 +0000
Committer: brunobat <br...@gmail.com>
Committed: Mon Nov 19 14:03:03 2018 +0000

----------------------------------------------------------------------
 ...ilsafeContainerExecutionManagerProvider.java |  6 +++--
 .../src/main/resources/META-INF/beans.xml       |  3 +++
 ...feContainerExecutionManagerProviderTest.java | 26 +++++++++++++++++---
 3 files changed, 30 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/37bc867f/tomee/tomee-microprofile/tomee-microprofile-common/src/main/java/org/apache/tomee/microprofile/faulttolerance/FailsafeContainerExecutionManagerProvider.java
----------------------------------------------------------------------
diff --git a/tomee/tomee-microprofile/tomee-microprofile-common/src/main/java/org/apache/tomee/microprofile/faulttolerance/FailsafeContainerExecutionManagerProvider.java b/tomee/tomee-microprofile/tomee-microprofile-common/src/main/java/org/apache/tomee/microprofile/faulttolerance/FailsafeContainerExecutionManagerProvider.java
index 8ea705a..8f437e2 100644
--- a/tomee/tomee-microprofile/tomee-microprofile-common/src/main/java/org/apache/tomee/microprofile/faulttolerance/FailsafeContainerExecutionManagerProvider.java
+++ b/tomee/tomee-microprofile/tomee-microprofile-common/src/main/java/org/apache/tomee/microprofile/faulttolerance/FailsafeContainerExecutionManagerProvider.java
@@ -33,20 +33,22 @@ import javax.enterprise.concurrent.ManagedScheduledExecutorService;
 import javax.enterprise.context.ApplicationScoped;
 import javax.enterprise.inject.Alternative;
 import javax.enterprise.inject.Specializes;
+import javax.enterprise.inject.spi.Extension;
 import javax.interceptor.Interceptor;
 import javax.ws.rs.Produces;
 
 @Alternative
+@Specializes
 @Priority(Interceptor.Priority.APPLICATION+10)
 @ApplicationScoped
-public class FailsafeContainerExecutionManagerProvider extends FailsafeExecutionManagerProvider {
+public class FailsafeContainerExecutionManagerProvider extends FailsafeExecutionManagerProvider implements Extension {
 
     @Resource(name = "DefaultManagedScheduledExecutorService")
     ManagedScheduledExecutorService executor;
 
+    @Override
     @Produces
     @ApplicationScoped
-    @Override
     public ExecutionManager createExecutionManager() {
 
         final MicroprofileAnnotationMapper mapper = MicroprofileAnnotationMapper.getInstance();

http://git-wip-us.apache.org/repos/asf/tomee/blob/37bc867f/tomee/tomee-microprofile/tomee-microprofile-common/src/main/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/tomee/tomee-microprofile/tomee-microprofile-common/src/main/resources/META-INF/beans.xml b/tomee/tomee-microprofile/tomee-microprofile-common/src/main/resources/META-INF/beans.xml
index 6668db4..1756cff 100644
--- a/tomee/tomee-microprofile/tomee-microprofile-common/src/main/resources/META-INF/beans.xml
+++ b/tomee/tomee-microprofile/tomee-microprofile-common/src/main/resources/META-INF/beans.xml
@@ -16,4 +16,7 @@
     limitations under the License.
 -->
 <beans>
+    <alternatives>
+        <class>org.apache.tomee.microprofile.faulttolerance.FailsafeContainerExecutionManagerProvider</class>
+    </alternatives>
 </beans>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tomee/blob/37bc867f/tomee/tomee-microprofile/tomee-microprofile-common/src/test/java/org/apache/tomee/microprofile/faulttolerance/FailsafeContainerExecutionManagerProviderTest.java
----------------------------------------------------------------------
diff --git a/tomee/tomee-microprofile/tomee-microprofile-common/src/test/java/org/apache/tomee/microprofile/faulttolerance/FailsafeContainerExecutionManagerProviderTest.java b/tomee/tomee-microprofile/tomee-microprofile-common/src/test/java/org/apache/tomee/microprofile/faulttolerance/FailsafeContainerExecutionManagerProviderTest.java
index e38dd33..a28330e 100644
--- a/tomee/tomee-microprofile/tomee-microprofile-common/src/test/java/org/apache/tomee/microprofile/faulttolerance/FailsafeContainerExecutionManagerProviderTest.java
+++ b/tomee/tomee-microprofile/tomee-microprofile-common/src/test/java/org/apache/tomee/microprofile/faulttolerance/FailsafeContainerExecutionManagerProviderTest.java
@@ -23,11 +23,15 @@ import org.apache.openejb.testing.Classes;
 import org.apache.openejb.testing.Module;
 import org.apache.safeguard.api.ExecutionManager;
 import org.apache.safeguard.impl.cdi.FailsafeExecutionManagerProvider;
+import org.apache.safeguard.impl.cdi.SafeguardInterceptor;
+import org.eclipse.microprofile.faulttolerance.CircuitBreaker;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import javax.ejb.Singleton;
 import javax.inject.Inject;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 @RunWith(ApplicationComposer.class)
@@ -36,10 +40,15 @@ public class FailsafeContainerExecutionManagerProviderTest {
     @Inject
     private FailsafeExecutionManagerProvider manager;
 
+    @Inject
+    private MyClass myClass;
+
     @Module
     @Classes(value = {FailsafeContainerExecutionManagerProvider.class,
             FailsafeExecutionManagerProvider.class,
-            ExecutionManager.class},
+            ExecutionManager.class,
+            SafeguardInterceptor.class,
+            MyClass.class},
             cdi = true)
     public WebApp app() {
         return new WebApp();
@@ -47,10 +56,21 @@ public class FailsafeContainerExecutionManagerProviderTest {
 
     @Test
     public void testManagerInjection() throws Exception {
-        manager.createExecutionManager();
-        assertTrue("We must override the original FailsafeExecutionManagerProvider",
+
+        assertEquals("called", myClass.validateInjectedClass());
+
+        assertTrue("We must override the original FailsafeExecutionManagerProvider, was:" + manager.getClass(),
                 manager instanceof FailsafeContainerExecutionManagerProvider);
     }
 
 
+    @Singleton
+    public static class MyClass {
+
+        @CircuitBreaker
+        public String validateInjectedClass() {
+            return "called";
+        }
+    }
+
 }
\ No newline at end of file