You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2008/05/09 06:16:31 UTC
svn commit: r654680 - in /activemq/camel/trunk/components/camel-mail/src:
main/java/org/apache/camel/component/mail/
test/java/org/apache/camel/component/mail/
Author: davsclaus
Date: Thu May 8 21:16:30 2008
New Revision: 654680
URL: http://svn.apache.org/viewvc?rev=654680&view=rev
Log:
CAMEL-495
- Throwing IAE for invalid configuration such as using smtp for consuming mails
- Javadoc polished
Added:
activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/InvalidConfigurationTest.java (with props)
Modified:
activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailComponent.java
activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailEndpoint.java
activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailProducer.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=654680&r1=654679&r2=654680&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 8 21:16:30 2008
@@ -24,6 +24,8 @@
import org.apache.camel.impl.DefaultComponent;
/**
+ * Component for JavaMail.
+ *
* @version $Revision:520964 $
*/
public class MailComponent extends DefaultComponent<MailExchange> {
Modified: activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailEndpoint.java?rev=654680&r1=654679&r2=654680&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailEndpoint.java (original)
+++ activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailEndpoint.java Thu May 8 21:16:30 2008
@@ -27,6 +27,8 @@
import org.springframework.mail.javamail.JavaMailSenderImpl;
/**
+ * Endpoint for Camel Mail.
+ *
* @version $Revision:520964 $
*/
public class MailEndpoint extends ScheduledPollEndpoint<MailExchange> {
@@ -51,6 +53,11 @@
}
public Consumer<MailExchange> createConsumer(Processor processor) throws Exception {
+ if (configuration.getProtocol().startsWith("smtp")) {
+ throw new IllegalArgumentException("Protocol " + configuration.getProtocol() +
+ " can not be used for a MailConsumer. Please use another protocol such as pop3 or imap.");
+ }
+
JavaMailSenderImpl sender = configuration.createJavaMailSender();
return createConsumer(processor, sender);
}
Modified: activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailProducer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailProducer.java?rev=654680&r1=654679&r2=654680&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailProducer.java (original)
+++ activemq/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailProducer.java Thu May 8 21:16:30 2008
@@ -27,6 +27,8 @@
import org.springframework.mail.javamail.MimeMessagePreparator;
/**
+ * A Producer to send messages using JavaMail.
+ *
* @version $Revision$
*/
public class MailProducer extends DefaultProducer<MailExchange> {
@@ -45,7 +47,7 @@
public void prepare(MimeMessage mimeMessage) throws Exception {
endpoint.getBinding().populateMailMessage(endpoint, mimeMessage, exchange);
if (LOG.isDebugEnabled()) {
- LOG.debug("Sending MineMessage: " + MailUtils.dumpMessage(mimeMessage));
+ LOG.debug("Sending MimeMessage: " + MailUtils.dumpMessage(mimeMessage));
}
}
});
Added: 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=654680&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/InvalidConfigurationTest.java (added)
+++ activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/InvalidConfigurationTest.java Thu May 8 21:16:30 2008
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.mail;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Endpoint;
+import org.apache.camel.PollingConsumer;
+
+/**
+ * Unit test for various invalid configurations etc.
+ */
+public class InvalidConfigurationTest extends ContextTestSupport {
+
+ public void testSMTPCanNotBeUsedForConsumingMails() throws Exception {
+ Endpoint endpoint = this.context.getEndpoint("smtp://localhost?username=james");
+ PollingConsumer consumer = endpoint.createPollingConsumer();
+ try {
+ consumer.start();
+ fail("Should have thrown NoSuchProviderException as stmp protocol can not be used for consuming mails");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ public void testSMTPSCanNotBeUsedForConsumingMails() throws Exception {
+ Endpoint endpoint = this.context.getEndpoint("smtps://localhost?username=james");
+ PollingConsumer consumer = endpoint.createPollingConsumer();
+ try {
+ consumer.start();
+ fail("Should have thrown NoSuchProviderException as stmp protocol can not be used for consuming mails");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+}
Propchange: activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/InvalidConfigurationTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/InvalidConfigurationTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date