Author: aco
Date: Mon Jul  9 22:50:12 2007
New Revision: 554837

URL: http://svn.apache.org/viewvc?view=rev&rev=554837
Log:
- Remove printing of stack trace in DeliveryChannelImpl, exception is getting 
thrown anyway
- Minor mod to the DeliveryChannelImplTest to make it actually fail when there 
is an exception in the second thread
- Changed all System.out and System.err to use commons logging

Modified:
    
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImpl.java
    
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/tck/SenderPojo.java
    
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/client/SimpleClientTest.java
    
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/deployment/ComponentTest.java
    
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/jaxp/StaxSourceTest.java
    
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/jaxp/W3CDOMStreamReaderTest.java
    
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImplTest.java
    
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/nmr/PubSubTest.java
    
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/security/SecuredBrokerTest.java
    
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/security/SpringSecuredBrokerTest.java

Modified: 
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImpl.java?view=diff&rev=554837&r1=554836&r2=554837
==============================================================================
--- 
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImpl.java
 (original)
+++ 
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImpl.java
 Mon Jul  9 22:50:12 2007
@@ -483,7 +483,7 @@
         } catch (InterruptedException e) {
             throw new MessagingException(e);
         } catch (RuntimeException e) {
-            e.printStackTrace();
+//            e.printStackTrace();
             throw e;
         } finally {
             exchangesById.remove(exchangeKey);

Modified: 
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/tck/SenderPojo.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/tck/SenderPojo.java?view=diff&rev=554837&r1=554836&r2=554837
==============================================================================
--- 
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/tck/SenderPojo.java
 (original)
+++ 
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/tck/SenderPojo.java
 Mon Jul  9 22:50:12 2007
@@ -76,12 +76,12 @@
     }
     
     public void sendMessages(int messageCount, boolean sync) throws 
