tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pottlin...@apache.org
Subject incubator-tamaya-extensions git commit: TAMAYA-324: Fixes for test failures provided by William Lieurance
Date Sat, 20 Jan 2018 20:33:22 GMT
Repository: incubator-tamaya-extensions
Updated Branches:
  refs/heads/master c2a5625e5 -> 8f657bb92


TAMAYA-324: Fixes for test failures provided by William Lieurance

First, the CDIAwareServiceContextTest now uses the same Arquillian
backing as various other successful tests.

Second, the ConfiguredVetoExtensionTest is now more idempotent with respect
to the ConfigurationProvider.  Previously, it would leave the shared
ConfigurationProvider pointing at the mocked ConfigurationContext, which
caused other tests (specifically ConfiguredBTest) which rely on a valid
ConfigurationContext to fail.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/8f657bb9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/8f657bb9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/8f657bb9

Branch: refs/heads/master
Commit: 8f657bb92d6c656b0724a83d875063ad2c011e60
Parents: c2a5625
Author: Hugo Hirsch <github@hugo-hirsch.de>
Authored: Sat Jan 20 21:32:10 2018 +0100
Committer: Hugo Hirsch <github@hugo-hirsch.de>
Committed: Sat Jan 20 21:32:10 2018 +0100

----------------------------------------------------------------------
 .../tamaya/cdi/CDIAwareServiceContextTest.java  |   5 +-
 .../cdi/extra/ConfiguredVetoExtensionTest.java  | 116 +++++++++++--------
 2 files changed, 74 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/8f657bb9/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/CDIAwareServiceContextTest.java
----------------------------------------------------------------------
diff --git a/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/CDIAwareServiceContextTest.java
b/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/CDIAwareServiceContextTest.java
index 5679f66..7d1bb22 100644
--- a/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/CDIAwareServiceContextTest.java
+++ b/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/CDIAwareServiceContextTest.java
@@ -21,8 +21,11 @@ package org.apache.tamaya.cdi;
 import org.junit.Test;
 
 import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+import org.jboss.arquillian.junit.Arquillian;
+import org.junit.runner.RunWith;
 
