Author: jstrachan
Date: Mon Aug 11 08:29:29 2008
New Revision: 684779

URL: http://svn.apache.org/viewvc?rev=684779&view=rev
Log:
added a test case for CAMEL-810 showing that async methods can be invoked 
without blocking

Added:
    
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/IAsyncService.java
   (contents, props changed)
      - copied, changed from r684733, 
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/ISay.java
    
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/SpringRemotingWithOneWayTest.java
   (contents, props changed)
      - copied, changed from r684733, 
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/SpringRemotingRouteTest.java
    
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/SpringRemotingWithOneWayTest-context.xml
   (contents, props changed)
      - copied, changed from r684733, 
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring.xml

Copied: 
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/IAsyncService.java
 (from r684733, 
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/ISay.java)
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/IAsyncService.java?p2=activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/IAsyncService.java&p1=activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/ISay.java&r1=684733&r2=684779&rev=684779&view=diff
==============================================================================
--- 
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/ISay.java
 (original)
+++ 
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/IAsyncService.java
 Mon Aug 11 08:29:29 2008
@@ -16,9 +16,15 @@
  */
 package org.apache.camel.spring.remoting;
 
+import org.apache.camel.OneWay;
+
 import java.rmi.Remote;
 import java.rmi.RemoteException;
 
-public interface ISay extends Remote {
-    String say() throws RemoteException;
-}
+/**
+ * A dummy interface which has a oneway method via the [EMAIL PROTECTED] 
org.apache.camel.OneWay} annotation
+ */
+public interface IAsyncService {
+    @OneWay
+    void doSomethingAsync(String body);
+}
\ No newline at end of file

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

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

Propchange: 
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/IAsyncService.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: 
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/SpringRemotingWithOneWayTest.java
 (from r684733, 
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/SpringRemotingRouteTest.java)
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/SpringRemotingWithOneWayTest.java?p2=activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/SpringRemotingWithOneWayTest.java&p1=activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/SpringRemotingRouteTest.java&r1=684733&r2=684779&rev=684779&view=diff
==============================================================================
--- 
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/SpringRemotingRouteTest.java
 (original)
+++ 
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/SpringRemotingWithOneWayTest.java
 Mon Aug 11 08:29:29 2008
@@ -19,40 +19,46 @@
 import junit.framework.TestCase;
 
 import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.spring.SpringCamelContext;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import org.springframework.context.support.AbstractXmlApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
+import 
org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.List;
 
 /**
  * @version $Revision$
  */
-public class SpringRemotingRouteTest extends TestCase {
-    private static final Log LOG = 
LogFactory.getLog(SpringRemotingRouteTest.class);
[EMAIL PROTECTED]
+public class SpringRemotingWithOneWayTest extends 
AbstractJUnit38SpringContextTests {
+    private static final Log LOG = 
LogFactory.getLog(SpringRemotingWithOneWayTest.class);
 
-    public void testPojoRoutes() throws Exception {
-        AbstractXmlApplicationContext applicationContext = 
createApplicationContext();
-/*
-        Object service = applicationContext.getBean("say");
-        log.info("Found service!: " + service);
-        assertTrue("not an ISay!", service instanceof ISay);
-*/
-
-        CamelContext camelContext = 
SpringCamelContext.springCamelContext(applicationContext);
-
-        // START SNIPPET: invoke
-        ISay proxy = (ISay) applicationContext.getBean("sayProxy");
-        String rc = proxy.say();
-        assertEquals("Hello", rc);
-        // END SNIPPET: invoke
+    @Autowired
+    protected IAsyncService myService;
 
-        camelContext.stop();
-        applicationContext.destroy();
-    }
+    @EndpointInject(uri = "mock:results")
+    protected MockEndpoint endpoint;
+
+    public void testAsyncInvocation() throws Exception {
+        endpoint.expectedMessageCount(1);
+
+        // we should not block even though there is no consumer on the 
endpoint!
+        myService.doSomethingAsync("Hello");
+
+        endpoint.assertIsSatisfied();
+
+        List<Exchange> list = endpoint.getReceivedExchanges();
+        for (Exchange exchange : list) {
+            LOG.info("Received: " + exchange.getIn().getBody());
+        }
 
-    protected AbstractXmlApplicationContext createApplicationContext() {
-        return new 
ClassPathXmlApplicationContext("org/apache/camel/spring/remoting/spring.xml");
     }
-}
+}
\ No newline at end of file

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

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

Propchange: 
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/SpringRemotingWithOneWayTest.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: 
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/SpringRemotingWithOneWayTest-context.xml
 (from r684733, 
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring.xml)
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/SpringRemotingWithOneWayTest-context.xml?p2=activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/SpringRemotingWithOneWayTest-context.xml&p1=activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring.xml&r1=684733&r2=684779&rev=684779&view=diff
==============================================================================
--- 
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring.xml
 (original)
+++ 
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/SpringRemotingWithOneWayTest-context.xml
 Mon Aug 11 08:29:29 2008
@@ -22,24 +22,9 @@
        http://activemq.apache.org/camel/schema/spring 
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
     ">
 
-  <!-- START SNIPPET: export -->
-  <bean id="sayService" class="org.apache.camel.spring.remoting.SayService" 
scope="singleton"/>
-  <!-- END SNIPPET: export -->
-
-  <!-- START SNIPPET: proxy -->
-  <!--  Creates a proxy to the direct:say endpoint. -->
-  <bean id="sayProxy" 
class="org.apache.camel.spring.remoting.CamelProxyFactoryBean">
-    <property name="serviceUrl" value="direct:say"/>
-    <property name="serviceInterface" 
value="org.apache.camel.spring.remoting.ISay"/>
-  </bean>
-  <!-- END SNIPPET: proxy -->
-
   <!-- START SNIPPET: example -->
   <camelContext id="camel" 
xmlns="http://activemq.apache.org/camel/schema/spring";>
-    <route>
-      <from uri="direct:say"/>
-      <to uri="pojo:sayService"/>
-    </route>
+    <proxy id="myService" 
serviceInterface="org.apache.camel.spring.remoting.IAsyncService" 
serviceUrl="mock:results"/>
   </camelContext>
   <!-- END SNIPPET: example -->
 

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

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

Propchange: 
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/SpringRemotingWithOneWayTest-context.xml
------------------------------------------------------------------------------
    svn:mergeinfo = 

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


Reply via email to