You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by as...@apache.org on 2019/05/06 08:25:48 UTC

[camel] branch master updated: CAMEL-12834: Fix failing CDI tests

This is an automated email from the ASF dual-hosted git repository.

astefanutti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 5f27950  CAMEL-12834: Fix failing CDI tests
5f27950 is described below

commit 5f27950ada502203a6f9567b2fe4756c7a119608
Author: Denis Istomin <is...@gmail.com>
AuthorDate: Mon May 6 12:26:08 2019 +0500

    CAMEL-12834: Fix failing CDI tests
---
 components/camel-cdi/pom.xml                           | 18 ------------------
 .../camel/cdi/rule/ExpectedDeploymentException.java    | 15 ++++++++++++++-
 .../apache/camel/cdi/test/UriWithWrongContextTest.java | 15 ++++++++-------
 3 files changed, 22 insertions(+), 26 deletions(-)

diff --git a/components/camel-cdi/pom.xml b/components/camel-cdi/pom.xml
index 334c109..e079a3d 100644
--- a/components/camel-cdi/pom.xml
+++ b/components/camel-cdi/pom.xml
@@ -258,10 +258,6 @@
                         <configuration>
                             <excludes>
                                 <exclude>**/*Cdi20Test.java</exclude>
-                                <!-- Reactivate when CAMEL-12834 is fixed -->
-                                <exclude>**/UnsatisfiedContextForEndpointInjectTest.java</exclude>
-                                <!-- Reactivate when CAMEL-12834 is fixed -->
-                                <exclude>**/UriWithWrongContextTest.java</exclude>
                             </excludes>
                         </configuration>
                     </plugin>
@@ -306,14 +302,6 @@
                     <plugin>
                         <groupId>org.apache.maven.plugins</groupId>
                         <artifactId>maven-surefire-plugin</artifactId>
-                        <configuration>
-                            <excludes>
-                                <!-- Reactivate when CAMEL-12834 is fixed -->
-                                <exclude>**/UnsatisfiedContextForEndpointInjectTest.java</exclude>
-                                <!-- Reactivate when CAMEL-12834 is fixed -->
-                                <exclude>**/UriWithWrongContextTest.java</exclude>
-                            </excludes>
-                        </configuration>
                     </plugin>
                 </plugins>
             </build>
@@ -531,12 +519,6 @@
                         <artifactId>maven-surefire-plugin</artifactId>
                         <configuration>
                             <reuseForks>true</reuseForks>
-                            <excludes>
-                                <!-- Reactivate when CAMEL-12834 is fixed -->
-                                <exclude>**/UnsatisfiedContextForEndpointInjectTest.java</exclude>
-                                <!-- Reactivate when CAMEL-12834 is fixed -->
-                                <exclude>**/UriWithWrongContextTest.java</exclude>
-                            </excludes>
                         </configuration>
                     </plugin>
                     <plugin>
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/rule/ExpectedDeploymentException.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/rule/ExpectedDeploymentException.java
index 5432ffe..13845b6 100644
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/rule/ExpectedDeploymentException.java
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/rule/ExpectedDeploymentException.java
@@ -55,7 +55,9 @@ public final class ExpectedDeploymentException implements TestRule {
                             // OpenWebBeans logs the deployment exception details
                             // TODO: OpenWebBeans only log the root cause of exception thrown in producer methods
                             //assertThat(log.getMessages(), containsInRelativeOrder(pecs(messages)))
-                            assertThat(log.getMessages(), anyOf(hasItems(messages)));
+
+                            List<String> causeExceptionsMessages = getCauseExceptionsMessages(exception);
+                            assertThat(causeExceptionsMessages, anyOf(hasItems(messages)));
                         } catch (AssertionError error) {
                             // Weld stores the deployment exception details in the exception message
                             assertThat(exception.getMessage(), allOf(pecs(messages)));
@@ -65,6 +67,17 @@ public final class ExpectedDeploymentException implements TestRule {
             });
     }
 
+    private List<String> getCauseExceptionsMessages(Throwable exception) {
+        List<String> exceptionsMessages = new ArrayList<>();
+        Throwable cause = exception;
+        while (cause.getCause() != null && cause.getCause() != cause) {
+            cause = cause.getCause();
+            exceptionsMessages.add(cause.getMessage());
+        }
+        exceptionsMessages.addAll(log.getMessages());
+        return exceptionsMessages;
+    }
+
     public static ExpectedDeploymentException none() {
         return new ExpectedDeploymentException();
     }
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UriWithWrongContextTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UriWithWrongContextTest.java
index 9dd1db0..cddb8b1 100644
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UriWithWrongContextTest.java
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UriWithWrongContextTest.java
@@ -45,12 +45,12 @@ public class UriWithWrongContextTest {
     @ClassRule
     public static TestRule exception = ExpectedDeploymentException.none()
         .expect(RuntimeException.class)
-//        .expectMessage(containsString("Error adding routes of type [" + UriWithWrongContextRoute.class.getName() + "] to Camel context [first]"))
-//        .expectMessage(containsString("Error injecting endpoint annotated with @org.apache.camel.cdi.Uri"))
-        .expectMessage(allOf(
-                containsString("WELD-001408 Unsatisfied dependencies for type [Endpoint] with qualifiers ["),
-                containsString("] at injection point [[field] @"),
-                containsString(" org.apache.camel.cdi.test.UriWithWrongContextRoute.inbound]")));
+        .expectMessage(
+            // WELD-1.0, WELD-1.2, WELD-2.0 have different exception messages
+            // Check only error code and injection point
+            allOf(
+                containsString("WELD-001408"),
+                containsString("org.apache.camel.cdi.test.UriWithWrongContextRoute.inbound")));
 
     @Deployment
     public static Archive<?> deployment() {
@@ -72,7 +72,8 @@ public class UriWithWrongContextTest {
 class UriWithWrongContextRoute extends RouteBuilder {
 
     @Inject
-    @Uri(value = "direct:inbound") @ContextName("second")
+    @Uri(value = "direct:inbound")
+    @ContextName("second")
     Endpoint inbound;
 
     @Override