-public class CDIAwareServiceContextTest {
+@RunWith(Arquillian.class)
+public class CDIAwareServiceContextTest extends BaseTestConfiguration {
     private CDIAwareServiceContext context = new CDIAwareServiceContext();
 
     @Test

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/8f657bb9/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/extra/ConfiguredVetoExtensionTest.java
----------------------------------------------------------------------
diff --git a/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/extra/ConfiguredVetoExtensionTest.java
b/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/extra/ConfiguredVetoExtensionTest.java
index 11f7dfd..25b484f 100644
--- a/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/extra/ConfiguredVetoExtensionTest.java
+++ b/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/extra/ConfiguredVetoExtensionTest.java
@@ -23,55 +23,68 @@ import org.apache.tamaya.Configuration;
 import org.apache.tamaya.spi.ConfigurationContext;
 import org.junit.Test;
 
-
 import javax.enterprise.inject.spi.AnnotatedType;
 import javax.enterprise.inject.spi.ProcessAnnotatedType;
 
 import static org.mockito.Mockito.*;
 
 public class ConfiguredVetoExtensionTest {
+
     ConfiguredVetoExtension extension = new ConfiguredVetoExtension();
 
     @Test
     public void willBeVetoedIfTypeHasBeenConfiguredAsConcreteClassName() {
-        ConfigurationContext context = mock(ConfigurationContext.class);
-        Configuration configuration = mock(Configuration.class);
 
-        when(configuration.getContext()).thenReturn(context);
-        when(configuration.get("javax.enterprise.inject.vetoed")).thenReturn("org.apache.tamaya.cdi.extra.TestKlazz");
+        Configuration oldConfiguration = ConfigurationProvider.getConfiguration();
+
+        try {
 
-        ConfigurationProvider.setConfiguration(configuration);
+            ConfigurationContext context = mock(ConfigurationContext.class);
+            Configuration configuration = mock(Configuration.class);
 
-        AnnotatedType<TestKlazz> annotatedType = mock(AnnotatedType.class);
-        when(annotatedType.getJavaClass()).thenReturn(TestKlazz.class);
+            when(configuration.getContext()).thenReturn(context);
+            when(configuration.get("javax.enterprise.inject.vetoed")).thenReturn("org.apache.tamaya.cdi.extra.TestKlazz");
 
-        ProcessAnnotatedType<TestKlazz> processAnnotatedType = mock(ProcessAnnotatedType.class);
-        when(processAnnotatedType.getAnnotatedType()).thenReturn(annotatedType);
+            ConfigurationProvider.setConfiguration(configuration);
+            AnnotatedType<TestKlazz> annotatedType = mock(AnnotatedType.class);
+            when(annotatedType.getJavaClass()).thenReturn(TestKlazz.class);
 
-        extension.observesBean(processAnnotatedType);
+            ProcessAnnotatedType<TestKlazz> processAnnotatedType = mock(ProcessAnnotatedType.class);
+            when(processAnnotatedType.getAnnotatedType()).thenReturn(annotatedType);
 
-        (processAnnotatedType).veto();
+            extension.observesBean(processAnnotatedType);
+
+            (processAnnotatedType).veto();
+        } finally {
+            ConfigurationProvider.setConfiguration(oldConfiguration);
+        }
     }
 
     @Test
     public void willNotBeVetoedIfTypeHasNotBeenConfigured() {
-        ConfigurationContext context = mock(ConfigurationContext.class);
-        Configuration configuration = mock(Configuration.class);
+        Configuration oldConfiguration = ConfigurationProvider.getConfiguration();
+
+        try {
 
-        when(configuration.getContext()).thenReturn(context);
-        when(configuration.get("javax.enterprise.inject.vetoed")).thenReturn("org.apache.tamaya.cdi.extra.O");
+            ConfigurationContext context = mock(ConfigurationContext.class);
+            Configuration configuration = mock(Configuration.class);
 
-        ConfigurationProvider.setConfiguration(configuration);
+            when(configuration.getContext()).thenReturn(context);
+            when(configuration.get("javax.enterprise.inject.vetoed")).thenReturn("org.apache.tamaya.cdi.extra.O");
 
-        AnnotatedType<TestKlazz> annotatedType = mock(AnnotatedType.class);
-        when(annotatedType.getJavaClass()).thenReturn(TestKlazz.class);
+            ConfigurationProvider.setConfiguration(configuration);
+            AnnotatedType<TestKlazz> annotatedType = mock(AnnotatedType.class);
+            when(annotatedType.getJavaClass()).thenReturn(TestKlazz.class);
 
-        ProcessAnnotatedType<TestKlazz> processAnnotatedType = mock(ProcessAnnotatedType.class);
-        when(processAnnotatedType.getAnnotatedType()).thenReturn(annotatedType);
+            ProcessAnnotatedType<TestKlazz> processAnnotatedType = mock(ProcessAnnotatedType.class);
+            when(processAnnotatedType.getAnnotatedType()).thenReturn(annotatedType);
 
-        extension.observesBean(processAnnotatedType);
+            extension.observesBean(processAnnotatedType);
 
-        verify(processAnnotatedType, never()).veto();
+            verify(processAnnotatedType, never()).veto();
+        } finally {
+            ConfigurationProvider.setConfiguration(oldConfiguration);
+        }
     }
 
     @Test
@@ -79,23 +92,29 @@ public class ConfiguredVetoExtensionTest {
         String configuredValue = "  " + TestKlazz.class.getName() +
                                  ",\t" + TestKlazz2.class.getName();
 
-        ConfigurationContext context = mock(ConfigurationContext.class);
-        Configuration configuration = mock(Configuration.class);
+        Configuration oldConfiguration = ConfigurationProvider.getConfiguration();
+
+        try {
+            ConfigurationContext context = mock(ConfigurationContext.class);
+            Configuration configuration = mock(Configuration.class);
 
-        when(configuration.getContext()).thenReturn(context);
-        when(configuration.get("javax.enterprise.inject.vetoed")).thenReturn(configuredValue);
+            when(configuration.getContext()).thenReturn(context);
+            when(configuration.get("javax.enterprise.inject.vetoed")).thenReturn(configuredValue);
 
-        ConfigurationProvider.setConfiguration(configuration);
+            ConfigurationProvider.setConfiguration(configuration);
 
-        AnnotatedType<TestKlazz> annotatedType = mock(AnnotatedType.class);
-        when(annotatedType.getJavaClass()).thenReturn(TestKlazz.class);
+            AnnotatedType<TestKlazz> annotatedType = mock(AnnotatedType.class);
+            when(annotatedType.getJavaClass()).thenReturn(TestKlazz.class);
 
-        ProcessAnnotatedType<TestKlazz> processAnnotatedType = mock(ProcessAnnotatedType.class);
-        when(processAnnotatedType.getAnnotatedType()).thenReturn(annotatedType);
+            ProcessAnnotatedType<TestKlazz> processAnnotatedType = mock(ProcessAnnotatedType.class);
+            when(processAnnotatedType.getAnnotatedType()).thenReturn(annotatedType);
 
-        extension.observesBean(processAnnotatedType);
+            extension.observesBean(processAnnotatedType);
 
-        verify(processAnnotatedType).veto();
+            verify(processAnnotatedType).veto();
+        } finally {
+            ConfigurationProvider.setConfiguration(oldConfiguration);
+        }
     }
 
     @Test
@@ -103,22 +122,27 @@ public class ConfiguredVetoExtensionTest {
         String configuredValue = "  " + TestKlazz.class.getPackage().getName() +
                                  "\\..+";
 
-        ConfigurationContext context = mock(ConfigurationContext.class);
-        Configuration configuration = mock(Configuration.class);
+        Configuration oldConfiguration = ConfigurationProvider.getConfiguration();
 
-        when(configuration.getContext()).thenReturn(context);
-        when(configuration.get("javax.enterprise.inject.vetoed")).thenReturn(configuredValue);
+        try {
+            ConfigurationContext context = mock(ConfigurationContext.class);
+            Configuration configuration = mock(Configuration.class);
 
-        ConfigurationProvider.setConfiguration(configuration);
+            when(configuration.getContext()).thenReturn(context);
+            when(configuration.get("javax.enterprise.inject.vetoed")).thenReturn(configuredValue);
 
-        AnnotatedType<TestKlazz> annotatedType = mock(AnnotatedType.class);
-        when(annotatedType.getJavaClass()).thenReturn(TestKlazz.class);
+            ConfigurationProvider.setConfiguration(configuration);
+            AnnotatedType<TestKlazz> annotatedType = mock(AnnotatedType.class);
+            when(annotatedType.getJavaClass()).thenReturn(TestKlazz.class);
 
-        ProcessAnnotatedType<TestKlazz> processAnnotatedType = mock(ProcessAnnotatedType.class);
-        when(processAnnotatedType.getAnnotatedType()).thenReturn(annotatedType);
+            ProcessAnnotatedType<TestKlazz> processAnnotatedType = mock(ProcessAnnotatedType.class);
+            when(processAnnotatedType.getAnnotatedType()).thenReturn(annotatedType);
 
-        extension.observesBean(processAnnotatedType);
+            extension.observesBean(processAnnotatedType);
 
-        verify(processAnnotatedType).veto();
+            verify(processAnnotatedType).veto();
+        } finally {
+            ConfigurationProvider.setConfiguration(oldConfiguration);
+        }
     }
-}
\ No newline at end of file
+}


Mime
View raw message