You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2015/05/20 09:27:15 UTC
camel git commit: CAMEL-8783 Fixed the issue that the Transacted DSL
doesn't work out of box
Repository: camel
Updated Branches:
refs/heads/master 45a3c047b -> 8bf2af2c7
CAMEL-8783 Fixed the issue that the Transacted DSL doesn't work out of box
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8bf2af2c
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8bf2af2c
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8bf2af2c
Branch: refs/heads/master
Commit: 8bf2af2c74816132696874bd969cd932f0221eb3
Parents: 45a3c04
Author: Willem Jiang <wi...@gmail.com>
Authored: Wed May 20 15:25:55 2015 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Wed May 20 15:26:16 2015 +0800
----------------------------------------------------------------------
.../camel/scala/dsl/SAbstractDefinition.scala | 4 +-
.../camel/scala/dsl/STransactedDefinition.scala | 28 +++++++++
.../apache/camel/scala/dsl/TransactedTest.scala | 61 ++++++++++++++++++++
3 files changed, 91 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/8bf2af2c/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractDefinition.scala
----------------------------------------------------------------------
diff --git a/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractDefinition.scala b/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractDefinition.scala
index c7f81a5..a166f37 100644
--- a/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractDefinition.scala
+++ b/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractDefinition.scala
@@ -148,8 +148,8 @@ abstract class SAbstractDefinition[P <: ProcessorDefinition[_]] extends DSL with
def threads = SThreadsDefinition(target.threads)
def throttle(frequency: Frequency) = SThrottleDefinition(target.throttle(frequency.count).timePeriodMillis(frequency.period.milliseconds))
def throwException(exception: Exception) = wrap(target.throwException(exception))
- def transacted = wrap(target.transacted)
- def transacted(ref: String) = wrap(target.transacted(ref))
+ def transacted = STransactedDefinition(target.transacted)
+ def transacted(ref: String) = STransactedDefinition(target.transacted(ref))
def transform(expression: Exchange => Any) = wrap(target.transform(expression))
def unmarshal(format: DataFormatDefinition) = wrap(target.unmarshal(format))
http://git-wip-us.apache.org/repos/asf/camel/blob/8bf2af2c/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/STransactedDefinition.scala
----------------------------------------------------------------------
diff --git a/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/STransactedDefinition.scala b/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/STransactedDefinition.scala
new file mode 100644
index 0000000..ca7ddae
--- /dev/null
+++ b/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/STransactedDefinition.scala
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.scala.dsl
+
+import org.apache.camel.model.TransactedDefinition
+import org.apache.camel.scala.dsl.builder.RouteBuilder
+
+/**
+ * Scala enrichment for Camel's TransactedDefinition
+ */
+case class STransactedDefinition(override val target: TransactedDefinition)(implicit val builder: RouteBuilder) extends SAbstractDefinition[TransactedDefinition] {
+
+}
+
http://git-wip-us.apache.org/repos/asf/camel/blob/8bf2af2c/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/TransactedTest.scala
----------------------------------------------------------------------
diff --git a/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/TransactedTest.scala b/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/TransactedTest.scala
new file mode 100644
index 0000000..700ce50
--- /dev/null
+++ b/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/TransactedTest.scala
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.scala.dsl
+
+import org.apache.camel.impl.{JndiRegistry, SimpleRegistry, CompositeRegistry}
+import org.apache.camel.scala.dsl.builder.{ScalaRouteBuilder, RouteBuilder}
+import org.junit.Test
+import org.springframework.transaction.support.{DefaultTransactionStatus, AbstractPlatformTransactionManager}
+import org.springframework.transaction.{TransactionDefinition, TransactionStatus, PlatformTransactionManager}
+
+
+class TransactedTest extends ScalaTestSupport {
+
+ @throws(classOf[Exception])
+ override def createRegistry: JndiRegistry = {
+ val registry = super.createRegistry
+ // Just setup a dummy platform transaction manager for testing
+ registry.bind("transactionManager", new AbstractPlatformTransactionManager() {
+ override def doCommit(status: DefaultTransactionStatus): Unit = {}
+
+ override def doBegin(transaction: scala.Any, definition: TransactionDefinition): Unit = {}
+
+ override def doRollback(status: DefaultTransactionStatus): Unit = {}
+
+ override def doGetTransaction(): AnyRef = {new Object()}
+ })
+ registry
+ }
+
+ @Test
+ def testScalaRouteBuilder() {
+ getMockEndpoint("mock:result").expectedMessageCount(1)
+
+ template().sendBody("direct:start", "Hello World")
+
+ assertMockEndpointsSatisfied()
+ }
+
+ // must use lazy as we want to evaluate this after CamelContext has been created
+ override lazy val builder = {
+
+ new ScalaRouteBuilder(context()) {
+ from("direct:start").transacted.to("mock:result")
+ }
+ }
+}
+