openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1811326 - in /openwebbeans/meecrowave/trunk/meecrowave-junit: ./ src/main/java/org/apache/meecrowave/junit5/ src/main/java/org/apache/meecrowave/testing/
Date Fri, 06 Oct 2017 12:58:11 GMT
Author: rmannibucau
Date: Fri Oct  6 12:58:11 2017
New Revision: 1811326

URL: http://svn.apache.org/viewvc?rev=1811326&view=rev
Log:
MEECROWAVE-69 junit 5 upgrade

Modified:
    openwebbeans/meecrowave/trunk/meecrowave-junit/pom.xml
    openwebbeans/meecrowave/trunk/meecrowave-junit/src/main/java/org/apache/meecrowave/junit5/MeecrowaveExtension.java
    openwebbeans/meecrowave/trunk/meecrowave-junit/src/main/java/org/apache/meecrowave/junit5/MonoMeecrowaveExtension.java
    openwebbeans/meecrowave/trunk/meecrowave-junit/src/main/java/org/apache/meecrowave/testing/Injector.java

Modified: openwebbeans/meecrowave/trunk/meecrowave-junit/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-junit/pom.xml?rev=1811326&r1=1811325&r2=1811326&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-junit/pom.xml (original)
+++ openwebbeans/meecrowave/trunk/meecrowave-junit/pom.xml Fri Oct  6 12:58:11 2017
@@ -57,7 +57,7 @@
   </dependencies>
 
   <properties>
-    <junit5.version>5.0.0-M3</junit5.version>
+    <junit5.version>5.0.1</junit5.version>
   </properties>
 
   <build>
@@ -73,7 +73,7 @@
           <dependency>
             <groupId>org.junit.platform</groupId>
             <artifactId>junit-platform-surefire-provider</artifactId>
-            <version>1.0.0-M3</version>
+            <version>1.0.1</version>
           </dependency>
           <dependency>
             <groupId>org.junit.jupiter</groupId>
@@ -83,7 +83,7 @@
           <dependency>
             <groupId>org.junit.vintage</groupId>
             <artifactId>junit-vintage-engine</artifactId>
-            <version>4.12.0-M3</version>
+            <version>4.12.1</version>
           </dependency>
         </dependencies>
       </plugin>

Modified: openwebbeans/meecrowave/trunk/meecrowave-junit/src/main/java/org/apache/meecrowave/junit5/MeecrowaveExtension.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-junit/src/main/java/org/apache/meecrowave/junit5/MeecrowaveExtension.java?rev=1811326&r1=1811325&r2=1811326&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-junit/src/main/java/org/apache/meecrowave/junit5/MeecrowaveExtension.java
(original)
+++ openwebbeans/meecrowave/trunk/meecrowave-junit/src/main/java/org/apache/meecrowave/junit5/MeecrowaveExtension.java
Fri Oct  6 12:58:11 2017
@@ -18,27 +18,26 @@
  */
 package org.apache.meecrowave.junit5;
 
+import java.io.File;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Optional;
+
+import javax.enterprise.context.spi.CreationalContext;
+
 import org.apache.meecrowave.Meecrowave;
 import org.apache.meecrowave.testing.Injector;
 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.ContainerExtensionContext;
 import org.junit.jupiter.api.extension.ExtensionContext;
-import org.junit.jupiter.api.extension.TestExtensionContext;
-
-import javax.enterprise.context.spi.CreationalContext;
-import java.io.File;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.Optional;
 
 public class MeecrowaveExtension implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback,
