camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1297126 - in /camel/trunk/components/camel-websocket/src: main/java/org/apache/camel/component/websocket/ test/java/org/apache/camel/component/websocket/
Date Mon, 05 Mar 2012 16:50:43 GMT
Author: davsclaus
Date: Mon Mar  5 16:50:42 2012
New Revision: 1297126

URL: http://svn.apache.org/viewvc?rev=1297126&view=rev
Log:
CAMEL-5061: Polished camel-websocket

Added:
    camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/DefaultNodeSynchronization.java
      - copied, changed from r1297105, camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/NodeSynchronizationImpl.java
Removed:
    camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/NodeSynchronizationImpl.java
Modified:
    camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/DefaultWebsocket.java
    camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/NodeSynchronization.java
    camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponent.java
    camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponentServlet.java
    camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketConfiguration.java
    camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketConstants.java
    camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketConsumer.java
    camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketEndpoint.java
    camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketProducer.java
    camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/DefaultWebsocketTest.java
    camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/MemoryWebsocketStoreTest.java
    camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/NodeSynchronizationImplTest.java
    camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentServletTest.java
    camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentTest.java
    camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketConfigurationTest.java
    camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketConsumerTest.java
    camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketEndpointTest.java
    camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketProducerTest.java

