Author: davsclaus
Date: Thu May 15 22:43:45 2008
New Revision: 656940

URL: http://svn.apache.org/viewvc?rev=656940&view=rev
Log:
CAMEL-518
- throws UnsupportedOperationException for nntp protocol

Modified:
    
activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailComponent.java
    
activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/InvalidConfigurationTest.java

Modified: 
activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailComponent.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailComponent.java?rev=656940&r1=656939&r2=656940&view=diff
==============================================================================
--- 
activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailComponent.java
 (original)
+++ 
activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailComponent.java
 Thu May 15 22:43:45 2008
@@ -61,8 +61,13 @@
     @Override
     protected Endpoint<MailExchange> createEndpoint(String uri, String 
remaining, Map parameters) throws Exception {
 
+        URI url = new URI(uri);
+        if ("nntp".equalsIgnoreCase(url.getScheme())) {
+            throw new UnsupportedOperationException("nntp protocol is not 
supported");
+        }
+        
         MailConfiguration config = new MailConfiguration();
-        config.configure(new URI(uri));
+        config.configure(url);
 
         // lets make sure we copy the configuration as each endpoint can 
customize its own version
         MailEndpoint endpoint = new MailEndpoint(uri, this, config);

Modified: 
activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/InvalidConfigurationTest.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/InvalidConfigurationTest.java?rev=656940&r1=656939&r2=656940&view=diff
==============================================================================
--- 
activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/InvalidConfigurationTest.java
 (original)
+++ 
activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/InvalidConfigurationTest.java
 Thu May 15 22:43:45 2008
@@ -19,6 +19,7 @@
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Endpoint;
 import org.apache.camel.PollingConsumer;
+import org.apache.camel.ResolveEndpointFailedException;
 
 /**
  * Unit test for various invalid configurations etc.
@@ -47,4 +48,14 @@
         }
     }
 
+    public void testNNTPNotSupported() throws Exception {
+        try {
+            this.context.getEndpoint("nntp://localhost?username=james";);
+            fail("Should have thrown UnsupportedOperationException");
+        } catch (ResolveEndpointFailedException e) {
+            // expected
+            assertTrue(e.getCause() instanceof UnsupportedOperationException);
+        }
+    }
+
 }


Reply via email to