fixed bug 35834: platform modules fail in CI
authorAsier Lostalé <asier.lostale@openbravo.com>
Tue, 25 Apr 2017 15:59:15 +0200
changeset 31980 a157881ce096
parent 31979 e833242c1051
child 31981 da58b93b6302
fixed bug 35834: platform modules fail in CI

Two different instances of Weld bean manager were in use, this caused dependant
context not to be consistently handled in jUnit Arquillian test cases.

Solved by setting the same instance for static and instance bean manager in WeldUtils
whenever a test class is statarted.
modules/org.openbravo.base.weld/src-test/org/openbravo/base/weld/test/WeldBaseTest.java
modules/org.openbravo.base.weld/src/org/openbravo/base/weld/WeldUtils.java
--- a/modules/org.openbravo.base.weld/src-test/org/openbravo/base/weld/test/WeldBaseTest.java	Sun Apr 16 13:16:12 2017 -0400
+++ b/modules/org.openbravo.base.weld/src-test/org/openbravo/base/weld/test/WeldBaseTest.java	Tue Apr 25 15:59:15 2017 +0200
@@ -94,6 +94,9 @@
   private BeanManager beanManager;
 
   @Inject
+  private WeldUtils weldUtils;
+
+  @Inject
   private KernelInitializer kernelInitializer;
 
   /**
@@ -110,6 +113,7 @@
     if (!initialized) {
       WeldUtils.setStaticInstanceBeanManager(beanManager);
       kernelInitializer.setInterceptor();
+      weldUtils.setBeanManager(beanManager);
       initialized = true;
     }
     super.setUp();
--- a/modules/org.openbravo.base.weld/src/org/openbravo/base/weld/WeldUtils.java	Sun Apr 16 13:16:12 2017 -0400
+++ b/modules/org.openbravo.base.weld/src/org/openbravo/base/weld/WeldUtils.java	Tue Apr 25 15:59:15 2017 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010-2016 Openbravo SLU
+ * All portions are Copyright (C) 2010-2017 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -139,4 +139,12 @@
     }
     return instances;
   }
+
+  /**
+   * Sets bean manager. The purpose of this setter is to be used just in jUnit test cases. When
+   * working within a container, bean manager should be handled by container.
+   */
+  public void setBeanManager(BeanManager beanManager) {
+    this.beanManager = beanManager;
+  }
 }