[jboss-svn-commits] JBL Code SVN: r19616 - labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/notification.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Apr 18 03:50:03 EDT 2008


Author: mark.little at jboss.com
Date: 2008-04-18 03:50:03 -0400 (Fri, 18 Apr 2008)
New Revision: 19616

Modified:
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/notification/NotifyTcpUnitTest.java
Log:
JBESB-1143

Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/notification/NotifyTcpUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/notification/NotifyTcpUnitTest.java	2008-04-18 07:05:44 UTC (rev 19615)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/notification/NotifyTcpUnitTest.java	2008-04-18 07:50:03 UTC (rev 19616)
@@ -38,7 +38,7 @@
 public class NotifyTcpUnitTest extends TestCase
 {
     public static final String DATA = "Hello World";
- 
+
     public void testBadURI () throws Exception
     {
         ConfigTree rootEl = new ConfigTree("notif");
@@ -53,7 +53,7 @@
         {
             // Expected
         }
-        
+
         tcpEl.setAttribute("URI", "udp://foo:8080");
 
         try
@@ -66,14 +66,14 @@
             // Expected
         }
     }
-    
+
     public void testValidURI () throws Exception
     {
         ConfigTree rootEl = new ConfigTree("notif");
         ConfigTree tcpEl = new ConfigTree("destination", rootEl);
-        
+
         tcpEl.setAttribute("URI", "tcp://localhost:9090");
-        
+
         try
         {
             new NotifyTcp(rootEl);
@@ -88,42 +88,34 @@
     {
         try
         {
-            ServerSocket sock = new ServerSocket(0);     
+            ServerSocket sock = new ServerSocket(0);
             int port = sock.getLocalPort();
             Sender sender = new Sender(port);
-            
+
             sender.start();
-            
+
             Socket receiver = sock.accept();
 
             InputStream stream = receiver.getInputStream();
-            
+
             while (stream.available() == 0)
             {
                 Thread.yield();
             }
-            
-            if (stream.available() != DATA.length())
+
+            byte[] data = new byte[stream.available()];
+
+            stream.read(data);
+
+            String receivedString = new String(data);
+
+            if (!receivedString.startsWith(DATA))
             {
-                System.err.println("Invalid stream size: "+stream.available());
-                
+                System.err.println("Did not receive correct data: "
+                        + receivedString);
+
                 fail();
             }
-            else
-            {
-                byte[] data = new byte[stream.available()];
-                
-                stream.read(data);
-                
-                String receivedString = new String(data);
-                
-                if (!receivedString.equals(DATA))
-                {
-                    System.err.println("Did not receive correct data: "+receivedString);
-                    
-                    fail();
-                }
-            }        
         }
         catch (IllegalArgumentException e)
         {
@@ -133,22 +125,22 @@
 
     class Sender extends Thread
     {
-        public Sender (int s)
+        public Sender(int s)
         {
             _port = s;
         }
-        
+
         public void run ()
         {
             try
             {
                 ConfigTree rootEl = new ConfigTree("notif");
                 ConfigTree tcpEl = new ConfigTree("destination", rootEl);
-                
-                tcpEl.setAttribute("URI", "tcp://localhost:"+_port);
-                
+
+                tcpEl.setAttribute("URI", "tcp://localhost:" + _port);
+
                 Message msg = MessageFactory.getInstance().getMessage();
-                
+
                 msg.getBody().add(DATA);
 
                 NotifyTcp test = new NotifyTcp(rootEl);




More information about the jboss-svn-commits mailing list