MessagingException {
-        System.out.println("Looking for services for interface: " + 
interfaceName);
+        log.info("Looking for services for interface: " + interfaceName);
 
         ServiceEndpoint[] endpoints = 
context.getEndpointsForService(interfaceName);
         if (endpoints.length > 0) {
             ServiceEndpoint endpoint = endpoints[0];
-            System.out.println("Sending to endpoint: " + endpoint);
+            log.info("Sending to endpoint: " + endpoint);
             
             for (int i = 0; i < messageCount; i++) {
                 InOnly exchange = 
context.getDeliveryChannel().createExchangeFactory().createInOnlyExchange();
@@ -91,9 +91,9 @@
                 // lets set the XML as a byte[], String or DOM etc
                 String xml = "<s12:Envelope 
xmlns:s12='http://www.w3.org/2003/05/soap-envelope'><s12:Body> 
<foo>Hello!</foo> </s12:Body></s12:Envelope>";
                 message.setContent(new StringSource(xml));
-                System.out.println("sending message: " + i);
+                log.info("sending message: " + i);
                 DeliveryChannel deliveryChannel = context.getDeliveryChannel();
-                System.out.println("sync send on deliverychannel: " + 
deliveryChannel);
+                log.info("sync send on deliverychannel: " + deliveryChannel);
                 if (sync) {
                        deliveryChannel.sendSync(exchange);
                 } else {

Modified: 
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/client/SimpleClientTest.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/client/SimpleClientTest.java?view=diff&rev=554837&r1=554836&r2=554837
==============================================================================
--- 
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/client/SimpleClientTest.java
 (original)
+++ 
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/client/SimpleClientTest.java
 Mon Jul  9 22:50:12 2007
@@ -21,6 +21,8 @@
 import org.apache.servicemix.components.util.OutBinding;
 import org.apache.servicemix.jbi.container.ActivationSpec;
 import org.apache.servicemix.jbi.container.JBIContainer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import javax.jbi.messaging.InOnly;
 import javax.jbi.messaging.MessageExchange;
@@ -37,6 +39,9 @@
  * @version $Revision$
  */
 public class SimpleClientTest extends TestCase {
+
+    private static final Log log = LogFactory.getLog(SimpleClientTest.class);
+
     protected JBIContainer container;
     protected OutBinding out;
     protected ServiceMixClient client;
@@ -48,7 +53,7 @@
         container.start();
         out = new OutBinding() {
             protected void process(MessageExchange exchange, NormalizedMessage 
message) throws MessagingException {
-                System.out.println("Received: " + message);
+                log.info("Received: " + message);
                 done(exchange);
             }
         };

Modified: 
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/deployment/ComponentTest.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/deployment/ComponentTest.java?view=diff&rev=554837&r1=554836&r2=554837
==============================================================================
--- 
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/deployment/ComponentTest.java
 (original)
+++ 
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/deployment/ComponentTest.java
 Mon Jul  9 22:50:12 2007
@@ -23,6 +23,8 @@
 import junit.framework.TestCase;
 
 import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.w3c.dom.DocumentFragment;
 
 /**
@@ -30,6 +32,8 @@
  */
 public class ComponentTest extends TestCase {
 
+    private static final Log log = LogFactory.getLog(ComponentTest.class);
+
     protected SourceTransformer transformer = new SourceTransformer();
 
     public void testParse() throws Exception {
@@ -61,8 +65,8 @@
         DocumentFragment fragment = 
descriptorExtension.getDescriptorExtension();
         assertNotNull("fragment is null", fragment);
 
-        System.out.println("Created document fragment: " + fragment);
-        System.out.println("XML: " + transformer.toString(new 
DOMSource(fragment)));
+        log.info("Created document fragment: " + fragment);
+        log.info("XML: " + transformer.toString(new DOMSource(fragment)));
     }
 
     protected void assertArrayEquals(String text, Object[] expected, Object[] 
actual) {

Modified: 
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/jaxp/StaxSourceTest.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/jaxp/StaxSourceTest.java?view=diff&rev=554837&r1=554836&r2=554837
==============================================================================
--- 
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/jaxp/StaxSourceTest.java
 (original)
+++ 
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/jaxp/StaxSourceTest.java
 Mon Jul  9 22:50:12 2007
@@ -102,9 +102,9 @@
         StringSource src = new StringSource(msg);
         DOMSource dom = new SourceTransformer().toDOMSource(src);
         StreamSource stream = new SourceTransformer().toStreamSource(dom);
-        System.err.println(new SourceTransformer().toString(stream));
+        log.info(new SourceTransformer().toString(stream));
         SAXSource sax = new SourceTransformer().toSAXSource(dom);
-        System.err.println(new SourceTransformer().toString(sax));
+        log.info(new SourceTransformer().toString(sax));
     }
 
     protected void checkDomResult(Document doc) {

Modified: 
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/jaxp/W3CDOMStreamReaderTest.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/jaxp/W3CDOMStreamReaderTest.java?view=diff&rev=554837&r1=554836&r2=554837
==============================================================================
--- 
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/jaxp/W3CDOMStreamReaderTest.java
 (original)
+++ 
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/jaxp/W3CDOMStreamReaderTest.java
 Mon Jul  9 22:50:12 2007
@@ -17,6 +17,7 @@
 package org.apache.servicemix.jbi.jaxp;
 
 import java.io.OutputStream;
+import java.io.ByteArrayOutputStream;
 
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.stream.XMLStreamReader;
@@ -31,6 +32,8 @@
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 
 /**
@@ -40,7 +43,8 @@
 public class W3CDOMStreamReaderTest
     extends AbstractStreamReaderTest
 {
-    
+
+    private static final Log log = 
LogFactory.getLog(W3CDOMStreamReaderTest.class);
     
     public void testSingleElement() throws Exception
     {
@@ -50,13 +54,15 @@
         doc.appendChild(e);
         
         assertEquals(1, e.getAttributes().getLength());
-        System.out.println("start: " + XMLStreamReader.START_ELEMENT);
-        System.out.println("attr: " + XMLStreamReader.ATTRIBUTE);
-        System.out.println("ns: " + XMLStreamReader.NAMESPACE);
-        System.out.println("chars: " + XMLStreamReader.CHARACTERS);
-        System.out.println("end: " + XMLStreamReader.END_ELEMENT);
-        
-        writeXml(doc,System.out);
+        log.info("start: " + XMLStreamReader.START_ELEMENT);
+        log.info("attr: " + XMLStreamReader.ATTRIBUTE);
+        log.info("ns: " + XMLStreamReader.NAMESPACE);
+        log.info("chars: " + XMLStreamReader.CHARACTERS);
+        log.info("end: " + XMLStreamReader.END_ELEMENT);
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        writeXml(doc, baos);
+        log.info(baos.toString());
         W3CDOMStreamReader reader = new 
W3CDOMStreamReader(doc.getDocumentElement());
         testSingleElement(reader);
     }
@@ -77,9 +83,11 @@
         doc.appendChild(e);
         Node text = doc.createTextNode("Hello World");
         e.appendChild(text);
-        
-        writeXml(doc,System.out);
-        
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        writeXml(doc, baos);
+        log.info(baos.toString());
+
         W3CDOMStreamReader reader = new W3CDOMStreamReader(e);
         testTextChild(reader);
     }
@@ -97,8 +105,10 @@
         e.appendChild(child);
         text = doc.createTextNode(" more text");
         e.appendChild(text);
-        
-        writeXml(doc,System.out);
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        writeXml(doc, baos);
+        log.info(baos);
         
         W3CDOMStreamReader reader = new W3CDOMStreamReader(e);
         testMixedContent(reader);
@@ -121,7 +131,10 @@
         e.setAttribute("xmlns:p", "urn:test2");
         
         e.setAttributeNode(attr);
-        writeXml(doc,System.out);
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        writeXml(doc, baos);
+        log.info(baos.toString());
         
         W3CDOMStreamReader reader = new 
W3CDOMStreamReader(doc.getDocumentElement());
         
@@ -139,7 +152,10 @@
         child.setPrefix("a");
         e.appendChild(child);
         doc.appendChild(e);
-        writeXml(doc,System.out);
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        writeXml(doc, baos);
+        log.info(baos.toString());
         
         W3CDOMStreamReader reader = new W3CDOMStreamReader(e);
         testElementChild(reader);

Modified: 
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImplTest.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImplTest.java?view=diff&rev=554837&r1=554836&r2=554837
==============================================================================
--- 
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImplTest.java
 (original)
+++ 
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImplTest.java
 Mon Jul  9 22:50:12 2007
@@ -30,9 +30,15 @@
 import org.apache.servicemix.jbi.container.ActivationSpec;
 import org.apache.servicemix.jbi.container.JBIContainer;
 import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.concurrent.atomic.AtomicBoolean;
 
 public class DeliveryChannelImplTest extends TestCase {
 
+    private static final Log log = 
LogFactory.getLog(DeliveryChannelImplTest.class);
+
     protected JBIContainer container;
     
     protected void setUp() throws Exception {
@@ -79,6 +85,8 @@
         TestComponent component = new TestComponent(new QName("service"), 
"endpoint");
         container.activateComponent(new ActivationSpec("component", 
component));
         final DeliveryChannel channel = component.getChannel();
+        final AtomicBoolean success = new AtomicBoolean(false);
+        final AtomicBoolean done = new AtomicBoolean(false);
 
         // Create another thread
         new Thread() {
@@ -89,9 +97,12 @@
                     nm.setContent(new StringSource("<response/>"));
                     me.setOutMessage(nm);
                     channel.sendSync(me);
+                    success.set(true);
+                    done.set(true);
                 } catch (MessagingException e) {
-                    e.printStackTrace();
-                    fail("Exception caught: " + e);
+                    log.error(e.getMessage(), e);
+                    success.set(false);
+                    done.set(true);
                 }
             }
         }.start();
@@ -105,6 +116,15 @@
         assertEquals(ExchangeStatus.ACTIVE, me.getStatus());
         me.setStatus(ExchangeStatus.DONE);
         channel.send(me);
+
+        if (!done.get()) {
+            synchronized(done) {
+                done.wait(5000);
+            }
+        }
+
+        assertTrue("Secondary thread didn't finish", done.get());
+        assertTrue("Exception in secondary thread", success.get());
     }
     
     public static class TestComponent extends ComponentSupport {

Modified: 
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/nmr/PubSubTest.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/nmr/PubSubTest.java?view=diff&rev=554837&r1=554836&r2=554837
==============================================================================
--- 
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/nmr/PubSubTest.java
 (original)
+++ 
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/nmr/PubSubTest.java
 Mon Jul  9 22:50:12 2007
@@ -27,9 +27,13 @@
 import org.apache.servicemix.jbi.resolver.SubscriptionFilter;
 import org.apache.servicemix.tck.ReceiverComponent;
 import org.apache.servicemix.tck.SenderComponent;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 public class PubSubTest extends TestCase {
 
+    private static final Log log = LogFactory.getLog(PubSubTest.class);
+
     private SenderComponent sender;
     private JBIContainer container;
 
@@ -87,7 +91,7 @@
     public static class Filter implements SubscriptionFilter {
 
         public boolean matches(MessageExchange arg0) {
-            System.out.println("Matches");
+            log.info("Matches");
             return true;
         }
         

Modified: 
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/security/SecuredBrokerTest.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/security/SecuredBrokerTest.java?view=diff&rev=554837&r1=554836&r2=554837
==============================================================================
--- 
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/security/SecuredBrokerTest.java
 (original)
+++ 
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/security/SecuredBrokerTest.java
 Mon Jul  9 22:50:12 2007
@@ -41,8 +41,11 @@
 import org.apache.servicemix.jbi.security.acl.impl.AuthorizationEntry;
 import org.apache.servicemix.jbi.security.acl.impl.DefaultAuthorizationMap;
 import org.apache.servicemix.tck.ReceiverComponent;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 public class SecuredBrokerTest extends TestCase {
+    private static final Log log = LogFactory.getLog(SecuredBrokerTest.class);
 
     static {
         String path = System.getProperty("java.security.auth.login.config");
@@ -53,7 +56,7 @@
                 System.setProperty("java.security.auth.login.config", path);
             }
         }
-        System.out.println("Path to login config: " + path);
+        log.info("Path to login config: " + path);
     }
 
     protected JBIContainer jbi;

Modified: 
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/security/SpringSecuredBrokerTest.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/security/SpringSecuredBrokerTest.java?view=diff&rev=554837&r1=554836&r2=554837
==============================================================================
--- 
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/security/SpringSecuredBrokerTest.java
 (original)
+++ 
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/jbi/security/SpringSecuredBrokerTest.java
 Mon Jul  9 22:50:12 2007
@@ -36,10 +36,14 @@
 import org.apache.servicemix.tck.Receiver;
 import org.apache.servicemix.tck.SpringTestSupport;
 import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.springframework.context.support.AbstractXmlApplicationContext;
 
 public class SpringSecuredBrokerTest extends SpringTestSupport {
 
+    private static final Log log = 
LogFactory.getLog(SpringSecuredBrokerTest.class);
+
     static {
         String path = System.getProperty("java.security.auth.login.config");
         if (path == null) {
@@ -49,7 +53,7 @@
                 System.setProperty("java.security.auth.login.config", path);
             }
         }
-        System.err.println("Path to login config: " + path);
+        log.info("Path to login config: " + path);
     }
 
     protected Receiver receiver1;


Reply via email to