Copied: camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/DefaultNodeSynchronization.java (from r1297105, camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/NodeSynchronizationImpl.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/DefaultNodeSynchronization.java?p2=camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/DefaultNodeSynchronization.java&p1=camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/NodeSynchronizationImpl.java&r1=1297105&r2=1297126&rev=1297126&view=diff
==============================================================================
--- camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/NodeSynchronizationImpl.java (original)
+++ camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/DefaultNodeSynchronization.java Mon Mar  5 16:50:42 2012
@@ -16,25 +16,24 @@
  */
 package org.apache.camel.component.websocket;
 
-public class NodeSynchronizationImpl implements NodeSynchronization {
+public class DefaultNodeSynchronization implements NodeSynchronization {
 
     private WebsocketStore memoryStore;
-
     private WebsocketStore globalStore;
 
-    public NodeSynchronizationImpl(WebsocketStore memoryStore, WebsocketStore globalStore) {
+    public DefaultNodeSynchronization(WebsocketStore memoryStore, WebsocketStore globalStore) {
         this.memoryStore = memoryStore;
         this.globalStore = globalStore;
     }
 
-    public NodeSynchronizationImpl(WebsocketStore memoryStore) {
+    public DefaultNodeSynchronization(WebsocketStore memoryStore) {
         this.memoryStore = memoryStore;
     }
 
     @Override
     public void addSocket(DefaultWebsocket socket) {
         memoryStore.add(socket);
-        if (this.globalStore != null) {
+        if (globalStore != null) {
             globalStore.add(socket);
         }
     }
@@ -42,7 +41,7 @@ public class NodeSynchronizationImpl imp
     @Override
     public void removeSocket(String id) {
         memoryStore.remove(id);
-        if (this.globalStore != null) {
+        if (globalStore != null) {
             globalStore.remove(id);
         }
     }
@@ -50,7 +49,7 @@ public class NodeSynchronizationImpl imp
     @Override
     public void removeSocket(DefaultWebsocket socket) {
         memoryStore.remove(socket);
-        if (this.globalStore != null) {
+        if (globalStore != null) {
             globalStore.remove(socket);
         }
     }

Modified: camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/DefaultWebsocket.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/DefaultWebsocket.java?rev=1297126&r1=1297125&r2=1297126&view=diff
==============================================================================
--- camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/DefaultWebsocket.java (original)
+++ camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/DefaultWebsocket.java Mon Mar  5 16:50:42 2012
@@ -21,15 +21,17 @@ import java.util.UUID;
 
 import org.eclipse.jetty.websocket.WebSocket;
 import org.eclipse.jetty.websocket.WebSocket.OnTextMessage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class DefaultWebsocket implements WebSocket, OnTextMessage, Serializable {
 
     private static final long serialVersionUID = -575701599776801400L;
-    private Connection connection;
-    private String connectionKey;
-    private NodeSynchronization sync;
-
+    private static final Logger LOG = LoggerFactory.getLogger(DefaultWebsocket.class);
+    private transient Connection connection;
     private transient WebsocketConsumer consumer;
+    private transient NodeSynchronization sync;
+    private String connectionKey;
 
     public DefaultWebsocket(NodeSynchronization sync, WebsocketConsumer consumer) {
         this.sync = sync;
@@ -44,21 +46,20 @@ public class DefaultWebsocket implements
     @Override
     public void onOpen(Connection connection) {
         this.connection = connection;
-
         this.connectionKey = UUID.randomUUID().toString();
         sync.addSocket(this);
     }
 
     @Override
     public void onMessage(String message) {
+        LOG.debug("onMessage: {}", message);
         if (this.consumer != null) {
             this.consumer.sendExchange(this.connectionKey, message);
+        } else {
+            LOG.debug("No consumer to handle message received: {}", message);
         }
-        // consumer is not set, this is produce only websocket
-        // TODO - 06.06.2011, LK - deliver exchange to dead letter channel
     }
 
-    // getters and setters
     public Connection getConnection() {
         return connection;
     }

Modified: camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/NodeSynchronization.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/NodeSynchronization.java?rev=1297126&r1=1297125&r2=1297126&view=diff
==============================================================================
--- camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/NodeSynchronization.java (original)
+++ camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/NodeSynchronization.java Mon Mar  5 16:50:42 2012
@@ -18,13 +18,25 @@ package org.apache.camel.component.webso
 
 public interface NodeSynchronization {
 
-    /** adds the Websocket to both (always if present) stores */
+    /**
+     * Adds the web socket to both (always if present) stores.
+     *
+     * @param socket the web socket
+     */
     void addSocket(DefaultWebsocket socket);
 
-    /** deletes the Websocket from both stores */
+    /**
+     * Removes the Websocket from both stores
+     *
+     * @param id id of the web socket
+     */
     void removeSocket(String id);
 
-    /** deletes the Websocket from both stores */
+    /**
+     * Removes the Websocket from both stores
+     *
+     * @param socket web socket to remove
+     */
     void removeSocket(DefaultWebsocket socket);
 
 }

Modified: camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponent.java?rev=1297126&r1=1297125&r2=1297126&view=diff
==============================================================================
--- camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponent.java (original)
+++ camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponent.java Mon Mar  5 16:50:42 2012
@@ -38,18 +38,13 @@ public class WebsocketComponent extends 
 
     private ServletContextHandler context;
     private Server server;
-
-    /** Host name for server. */
     private String host = WebsocketConstants.DEFAULT_HOST;
-
-    /** Port for server. */
     private int port = WebsocketConstants.DEFAULT_PORT;
-
-    /** Server static content location. */
     private String staticResources;
 
     /**
-     * Map for storing endpoints. Endpoint is identified by remaining part from endpoint URI. Eg. <tt>ws://foo?bar=123</tt> and <tt>ws://foo</tt> are referring to the same endpoint.
+     * Map for storing endpoints. Endpoint is identified by remaining part from endpoint URI.
+     * Eg. <tt>ws://foo?bar=123</tt> and <tt>ws://foo</tt> are referring to the same endpoint.
      */
     private Map<String, WebsocketEndpoint> endpoints = new HashMap<String, WebsocketEndpoint>();
 
@@ -73,26 +68,14 @@ public class WebsocketComponent extends 
         return endpoint;
     }
 
-    /**
-     * @param host
-     *            the host to set
-     */
     public void setHost(String host) {
         this.host = host;
     }
 
-    /**
-     * @param port
-     *            the port to set
-     */
     public void setPort(int port) {
         this.port = port;
     }
 
-    /**
-     * @param staticResources
-     *            the staticResources to set
-     */
     public void setStaticResources(String staticResources) {
         this.staticResources = staticResources;
     }
@@ -128,7 +111,6 @@ public class WebsocketComponent extends 
     }
 
     public WebsocketComponentServlet addServlet(NodeSynchronization sync, WebsocketConsumer consumer, String remaining) {
-
         String pathSpec = createPathSpec(remaining);
         WebsocketComponentServlet servlet = servlets.get(pathSpec);
         if (servlet == null) {
@@ -149,16 +131,12 @@ public class WebsocketComponent extends 
     }
 
     WebsocketComponentServlet createServlet(NodeSynchronization sync, String pathSpec, Map<String, WebsocketComponentServlet> servlets, ServletContextHandler handler) {
-
         WebsocketComponentServlet servlet = new WebsocketComponentServlet(sync);
         servlets.put(pathSpec, servlet);
         handler.addServlet(new ServletHolder(servlet), pathSpec);
         return servlet;
     }
 
-    /**
-     * @see org.apache.camel.impl.DefaultComponent#doStart()
-     */
     @Override
     protected void doStart() throws Exception {
         super.doStart();
@@ -168,9 +146,6 @@ public class WebsocketComponent extends 
         server.start();
     }
 
-    /**
-     * @see org.apache.camel.impl.DefaultComponent#doStop()
-     */
     @Override
     public void doStop() throws Exception {
         if (server != null) {

Modified: camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponentServlet.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponentServlet.java?rev=1297126&r1=1297125&r2=1297126&view=diff
==============================================================================
--- camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponentServlet.java (original)
+++ camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketComponentServlet.java Mon Mar  5 16:50:42 2012
@@ -36,30 +36,23 @@ public class WebsocketComponentServlet e
         this.sync = sync;
     }
 
-    /**
-     * @return the consumer
-     */
     public WebsocketConsumer getConsumer() {
         return consumer;
     }
 
-    /**
-     * @param consumer
-     *            the consumer to set
-     */
     public void setConsumer(WebsocketConsumer consumer) {
         this.consumer = consumer;
     }
 
     @Override
-    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-
-        getServletContext().getNamedDispatcher("default").forward(request, response);
+    public WebSocket doWebSocketConnect(HttpServletRequest request, String protocol) {
+        return new DefaultWebsocket(sync, consumer);
     }
 
     @Override
-    public WebSocket doWebSocketConnect(HttpServletRequest request, String protocol) {
-        return new DefaultWebsocket(sync, consumer);
+    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+        // TODO: why do we grab the default servlet?
+        getServletContext().getNamedDispatcher("default").forward(request, response);
     }
 
 }

Modified: camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketConfiguration.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketConfiguration.java?rev=1297126&r1=1297125&r2=1297126&view=diff
==============================================================================
--- camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketConfiguration.java (original)
+++ camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketConfiguration.java Mon Mar  5 16:50:42 2012
@@ -16,7 +16,11 @@
  */
 package org.apache.camel.component.websocket;
 
-public class WebsocketConfiguration {
+import java.io.Serializable;
+
+public class WebsocketConfiguration implements Serializable {
+
+    private static final long serialVersionUID = 1L;
 
     private String globalStore;
 

Modified: camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketConstants.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketConstants.java?rev=1297126&r1=1297125&r2=1297126&view=diff
==============================================================================
--- camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketConstants.java (original)
+++ camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketConstants.java Mon Mar  5 16:50:42 2012
@@ -26,5 +26,4 @@ public final class WebsocketConstants {
     private WebsocketConstants() {
     };
 
-
 }

Modified: camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketConsumer.java?rev=1297126&r1=1297125&r2=1297126&view=diff
==============================================================================
--- camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketConsumer.java (original)
+++ camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketConsumer.java Mon Mar  5 16:50:42 2012
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.websocket;
 
+import org.apache.camel.AsyncCallback;
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
@@ -27,21 +28,22 @@ public class WebsocketConsumer extends D
         super(endpoint, processor);
     }
 
-    public void sendExchange(String connectionKey, String message) {
-        Exchange exchange = this.getEndpoint().createExchange();
+    public void sendExchange(final String connectionKey, final String message) {
+        final Exchange exchange = getEndpoint().createExchange();
 
         // set header and body
         exchange.getIn().setHeader(WebsocketConstants.CONNECTION_KEY, connectionKey);
         exchange.getIn().setBody(message);
 
-        // send exchange
-        try {
-            this.getProcessor().process(exchange);
-        } catch (Exception e) {
-            if (exchange.getException() != null) {
-                this.getExceptionHandler().handleException(String.format("Error processing exchange for websocket consumer on message '%s'.", message), exchange, exchange.getException());
+        // send exchange using the async routing engine
+        getAsyncProcessor().process(exchange, new AsyncCallback() {
+            public void done(boolean doneSync) {
+                if (exchange.getException() != null) {
+                    getExceptionHandler().handleException(String.format("Error processing exchange for websocket consumer on message '%s'.", message),
+                            exchange, exchange.getException());
+                }
             }
-        }
+        });
     }
 
 }

Modified: camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketEndpoint.java?rev=1297126&r1=1297125&r2=1297126&view=diff
==============================================================================
--- camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketEndpoint.java (original)
+++ camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketEndpoint.java Mon Mar  5 16:50:42 2012
@@ -51,7 +51,7 @@ public class WebsocketEndpoint extends D
         }
 
         // this.sync = new NodeSynchronizationImpl(this.memoryStore, null);
-        this.sync = new NodeSynchronizationImpl(this.memoryStore, this.globalStore);
+        this.sync = new DefaultNodeSynchronization(this.memoryStore, this.globalStore);
     }
 
     public WebsocketStore getMemoryStore() {

Modified: camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketProducer.java?rev=1297126&r1=1297125&r2=1297126&view=diff
==============================================================================
--- camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketProducer.java (original)
+++ camel/trunk/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketProducer.java Mon Mar  5 16:50:42 2012
@@ -19,13 +19,13 @@ package org.apache.camel.component.webso
 import java.io.IOException;
 import java.util.Collection;
 
+import org.apache.camel.CamelExchangeException;
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.impl.DefaultProducer;
 
 public class WebsocketProducer extends DefaultProducer {
-
     private WebsocketStore store;
 
     public WebsocketProducer(Endpoint endpoint) {
@@ -39,12 +39,11 @@ public class WebsocketProducer extends D
 
     @Override
     public void process(Exchange exchange) throws Exception {
-
         Message in = exchange.getIn();
-        String message = in.getBody(String.class);
+        String message = in.getMandatoryBody(String.class);
 
         if (isSendToAllSet(in)) {
-            sendToAll(this.store, message);
+            sendToAll(store, message, exchange);
         } else {
             // look for connection key and get Websocket
             String connectionKey = in.getHeader(WebsocketConstants.CONNECTION_KEY, String.class);
@@ -63,7 +62,7 @@ public class WebsocketProducer extends D
         return value == null ? false : (Boolean) value;
     }
 
-    void sendToAll(WebsocketStore store, String message) throws Exception {
+    void sendToAll(WebsocketStore store, String message, Exchange exchange) throws Exception {
         Collection<DefaultWebsocket> websockets = store.getAll();
         Exception exception = null;
         for (DefaultWebsocket websocket : websockets) {
@@ -71,7 +70,7 @@ public class WebsocketProducer extends D
                 sendMessage(websocket, message);
             } catch (Exception e) {
                 if (exception == null) {
-                    exception = new Exception("Failed to deliver message to one or more recipients.", e);
+                    exception = new CamelExchangeException("Failed to deliver message to one or more recipients.", exchange, e);
                 }
             }
         }
@@ -81,8 +80,7 @@ public class WebsocketProducer extends D
     }
 
     void sendMessage(DefaultWebsocket websocket, String message) throws IOException {
-        // in case there is web socket and socket connection is open - send
-        // message
+        // in case there is web socket and socket connection is open - send message
         if (websocket != null && websocket.getConnection().isOpen()) {
             websocket.getConnection().sendMessage(message);
         }

Modified: camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/DefaultWebsocketTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/DefaultWebsocketTest.java?rev=1297126&r1=1297125&r2=1297126&view=diff
==============================================================================
--- camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/DefaultWebsocketTest.java (original)
+++ camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/DefaultWebsocketTest.java Mon Mar  5 16:50:42 2012
@@ -42,28 +42,19 @@ public class DefaultWebsocketTest {
 
     @Mock
     private Connection connection;
-
     @Mock
     private WebsocketConsumer consumer;
-
     @Mock
     private NodeSynchronization sync;
 
     private DefaultWebsocket defaultWebsocket;
 
-    /**
-     * @throws Exception
-     */
     @Before
     public void setUp() throws Exception {
-        // sync = new NodeSynchronizationImpl(new MemoryWebsocketStore());
         defaultWebsocket = new DefaultWebsocket(sync, consumer);
         defaultWebsocket.setConnectionKey(CONNECTION_KEY);
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.DefaultWebsocket#onClose(int, String)} .
-     */
     @Test
     public void testOnClose() {
         defaultWebsocket.onClose(CLOSE_CODE, MESSAGE);
@@ -72,9 +63,6 @@ public class DefaultWebsocketTest {
         inOrder.verifyNoMoreInteractions();
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.DefaultWebsocket#onOpen(org.eclipse.jetty.websocket.WebSocket.Connection)} .
-     */
     @Test
     public void testOnOpen() {
         defaultWebsocket.onOpen(connection);
@@ -89,9 +77,6 @@ public class DefaultWebsocketTest {
         assertEquals(connection, defaultWebsocket.getConnection());
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.DefaultWebsocket#onMessage(String)} .
-     */
     @Test
     public void testOnMessage() {
         defaultWebsocket.setConnectionKey(CONNECTION_KEY);
@@ -101,9 +86,6 @@ public class DefaultWebsocketTest {
         inOrder.verifyNoMoreInteractions();
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.DefaultWebsocket#onMessage(String)} .
-     */
     @Test
     public void testOnMessageWithNullConsumer() {
         defaultWebsocket = new DefaultWebsocket(sync, null);
@@ -114,9 +96,6 @@ public class DefaultWebsocketTest {
         inOrder.verifyNoMoreInteractions();
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.DefaultWebsocket#getConnection()} .
-     */
     @Test
     public void testGetConnection() {
         assertNull(defaultWebsocket.getConnection());
@@ -128,17 +107,11 @@ public class DefaultWebsocketTest {
         assertEquals(connection, defaultWebsocket.getConnection());
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.DefaultWebsocket#setConnection(org.eclipse.jetty.websocket.WebSocket.Connection)} .
-     */
     @Test
     public void testSetConnection() {
         testGetConnection();
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.DefaultWebsocket#getConnectionKey()} .
-     */
     @Test
     public void testGetConnectionKey() {
         defaultWebsocket.setConnectionKey(null);
@@ -151,11 +124,9 @@ public class DefaultWebsocketTest {
         assertNull(defaultWebsocket.getConnectionKey());
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.DefaultWebsocket#setConnectionKey(String)} .
-     */
     @Test
     public void testSetConnectionKey() {
         testGetConnectionKey();
     }
+
 }

Modified: camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/MemoryWebsocketStoreTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/MemoryWebsocketStoreTest.java?rev=1297126&r1=1297125&r2=1297126&view=diff
==============================================================================
--- camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/MemoryWebsocketStoreTest.java (original)
+++ camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/MemoryWebsocketStoreTest.java Mon Mar  5 16:50:42 2012
@@ -44,21 +44,15 @@ public class MemoryWebsocketStoreTest {
 
     @Mock
     private WebsocketConsumer consumer;
-
     @Mock
     private NodeSynchronization sync;
-
     @Mock
     private DefaultWebsocket websocket1 = new DefaultWebsocket(sync, consumer);;
-
     @Mock
     private DefaultWebsocket websocket2 = new DefaultWebsocket(sync, consumer);;
 
     private MemoryWebsocketStore store;
 
-    /**
-     * @throws Exception
-     */
     @Before
     public void setUp() throws Exception {
         store = new MemoryWebsocketStore();
@@ -66,9 +60,6 @@ public class MemoryWebsocketStoreTest {
         when(websocket2.getConnectionKey()).thenReturn(KEY_2);
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.MemoryWebsocketStore#add(String, org.apache.camel.component.websocket.DefaultWebsocket)} .
-     */
     @Test
     public void testAdd() {
         assertNotNull(websocket1.getConnectionKey());
@@ -80,17 +71,11 @@ public class MemoryWebsocketStoreTest {
         assertEquals(websocket2, store.get(KEY_2));
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.MemoryWebsocketStore#add(org.apache.camel.component.websocket.DefaultWebsocket)} .
-     */
     @Test(expected = NullPointerException.class)
     public void testAddNullValue() {
         store.add(null);
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.MemoryWebsocketStore#remove(org.apache.camel.component.websocket.DefaultWebsocket)} .
-     */
     @Test
     public void testRemoveDefaultWebsocket() {
         // first call of websocket1.getConnectionKey()
@@ -105,9 +90,6 @@ public class MemoryWebsocketStoreTest {
         inOrder.verifyNoMoreInteractions();
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.MemoryWebsocketStore#remove(org.apache.camel.component.websocket.DefaultWebsocket)} .
-     */
     @Test
     public void testRemoveDefaultWebsocketKeyNotSet() {
         // first call of websocket1.getConnectionKey()
@@ -130,9 +112,6 @@ public class MemoryWebsocketStoreTest {
         inOrder.verifyNoMoreInteractions();
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.MemoryWebsocketStore#remove(org.apache.camel.component.websocket.DefaultWebsocket)} .
-     */
     @Test
     public void testRemoveNotExisting() {
         websocket1.setConnectionKey(KEY_1);
@@ -148,9 +127,6 @@ public class MemoryWebsocketStoreTest {
         inOrder.verifyNoMoreInteractions();
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.MemoryWebsocketStore#remove(String)} .
-     */
     @Test
     public void testRemoveString() {
         websocket1.setConnectionKey(KEY_1);
@@ -160,9 +136,6 @@ public class MemoryWebsocketStoreTest {
         assertNull(store.get(KEY_1));
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.MemoryWebsocketStore#remove(String)} .
-     */
     @Test
     public void testRemoveStringNotExisting() {
         websocket1.setConnectionKey(KEY_1);
@@ -174,9 +147,6 @@ public class MemoryWebsocketStoreTest {
         assertNull(store.get(KEY_2));
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.MemoryWebsocketStore#get(String)} .
-     */
     @Test
     public void testGetString() {
         websocket1.setConnectionKey(KEY_1);
@@ -189,9 +159,6 @@ public class MemoryWebsocketStoreTest {
         assertEquals(websocket2, store.get(KEY_2));
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.MemoryWebsocketStore#getAll()} .
-     */
     @Test
     public void testGetAll() {
         Collection<DefaultWebsocket> sockets = store.getAll();
@@ -213,4 +180,5 @@ public class MemoryWebsocketStoreTest {
         assertTrue(sockets.contains(websocket1));
         assertTrue(sockets.contains(websocket2));
     }
+
 }

Modified: camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/NodeSynchronizationImplTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/NodeSynchronizationImplTest.java?rev=1297126&r1=1297125&r2=1297126&view=diff
==============================================================================
--- camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/NodeSynchronizationImplTest.java (original)
+++ camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/NodeSynchronizationImplTest.java Mon Mar  5 16:50:42 2012
@@ -72,7 +72,7 @@ public class NodeSynchronizationImplTest
      */
     @Test
     public void testAddSocketMemoryAndGlobal() {
-        sync = new NodeSynchronizationImpl(store1, store2);
+        sync = new DefaultNodeSynchronization(store1, store2);
 
         sync.addSocket(websocket1);
         assertEquals(websocket1, store1.get(KEY_1));
@@ -88,7 +88,7 @@ public class NodeSynchronizationImplTest
      */
     @Test
     public void testAddSocketMemoryOnly() {
-        sync = new NodeSynchronizationImpl(store1);
+        sync = new DefaultNodeSynchronization(store1);
 
         sync.addSocket(websocket1);
         assertEquals(websocket1, store1.get(KEY_1));
@@ -99,7 +99,7 @@ public class NodeSynchronizationImplTest
      */
     @Test
     public void testAddSocketMemoryAndNullGlobal() {
-        sync = new NodeSynchronizationImpl(store1, null);
+        sync = new DefaultNodeSynchronization(store1, null);
 
         sync.addSocket(websocket1);
         assertEquals(websocket1, store1.get(KEY_1));
@@ -118,7 +118,7 @@ public class NodeSynchronizationImplTest
      */
     @Test
     public void testRemoveDefaultWebsocket() {
-        sync = new NodeSynchronizationImpl(store1, store2);
+        sync = new DefaultNodeSynchronization(store1, store2);
 
         // first call of websocket1.getConnectionKey()
         sync.addSocket(websocket1);
@@ -147,7 +147,7 @@ public class NodeSynchronizationImplTest
      */
     @Test
     public void testRemoveDefaultWebsocketKeyNotSet() {
-        sync = new NodeSynchronizationImpl(store1);
+        sync = new DefaultNodeSynchronization(store1);
 
         // first call of websocket1.getConnectionKey()
         sync.addSocket(websocket1);
@@ -170,7 +170,7 @@ public class NodeSynchronizationImplTest
      */
     @Test
     public void testRemoveNotExisting() {
-        sync = new NodeSynchronizationImpl(store1);
+        sync = new DefaultNodeSynchronization(store1);
 
         // first call of websocket1.getConnectionKey()
         sync.addSocket(websocket1);
@@ -188,7 +188,7 @@ public class NodeSynchronizationImplTest
      */
     @Test
     public void testRemoveString() {
-        sync = new NodeSynchronizationImpl(store1, store2);
+        sync = new DefaultNodeSynchronization(store1, store2);
 
         // first call of websocket1.getConnectionKey()
         sync.addSocket(websocket1);
@@ -218,7 +218,7 @@ public class NodeSynchronizationImplTest
     @Test
     public void testRemoveStringNotExisting() {
 
-        sync = new NodeSynchronizationImpl(store1);
+        sync = new DefaultNodeSynchronization(store1);
 
         // first call of websocket1.getConnectionKey()
         sync.addSocket(websocket1);

Modified: camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentServletTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentServletTest.java?rev=1297126&r1=1297125&r2=1297126&view=diff
==============================================================================
--- camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentServletTest.java (original)
+++ camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentServletTest.java Mon Mar  5 16:50:42 2012
@@ -46,26 +46,18 @@ public class WebsocketComponentServletTe
 
     @Mock
     private WebsocketConsumer consumer;
-
     @Mock
     private NodeSynchronization sync;
-
     @Mock
     private HttpServletRequest request;
 
     private WebsocketComponentServlet websocketComponentServlet;
 
-    /**
-     * @throws Exception
-     */
     @Before
     public void setUp() throws Exception {
         websocketComponentServlet = new WebsocketComponentServlet(sync);
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.WebsocketComponentServlet#getConsumer()} .
-     */
     @Test
     public void testGetConsumer() {
         assertNull(websocketComponentServlet.getConsumer());
@@ -73,17 +65,11 @@ public class WebsocketComponentServletTe
         assertEquals(consumer, websocketComponentServlet.getConsumer());
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.WebsocketComponentServlet#setConsumer(org.apache.camel.component.websocket.WebsocketConsumer)} .
-     */
     @Test
     public void testSetConsumer() {
         testGetConsumer();
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.WebsocketComponentServlet#doWebSocketConnect(javax.servlet.http.HttpServletRequest, String)} .
-     */
     @Test
     public void testDoWebSocketConnect() {
         websocketComponentServlet.setConsumer(consumer);
@@ -98,9 +84,6 @@ public class WebsocketComponentServletTe
         inOrder.verifyNoMoreInteractions();
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.WebsocketComponentServlet#doWebSocketConnect(javax.servlet.http.HttpServletRequest, String)} .
-     */
     @Test
     public void testDoWebSocketConnectConsumerIsNull() {
         WebSocket webSocket = websocketComponentServlet.doWebSocketConnect(request, PROTOCOL);
@@ -112,4 +95,5 @@ public class WebsocketComponentServletTe
         InOrder inOrder = inOrder(consumer, sync, request);
         inOrder.verifyNoMoreInteractions();
     }
+
 }

Modified: camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentTest.java?rev=1297126&r1=1297125&r2=1297126&view=diff
==============================================================================
--- camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentTest.java (original)
+++ camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentTest.java Mon Mar  5 16:50:42 2012
@@ -56,44 +56,30 @@ public class WebsocketComponentTest {
 
     @Mock
     private WebsocketConsumer consumer;
-
     @Mock
     private NodeSynchronization sync;
-
     @Mock
     private WebsocketComponentServlet servlet;
-
     @Mock
     private Map<String, WebsocketComponentServlet> servlets;
-
     @Mock
     private ServletContextHandler handler;
-
     @Mock
     private CamelContext camelContext;
 
     private WebsocketComponent component;
 
-    /**
-     * @throws Exception
-     */
     @Before
     public void setUp() throws Exception {
         component = new WebsocketComponent();
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.WebsocketComponent#createContext()} .
-     */
     @Test
     public void testCreateContext() {
         ServletContextHandler handler = component.createContext();
         assertNotNull(handler);
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.WebsocketComponent#createServer(org.eclipse.jetty.servlet.ServletContextHandler, String, int, String)} .
-     */
     @Test
     public void testCreateServerWithoutStaticContent() {
         ServletContextHandler handler = component.createContext();
@@ -111,9 +97,6 @@ public class WebsocketComponentTest {
         assertNull(handler.getServletHandler().getHolderEntry("/"));
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.WebsocketComponent#createServer(org.eclipse.jetty.servlet.ServletContextHandler, String, int, String)} .
-     */
     @Test
     public void testCreateServerWithStaticContent() {
         ServletContextHandler handler = component.createContext();
@@ -132,9 +115,6 @@ public class WebsocketComponentTest {
         assertNotNull(handler.getServletHandler().getHolderEntry("/"));
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.WebsocketComponent#createEndpoint(String, String, java.util.Map)} .
-     */
     @Test
     public void testCreateEndpoint() throws Exception {
         Map<String, Object> parameters = new HashMap<String, Object>();
@@ -152,9 +132,6 @@ public class WebsocketComponentTest {
         assertNotSame(e2, e3);
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.WebsocketComponent#setServletConsumer(WebsocketComponentServlet, WebsocketConsumer)} .
-     */
     @Test
     public void testSetServletConsumer() throws Exception {
         when(servlet.getConsumer()).thenReturn(null, null, consumer);
@@ -169,9 +146,6 @@ public class WebsocketComponentTest {
         inOrder.verify(servlet, times(0)).setConsumer(consumer);
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.WebsocketComponent#createServlet(WebsocketStore, String, java.util.Map, ServletContextHandler)} .
-     */
     @Test
     public void testCreateServlet() throws Exception {
         component.createServlet(sync, PATH_SPEC_ONE, servlets, handler);
@@ -184,18 +158,12 @@ public class WebsocketComponentTest {
         assertEquals(servletCaptor.getValue(), holderCaptor.getValue().getServlet());
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.WebsocketComponent#createPathSpec(String)} .
-     */
     @Test
     public void testCreatePathSpec() {
         assertEquals(PATH_SPEC_ONE, component.createPathSpec(PATH_ONE));
         assertEquals(PATH_SPEC_TWO, component.createPathSpec(PATH_TWO));
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.WebsocketComponent#addServlet(WebsocketStore, WebsocketConsumer, String)} .
-     */
     @Test
     public void testAddServletProducersOnly() throws Exception {
         component.setCamelContext(camelContext);
@@ -211,9 +179,6 @@ public class WebsocketComponentTest {
         component.doStop();
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.WebsocketComponent#addServlet(WebsocketStore, WebsocketConsumer, String)} .
-     */
     @Test
     public void testAddServletConsumersOnly() throws Exception {
         component.setCamelContext(camelContext);
@@ -229,9 +194,6 @@ public class WebsocketComponentTest {
         component.doStop();
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.WebsocketComponent#addServlet(WebsocketStore, WebsocketConsumer, String)} .
-     */
     @Test
     public void testAddServletProducerAndConsumer() throws Exception {
         component.setCamelContext(camelContext);
@@ -246,9 +208,6 @@ public class WebsocketComponentTest {
         component.doStop();
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.WebsocketComponent#addServlet(WebsocketStore, WebsocketConsumer, String)} .
-     */
     @Test
     public void testAddServletConsumerAndProducer() throws Exception {
         component.setCamelContext(camelContext);
@@ -262,4 +221,5 @@ public class WebsocketComponentTest {
         assertEquals(consumer, s1.getConsumer());
         component.doStop();
     }
+
 }

Modified: camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketConfigurationTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketConfigurationTest.java?rev=1297126&r1=1297125&r2=1297126&view=diff
==============================================================================
--- camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketConfigurationTest.java (original)
+++ camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketConfigurationTest.java Mon Mar  5 16:50:42 2012
@@ -32,12 +32,10 @@ public class WebsocketConfigurationTest 
 
     @Mock
     private WebsocketComponent component;
-
     @Mock
     private CamelContext camelContext;
 
     private WebsocketEndpoint websocketEndpoint;
-
     private WebsocketConfiguration wsConfig = new WebsocketConfiguration();
 
     @Before
@@ -48,19 +46,15 @@ public class WebsocketConfigurationTest 
 
     @Test
     public void testParameters() throws Exception {
-
         assertNull(wsConfig.getGlobalStore());
-
         wsConfig.setGlobalStore(PARAMETERS);
 
         assertNotNull(wsConfig.getGlobalStore());
-
         websocketEndpoint = new WebsocketEndpoint(URI, component, REMAINING, wsConfig);
 
         assertNotNull(websocketEndpoint);
         assertNotNull(REMAINING);
         assertNotNull(wsConfig.getGlobalStore());
-
     }
 
 }

Modified: camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketConsumerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketConsumerTest.java?rev=1297126&r1=1297125&r2=1297126&view=diff
==============================================================================
--- camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketConsumerTest.java (original)
+++ camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketConsumerTest.java Mon Mar  5 16:50:42 2012
@@ -46,35 +46,24 @@ public class WebsocketConsumerTest {
 
     @Mock
     private Endpoint endpoint;
-
     @Mock
     private ExceptionHandler exceptionHandler;
-
     @Mock
     private Processor processor;
-
     @Mock
     private Exchange exchange;
-
     @Mock
     private Message outMessage;
 
     private Exception exception = new Exception("BAD NEWS EVERYONE!");
-
     private WebsocketConsumer websocketConsumer;
 
-    /**
-     * @throws Exception
-     */
     @Before
     public void setUp() throws Exception {
         websocketConsumer = new WebsocketConsumer(endpoint, processor);
         websocketConsumer.setExceptionHandler(exceptionHandler);
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.WebsocketConsumer#sendExchange(String, String)} .
-     */
     @Test
     public void testSendExchange() throws Exception {
         when(endpoint.createExchange()).thenReturn(exchange);
@@ -89,12 +78,10 @@ public class WebsocketConsumerTest {
         inOrder.verify(exchange, times(1)).getIn();
         inOrder.verify(outMessage, times(1)).setBody(MESSAGE);
         inOrder.verify(processor, times(1)).process(exchange);
+        inOrder.verify(exchange, times(1)).getException();
         inOrder.verifyNoMoreInteractions();
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.WebsocketConsumer#sendExchange(String, String)} .
-     */
     @Test
     public void testSendExchangeWithException() throws Exception {
         when(endpoint.createExchange()).thenReturn(exchange);
@@ -116,9 +103,6 @@ public class WebsocketConsumerTest {
         inOrder.verifyNoMoreInteractions();
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.WebsocketConsumer#sendExchange(String, String)} .
-     */
     @Test
     public void testSendExchangeWithExchangeExceptionIsNull() throws Exception {
         when(endpoint.createExchange()).thenReturn(exchange);
@@ -138,4 +122,5 @@ public class WebsocketConsumerTest {
         inOrder.verify(exchange, times(1)).getException();
         inOrder.verifyNoMoreInteractions();
     }
+
 }

Modified: camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketEndpointTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketEndpointTest.java?rev=1297126&r1=1297125&r2=1297126&view=diff
==============================================================================
--- camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketEndpointTest.java (original)
+++ camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketEndpointTest.java Mon Mar  5 16:50:42 2012
@@ -74,7 +74,7 @@ public class WebsocketEndpointTest {
         inOrder.verify(component, times(1)).addServlet(synchronizationCaptor.capture(), consumerCaptor.capture(), eq(REMAINING));
         inOrder.verifyNoMoreInteractions();
 
-        assertEquals(NodeSynchronizationImpl.class, synchronizationCaptor.getValue().getClass());
+        assertEquals(DefaultNodeSynchronization.class, synchronizationCaptor.getValue().getClass());
 
         assertEquals(consumer, consumerCaptor.getValue());
     }
@@ -92,7 +92,7 @@ public class WebsocketEndpointTest {
         inOrder.verify(component, times(1)).addServlet(synchronizationCaptor.capture(), (WebsocketConsumer) isNull(), eq(REMAINING));
         inOrder.verifyNoMoreInteractions();
 
-        assertEquals(NodeSynchronizationImpl.class, synchronizationCaptor.getValue().getClass());
+        assertEquals(DefaultNodeSynchronization.class, synchronizationCaptor.getValue().getClass());
     }
 
     /**

Modified: camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketProducerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketProducerTest.java?rev=1297126&r1=1297125&r2=1297126&view=diff
==============================================================================
--- camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketProducerTest.java (original)
+++ camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketProducerTest.java Mon Mar  5 16:50:42 2012
@@ -53,47 +53,33 @@ public class WebsocketProducerTest {
 
     @Mock
     private Endpoint endpoint;
-
     @Mock
     private WebsocketStore store;
-
     @Mock
     private Connection connection;
-
     @Mock
     private DefaultWebsocket defaultWebsocket1;
-
     @Mock
     private DefaultWebsocket defaultWebsocket2;
-
     @Mock
     private Exchange exchange;
-
     @Mock
     private Message inMessage;
 
     private IOException exception = new IOException("BAD NEWS EVERYONE!");
-
     private WebsocketProducer websocketProducer;
-
     private Collection<DefaultWebsocket> sockets;
 
-    /**
-     * @throws Exception
-     */
     @Before
     public void setUp() throws Exception {
         websocketProducer = new WebsocketProducer(endpoint, store);
         sockets = Arrays.asList(defaultWebsocket1, defaultWebsocket2);
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.WebsocketProducer#process(org.apache.camel.Exchange)} .
-     */
     @Test
     public void testProcessSingleMessage() throws Exception {
         when(exchange.getIn()).thenReturn(inMessage);
-        when(inMessage.getBody(String.class)).thenReturn(MESSAGE);
+        when(inMessage.getMandatoryBody(String.class)).thenReturn(MESSAGE);
         when(inMessage.getHeader(WebsocketConstants.SEND_TO_ALL)).thenReturn(null);
         when(inMessage.getHeader(WebsocketConstants.CONNECTION_KEY, String.class)).thenReturn(SESSION_KEY);
         when(store.get(SESSION_KEY)).thenReturn(defaultWebsocket1);
@@ -104,7 +90,7 @@ public class WebsocketProducerTest {
 
         InOrder inOrder = inOrder(endpoint, store, connection, defaultWebsocket1, defaultWebsocket2, exchange, inMessage);
         inOrder.verify(exchange, times(1)).getIn();
-        inOrder.verify(inMessage, times(1)).getBody(String.class);
+        inOrder.verify(inMessage, times(1)).getMandatoryBody(String.class);
         inOrder.verify(inMessage, times(1)).getHeader(WebsocketConstants.SEND_TO_ALL);
         inOrder.verify(inMessage, times(1)).getHeader(WebsocketConstants.CONNECTION_KEY, String.class);
         inOrder.verify(store, times(1)).get(SESSION_KEY);
@@ -115,13 +101,10 @@ public class WebsocketProducerTest {
         inOrder.verifyNoMoreInteractions();
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.WebsocketProducer#process(org.apache.camel.Exchange)} .
-     */
     @Test
     public void testProcessSingleMessageWithException() throws Exception {
         when(exchange.getIn()).thenReturn(inMessage);
-        when(inMessage.getBody(String.class)).thenReturn(MESSAGE);
+        when(inMessage.getMandatoryBody(String.class)).thenReturn(MESSAGE);
         when(inMessage.getHeader(WebsocketConstants.SEND_TO_ALL)).thenReturn(false);
         when(inMessage.getHeader(WebsocketConstants.CONNECTION_KEY, String.class)).thenReturn(SESSION_KEY);
         when(store.get(SESSION_KEY)).thenReturn(defaultWebsocket1);
@@ -138,7 +121,7 @@ public class WebsocketProducerTest {
 
         InOrder inOrder = inOrder(endpoint, store, connection, defaultWebsocket1, defaultWebsocket2, exchange, inMessage);
         inOrder.verify(exchange, times(1)).getIn();
-        inOrder.verify(inMessage, times(1)).getBody(String.class);
+        inOrder.verify(inMessage, times(1)).getMandatoryBody(String.class);
         inOrder.verify(inMessage, times(1)).getHeader(WebsocketConstants.SEND_TO_ALL);
         inOrder.verify(inMessage, times(1)).getHeader(WebsocketConstants.CONNECTION_KEY, String.class);
         inOrder.verify(store, times(1)).get(SESSION_KEY);
@@ -149,13 +132,10 @@ public class WebsocketProducerTest {
         inOrder.verifyNoMoreInteractions();
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.WebsocketProducer#process(org.apache.camel.Exchange)} .
-     */
     @Test
     public void testProcessMultipleMessages() throws Exception {
         when(exchange.getIn()).thenReturn(inMessage);
-        when(inMessage.getBody(String.class)).thenReturn(MESSAGE);
+        when(inMessage.getMandatoryBody(String.class)).thenReturn(MESSAGE);
         when(inMessage.getHeader(WebsocketConstants.SEND_TO_ALL)).thenReturn(true);
         when(store.getAll()).thenReturn(sockets);
         when(defaultWebsocket1.getConnection()).thenReturn(connection);
@@ -166,7 +146,7 @@ public class WebsocketProducerTest {
 
         InOrder inOrder = inOrder(endpoint, store, connection, defaultWebsocket1, defaultWebsocket2, exchange, inMessage);
         inOrder.verify(exchange, times(1)).getIn();
-        inOrder.verify(inMessage, times(1)).getBody(String.class);
+        inOrder.verify(inMessage, times(1)).getMandatoryBody(String.class);
         inOrder.verify(inMessage, times(1)).getHeader(WebsocketConstants.SEND_TO_ALL);
         inOrder.verify(store, times(1)).getAll();
         inOrder.verify(defaultWebsocket1, times(1)).getConnection();
@@ -180,13 +160,10 @@ public class WebsocketProducerTest {
         inOrder.verifyNoMoreInteractions();
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.WebsocketProducer#process(org.apache.camel.Exchange)} .
-     */
     @Test
     public void testProcessMultipleMessagesWithExcpetion() throws Exception {
         when(exchange.getIn()).thenReturn(inMessage);
-        when(inMessage.getBody(String.class)).thenReturn(MESSAGE);
+        when(inMessage.getMandatoryBody(String.class)).thenReturn(MESSAGE);
         when(inMessage.getHeader(WebsocketConstants.SEND_TO_ALL)).thenReturn(true);
         when(store.getAll()).thenReturn(sockets);
         when(defaultWebsocket1.getConnection()).thenReturn(connection);
@@ -203,7 +180,7 @@ public class WebsocketProducerTest {
 
         InOrder inOrder = inOrder(endpoint, store, connection, defaultWebsocket1, defaultWebsocket2, exchange, inMessage);
         inOrder.verify(exchange, times(1)).getIn();
-        inOrder.verify(inMessage, times(1)).getBody(String.class);
+        inOrder.verify(inMessage, times(1)).getMandatoryBody(String.class);
         inOrder.verify(inMessage, times(1)).getHeader(WebsocketConstants.SEND_TO_ALL);
         inOrder.verify(store, times(1)).getAll();
         inOrder.verify(defaultWebsocket1, times(1)).getConnection();
@@ -217,9 +194,6 @@ public class WebsocketProducerTest {
         inOrder.verifyNoMoreInteractions();
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.WebsocketProducer#process(org.apache.camel.Exchange)} .
-     */
     @Test
     public void testProcessSingleMessageNoConnectionKey() throws Exception {
         when(exchange.getIn()).thenReturn(inMessage);
@@ -238,15 +212,12 @@ public class WebsocketProducerTest {
 
         InOrder inOrder = inOrder(endpoint, store, connection, defaultWebsocket1, defaultWebsocket2, exchange, inMessage);
         inOrder.verify(exchange, times(1)).getIn();
-        inOrder.verify(inMessage, times(1)).getBody(String.class);
+        inOrder.verify(inMessage, times(1)).getMandatoryBody(String.class);
         inOrder.verify(inMessage, times(1)).getHeader(WebsocketConstants.SEND_TO_ALL);
         inOrder.verify(inMessage, times(1)).getHeader(WebsocketConstants.CONNECTION_KEY, String.class);
         inOrder.verifyNoMoreInteractions();
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.WebsocketProducer#sendMessage(org.apache.camel.component.websocket.DefaultWebsocket, String)} .
-     */
     @Test
     public void testSendMessage() throws Exception {
         when(defaultWebsocket1.getConnection()).thenReturn(connection);
@@ -262,21 +233,14 @@ public class WebsocketProducerTest {
         inOrder.verifyNoMoreInteractions();
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.WebsocketProducer#sendMessage(org.apache.camel.component.websocket.DefaultWebsocket, String)} .
-     */
     @Test
     public void testSendMessageWebsocketIsNull() throws Exception {
-
         websocketProducer.sendMessage(null, MESSAGE);
 
         InOrder inOrder = inOrder(endpoint, store, connection, defaultWebsocket1, defaultWebsocket2, exchange, inMessage);
         inOrder.verifyNoMoreInteractions();
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.WebsocketProducer#sendMessage(org.apache.camel.component.websocket.DefaultWebsocket, String)} .
-     */
     @Test
     public void testSendMessageConnetionIsClosed() throws Exception {
         when(defaultWebsocket1.getConnection()).thenReturn(connection);
@@ -290,9 +254,6 @@ public class WebsocketProducerTest {
         inOrder.verifyNoMoreInteractions();
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.WebsocketProducer#sendMessage(org.apache.camel.component.websocket.DefaultWebsocket, String)} .
-     */
     @Test
     public void testSendMessageWithException() throws Exception {
         when(defaultWebsocket1.getConnection()).thenReturn(connection);
@@ -314,9 +275,6 @@ public class WebsocketProducerTest {
         inOrder.verifyNoMoreInteractions();
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.WebsocketProducer#isSendToAllSet(Message)} .
-     */
     @Test
     public void testIsSendToAllSet() {
         when(inMessage.getHeader(WebsocketConstants.SEND_TO_ALL)).thenReturn(true, false);
@@ -327,9 +285,6 @@ public class WebsocketProducerTest {
         inOrder.verifyNoMoreInteractions();
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.WebsocketProducer#isSendToAllSet(Message)} .
-     */
     @Test
     public void testIsSendToAllSetHeaderNull() {
         when(inMessage.getHeader(WebsocketConstants.SEND_TO_ALL)).thenReturn(null);
@@ -339,9 +294,6 @@ public class WebsocketProducerTest {
         inOrder.verifyNoMoreInteractions();
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.WebsocketProducer#sendToAll(WebsocketStore, String)} .
-     */
     @Test
     public void testSendToAll() throws Exception {
         when(store.getAll()).thenReturn(sockets);
@@ -349,7 +301,7 @@ public class WebsocketProducerTest {
         when(defaultWebsocket2.getConnection()).thenReturn(connection);
         when(connection.isOpen()).thenReturn(true);
 
-        websocketProducer.sendToAll(store, MESSAGE);
+        websocketProducer.sendToAll(store, MESSAGE, exchange);
 
         InOrder inOrder = inOrder(store, connection, defaultWebsocket1, defaultWebsocket2);
         inOrder.verify(store, times(1)).getAll();
@@ -364,9 +316,6 @@ public class WebsocketProducerTest {
         inOrder.verifyNoMoreInteractions();
     }
 
-    /**
-     * Test method for {@link org.apache.camel.component.websocket.WebsocketProducer#sendToAll(WebsocketStore, String)} .
-     */
     @Test
     public void testSendToAllWithExcpetion() throws Exception {
         when(store.getAll()).thenReturn(sockets);
@@ -376,7 +325,7 @@ public class WebsocketProducerTest {
         when(connection.isOpen()).thenReturn(true);
 
         try {
-            websocketProducer.sendToAll(store, MESSAGE);
+            websocketProducer.sendToAll(store, MESSAGE, exchange);
             fail("Exception expected");
         } catch (Exception e) {
             assertEquals(exception, e.getCause());



Mime
View raw message