You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2009/08/06 07:30:03 UTC

svn commit: r801511 - in /camel/trunk/components/camel-spring/src/test: java/org/apache/camel/spring/remoting/ resources/org/apache/camel/spring/remoting/

Author: davsclaus
Date: Thu Aug  6 05:30:02 2009
New Revision: 801511

URL: http://svn.apache.org/viewvc?rev=801511&view=rev
Log:
Added unit test based on user forum issue.

Added:
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/Echo.java   (with props)
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/EchoPojo.java   (with props)
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/EchoService.java   (with props)
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/EchoSpringRemotingPojoTest.java   (with props)
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/EchoSpringRemotingThrowingRuntimeExceptionTest.java   (with props)
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/MyEchoRuntimeException.java   (with props)
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/echo-pojo.xml   (with props)
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/echo.xml
      - copied, changed from r801507, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/SpringRemotingWithOneWayTest-context.xml

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/Echo.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/Echo.java?rev=801511&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/Echo.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/Echo.java Thu Aug  6 05:30:02 2009
@@ -0,0 +1,25 @@
+/**
+ * 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.spring.remoting;
+
+/**
+ * @version $Revision$
+ */
+public interface Echo {
+
+    String echo(String name);
+}

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/Echo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/Echo.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/EchoPojo.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/EchoPojo.java?rev=801511&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/EchoPojo.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/EchoPojo.java Thu Aug  6 05:30:02 2009
@@ -0,0 +1,36 @@
+/**
+ * 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.spring.remoting;
+
+import org.apache.camel.Consume;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+
+/**
+ * @version $Revision$
+ */
+public class EchoPojo {
+
+    @Produce(uri = "direct:echo")
+    private ProducerTemplate service;
+
+    @Consume(uri = "direct:start")
+    public String onEcho(String name) {
+        return (String) service.requestBody(name);
+    }
+    
+}

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/EchoPojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/EchoPojo.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/EchoService.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/EchoService.java?rev=801511&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/EchoService.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/EchoService.java Thu Aug  6 05:30:02 2009
@@ -0,0 +1,31 @@
+/**
+ * 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.spring.remoting;
+
+/**
+ * @version $Revision$
+ */
+public class EchoService implements Echo {
+
+    public String echo(String name) {
+        if (name.startsWith("Kabom")) {
+            throw new MyEchoRuntimeException("Damn something went wrong");
+        }
+        return name + " " + name;
+    }
+
+}

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/EchoService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/EchoService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/EchoSpringRemotingPojoTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/EchoSpringRemotingPojoTest.java?rev=801511&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/EchoSpringRemotingPojoTest.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/EchoSpringRemotingPojoTest.java Thu Aug  6 05:30:02 2009
@@ -0,0 +1,53 @@
+/**
+ * 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.spring.remoting;
+
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version $Revision$
+ */
+public class EchoSpringRemotingPojoTest extends SpringTestSupport {
+
+    @Override
+    protected int getExpectedRouteCount() {
+        return 0;
+    }
+
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/spring/remoting/echo-pojo.xml");
+    }
+
+    public void testPojoOk() throws Exception {
+        String out = template.requestBody("direct:start", "Claus", String.class);
+        assertEquals("Claus Claus", out);
+    }
+
+    public void testPojoKabom() throws Exception {
+        try {
+            template.requestBody("direct:start", "Kabom", String.class);
+            fail("Should have thrown exception");
+        } catch (RuntimeCamelException e) {
+            assertIsInstanceOf(MyEchoRuntimeException.class, e.getCause());
+            assertEquals("Damn something went wrong", e.getCause().getMessage());
+        }
+    }
+
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/EchoSpringRemotingPojoTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/EchoSpringRemotingPojoTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/EchoSpringRemotingThrowingRuntimeExceptionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/EchoSpringRemotingThrowingRuntimeExceptionTest.java?rev=801511&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/EchoSpringRemotingThrowingRuntimeExceptionTest.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/EchoSpringRemotingThrowingRuntimeExceptionTest.java Thu Aug  6 05:30:02 2009
@@ -0,0 +1,63 @@
+/**
+ * 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.spring.remoting;
+
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version $Revision$
+ */
+public class EchoSpringRemotingThrowingRuntimeExceptionTest extends SpringTestSupport {
+
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/spring/remoting/echo.xml");
+    }
+
+    public void testEchoOk() throws Exception {
+        String out = template.requestBody("direct:echo", "Claus", String.class);
+        assertEquals("Claus Claus", out);
+    }
+    
+    public void testEchoKabom() throws Exception {
+        try {
+            template.requestBody("direct:echo", "Kabom", String.class);
+            fail("Should have thrown exception");
+        } catch (RuntimeCamelException e) {
+            assertIsInstanceOf(MyEchoRuntimeException.class, e.getCause());
+            assertEquals("Damn something went wrong", e.getCause().getMessage());
+        }
+    }
+
+    public void testRouteOk() throws Exception {
+        String out = template.requestBody("direct:start", "Claus", String.class);
+        assertEquals("Claus Claus", out);
+    }
+
+    public void testRouteKabom() throws Exception {
+        try {
+            template.requestBody("direct:start", "Kabom", String.class);
+            fail("Should have thrown exception");
+        } catch (RuntimeCamelException e) {
+            assertIsInstanceOf(MyEchoRuntimeException.class, e.getCause());
+            assertEquals("Damn something went wrong", e.getCause().getMessage());
+        }
+    }
+
+}

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/EchoSpringRemotingThrowingRuntimeExceptionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/EchoSpringRemotingThrowingRuntimeExceptionTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/MyEchoRuntimeException.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/MyEchoRuntimeException.java?rev=801511&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/MyEchoRuntimeException.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/MyEchoRuntimeException.java Thu Aug  6 05:30:02 2009
@@ -0,0 +1,29 @@
+/**
+ * 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.spring.remoting;
+
+/**
+ * @version $Revision$
+ */
+public class MyEchoRuntimeException extends RuntimeException {
+
+    private static final long serialVersionUID = 1L;
+
+    public MyEchoRuntimeException(String s) {
+        super(s);
+    }
+}

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/MyEchoRuntimeException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/MyEchoRuntimeException.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/echo-pojo.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/echo-pojo.xml?rev=801511&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/echo-pojo.xml (added)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/echo-pojo.xml Thu Aug  6 05:30:02 2009
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+    <bean id="echoService" class="org.apache.camel.spring.remoting.EchoService"/>
+
+    <bean id="myPojo" class="org.apache.camel.spring.remoting.EchoPojo"/>
+
+    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+        <export id="echo" serviceInterface="org.apache.camel.spring.remoting.Echo" serviceRef="echoService" uri="direct:echo"/>
+    </camelContext>
+
+</beans>

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/echo-pojo.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/echo-pojo.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/echo-pojo.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Copied: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/echo.xml (from r801507, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/SpringRemotingWithOneWayTest-context.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/echo.xml?p2=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/echo.xml&p1=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/SpringRemotingWithOneWayTest-context.xml&r1=801507&r2=801511&rev=801511&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/SpringRemotingWithOneWayTest-context.xml (original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/echo.xml Thu Aug  6 05:30:02 2009
@@ -22,10 +22,15 @@
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
     ">
 
-  <!-- START SNIPPET: example -->
-  <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
-    <proxy id="myService" serviceInterface="org.apache.camel.spring.remoting.IAsyncService" serviceUrl="mock:results"/>
-  </camelContext>
-  <!-- END SNIPPET: example -->
+    <bean id="echoService" class="org.apache.camel.spring.remoting.EchoService"/>
+
+    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+        <export id="echo" serviceInterface="org.apache.camel.spring.remoting.Echo" serviceRef="echoService" uri="direct:echo"/>
+
+        <route>
+            <from uri="direct:start"/>
+            <to uri="direct:echo"/>
+        </route>
+    </camelContext>
 
 </beans>