camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/2] git commit: CAMEL-7835:Camel listener with the Ordered
Date Wed, 24 Sep 2014 12:14:10 GMT
Repository: camel
Updated Branches:
  refs/heads/master c1cbe8873 -> d1dab1320


CAMEL-7835:Camel listener with the Ordered


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8053a274
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8053a274
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8053a274

Branch: refs/heads/master
Commit: 8053a274977d4a710ace777df355cdcfd84d62a4
Parents: cff3b11
Author: wuwen <wuwen.55@gmail.com>
Authored: Wed Sep 24 20:08:01 2014 +0800
Committer: wuwen <wuwen.55@gmail.com>
Committed: Wed Sep 24 20:08:01 2014 +0800

----------------------------------------------------------------------
 .../test/spring/CamelSpringJUnit4ClassRunner.java      |  4 +++-
 ...elSpringTestContextLoaderTestExecutionListener.java | 13 +++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/8053a274/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunner.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunner.java
b/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunner.java
index 3d88020..64d1721 100644
--- a/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunner.java
+++ b/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunner.java
@@ -19,6 +19,7 @@ package org.apache.camel.test.spring;
 import java.util.List;
 
 import org.junit.runners.model.InitializationError;
+import org.springframework.core.OrderComparator;
 import org.springframework.test.context.TestContextManager;
 import org.springframework.test.context.TestExecutionListener;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -57,9 +58,10 @@ public class CamelSpringJUnit4ClassRunner extends SpringJUnit4ClassRunner
{
 
             // inject Camel first, and then disable jmx and add the stop-watch
             List<TestExecutionListener> list = getTestExecutionListeners();
-            list.add(0, new CamelSpringTestContextLoaderTestExecutionListener());
+            list.add(new CamelSpringTestContextLoaderTestExecutionListener());
             list.add(new DisableJmxTestExecutionListener());
             list.add(new StopWatchTestExecutionListener());
+            OrderComparator.sort(list);
             registerTestExecutionListeners(list);
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/8053a274/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoaderTestExecutionListener.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoaderTestExecutionListener.java
b/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoaderTestExecutionListener.java
index c96943d..d8533d1 100644
--- a/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoaderTestExecutionListener.java
+++ b/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoaderTestExecutionListener.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.test.spring;
 
+import org.springframework.core.Ordered;
 import org.springframework.test.context.TestContext;
 import org.springframework.test.context.support.AbstractTestExecutionListener;
 
@@ -29,6 +30,18 @@ import org.springframework.test.context.support.AbstractTestExecutionListener;
  */
 public class CamelSpringTestContextLoaderTestExecutionListener extends AbstractTestExecutionListener
{
 
+    /**
+     * The default implementation returns {@link org.springframework.core.Ordered#LOWEST_PRECEDENCE},
+     * thereby ensuring that custom listeners are ordered after default
+     * listeners supplied by the framework. Can be overridden by subclasses
+     * as necessary.
+     */
+    @Override
+    public int getOrder() {
+        //set Camel first
+        return Ordered.HIGHEST_PRECEDENCE;
+    }
+
     @Override
     public void prepareTestInstance(TestContext testContext) throws Exception {
         CamelSpringTestHelper.setTestClass(testContext.getTestClass());


Mime
View raw message