AfterEachCallback {
     private static final ExtensionContext.Namespace NAMESPACE = ExtensionContext.Namespace.create(MeecrowaveExtension.class.getName());
 
     @Override
-    public void beforeAll(final ContainerExtensionContext context) throws Exception {
+    public void beforeAll(final ExtensionContext context) throws Exception {
         final Meecrowave.Builder builder = new Meecrowave.Builder();
         final Optional<MeecrowaveConfig> meecrowaveConfig = context.getElement().map(e
-> e.getAnnotation(MeecrowaveConfig.class));
         final String ctx;
@@ -85,18 +84,18 @@ public class MeecrowaveExtension impleme
     }
 
     @Override
-    public void afterAll(final ContainerExtensionContext context) throws Exception {
+    public void afterAll(final ExtensionContext context) throws Exception {
         Meecrowave.class.cast(context.getStore(NAMESPACE).get(Meecrowave.class.getName())).close();
     }
 
     @Override
-    public void beforeEach(final TestExtensionContext context) throws Exception {
-        context.getStore(NAMESPACE).put(CreationalContext.class.getName(), Injector.inject(context.getTestInstance()));
-        Injector.injectConfig(Meecrowave.Builder.class.cast(context.getStore(NAMESPACE).get(Meecrowave.Builder.class.getName())),
context.getTestInstance());
+    public void beforeEach(final ExtensionContext context) throws Exception {
+        context.getStore(NAMESPACE).put(CreationalContext.class.getName(), Injector.inject(context.getTestInstance().orElse(null)));
+        Injector.injectConfig(Meecrowave.Builder.class.cast(context.getStore(NAMESPACE).get(Meecrowave.Builder.class.getName())),
context.getTestInstance().orElse(null));
     }
 
     @Override
-    public void afterEach(final TestExtensionContext context) throws Exception {
+    public void afterEach(final ExtensionContext context) throws Exception {
         CreationalContext.class.cast(context.getStore(NAMESPACE).get(CreationalContext.class.getName())).release();
     }
 }

Modified: openwebbeans/meecrowave/trunk/meecrowave-junit/src/main/java/org/apache/meecrowave/junit5/MonoMeecrowaveExtension.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-junit/src/main/java/org/apache/meecrowave/junit5/MonoMeecrowaveExtension.java?rev=1811326&r1=1811325&r2=1811326&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-junit/src/main/java/org/apache/meecrowave/junit5/MonoMeecrowaveExtension.java
(original)
+++ openwebbeans/meecrowave/trunk/meecrowave-junit/src/main/java/org/apache/meecrowave/junit5/MonoMeecrowaveExtension.java
Fri Oct  6 12:58:11 2017
@@ -18,35 +18,33 @@
  */
 package org.apache.meecrowave.junit5;
 
+import javax.enterprise.context.spi.CreationalContext;
+
 import org.apache.meecrowave.Meecrowave;
 import org.apache.meecrowave.testing.Injector;
 import org.apache.meecrowave.testing.MonoBase;
 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.ContainerExtensionContext;
 import org.junit.jupiter.api.extension.ExtensionContext;
-import org.junit.jupiter.api.extension.TestExtensionContext;
-
-import javax.enterprise.context.spi.CreationalContext;
 
 public class MonoMeecrowaveExtension implements BeforeAllCallback, BeforeEachCallback, AfterEachCallback
{
     private static final MonoBase BASE = new MonoBase();
     private static final ExtensionContext.Namespace NAMESPACE = ExtensionContext.Namespace.create(MonoMeecrowaveExtension.class.getName());
 
     @Override
-    public void beforeAll(final ContainerExtensionContext context) throws Exception {
+    public void beforeAll(final ExtensionContext context) throws Exception {
         context.getStore(NAMESPACE).put(Meecrowave.Builder.class.getName(), BASE.startIfNeeded());
     }
 
     @Override
-    public void beforeEach(final TestExtensionContext context) throws Exception {
-        context.getStore(NAMESPACE).put(CreationalContext.class.getName(), Injector.inject(context.getTestInstance()));
-        Injector.injectConfig(Meecrowave.Builder.class.cast(context.getStore(NAMESPACE).get(Meecrowave.Builder.class.getName())),
context.getTestInstance());
+    public void beforeEach(final ExtensionContext context) throws Exception {
+        context.getStore(NAMESPACE).put(CreationalContext.class.getName(), Injector.inject(context.getTestInstance().orElse(null)));
+        Injector.injectConfig(Meecrowave.Builder.class.cast(context.getStore(NAMESPACE).get(Meecrowave.Builder.class.getName())),
context.getTestInstance().orElse(null));
     }
 
     @Override
-    public void afterEach(final TestExtensionContext context) throws Exception {
+    public void afterEach(final ExtensionContext context) throws Exception {
         CreationalContext.class.cast(context.getStore(NAMESPACE).get(CreationalContext.class.getName())).release();
     }
 }

Modified: openwebbeans/meecrowave/trunk/meecrowave-junit/src/main/java/org/apache/meecrowave/testing/Injector.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-junit/src/main/java/org/apache/meecrowave/testing/Injector.java?rev=1811326&r1=1811325&r2=1811326&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-junit/src/main/java/org/apache/meecrowave/testing/Injector.java
(original)
+++ openwebbeans/meecrowave/trunk/meecrowave-junit/src/main/java/org/apache/meecrowave/testing/Injector.java
Fri Oct  6 12:58:11 2017
@@ -33,6 +33,9 @@ public final class Injector {
     }
 
     public static CreationalContext<?> inject(final Object testInstance) {
+        if (testInstance == null) {
+            return null;
+        }
         final BeanManager bm = CDI.current().getBeanManager();
         final AnnotatedType<?> annotatedType = bm.createAnnotatedType(testInstance.getClass());
         final InjectionTarget injectionTarget = bm.createInjectionTarget(annotatedType);
@@ -42,6 +45,9 @@ public final class Injector {
     }
 
     public static void injectConfig(final Meecrowave.Builder config, final Object test) {
+        if (test == null) {
+            return;
+        }
         final Class<?> aClass = test.getClass();
         Stream.of(aClass.getDeclaredFields())
                 .filter(f -> f.isAnnotationPresent(ConfigurationInject.class))



Mime
View raw message