You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2014/12/02 22:08:11 UTC
[1/5] camel git commit: Fix CS
Repository: camel
Updated Branches:
refs/heads/master 7ffb70e2b -> 4b45630f6
Fix CS
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/38c0a977
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/38c0a977
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/38c0a977
Branch: refs/heads/master
Commit: 38c0a97777f256708cce50b68937c24d33c5e5db
Parents: 3c6769d
Author: Jonathan Anstey <ja...@gmail.com>
Authored: Tue Dec 2 17:16:36 2014 -0330
Committer: Jonathan Anstey <ja...@gmail.com>
Committed: Tue Dec 2 17:16:54 2014 -0330
----------------------------------------------------------------------
.../mail/BatchGoogleMailClientFactory.java | 12 +--
.../google/mail/GoogleMailComponent.java | 18 ++---
.../google/mail/GoogleMailConfiguration.java | 10 +--
.../google/mail/GoogleMailConsumer.java | 8 +-
.../google/mail/GoogleMailEndpoint.java | 62 +++++++--------
.../google/mail/GoogleMailProducer.java | 5 +-
.../mail/AbstractGoogleMailTestSupport.java | 17 ++---
.../google/mail/GmailUsersIntegrationTest.java | 11 +--
.../mail/GmailUsersLabelsIntegrationTest.java | 27 +++----
.../mail/GmailUsersMessagesIntegrationTest.java | 80 ++++++++------------
.../mail/GmailUsersThreadsIntegrationTest.java | 56 ++++++--------
parent/pom.xml | 1 +
12 files changed, 128 insertions(+), 179 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/38c0a977/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/BatchGoogleMailClientFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/BatchGoogleMailClientFactory.java b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/BatchGoogleMailClientFactory.java
index 626d232..ea6b085 100644
--- a/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/BatchGoogleMailClientFactory.java
+++ b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/BatchGoogleMailClientFactory.java
@@ -45,24 +45,20 @@ public class BatchGoogleMailClientFactory implements GoogleMailClientFactory {
if (refreshToken != null && !"".equals(refreshToken)) {
credential.setRefreshToken(refreshToken);
- }
+ }
if (accessToken != null && !"".equals(accessToken)) {
credential.setAccessToken(accessToken);
}
return new Gmail.Builder(transport, jsonFactory, credential).setApplicationName(applicationName).build();
} catch (Exception e) {
- LOG.error("Could not create Google Drive client.", e);
+ LOG.error("Could not create Google Drive client.", e);
}
return null;
}
-
+
// Authorizes the installed application to access user's protected data.
private Credential authorize(String clientId, String clientSecret, Collection<String> scopes) throws Exception {
// authorize
- return new GoogleCredential.Builder()
- .setJsonFactory(jsonFactory)
- .setTransport(transport)
- .setClientSecrets(clientId, clientSecret)
- .build();
+ return new GoogleCredential.Builder().setJsonFactory(jsonFactory).setTransport(transport).setClientSecrets(clientId, clientSecret).build();
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/38c0a977/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailComponent.java b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailComponent.java
index 4d88110..b19d485 100644
--- a/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailComponent.java
+++ b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailComponent.java
@@ -16,15 +16,12 @@
*/
package org.apache.camel.component.google.mail;
-
import com.google.api.services.gmail.Gmail;
import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
import org.apache.camel.spi.UriEndpoint;
import org.apache.camel.util.component.AbstractApiComponent;
-import org.apache.camel.component.google.mail.internal.GoogleMailApiCollection;
-import org.apache.camel.component.google.mail.internal.GoogleMailApiName;
/**
* Represents the component that manages {@link GoogleMailEndpoint}.
@@ -34,7 +31,7 @@ public class GoogleMailComponent extends AbstractApiComponent<GoogleMailApiName,
private Gmail client;
private GoogleMailClientFactory clientFactory;
-
+
public GoogleMailComponent() {
super(GoogleMailEndpoint.class, GoogleMailApiName.class, GoogleMailApiCollection.getCollection());
}
@@ -50,26 +47,25 @@ public class GoogleMailComponent extends AbstractApiComponent<GoogleMailApiName,
public Gmail getClient() {
if (client == null) {
- client = getClientFactory().makeClient(configuration.getClientId(), configuration.getClientSecret(), configuration.getScopes(),
- configuration.getApplicationName(), configuration.getRefreshToken(), configuration.getAccessToken());
+ client = getClientFactory().makeClient(configuration.getClientId(), configuration.getClientSecret(), configuration.getScopes(), configuration.getApplicationName(),
+ configuration.getRefreshToken(), configuration.getAccessToken());
}
return client;
}
-
+
public GoogleMailClientFactory getClientFactory() {
if (clientFactory == null) {
clientFactory = new BatchGoogleMailClientFactory();
}
return clientFactory;
}
-
+
public void setClientFactory(GoogleMailClientFactory clientFactory) {
this.clientFactory = clientFactory;
}
-
+
@Override
- protected Endpoint createEndpoint(String uri, String methodName, GoogleMailApiName apiName,
- GoogleMailConfiguration endpointConfiguration) {
+ protected Endpoint createEndpoint(String uri, String methodName, GoogleMailApiName apiName, GoogleMailConfiguration endpointConfiguration) {
return new GoogleMailEndpoint(uri, this, apiName, methodName, endpointConfiguration);
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/38c0a977/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailConfiguration.java b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailConfiguration.java
index 66786a7..1b9417e 100644
--- a/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailConfiguration.java
+++ b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailConfiguration.java
@@ -29,11 +29,11 @@ import org.apache.camel.spi.UriParams;
*/
@UriParams
public class GoogleMailConfiguration {
- private static final List<String> DEFAULT_SCOPES = Arrays.asList(GmailScopes.GMAIL_COMPOSE, GmailScopes.GMAIL_MODIFY, GmailScopes.MAIL_GOOGLE_COM);
-
+ private static final List<String> DEFAULT_SCOPES = Arrays.asList(GmailScopes.GMAIL_COMPOSE, GmailScopes.GMAIL_MODIFY, GmailScopes.MAIL_GOOGLE_COM);
+
@UriParam
private List<String> scopes = DEFAULT_SCOPES;
-
+
@UriParam
private String clientId;
@@ -48,7 +48,7 @@ public class GoogleMailConfiguration {
@UriParam
private String applicationName;
-
+
public String getClientId() {
return clientId;
}
@@ -88,7 +88,7 @@ public class GoogleMailConfiguration {
public void setApplicationName(String applicationName) {
this.applicationName = applicationName;
}
-
+
public List<String> getScopes() {
return scopes;
}
http://git-wip-us.apache.org/repos/asf/camel/blob/38c0a977/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailConsumer.java b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailConsumer.java
index 65dbc84..d2075c2 100644
--- a/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailConsumer.java
+++ b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailConsumer.java
@@ -16,7 +16,6 @@
*/
package org.apache.camel.component.google.mail;
-import java.io.IOException;
import java.util.Map;
import com.google.api.client.googleapis.services.AbstractGoogleClientRequest;
@@ -25,7 +24,6 @@ import org.apache.camel.Processor;
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.util.IntrospectionSupport;
import org.apache.camel.util.component.AbstractApiConsumer;
-import org.apache.camel.component.google.mail.internal.GoogleMailApiName;
/**
* The GoogleMail consumer.
@@ -35,7 +33,7 @@ public class GoogleMailConsumer extends AbstractApiConsumer<GoogleMailApiName, G
public GoogleMailConsumer(GoogleMailEndpoint endpoint, Processor processor) {
super(endpoint, processor);
}
-
+
@Override
protected Object doInvokeMethod(Map<String, Object> properties) throws RuntimeCamelException {
AbstractGoogleClientRequest request = (AbstractGoogleClientRequest) super.doInvokeMethod(properties);
@@ -43,13 +41,13 @@ public class GoogleMailConsumer extends AbstractApiConsumer<GoogleMailApiName, G
setProperty(properties, request, "q");
setProperty(properties, request, "maxResults");
setProperty(properties, request, "pageToken");
- setProperty(properties, request, "format");
+ setProperty(properties, request, "format");
return request.execute();
} catch (Exception e) {
throw new RuntimeCamelException(e);
}
}
-
+
private void setProperty(Map<String, Object> properties, AbstractGoogleClientRequest request, String key) throws Exception {
if (properties.containsKey(key)) {
IntrospectionSupport.setProperty(getEndpoint().getCamelContext().getTypeConverter(), request, key, properties.get(key));
http://git-wip-us.apache.org/repos/asf/camel/blob/38c0a977/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailEndpoint.java b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailEndpoint.java
index 516ce1b..92cd969 100644
--- a/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailEndpoint.java
+++ b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailEndpoint.java
@@ -23,14 +23,12 @@ import com.google.api.services.gmail.Gmail;
import org.apache.camel.Consumer;
import org.apache.camel.Processor;
import org.apache.camel.Producer;
+import org.apache.camel.component.google.mail.internal.GoogleMailConstants;
+import org.apache.camel.component.google.mail.internal.GoogleMailPropertiesHelper;
import org.apache.camel.spi.UriEndpoint;
import org.apache.camel.util.component.AbstractApiEndpoint;
import org.apache.camel.util.component.ApiMethod;
import org.apache.camel.util.component.ApiMethodPropertiesHelper;
-import org.apache.camel.component.google.mail.internal.GoogleMailApiCollection;
-import org.apache.camel.component.google.mail.internal.GoogleMailApiName;
-import org.apache.camel.component.google.mail.internal.GoogleMailConstants;
-import org.apache.camel.component.google.mail.internal.GoogleMailPropertiesHelper;
/**
* Represents a GoogleMail endpoint.
@@ -41,16 +39,17 @@ public class GoogleMailEndpoint extends AbstractApiEndpoint<GoogleMailApiName, G
// TODO create and manage API proxy
private Object apiProxy;
- public GoogleMailEndpoint(String uri, GoogleMailComponent component,
- GoogleMailApiName apiName, String methodName, GoogleMailConfiguration endpointConfiguration) {
+ public GoogleMailEndpoint(String uri, GoogleMailComponent component, GoogleMailApiName apiName, String methodName, GoogleMailConfiguration endpointConfiguration) {
super(uri, component, apiName, methodName, GoogleMailApiCollection.getCollection().getHelper(apiName), endpointConfiguration);
}
+ @Override
public Producer createProducer() throws Exception {
return new GoogleMailProducer(this);
}
+ @Override
public Consumer createConsumer(Processor processor) throws Exception {
// make sure inBody is not set for consumers
if (inBody != null) {
@@ -67,6 +66,7 @@ public class GoogleMailEndpoint extends AbstractApiEndpoint<GoogleMailApiName, G
return GoogleMailPropertiesHelper.getHelper();
}
+ @Override
protected String getThreadProfileName() {
return GoogleMailConstants.THREAD_PROFILE_NAME;
}
@@ -74,36 +74,36 @@ public class GoogleMailEndpoint extends AbstractApiEndpoint<GoogleMailApiName, G
@Override
protected void afterConfigureProperties() {
switch (apiName) {
- case ATTACHMENTS:
- apiProxy = getClient().users().messages().attachments();
- break;
- case DRAFTS:
- apiProxy = getClient().users().drafts();
- break;
- case HISTORY:
- apiProxy = getClient().users().history();
- break;
- case LABELS:
- apiProxy = getClient().users().labels();
- break;
- case MESSAGES:
- apiProxy = getClient().users().messages();
- break;
- case THREADS:
- apiProxy = getClient().users().threads();
- break;
- case USERS:
- apiProxy = getClient().users();
- break;
- default:
- throw new IllegalArgumentException("Invalid API name " + apiName);
+ case ATTACHMENTS:
+ apiProxy = getClient().users().messages().attachments();
+ break;
+ case DRAFTS:
+ apiProxy = getClient().users().drafts();
+ break;
+ case HISTORY:
+ apiProxy = getClient().users().history();
+ break;
+ case LABELS:
+ apiProxy = getClient().users().labels();
+ break;
+ case MESSAGES:
+ apiProxy = getClient().users().messages();
+ break;
+ case THREADS:
+ apiProxy = getClient().users().threads();
+ break;
+ case USERS:
+ apiProxy = getClient().users();
+ break;
+ default:
+ throw new IllegalArgumentException("Invalid API name " + apiName);
}
}
public Gmail getClient() {
- return ((GoogleMailComponent)getComponent()).getClient();
+ return ((GoogleMailComponent) getComponent()).getClient();
}
-
+
@Override
public Object getApiProxy(ApiMethod method, Map<String, Object> args) {
return apiProxy;
http://git-wip-us.apache.org/repos/asf/camel/blob/38c0a977/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailProducer.java b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailProducer.java
index 763ca17..64d6029 100644
--- a/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailProducer.java
+++ b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailProducer.java
@@ -21,11 +21,10 @@ import java.util.Map;
import com.google.api.client.googleapis.services.AbstractGoogleClientRequest;
import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.component.google.mail.internal.GoogleMailPropertiesHelper;
import org.apache.camel.util.IntrospectionSupport;
import org.apache.camel.util.component.AbstractApiProducer;
import org.apache.camel.util.component.ApiMethod;
-import org.apache.camel.component.google.mail.internal.GoogleMailApiName;
-import org.apache.camel.component.google.mail.internal.GoogleMailPropertiesHelper;
/**
* The GoogleMail producer.
@@ -35,7 +34,7 @@ public class GoogleMailProducer extends AbstractApiProducer<GoogleMailApiName, G
public GoogleMailProducer(GoogleMailEndpoint endpoint) {
super(endpoint, GoogleMailPropertiesHelper.getHelper());
}
-
+
@Override
protected Object doInvokeMethod(ApiMethod method, Map<String, Object> properties) throws RuntimeCamelException {
AbstractGoogleClientRequest request = (AbstractGoogleClientRequest) super.doInvokeMethod(method, properties);
http://git-wip-us.apache.org/repos/asf/camel/blob/38c0a977/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/AbstractGoogleMailTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/AbstractGoogleMailTestSupport.java b/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/AbstractGoogleMailTestSupport.java
index 77f5e35..464e60d 100644
--- a/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/AbstractGoogleMailTestSupport.java
+++ b/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/AbstractGoogleMailTestSupport.java
@@ -17,28 +17,25 @@
package org.apache.camel.component.google.mail;
import java.io.IOException;
-import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import org.apache.camel.CamelContext;
import org.apache.camel.CamelExecutionException;
-import org.apache.camel.component.google.mail.GoogleMailComponent;
-import org.apache.camel.component.google.mail.GoogleMailConfiguration;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.apache.camel.util.IntrospectionSupport;
/**
- * Abstract base class for GoogleMail Integration tests generated by Camel API component maven plugin.
+ * Abstract base class for GoogleMail Integration tests generated by Camel API
+ * component maven plugin.
*/
public class AbstractGoogleMailTestSupport extends CamelTestSupport {
+ // userid of the currently authenticated user
+ protected static final String CURRENT_USERID = "me";
private static final String TEST_OPTIONS_PROPERTIES = "/test-options.properties";
- // userid of the currently authenticated user
- public static final String CURRENT_USERID = "me";
-
@Override
protected CamelContext createCamelContext() throws Exception {
@@ -49,8 +46,7 @@ public class AbstractGoogleMailTestSupport extends CamelTestSupport {
try {
properties.load(getClass().getResourceAsStream(TEST_OPTIONS_PROPERTIES));
} catch (Exception e) {
- throw new IOException(String.format("%s could not be loaded: %s", TEST_OPTIONS_PROPERTIES, e.getMessage()),
- e);
+ throw new IOException(String.format("%s could not be loaded: %s", TEST_OPTIONS_PROPERTIES, e.getMessage()), e);
}
Map<String, Object> options = new HashMap<String, Object>();
@@ -76,8 +72,7 @@ public class AbstractGoogleMailTestSupport extends CamelTestSupport {
}
@SuppressWarnings("unchecked")
- protected <T> T requestBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers)
- throws CamelExecutionException {
+ protected <T> T requestBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers) throws CamelExecutionException {
return (T) template().requestBodyAndHeaders(endpointUri, body, headers);
}
http://git-wip-us.apache.org/repos/asf/camel/blob/38c0a977/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersIntegrationTest.java b/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersIntegrationTest.java
index 3e49fac..bf74a88 100644
--- a/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersIntegrationTest.java
+++ b/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersIntegrationTest.java
@@ -16,18 +16,11 @@
*/
package org.apache.camel.component.google.mail;
-import java.util.HashMap;
-import java.util.Map;
-
import org.apache.camel.builder.RouteBuilder;
-import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.camel.component.google.mail.internal.GoogleMailApiCollection;
-import org.apache.camel.component.google.mail.internal.GmailUsersApiMethod;
-
/**
* Test class for {@link com.google.api.services.gmail.Gmail$Users} APIs.
*/
@@ -49,10 +42,10 @@ public class GmailUsersIntegrationTest extends AbstractGoogleMailTestSupport {
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
+ @Override
public void configure() {
// test route for getProfile
- from("direct://GETPROFILE")
- .to("google-mail://" + PATH_PREFIX + "/getProfile?inBody=userId");
+ from("direct://GETPROFILE").to("google-mail://" + PATH_PREFIX + "/getProfile?inBody=userId");
}
};
http://git-wip-us.apache.org/repos/asf/camel/blob/38c0a977/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersLabelsIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersLabelsIntegrationTest.java b/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersLabelsIntegrationTest.java
index 2773924..69f1d84 100644
--- a/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersLabelsIntegrationTest.java
+++ b/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersLabelsIntegrationTest.java
@@ -25,8 +25,6 @@ import org.apache.camel.builder.RouteBuilder;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.camel.component.google.mail.internal.GoogleMailApiCollection;
-import org.apache.camel.component.google.mail.internal.GmailUsersLabelsApiMethod;
/**
* Test class for {@link com.google.api.services.gmail.Gmail$Users$Labels} APIs.
@@ -41,7 +39,7 @@ public class GmailUsersLabelsIntegrationTest extends AbstractGoogleMailTestSuppo
public void testLabels() throws Exception {
// using String message body for single parameter "userId"
com.google.api.services.gmail.model.ListLabelsResponse labels = requestBody("direct://LIST", CURRENT_USERID);
-
+
String labelId = null;
if (getTestLabel(labels) == null) {
Map<String, Object> headers = new HashMap<String, Object>();
@@ -50,9 +48,9 @@ public class GmailUsersLabelsIntegrationTest extends AbstractGoogleMailTestSuppo
Label label = new Label().setName(CAMEL_TEST_LABEL).setMessageListVisibility("show").setLabelListVisibility("labelShow");
// parameter type is com.google.api.services.gmail.model.Label
headers.put("CamelGoogleMail.content", label);
-
+
com.google.api.services.gmail.model.Label result = requestBodyAndHeaders("direct://CREATE", null, headers);
-
+
assertNotNull("create result", result);
labelId = result.getId();
} else {
@@ -88,30 +86,25 @@ public class GmailUsersLabelsIntegrationTest extends AbstractGoogleMailTestSuppo
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
+ @Override
public void configure() {
// test route for create
- from("direct://CREATE")
- .to("google-mail://" + PATH_PREFIX + "/create");
+ from("direct://CREATE").to("google-mail://" + PATH_PREFIX + "/create");
// test route for delete
- from("direct://DELETE")
- .to("google-mail://" + PATH_PREFIX + "/delete");
+ from("direct://DELETE").to("google-mail://" + PATH_PREFIX + "/delete");
// test route for get
- from("direct://GET")
- .to("google-mail://" + PATH_PREFIX + "/get");
+ from("direct://GET").to("google-mail://" + PATH_PREFIX + "/get");
// test route for list
- from("direct://LIST")
- .to("google-mail://" + PATH_PREFIX + "/list?inBody=userId");
+ from("direct://LIST").to("google-mail://" + PATH_PREFIX + "/list?inBody=userId");
// test route for patch
- from("direct://PATCH")
- .to("google-mail://" + PATH_PREFIX + "/patch");
+ from("direct://PATCH").to("google-mail://" + PATH_PREFIX + "/patch");
// test route for update
- from("direct://UPDATE")
- .to("google-mail://" + PATH_PREFIX + "/update");
+ from("direct://UPDATE").to("google-mail://" + PATH_PREFIX + "/update");
}
};
http://git-wip-us.apache.org/repos/asf/camel/blob/38c0a977/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersMessagesIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersMessagesIntegrationTest.java b/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersMessagesIntegrationTest.java
index b682ae0..ff51654 100644
--- a/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersMessagesIntegrationTest.java
+++ b/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersMessagesIntegrationTest.java
@@ -36,24 +36,23 @@ import org.apache.camel.builder.RouteBuilder;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.camel.component.google.mail.internal.GoogleMailApiCollection;
-import org.apache.camel.component.google.mail.internal.GmailUsersMessagesApiMethod;
/**
- * Test class for {@link com.google.api.services.gmail.Gmail$Users$Messages} APIs.
+ * Test class for {@link com.google.api.services.gmail.Gmail$Users$Messages}
+ * APIs.
*/
public class GmailUsersMessagesIntegrationTest extends AbstractGoogleMailTestSupport {
- // userid of the currently authenticated user
+ // userid of the currently authenticated user
public static final String CURRENT_USERID = "me";
private static final Logger LOG = LoggerFactory.getLogger(GmailUsersMessagesIntegrationTest.class);
private static final String PATH_PREFIX = GoogleMailApiCollection.getCollection().getApiName(GmailUsersMessagesApiMethod.class).getName();
@Test
public void testMessages() throws Exception {
-
+
// ==== Send test email ====
- Message testEmail = createTestEmail();
+ Message testEmail = createTestEmail();
Map<String, Object> headers = new HashMap<String, Object>();
// parameter type is String
headers.put("CamelGoogleMail.userId", CURRENT_USERID);
@@ -63,7 +62,7 @@ public class GmailUsersMessagesIntegrationTest extends AbstractGoogleMailTestSup
com.google.api.services.gmail.model.Message result = requestBodyAndHeaders("direct://SEND", null, headers);
assertNotNull("send result", result);
String testEmailId = result.getId();
-
+
// ==== Search for message we just sent ====
headers = new HashMap<String, Object>();
headers.put("CamelGoogleMail.q", "subject:\"Hello from camel-google-mail\"");
@@ -85,7 +84,7 @@ public class GmailUsersMessagesIntegrationTest extends AbstractGoogleMailTestSup
// using String message body for single parameter "userId"
listOfMessages = requestBody("direct://LIST", CURRENT_USERID);
assertFalse(idInList(testEmailId, listOfMessages));
-
+
// ===== untrash it ====
headers = new HashMap<String, Object>();
// parameter type is String
@@ -100,7 +99,7 @@ public class GmailUsersMessagesIntegrationTest extends AbstractGoogleMailTestSup
// using String message body for single parameter "userId"
listOfMessages = requestBody("direct://LIST", CURRENT_USERID);
assertTrue(idInList(testEmailId, listOfMessages));
-
+
// ===== permanently delete it ====
headers = new HashMap<String, Object>();
// parameter type is String
@@ -130,11 +129,11 @@ public class GmailUsersMessagesIntegrationTest extends AbstractGoogleMailTestSup
}
private Message createTestEmail() throws MessagingException, IOException {
- com.google.api.services.gmail.model.Profile profile = requestBody("google-mail://users/getProfile?inBody=userId", CURRENT_USERID);
+ com.google.api.services.gmail.model.Profile profile = requestBody("google-mail://users/getProfile?inBody=userId", CURRENT_USERID);
Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null);
MimeMessage mm = new MimeMessage(session);
- mm.addRecipients(RecipientType.TO, profile.getEmailAddress());
+ mm.addRecipients(javax.mail.Message.RecipientType.TO, profile.getEmailAddress());
mm.setSubject("Hello from camel-google-mail");
mm.setContent("Camel rocks!", "text/plain");
Message createMessageWithEmail = createMessageWithEmail(mm);
@@ -149,72 +148,59 @@ public class GmailUsersMessagesIntegrationTest extends AbstractGoogleMailTestSup
return new MimeMessage(session, new ByteArrayInputStream(emailBytes));
}
-
- private Message createMessageWithEmail(MimeMessage email)
- throws MessagingException, IOException {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- email.writeTo(baos);
- String encodedEmail = Base64.encodeBase64URLSafeString(baos.toByteArray());
- Message message = new Message();
- message.setRaw(encodedEmail);
- return message;
+
+ private Message createMessageWithEmail(MimeMessage email) throws MessagingException, IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ email.writeTo(baos);
+ String encodedEmail = Base64.encodeBase64URLSafeString(baos.toByteArray());
+ Message message = new Message();
+ message.setRaw(encodedEmail);
+ return message;
}
-
+
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
+ @Override
public void configure() {
// test route for attachments
- from("direct://ATTACHMENTS")
- .to("google-mail://" + PATH_PREFIX + "/attachments");
+ from("direct://ATTACHMENTS").to("google-mail://" + PATH_PREFIX + "/attachments");
// test route for delete
- from("direct://DELETE")
- .to("google-mail://" + PATH_PREFIX + "/delete");
+ from("direct://DELETE").to("google-mail://" + PATH_PREFIX + "/delete");
// test route for get
- from("direct://GET")
- .to("google-mail://" + PATH_PREFIX + "/get");
+ from("direct://GET").to("google-mail://" + PATH_PREFIX + "/get");
// test route for gmailImport
- from("direct://GMAILIMPORT")
- .to("google-mail://" + PATH_PREFIX + "/gmailImport");
+ from("direct://GMAILIMPORT").to("google-mail://" + PATH_PREFIX + "/gmailImport");
// test route for gmailImport
- from("direct://GMAILIMPORT_1")
- .to("google-mail://" + PATH_PREFIX + "/gmailImport");
+ from("direct://GMAILIMPORT_1").to("google-mail://" + PATH_PREFIX + "/gmailImport");
// test route for insert
- from("direct://INSERT")
- .to("google-mail://" + PATH_PREFIX + "/insert");
+ from("direct://INSERT").to("google-mail://" + PATH_PREFIX + "/insert");
// test route for insert
- from("direct://INSERT_1")
- .to("google-mail://" + PATH_PREFIX + "/insert");
+ from("direct://INSERT_1").to("google-mail://" + PATH_PREFIX + "/insert");
// test route for list
- from("direct://LIST")
- .to("google-mail://" + PATH_PREFIX + "/list?inBody=userId");
+ from("direct://LIST").to("google-mail://" + PATH_PREFIX + "/list?inBody=userId");
// test route for modify
- from("direct://MODIFY")
- .to("google-mail://" + PATH_PREFIX + "/modify");
+ from("direct://MODIFY").to("google-mail://" + PATH_PREFIX + "/modify");
// test route for send
- from("direct://SEND")
- .to("google-mail://" + PATH_PREFIX + "/send");
+ from("direct://SEND").to("google-mail://" + PATH_PREFIX + "/send");
// test route for send
- from("direct://SEND_1")
- .to("google-mail://" + PATH_PREFIX + "/send");
+ from("direct://SEND_1").to("google-mail://" + PATH_PREFIX + "/send");
// test route for trash
- from("direct://TRASH")
- .to("google-mail://" + PATH_PREFIX + "/trash");
+ from("direct://TRASH").to("google-mail://" + PATH_PREFIX + "/trash");
// test route for untrash
- from("direct://UNTRASH")
- .to("google-mail://" + PATH_PREFIX + "/untrash");
+ from("direct://UNTRASH").to("google-mail://" + PATH_PREFIX + "/untrash");
}
};
http://git-wip-us.apache.org/repos/asf/camel/blob/38c0a977/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersThreadsIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersThreadsIntegrationTest.java b/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersThreadsIntegrationTest.java
index 023be8c..4ac5f4d 100644
--- a/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersThreadsIntegrationTest.java
+++ b/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersThreadsIntegrationTest.java
@@ -31,15 +31,13 @@ import com.google.api.client.repackaged.org.apache.commons.codec.binary.Base64;
import com.google.api.services.gmail.model.Message;
import org.apache.camel.builder.RouteBuilder;
-import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.camel.component.google.mail.internal.GoogleMailApiCollection;
-import org.apache.camel.component.google.mail.internal.GmailUsersThreadsApiMethod;
/**
- * Test class for {@link com.google.api.services.gmail.Gmail$Users$Threads} APIs.
+ * Test class for {@link com.google.api.services.gmail.Gmail$Users$Threads}
+ * APIs.
*/
public class GmailUsersThreadsIntegrationTest extends AbstractGoogleMailTestSupport {
@@ -47,11 +45,11 @@ public class GmailUsersThreadsIntegrationTest extends AbstractGoogleMailTestSupp
private static final String PATH_PREFIX = GoogleMailApiCollection.getCollection().getApiName(GmailUsersThreadsApiMethod.class).getName();
private Message createThreadedTestEmail(String previousThreadId) throws MessagingException, IOException {
- com.google.api.services.gmail.model.Profile profile = requestBody("google-mail://users/getProfile?inBody=userId", CURRENT_USERID);
+ com.google.api.services.gmail.model.Profile profile = requestBody("google-mail://users/getProfile?inBody=userId", CURRENT_USERID);
Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null);
MimeMessage mm = new MimeMessage(session);
- mm.addRecipients(RecipientType.TO, profile.getEmailAddress());
+ mm.addRecipients(javax.mail.Message.RecipientType.TO, profile.getEmailAddress());
mm.setSubject("Hello from camel-google-mail");
mm.setContent("Camel rocks!", "text/plain");
Message createMessageWithEmail = createMessageWithEmail(mm);
@@ -67,32 +65,31 @@ public class GmailUsersThreadsIntegrationTest extends AbstractGoogleMailTestSupp
return requestBodyAndHeaders("google-mail://messages/send", null, headers);
}
-
- private Message createMessageWithEmail(MimeMessage email)
- throws MessagingException, IOException {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- email.writeTo(baos);
- String encodedEmail = Base64.encodeBase64URLSafeString(baos.toByteArray());
- Message message = new Message();
- message.setRaw(encodedEmail);
- return message;
+
+ private Message createMessageWithEmail(MimeMessage email) throws MessagingException, IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ email.writeTo(baos);
+ String encodedEmail = Base64.encodeBase64URLSafeString(baos.toByteArray());
+ Message message = new Message();
+ message.setRaw(encodedEmail);
+ return message;
}
-
+
@Test
public void testList() throws Exception {
Message m1 = createThreadedTestEmail(null);
- Message m2 = createThreadedTestEmail(m1.getThreadId());
-
+ Message m2 = createThreadedTestEmail(m1.getThreadId());
+
Map<String, Object> headers = new HashMap<String, Object>();
headers.put("CamelGoogleMail.q", "subject:\"Hello from camel-google-mail\"");
-
+
// using String message body for single parameter "userId"
com.google.api.services.gmail.model.ListThreadsResponse result = requestBodyAndHeaders("direct://LIST", CURRENT_USERID, headers);
assertNotNull("list result", result);
assertTrue(result.getThreads().size() > 0);
LOG.debug("list: " + result);
-
+
headers = new HashMap<String, Object>();
// parameter type is String
headers.put("CamelGoogleMail.userId", CURRENT_USERID);
@@ -105,30 +102,25 @@ public class GmailUsersThreadsIntegrationTest extends AbstractGoogleMailTestSupp
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
+ @Override
public void configure() {
// test route for delete
- from("direct://DELETE")
- .to("google-mail://" + PATH_PREFIX + "/delete");
+ from("direct://DELETE").to("google-mail://" + PATH_PREFIX + "/delete");
// test route for get
- from("direct://GET")
- .to("google-mail://" + PATH_PREFIX + "/get");
+ from("direct://GET").to("google-mail://" + PATH_PREFIX + "/get");
// test route for list
- from("direct://LIST")
- .to("google-mail://" + PATH_PREFIX + "/list?inBody=userId");
+ from("direct://LIST").to("google-mail://" + PATH_PREFIX + "/list?inBody=userId");
// test route for modify
- from("direct://MODIFY")
- .to("google-mail://" + PATH_PREFIX + "/modify");
+ from("direct://MODIFY").to("google-mail://" + PATH_PREFIX + "/modify");
// test route for trash
- from("direct://TRASH")
- .to("google-mail://" + PATH_PREFIX + "/trash");
+ from("direct://TRASH").to("google-mail://" + PATH_PREFIX + "/trash");
// test route for untrash
- from("direct://UNTRASH")
- .to("google-mail://" + PATH_PREFIX + "/untrash");
+ from("direct://UNTRASH").to("google-mail://" + PATH_PREFIX + "/untrash");
}
};
http://git-wip-us.apache.org/repos/asf/camel/blob/38c0a977/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 4d2e17a..7e61552 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -180,6 +180,7 @@
<google-api-client-version>1.19.0</google-api-client-version>
<google-api-services-drive-version>v2-rev151-1.19.0</google-api-services-drive-version>
<google-api-services-calendar-version>v3-rev99-1.19.0</google-api-services-calendar-version>
+ <google-api-services-mail-version>v1-rev15-1.19.0</google-api-services-mail-version>
<grizzly-websockets-version>2.3.17</grizzly-websockets-version>
<groovy-version>2.3.7</groovy-version>
<gson-version>2.3</gson-version>
Re: [2/5] camel git commit: CAMEL-8110 - google mail component
Posted by Jon Anstey <ja...@gmail.com>.
Fixed now. Looks like the Eclipse source cleanup function cleaned up a bit
too much :-)
On Wed, Dec 3, 2014 at 9:17 AM, Jon Anstey <ja...@gmail.com> wrote:
> Yep, will take a look.
>
> On Wed, Dec 3, 2014 at 12:23 AM, Willem Jiang <wi...@gmail.com>
> wrote:
>
>> Hi Jon,
>>
>> The build of new added camel-google-mail component is failed[1].
>> Could you take a look at it?
>>
>> [1]
>> https://builds.apache.org/job/Camel.trunk.notest/2237/org.apache.camel$camel-google-mail/console
>>
>> Regards,
>> --
>> Willem Jiang
>>
>> Red Hat, Inc.
>> Web: http://www.redhat.com
>> Blog: http://willemjiang.blogspot.com (English)
>> http://jnn.iteye.com (Chinese)
>> Twitter: willemjiang
>> Weibo: 姜宁willem
>>
>>
>>
>> On December 3, 2014 at 5:08:12 AM, janstey@apache.org (janstey@apache.org)
>> wrote:
>> > > CAMEL-8110 - google mail component
>> >
>> >
>> > Project: http://git-wip-us.apache.org/repos/asf/camel/repo
>> > Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/3c6769db
>> > Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/3c6769db
>> > Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/3c6769db
>> >
>> > Branch: refs/heads/master
>> > Commit: 3c6769dbd287d4ec919104649947b84eafc3050c
>> > Parents: 7ffb70e
>> > Author: Jonathan Anstey
>> > Authored: Tue Dec 2 17:13:30(
>> http://airmail.calendar/2014-12-02%2017:13:30%20GMT+8)
>> > 2014 -0330
>> > Committer: Jonathan Anstey
>> > Committed: Tue Dec 2 17:16:54(
>> http://airmail.calendar/2014-12-02%2017:16:54%20GMT+8)
>> > 2014 -0330
>>
>>
>
>
> --
> Cheers,
> Jon
> ---------------
> Red Hat, Inc.
> Email: janstey@redhat.com
> Web: http://redhat.com
> Twitter: jon_anstey
> Blog: http://janstey.blogspot.com
> Author of Camel in Action: http://manning.com/ibsen
>
--
Cheers,
Jon
---------------
Red Hat, Inc.
Email: janstey@redhat.com
Web: http://redhat.com
Twitter: jon_anstey
Blog: http://janstey.blogspot.com
Author of Camel in Action: http://manning.com/ibsen
Re: [2/5] camel git commit: CAMEL-8110 - google mail component
Posted by Jon Anstey <ja...@gmail.com>.
Yep, will take a look.
On Wed, Dec 3, 2014 at 12:23 AM, Willem Jiang <wi...@gmail.com>
wrote:
> Hi Jon,
>
> The build of new added camel-google-mail component is failed[1].
> Could you take a look at it?
>
> [1]
> https://builds.apache.org/job/Camel.trunk.notest/2237/org.apache.camel$camel-google-mail/console
>
> Regards,
> --
> Willem Jiang
>
> Red Hat, Inc.
> Web: http://www.redhat.com
> Blog: http://willemjiang.blogspot.com (English)
> http://jnn.iteye.com (Chinese)
> Twitter: willemjiang
> Weibo: 姜宁willem
>
>
>
> On December 3, 2014 at 5:08:12 AM, janstey@apache.org (janstey@apache.org)
> wrote:
> > > CAMEL-8110 - google mail component
> >
> >
> > Project: http://git-wip-us.apache.org/repos/asf/camel/repo
> > Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/3c6769db
> > Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/3c6769db
> > Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/3c6769db
> >
> > Branch: refs/heads/master
> > Commit: 3c6769dbd287d4ec919104649947b84eafc3050c
> > Parents: 7ffb70e
> > Author: Jonathan Anstey
> > Authored: Tue Dec 2 17:13:30(
> http://airmail.calendar/2014-12-02%2017:13:30%20GMT+8)
> > 2014 -0330
> > Committer: Jonathan Anstey
> > Committed: Tue Dec 2 17:16:54(
> http://airmail.calendar/2014-12-02%2017:16:54%20GMT+8)
> > 2014 -0330
>
>
--
Cheers,
Jon
---------------
Red Hat, Inc.
Email: janstey@redhat.com
Web: http://redhat.com
Twitter: jon_anstey
Blog: http://janstey.blogspot.com
Author of Camel in Action: http://manning.com/ibsen
Re: [2/5] camel git commit: CAMEL-8110 - google mail component
Posted by Willem Jiang <wi...@gmail.com>.
Hi Jon,
The build of new added camel-google-mail component is failed[1].
Could you take a look at it?
[1] https://builds.apache.org/job/Camel.trunk.notest/2237/org.apache.camel$camel-google-mail/console
Regards,
--
Willem Jiang
Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.iteye.com (Chinese)
Twitter: willemjiang
Weibo: 姜宁willem
On December 3, 2014 at 5:08:12 AM, janstey@apache.org (janstey@apache.org) wrote:
> > CAMEL-8110 - google mail component
>
>
> Project: http://git-wip-us.apache.org/repos/asf/camel/repo
> Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/3c6769db
> Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/3c6769db
> Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/3c6769db
>
> Branch: refs/heads/master
> Commit: 3c6769dbd287d4ec919104649947b84eafc3050c
> Parents: 7ffb70e
> Author: Jonathan Anstey
> Authored: Tue Dec 2 17:13:30(http://airmail.calendar/2014-12-02%2017:13:30%20GMT+8)
> 2014 -0330
> Committer: Jonathan Anstey
> Committed: Tue Dec 2 17:16:54(http://airmail.calendar/2014-12-02%2017:16:54%20GMT+8)
> 2014 -0330
[2/5] camel git commit: CAMEL-8110 - google mail component
Posted by ja...@apache.org.
CAMEL-8110 - google mail component
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/3c6769db
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/3c6769db
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/3c6769db
Branch: refs/heads/master
Commit: 3c6769dbd287d4ec919104649947b84eafc3050c
Parents: 7ffb70e
Author: Jonathan Anstey <ja...@gmail.com>
Authored: Tue Dec 2 17:13:30 2014 -0330
Committer: Jonathan Anstey <ja...@gmail.com>
Committed: Tue Dec 2 17:16:54 2014 -0330
----------------------------------------------------------------------
components/camel-google-mail/pom.xml | 311 +++++++++++++++++++
.../mail/BatchGoogleMailClientFactory.java | 68 ++++
.../google/mail/GoogleMailClientFactory.java | 27 ++
.../google/mail/GoogleMailComponent.java | 75 +++++
.../google/mail/GoogleMailConfiguration.java | 100 ++++++
.../google/mail/GoogleMailConsumer.java | 58 ++++
.../google/mail/GoogleMailEndpoint.java | 111 +++++++
.../google/mail/GoogleMailProducer.java | 58 ++++
.../mail/internal/GoogleMailConstants.java | 29 ++
.../internal/GoogleMailPropertiesHelper.java | 39 +++
.../org/apache/camel/component/google-mail | 1 +
.../mail/AbstractGoogleMailTestSupport.java | 88 ++++++
.../google/mail/GmailUsersIntegrationTest.java | 60 ++++
.../mail/GmailUsersLabelsIntegrationTest.java | 119 +++++++
.../mail/GmailUsersMessagesIntegrationTest.java | 222 +++++++++++++
.../mail/GmailUsersThreadsIntegrationTest.java | 136 ++++++++
.../src/test/resources/log4j.properties | 30 ++
.../src/test/resources/test-options.properties | 26 ++
18 files changed, 1558 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/3c6769db/components/camel-google-mail/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-google-mail/pom.xml b/components/camel-google-mail/pom.xml
new file mode 100644
index 0000000..f7c0272
--- /dev/null
+++ b/components/camel-google-mail/pom.xml
@@ -0,0 +1,311 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>components</artifactId>
+ <version>2.15-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-google-mail</artifactId>
+ <packaging>bundle</packaging>
+ <name>Camel GoogleMail Component</name>
+ <description>Camel Component for GoogleMail</description>
+
+ <properties>
+ <schemeName>google-mail</schemeName>
+ <componentName>GoogleMail</componentName>
+ <componentPackage>org.apache.camel.component.google.mail</componentPackage>
+ <outPackage>org.apache.camel.component.google.mail.internal</outPackage>
+ <camel.osgi.private.pkg>org.apache.camel.component.google.mail.internal</camel.osgi.private.pkg>
+ <camel.osgi.export.pkg>org.apache.camel.component.google.mail</camel.osgi.export.pkg>
+ <camel.osgi.export.service>
+ org.apache.camel.spi.ComponentResolver;component=google-mail
+ </camel.osgi.export.service>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.google.api-client</groupId>
+ <artifactId>google-api-client</artifactId>
+ <version>${google-api-client-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.oauth-client</groupId>
+ <artifactId>google-oauth-client-jetty</artifactId>
+ <version>${google-api-client-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.http-client</groupId>
+ <artifactId>google-http-client-jackson2</artifactId>
+ <version>${google-api-client-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.apis</groupId>
+ <artifactId>google-api-services-gmail</artifactId>
+ <version>${google-api-services-mail-version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ <version>${javax-mail-version}</version>
+ <exclusions>
+ <!-- javax activation is part of the JDK now -->
+ <exclusion>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!-- Camel annotations in provided scope to avoid compile errors in IDEs -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>spi-annotations</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- Component API javadoc in provided scope to read API signatures -->
+ <dependency>
+ <groupId>com.google.apis</groupId>
+ <artifactId>google-api-services-gmail</artifactId>
+ <version>${google-api-services-mail-version}</version>
+ <classifier>javadoc</classifier>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- logging -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- testing -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.5.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.6</version>
+ <configuration>
+ <encoding>UTF-8</encoding>
+ </configuration>
+ </plugin>
+
+ <!-- generate Component source and test source -->
+ <plugin>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-api-component-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-test-component-classes</id>
+ <goals>
+ <goal>fromApis</goal>
+ </goals>
+ <configuration>
+ <apis>
+ <api>
+ <apiName>threads</apiName>
+ <proxyClass>com.google.api.services.gmail.Gmail$Users$Threads</proxyClass>
+ <fromJavadoc />
+ </api>
+ <api>
+ <apiName>messages</apiName>
+ <proxyClass>com.google.api.services.gmail.Gmail$Users$Messages</proxyClass>
+ <fromJavadoc />
+ </api>
+ <api>
+ <apiName>attachments</apiName>
+ <proxyClass>com.google.api.services.gmail.Gmail$Users$Messages$Attachments</proxyClass>
+ <fromJavadoc />
+ </api>
+ <api>
+ <apiName>labels</apiName>
+ <proxyClass>com.google.api.services.gmail.Gmail$Users$Labels</proxyClass>
+ <fromJavadoc />
+ </api>
+ <api>
+ <apiName>history</apiName>
+ <proxyClass>com.google.api.services.gmail.Gmail$Users$History</proxyClass>
+ <fromJavadoc />
+ </api>
+ <api>
+ <apiName>drafts</apiName>
+ <proxyClass>com.google.api.services.gmail.Gmail$Users$Drafts</proxyClass>
+ <fromJavadoc />
+ </api>
+ <api>
+ <apiName>users</apiName>
+ <proxyClass>com.google.api.services.gmail.Gmail$Users</proxyClass>
+ <fromJavadoc>
+ <includeMethods>getProfile</includeMethods>
+ </fromJavadoc>
+ </api>
+ </apis>
+ <substitutions>
+ <substitution>
+ <method>^.+$</method>
+ <argName>content</argName>
+ <argType>com.google.api.services.gmail.model.Channel</argType>
+ <replacement>contentChannel</replacement>
+ </substitution>
+ <substitution>
+ <method>^.+$</method>
+ <argName>content</argName>
+ <argType>com.google.api.services.gmail.model.ModifyMessageRequest</argType>
+ <replacement>modifyMessageRequest</replacement>
+ </substitution>
+ </substitutions>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- add generated source and test source to build -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.8</version>
+ <executions>
+ <execution>
+ <id>add-generated-sources</id>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${project.build.directory}/generated-sources/camel-component</source>
+ </sources>
+ </configuration>
+ </execution>
+ <execution>
+ <id>add-generated-test-sources</id>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${project.build.directory}/generated-test-sources/camel-component</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-api-component-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <configuration>
+ <scheme>${schemeName}</scheme>
+ <componentName>${componentName}</componentName>
+ <componentPackage>${componentPackage}</componentPackage>
+ <outPackage>${outPackage}</outPackage>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-api-component-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <configuration>
+ <scheme>${schemeName}</scheme>
+ <componentName>${componentName}</componentName>
+ <componentPackage>${componentPackage}</componentPackage>
+ <outPackage>${outPackage}</outPackage>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <profiles>
+ <profile>
+ <id>google-mail-test</id>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <childDelegation>false</childDelegation>
+ <useFile>true</useFile>
+ <forkCount>1</forkCount>
+ <reuseForks>true</reuseForks>
+ <forkedProcessTimeoutInSeconds>300</forkedProcessTimeoutInSeconds>
+ <excludes>
+ <exclude>**/*XXXTest.java</exclude>
+ </excludes>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/3c6769db/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/BatchGoogleMailClientFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/BatchGoogleMailClientFactory.java b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/BatchGoogleMailClientFactory.java
new file mode 100644
index 0000000..626d232
--- /dev/null
+++ b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/BatchGoogleMailClientFactory.java
@@ -0,0 +1,68 @@
+/**
+ * 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.google.mail;
+
+import java.util.Collection;
+
+import com.google.api.client.auth.oauth2.Credential;
+import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
+import com.google.api.client.http.javanet.NetHttpTransport;
+import com.google.api.client.json.jackson2.JacksonFactory;
+import com.google.api.services.gmail.Gmail;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BatchGoogleMailClientFactory implements GoogleMailClientFactory {
+ private static final Logger LOG = LoggerFactory.getLogger(BatchGoogleMailClientFactory.class);
+ private NetHttpTransport transport;
+ private JacksonFactory jsonFactory;
+
+ public BatchGoogleMailClientFactory() {
+ this.transport = new NetHttpTransport();
+ this.jsonFactory = new JacksonFactory();
+ }
+
+ @Override
+ public Gmail makeClient(String clientId, String clientSecret, Collection<String> scopes, String applicationName, String refreshToken, String accessToken) {
+ Credential credential;
+ try {
+ credential = authorize(clientId, clientSecret, scopes);
+
+ if (refreshToken != null && !"".equals(refreshToken)) {
+ credential.setRefreshToken(refreshToken);
+ }
+ if (accessToken != null && !"".equals(accessToken)) {
+ credential.setAccessToken(accessToken);
+ }
+ return new Gmail.Builder(transport, jsonFactory, credential).setApplicationName(applicationName).build();
+ } catch (Exception e) {
+ LOG.error("Could not create Google Drive client.", e);
+ }
+ return null;
+ }
+
+ // Authorizes the installed application to access user's protected data.
+ private Credential authorize(String clientId, String clientSecret, Collection<String> scopes) throws Exception {
+ // authorize
+ return new GoogleCredential.Builder()
+ .setJsonFactory(jsonFactory)
+ .setTransport(transport)
+ .setClientSecrets(clientId, clientSecret)
+ .build();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/3c6769db/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailClientFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailClientFactory.java b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailClientFactory.java
new file mode 100644
index 0000000..d21e121
--- /dev/null
+++ b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailClientFactory.java
@@ -0,0 +1,27 @@
+/**
+ * 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.google.mail;
+
+import java.util.Collection;
+
+import com.google.api.services.gmail.Gmail;
+
+public interface GoogleMailClientFactory {
+
+ Gmail makeClient(String clientId, String clientSecret, Collection<String> scopes, String applicationName, String refreshToken, String accessToken);
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/3c6769db/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailComponent.java b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailComponent.java
new file mode 100644
index 0000000..4d88110
--- /dev/null
+++ b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailComponent.java
@@ -0,0 +1,75 @@
+/**
+ * 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.google.mail;
+
+
+import com.google.api.services.gmail.Gmail;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.util.component.AbstractApiComponent;
+import org.apache.camel.component.google.mail.internal.GoogleMailApiCollection;
+import org.apache.camel.component.google.mail.internal.GoogleMailApiName;
+
+/**
+ * Represents the component that manages {@link GoogleMailEndpoint}.
+ */
+@UriEndpoint(scheme = "google-mail", consumerClass = GoogleMailConsumer.class, consumerPrefix = "consumer")
+public class GoogleMailComponent extends AbstractApiComponent<GoogleMailApiName, GoogleMailConfiguration, GoogleMailApiCollection> {
+
+ private Gmail client;
+ private GoogleMailClientFactory clientFactory;
+
+ public GoogleMailComponent() {
+ super(GoogleMailEndpoint.class, GoogleMailApiName.class, GoogleMailApiCollection.getCollection());
+ }
+
+ public GoogleMailComponent(CamelContext context) {
+ super(context, GoogleMailEndpoint.class, GoogleMailApiName.class, GoogleMailApiCollection.getCollection());
+ }
+
+ @Override
+ protected GoogleMailApiName getApiName(String apiNameStr) throws IllegalArgumentException {
+ return GoogleMailApiName.fromValue(apiNameStr);
+ }
+
+ public Gmail getClient() {
+ if (client == null) {
+ client = getClientFactory().makeClient(configuration.getClientId(), configuration.getClientSecret(), configuration.getScopes(),
+ configuration.getApplicationName(), configuration.getRefreshToken(), configuration.getAccessToken());
+ }
+ return client;
+ }
+
+ public GoogleMailClientFactory getClientFactory() {
+ if (clientFactory == null) {
+ clientFactory = new BatchGoogleMailClientFactory();
+ }
+ return clientFactory;
+ }
+
+ public void setClientFactory(GoogleMailClientFactory clientFactory) {
+ this.clientFactory = clientFactory;
+ }
+
+ @Override
+ protected Endpoint createEndpoint(String uri, String methodName, GoogleMailApiName apiName,
+ GoogleMailConfiguration endpointConfiguration) {
+ return new GoogleMailEndpoint(uri, this, apiName, methodName, endpointConfiguration);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/3c6769db/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailConfiguration.java b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailConfiguration.java
new file mode 100644
index 0000000..66786a7
--- /dev/null
+++ b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailConfiguration.java
@@ -0,0 +1,100 @@
+/**
+ * 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.google.mail;
+
+import java.util.Arrays;
+import java.util.List;
+
+import com.google.api.services.gmail.GmailScopes;
+
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriParams;
+
+/**
+ * Component configuration for GoogleMail component.
+ */
+@UriParams
+public class GoogleMailConfiguration {
+ private static final List<String> DEFAULT_SCOPES = Arrays.asList(GmailScopes.GMAIL_COMPOSE, GmailScopes.GMAIL_MODIFY, GmailScopes.MAIL_GOOGLE_COM);
+
+ @UriParam
+ private List<String> scopes = DEFAULT_SCOPES;
+
+ @UriParam
+ private String clientId;
+
+ @UriParam
+ private String clientSecret;
+
+ @UriParam
+ private String accessToken;
+
+ @UriParam
+ private String refreshToken;
+
+ @UriParam
+ private String applicationName;
+
+ public String getClientId() {
+ return clientId;
+ }
+
+ public void setClientId(String clientId) {
+ this.clientId = clientId;
+ }
+
+ public String getClientSecret() {
+ return clientSecret;
+ }
+
+ public void setClientSecret(String clientSecret) {
+ this.clientSecret = clientSecret;
+ }
+
+ public String getAccessToken() {
+ return accessToken;
+ }
+
+ public void setAccessToken(String accessToken) {
+ this.accessToken = accessToken;
+ }
+
+ public String getRefreshToken() {
+ return refreshToken;
+ }
+
+ public void setRefreshToken(String refreshToken) {
+ this.refreshToken = refreshToken;
+ }
+
+ public String getApplicationName() {
+ return applicationName;
+ }
+
+ public void setApplicationName(String applicationName) {
+ this.applicationName = applicationName;
+ }
+
+ public List<String> getScopes() {
+ return scopes;
+ }
+
+ public void setScopes(List<String> scopes) {
+ this.scopes = scopes;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/3c6769db/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailConsumer.java b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailConsumer.java
new file mode 100644
index 0000000..65dbc84
--- /dev/null
+++ b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailConsumer.java
@@ -0,0 +1,58 @@
+/**
+ * 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.google.mail;
+
+import java.io.IOException;
+import java.util.Map;
+
+import com.google.api.client.googleapis.services.AbstractGoogleClientRequest;
+
+import org.apache.camel.Processor;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.util.IntrospectionSupport;
+import org.apache.camel.util.component.AbstractApiConsumer;
+import org.apache.camel.component.google.mail.internal.GoogleMailApiName;
+
+/**
+ * The GoogleMail consumer.
+ */
+public class GoogleMailConsumer extends AbstractApiConsumer<GoogleMailApiName, GoogleMailConfiguration> {
+
+ public GoogleMailConsumer(GoogleMailEndpoint endpoint, Processor processor) {
+ super(endpoint, processor);
+ }
+
+ @Override
+ protected Object doInvokeMethod(Map<String, Object> properties) throws RuntimeCamelException {
+ AbstractGoogleClientRequest request = (AbstractGoogleClientRequest) super.doInvokeMethod(properties);
+ try {
+ setProperty(properties, request, "q");
+ setProperty(properties, request, "maxResults");
+ setProperty(properties, request, "pageToken");
+ setProperty(properties, request, "format");
+ return request.execute();
+ } catch (Exception e) {
+ throw new RuntimeCamelException(e);
+ }
+ }
+
+ private void setProperty(Map<String, Object> properties, AbstractGoogleClientRequest request, String key) throws Exception {
+ if (properties.containsKey(key)) {
+ IntrospectionSupport.setProperty(getEndpoint().getCamelContext().getTypeConverter(), request, key, properties.get(key));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/3c6769db/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailEndpoint.java b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailEndpoint.java
new file mode 100644
index 0000000..516ce1b
--- /dev/null
+++ b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailEndpoint.java
@@ -0,0 +1,111 @@
+/**
+ * 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.google.mail;
+
+import java.util.Map;
+
+import com.google.api.services.gmail.Gmail;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.util.component.AbstractApiEndpoint;
+import org.apache.camel.util.component.ApiMethod;
+import org.apache.camel.util.component.ApiMethodPropertiesHelper;
+import org.apache.camel.component.google.mail.internal.GoogleMailApiCollection;
+import org.apache.camel.component.google.mail.internal.GoogleMailApiName;
+import org.apache.camel.component.google.mail.internal.GoogleMailConstants;
+import org.apache.camel.component.google.mail.internal.GoogleMailPropertiesHelper;
+
+/**
+ * Represents a GoogleMail endpoint.
+ */
+@UriEndpoint(scheme = "google-mail", consumerClass = GoogleMailConsumer.class, consumerPrefix = "consumer")
+public class GoogleMailEndpoint extends AbstractApiEndpoint<GoogleMailApiName, GoogleMailConfiguration> {
+
+ // TODO create and manage API proxy
+ private Object apiProxy;
+
+ public GoogleMailEndpoint(String uri, GoogleMailComponent component,
+ GoogleMailApiName apiName, String methodName, GoogleMailConfiguration endpointConfiguration) {
+ super(uri, component, apiName, methodName, GoogleMailApiCollection.getCollection().getHelper(apiName), endpointConfiguration);
+
+ }
+
+ public Producer createProducer() throws Exception {
+ return new GoogleMailProducer(this);
+ }
+
+ public Consumer createConsumer(Processor processor) throws Exception {
+ // make sure inBody is not set for consumers
+ if (inBody != null) {
+ throw new IllegalArgumentException("Option inBody is not supported for consumer endpoint");
+ }
+ final GoogleMailConsumer consumer = new GoogleMailConsumer(this, processor);
+ // also set consumer.* properties
+ configureConsumer(consumer);
+ return consumer;
+ }
+
+ @Override
+ protected ApiMethodPropertiesHelper<GoogleMailConfiguration> getPropertiesHelper() {
+ return GoogleMailPropertiesHelper.getHelper();
+ }
+
+ protected String getThreadProfileName() {
+ return GoogleMailConstants.THREAD_PROFILE_NAME;
+ }
+
+ @Override
+ protected void afterConfigureProperties() {
+ switch (apiName) {
+ case ATTACHMENTS:
+ apiProxy = getClient().users().messages().attachments();
+ break;
+ case DRAFTS:
+ apiProxy = getClient().users().drafts();
+ break;
+ case HISTORY:
+ apiProxy = getClient().users().history();
+ break;
+ case LABELS:
+ apiProxy = getClient().users().labels();
+ break;
+ case MESSAGES:
+ apiProxy = getClient().users().messages();
+ break;
+ case THREADS:
+ apiProxy = getClient().users().threads();
+ break;
+ case USERS:
+ apiProxy = getClient().users();
+ break;
+ default:
+ throw new IllegalArgumentException("Invalid API name " + apiName);
+ }
+ }
+
+ public Gmail getClient() {
+ return ((GoogleMailComponent)getComponent()).getClient();
+ }
+
+ @Override
+ public Object getApiProxy(ApiMethod method, Map<String, Object> args) {
+ return apiProxy;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/3c6769db/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailProducer.java b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailProducer.java
new file mode 100644
index 0000000..763ca17
--- /dev/null
+++ b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailProducer.java
@@ -0,0 +1,58 @@
+/**
+ * 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.google.mail;
+
+import java.util.Map;
+
+import com.google.api.client.googleapis.services.AbstractGoogleClientRequest;
+
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.util.IntrospectionSupport;
+import org.apache.camel.util.component.AbstractApiProducer;
+import org.apache.camel.util.component.ApiMethod;
+import org.apache.camel.component.google.mail.internal.GoogleMailApiName;
+import org.apache.camel.component.google.mail.internal.GoogleMailPropertiesHelper;
+
+/**
+ * The GoogleMail producer.
+ */
+public class GoogleMailProducer extends AbstractApiProducer<GoogleMailApiName, GoogleMailConfiguration> {
+
+ public GoogleMailProducer(GoogleMailEndpoint endpoint) {
+ super(endpoint, GoogleMailPropertiesHelper.getHelper());
+ }
+
+ @Override
+ protected Object doInvokeMethod(ApiMethod method, Map<String, Object> properties) throws RuntimeCamelException {
+ AbstractGoogleClientRequest request = (AbstractGoogleClientRequest) super.doInvokeMethod(method, properties);
+ try {
+ setProperty(properties, request, "q");
+ setProperty(properties, request, "maxResults");
+ setProperty(properties, request, "pageToken");
+ setProperty(properties, request, "format");
+ return request.execute();
+ } catch (Exception e) {
+ throw new RuntimeCamelException(e);
+ }
+ }
+
+ private void setProperty(Map<String, Object> properties, AbstractGoogleClientRequest request, String key) throws Exception {
+ if (properties.containsKey(key)) {
+ IntrospectionSupport.setProperty(getEndpoint().getCamelContext().getTypeConverter(), request, key, properties.get(key));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/3c6769db/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/internal/GoogleMailConstants.java
----------------------------------------------------------------------
diff --git a/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/internal/GoogleMailConstants.java b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/internal/GoogleMailConstants.java
new file mode 100644
index 0000000..f788ff3
--- /dev/null
+++ b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/internal/GoogleMailConstants.java
@@ -0,0 +1,29 @@
+/**
+ * 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.google.mail.internal;
+
+/**
+ * Constants for GoogleMail component.
+ */
+public interface GoogleMailConstants {
+
+ // suffix for parameters when passed as exchange header properties
+ String PROPERTY_PREFIX = "CamelGoogleMail.";
+
+ // thread profile name for this component
+ String THREAD_PROFILE_NAME = "CamelGoogleMail";
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/3c6769db/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/internal/GoogleMailPropertiesHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/internal/GoogleMailPropertiesHelper.java b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/internal/GoogleMailPropertiesHelper.java
new file mode 100644
index 0000000..17c2125
--- /dev/null
+++ b/components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/internal/GoogleMailPropertiesHelper.java
@@ -0,0 +1,39 @@
+/**
+ * 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.google.mail.internal;
+
+import org.apache.camel.component.google.mail.GoogleMailConfiguration;
+import org.apache.camel.util.component.ApiMethodPropertiesHelper;
+
+/**
+ * Singleton {@link ApiMethodPropertiesHelper} for GoogleMail component.
+ */
+public final class GoogleMailPropertiesHelper extends ApiMethodPropertiesHelper<GoogleMailConfiguration> {
+
+ private static GoogleMailPropertiesHelper helper;
+
+ private GoogleMailPropertiesHelper() {
+ super(GoogleMailConfiguration.class, GoogleMailConstants.PROPERTY_PREFIX);
+ }
+
+ public static synchronized GoogleMailPropertiesHelper getHelper() {
+ if (helper == null) {
+ helper = new GoogleMailPropertiesHelper();
+ }
+ return helper;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/3c6769db/components/camel-google-mail/src/main/resources/META-INF/services/org/apache/camel/component/google-mail
----------------------------------------------------------------------
diff --git a/components/camel-google-mail/src/main/resources/META-INF/services/org/apache/camel/component/google-mail b/components/camel-google-mail/src/main/resources/META-INF/services/org/apache/camel/component/google-mail
new file mode 100644
index 0000000..75513b1
--- /dev/null
+++ b/components/camel-google-mail/src/main/resources/META-INF/services/org/apache/camel/component/google-mail
@@ -0,0 +1 @@
+class=org.apache.camel.component.google.mail.GoogleMailComponent
http://git-wip-us.apache.org/repos/asf/camel/blob/3c6769db/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/AbstractGoogleMailTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/AbstractGoogleMailTestSupport.java b/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/AbstractGoogleMailTestSupport.java
new file mode 100644
index 0000000..77f5e35
--- /dev/null
+++ b/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/AbstractGoogleMailTestSupport.java
@@ -0,0 +1,88 @@
+/**
+ * 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.google.mail;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.component.google.mail.GoogleMailComponent;
+import org.apache.camel.component.google.mail.GoogleMailConfiguration;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.util.IntrospectionSupport;
+
+/**
+ * Abstract base class for GoogleMail Integration tests generated by Camel API component maven plugin.
+ */
+public class AbstractGoogleMailTestSupport extends CamelTestSupport {
+
+ private static final String TEST_OPTIONS_PROPERTIES = "/test-options.properties";
+ // userid of the currently authenticated user
+ public static final String CURRENT_USERID = "me";
+
+
+ @Override
+ protected CamelContext createCamelContext() throws Exception {
+
+ final CamelContext context = super.createCamelContext();
+
+ // read GoogleMail component configuration from TEST_OPTIONS_PROPERTIES
+ final Properties properties = new Properties();
+ try {
+ properties.load(getClass().getResourceAsStream(TEST_OPTIONS_PROPERTIES));
+ } catch (Exception e) {
+ throw new IOException(String.format("%s could not be loaded: %s", TEST_OPTIONS_PROPERTIES, e.getMessage()),
+ e);
+ }
+
+ Map<String, Object> options = new HashMap<String, Object>();
+ for (Map.Entry<Object, Object> entry : properties.entrySet()) {
+ options.put(entry.getKey().toString(), entry.getValue());
+ }
+
+ final GoogleMailConfiguration configuration = new GoogleMailConfiguration();
+ IntrospectionSupport.setProperties(configuration, options);
+
+ // add GoogleMailComponent to Camel context
+ final GoogleMailComponent component = new GoogleMailComponent(context);
+ component.setConfiguration(configuration);
+ context.addComponent("google-mail", component);
+
+ return context;
+ }
+
+ @Override
+ public boolean isCreateCamelContextPerClass() {
+ // only create the context once for this class
+ return true;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected <T> T requestBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers)
+ throws CamelExecutionException {
+ return (T) template().requestBodyAndHeaders(endpointUri, body, headers);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected <T> T requestBody(String endpoint, Object body) throws CamelExecutionException {
+ return (T) template().requestBody(endpoint, body);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/3c6769db/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersIntegrationTest.java b/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersIntegrationTest.java
new file mode 100644
index 0000000..3e49fac
--- /dev/null
+++ b/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersIntegrationTest.java
@@ -0,0 +1,60 @@
+/**
+ * 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.google.mail;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.camel.component.google.mail.internal.GoogleMailApiCollection;
+import org.apache.camel.component.google.mail.internal.GmailUsersApiMethod;
+
+/**
+ * Test class for {@link com.google.api.services.gmail.Gmail$Users} APIs.
+ */
+public class GmailUsersIntegrationTest extends AbstractGoogleMailTestSupport {
+
+ private static final Logger LOG = LoggerFactory.getLogger(GmailUsersIntegrationTest.class);
+ private static final String PATH_PREFIX = GoogleMailApiCollection.getCollection().getApiName(GmailUsersApiMethod.class).getName();
+
+ @Test
+ public void testGetProfile() throws Exception {
+ // using String message body for single parameter "userId"
+ final com.google.api.services.gmail.model.Profile result = requestBody("direct://GETPROFILE", CURRENT_USERID);
+
+ assertNotNull("getProfile result", result);
+ assertNotNull("Should be email address associated with current account", result.getEmailAddress());
+ LOG.debug("getProfile: " + result);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ // test route for getProfile
+ from("direct://GETPROFILE")
+ .to("google-mail://" + PATH_PREFIX + "/getProfile?inBody=userId");
+
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/3c6769db/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersLabelsIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersLabelsIntegrationTest.java b/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersLabelsIntegrationTest.java
new file mode 100644
index 0000000..2773924
--- /dev/null
+++ b/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersLabelsIntegrationTest.java
@@ -0,0 +1,119 @@
+/**
+ * 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.google.mail;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.google.api.services.gmail.model.Label;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.camel.component.google.mail.internal.GoogleMailApiCollection;
+import org.apache.camel.component.google.mail.internal.GmailUsersLabelsApiMethod;
+
+/**
+ * Test class for {@link com.google.api.services.gmail.Gmail$Users$Labels} APIs.
+ */
+public class GmailUsersLabelsIntegrationTest extends AbstractGoogleMailTestSupport {
+
+ private static final String CAMEL_TEST_LABEL = "CamelTestLabel";
+ private static final Logger LOG = LoggerFactory.getLogger(GmailUsersLabelsIntegrationTest.class);
+ private static final String PATH_PREFIX = GoogleMailApiCollection.getCollection().getApiName(GmailUsersLabelsApiMethod.class).getName();
+
+ @Test
+ public void testLabels() throws Exception {
+ // using String message body for single parameter "userId"
+ com.google.api.services.gmail.model.ListLabelsResponse labels = requestBody("direct://LIST", CURRENT_USERID);
+
+ String labelId = null;
+ if (getTestLabel(labels) == null) {
+ Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelGoogleMail.userId", CURRENT_USERID);
+ Label label = new Label().setName(CAMEL_TEST_LABEL).setMessageListVisibility("show").setLabelListVisibility("labelShow");
+ // parameter type is com.google.api.services.gmail.model.Label
+ headers.put("CamelGoogleMail.content", label);
+
+ com.google.api.services.gmail.model.Label result = requestBodyAndHeaders("direct://CREATE", null, headers);
+
+ assertNotNull("create result", result);
+ labelId = result.getId();
+ } else {
+ labelId = getTestLabel(labels).getId();
+ }
+
+ // using String message body for single parameter "userId"
+ labels = requestBody("direct://LIST", CURRENT_USERID);
+ assertTrue(getTestLabel(labels) != null);
+
+ Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelGoogleMail.userId", CURRENT_USERID);
+ // parameter type is String
+ headers.put("CamelGoogleMail.id", labelId);
+
+ requestBodyAndHeaders("direct://DELETE", null, headers);
+
+ // using String message body for single parameter "userId"
+ labels = requestBody("direct://LIST", CURRENT_USERID);
+ assertTrue(getTestLabel(labels) == null);
+ }
+
+ private Label getTestLabel(com.google.api.services.gmail.model.ListLabelsResponse labels) {
+ for (Label label : labels.getLabels()) {
+ if (CAMEL_TEST_LABEL.equals(label.getName())) {
+ return label;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ // test route for create
+ from("direct://CREATE")
+ .to("google-mail://" + PATH_PREFIX + "/create");
+
+ // test route for delete
+ from("direct://DELETE")
+ .to("google-mail://" + PATH_PREFIX + "/delete");
+
+ // test route for get
+ from("direct://GET")
+ .to("google-mail://" + PATH_PREFIX + "/get");
+
+ // test route for list
+ from("direct://LIST")
+ .to("google-mail://" + PATH_PREFIX + "/list?inBody=userId");
+
+ // test route for patch
+ from("direct://PATCH")
+ .to("google-mail://" + PATH_PREFIX + "/patch");
+
+ // test route for update
+ from("direct://UPDATE")
+ .to("google-mail://" + PATH_PREFIX + "/update");
+
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/3c6769db/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersMessagesIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersMessagesIntegrationTest.java b/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersMessagesIntegrationTest.java
new file mode 100644
index 0000000..b682ae0
--- /dev/null
+++ b/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersMessagesIntegrationTest.java
@@ -0,0 +1,222 @@
+/**
+ * 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.google.mail;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.mail.MessagingException;
+import javax.mail.Session;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMessage.RecipientType;
+
+import com.google.api.client.repackaged.org.apache.commons.codec.binary.Base64;
+import com.google.api.services.gmail.model.ListMessagesResponse;
+import com.google.api.services.gmail.model.Message;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.camel.component.google.mail.internal.GoogleMailApiCollection;
+import org.apache.camel.component.google.mail.internal.GmailUsersMessagesApiMethod;
+
+/**
+ * Test class for {@link com.google.api.services.gmail.Gmail$Users$Messages} APIs.
+ */
+public class GmailUsersMessagesIntegrationTest extends AbstractGoogleMailTestSupport {
+
+ // userid of the currently authenticated user
+ public static final String CURRENT_USERID = "me";
+ private static final Logger LOG = LoggerFactory.getLogger(GmailUsersMessagesIntegrationTest.class);
+ private static final String PATH_PREFIX = GoogleMailApiCollection.getCollection().getApiName(GmailUsersMessagesApiMethod.class).getName();
+
+ @Test
+ public void testMessages() throws Exception {
+
+ // ==== Send test email ====
+ Message testEmail = createTestEmail();
+ Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelGoogleMail.userId", CURRENT_USERID);
+ // parameter type is com.google.api.services.gmail.model.Message
+ headers.put("CamelGoogleMail.content", testEmail);
+
+ com.google.api.services.gmail.model.Message result = requestBodyAndHeaders("direct://SEND", null, headers);
+ assertNotNull("send result", result);
+ String testEmailId = result.getId();
+
+ // ==== Search for message we just sent ====
+ headers = new HashMap<String, Object>();
+ headers.put("CamelGoogleMail.q", "subject:\"Hello from camel-google-mail\"");
+ // using String message body for single parameter "userId"
+ ListMessagesResponse listOfMessages = requestBody("direct://LIST", CURRENT_USERID);
+ assertTrue(idInList(testEmailId, listOfMessages));
+
+ // ===== trash it ====
+ headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelGoogleMail.userId", CURRENT_USERID);
+ // parameter type is String
+ headers.put("CamelGoogleMail.id", testEmailId);
+ requestBodyAndHeaders("direct://TRASH", null, headers);
+
+ // ==== Search for message we just trashed ====
+ headers = new HashMap<String, Object>();
+ headers.put("CamelGoogleMail.q", "subject:\"Hello from camel-google-mail\"");
+ // using String message body for single parameter "userId"
+ listOfMessages = requestBody("direct://LIST", CURRENT_USERID);
+ assertFalse(idInList(testEmailId, listOfMessages));
+
+ // ===== untrash it ====
+ headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelGoogleMail.userId", CURRENT_USERID);
+ // parameter type is String
+ headers.put("CamelGoogleMail.id", testEmailId);
+ requestBodyAndHeaders("direct://UNTRASH", null, headers);
+
+ // ==== Search for message we just trashed ====
+ headers = new HashMap<String, Object>();
+ headers.put("CamelGoogleMail.q", "subject:\"Hello from camel-google-mail\"");
+ // using String message body for single parameter "userId"
+ listOfMessages = requestBody("direct://LIST", CURRENT_USERID);
+ assertTrue(idInList(testEmailId, listOfMessages));
+
+ // ===== permanently delete it ====
+ headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelGoogleMail.userId", CURRENT_USERID);
+ // parameter type is String
+ headers.put("CamelGoogleMail.id", testEmailId);
+ requestBodyAndHeaders("direct://DELETE", null, headers);
+
+ // ==== Search for message we just deleted ====
+ headers = new HashMap<String, Object>();
+ headers.put("CamelGoogleMail.q", "subject:\"Hello from camel-google-mail\"");
+ // using String message body for single parameter "userId"
+ listOfMessages = requestBody("direct://LIST", CURRENT_USERID);
+ assertFalse(idInList(testEmailId, listOfMessages));
+ }
+
+ private boolean idInList(String testEmailId, ListMessagesResponse listOfMessages) {
+ assertNotNull("list result", listOfMessages);
+ assertTrue(!listOfMessages.getMessages().isEmpty());
+ boolean foundMessage = false;
+ for (Message m : listOfMessages.getMessages()) {
+ if (testEmailId.equals(m.getId())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private Message createTestEmail() throws MessagingException, IOException {
+ com.google.api.services.gmail.model.Profile profile = requestBody("google-mail://users/getProfile?inBody=userId", CURRENT_USERID);
+ Properties props = new Properties();
+ Session session = Session.getDefaultInstance(props, null);
+ MimeMessage mm = new MimeMessage(session);
+ mm.addRecipients(RecipientType.TO, profile.getEmailAddress());
+ mm.setSubject("Hello from camel-google-mail");
+ mm.setContent("Camel rocks!", "text/plain");
+ Message createMessageWithEmail = createMessageWithEmail(mm);
+ return createMessageWithEmail;
+ }
+
+ private MimeMessage toMimeMessage(Message message) throws MessagingException {
+ byte[] emailBytes = Base64.decodeBase64(message.getRaw());
+
+ Properties props = new Properties();
+ Session session = Session.getDefaultInstance(props, null);
+
+ return new MimeMessage(session, new ByteArrayInputStream(emailBytes));
+ }
+
+ private Message createMessageWithEmail(MimeMessage email)
+ throws MessagingException, IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ email.writeTo(baos);
+ String encodedEmail = Base64.encodeBase64URLSafeString(baos.toByteArray());
+ Message message = new Message();
+ message.setRaw(encodedEmail);
+ return message;
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ // test route for attachments
+ from("direct://ATTACHMENTS")
+ .to("google-mail://" + PATH_PREFIX + "/attachments");
+
+ // test route for delete
+ from("direct://DELETE")
+ .to("google-mail://" + PATH_PREFIX + "/delete");
+
+ // test route for get
+ from("direct://GET")
+ .to("google-mail://" + PATH_PREFIX + "/get");
+
+ // test route for gmailImport
+ from("direct://GMAILIMPORT")
+ .to("google-mail://" + PATH_PREFIX + "/gmailImport");
+
+ // test route for gmailImport
+ from("direct://GMAILIMPORT_1")
+ .to("google-mail://" + PATH_PREFIX + "/gmailImport");
+
+ // test route for insert
+ from("direct://INSERT")
+ .to("google-mail://" + PATH_PREFIX + "/insert");
+
+ // test route for insert
+ from("direct://INSERT_1")
+ .to("google-mail://" + PATH_PREFIX + "/insert");
+
+ // test route for list
+ from("direct://LIST")
+ .to("google-mail://" + PATH_PREFIX + "/list?inBody=userId");
+
+ // test route for modify
+ from("direct://MODIFY")
+ .to("google-mail://" + PATH_PREFIX + "/modify");
+
+ // test route for send
+ from("direct://SEND")
+ .to("google-mail://" + PATH_PREFIX + "/send");
+
+ // test route for send
+ from("direct://SEND_1")
+ .to("google-mail://" + PATH_PREFIX + "/send");
+
+ // test route for trash
+ from("direct://TRASH")
+ .to("google-mail://" + PATH_PREFIX + "/trash");
+
+ // test route for untrash
+ from("direct://UNTRASH")
+ .to("google-mail://" + PATH_PREFIX + "/untrash");
+
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/3c6769db/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersThreadsIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersThreadsIntegrationTest.java b/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersThreadsIntegrationTest.java
new file mode 100644
index 0000000..023be8c
--- /dev/null
+++ b/components/camel-google-mail/src/test/java/org/apache/camel/component/google/mail/GmailUsersThreadsIntegrationTest.java
@@ -0,0 +1,136 @@
+/**
+ * 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.google.mail;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.mail.MessagingException;
+import javax.mail.Session;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMessage.RecipientType;
+
+import com.google.api.client.repackaged.org.apache.commons.codec.binary.Base64;
+import com.google.api.services.gmail.model.Message;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.camel.component.google.mail.internal.GoogleMailApiCollection;
+import org.apache.camel.component.google.mail.internal.GmailUsersThreadsApiMethod;
+
+/**
+ * Test class for {@link com.google.api.services.gmail.Gmail$Users$Threads} APIs.
+ */
+public class GmailUsersThreadsIntegrationTest extends AbstractGoogleMailTestSupport {
+
+ private static final Logger LOG = LoggerFactory.getLogger(GmailUsersThreadsIntegrationTest.class);
+ private static final String PATH_PREFIX = GoogleMailApiCollection.getCollection().getApiName(GmailUsersThreadsApiMethod.class).getName();
+
+ private Message createThreadedTestEmail(String previousThreadId) throws MessagingException, IOException {
+ com.google.api.services.gmail.model.Profile profile = requestBody("google-mail://users/getProfile?inBody=userId", CURRENT_USERID);
+ Properties props = new Properties();
+ Session session = Session.getDefaultInstance(props, null);
+ MimeMessage mm = new MimeMessage(session);
+ mm.addRecipients(RecipientType.TO, profile.getEmailAddress());
+ mm.setSubject("Hello from camel-google-mail");
+ mm.setContent("Camel rocks!", "text/plain");
+ Message createMessageWithEmail = createMessageWithEmail(mm);
+ if (previousThreadId != null) {
+ createMessageWithEmail.setThreadId(previousThreadId);
+ }
+
+ Map<String, Object> headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelGoogleMail.userId", CURRENT_USERID);
+ // parameter type is com.google.api.services.gmail.model.Message
+ headers.put("CamelGoogleMail.content", createMessageWithEmail);
+
+ return requestBodyAndHeaders("google-mail://messages/send", null, headers);
+ }
+
+ private Message createMessageWithEmail(MimeMessage email)
+ throws MessagingException, IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ email.writeTo(baos);
+ String encodedEmail = Base64.encodeBase64URLSafeString(baos.toByteArray());
+ Message message = new Message();
+ message.setRaw(encodedEmail);
+ return message;
+ }
+
+ @Test
+ public void testList() throws Exception {
+ Message m1 = createThreadedTestEmail(null);
+ Message m2 = createThreadedTestEmail(m1.getThreadId());
+
+ Map<String, Object> headers = new HashMap<String, Object>();
+ headers.put("CamelGoogleMail.q", "subject:\"Hello from camel-google-mail\"");
+
+ // using String message body for single parameter "userId"
+ com.google.api.services.gmail.model.ListThreadsResponse result = requestBodyAndHeaders("direct://LIST", CURRENT_USERID, headers);
+
+ assertNotNull("list result", result);
+ assertTrue(result.getThreads().size() > 0);
+ LOG.debug("list: " + result);
+
+ headers = new HashMap<String, Object>();
+ // parameter type is String
+ headers.put("CamelGoogleMail.userId", CURRENT_USERID);
+ // parameter type is String
+ headers.put("CamelGoogleMail.id", m1.getThreadId());
+
+ requestBodyAndHeaders("direct://DELETE", null, headers);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ // test route for delete
+ from("direct://DELETE")
+ .to("google-mail://" + PATH_PREFIX + "/delete");
+
+ // test route for get
+ from("direct://GET")
+ .to("google-mail://" + PATH_PREFIX + "/get");
+
+ // test route for list
+ from("direct://LIST")
+ .to("google-mail://" + PATH_PREFIX + "/list?inBody=userId");
+
+ // test route for modify
+ from("direct://MODIFY")
+ .to("google-mail://" + PATH_PREFIX + "/modify");
+
+ // test route for trash
+ from("direct://TRASH")
+ .to("google-mail://" + PATH_PREFIX + "/trash");
+
+ // test route for untrash
+ from("direct://UNTRASH")
+ .to("google-mail://" + PATH_PREFIX + "/untrash");
+
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/3c6769db/components/camel-google-mail/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/components/camel-google-mail/src/test/resources/log4j.properties b/components/camel-google-mail/src/test/resources/log4j.properties
new file mode 100644
index 0000000..a937abd
--- /dev/null
+++ b/components/camel-google-mail/src/test/resources/log4j.properties
@@ -0,0 +1,30 @@
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+#
+# The logging properties used
+#
+log4j.rootLogger=INFO, out
+
+# uncomment the following line to turn on Camel debugging
+#log4j.logger.org.apache.camel=DEBUG
+
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
+#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
http://git-wip-us.apache.org/repos/asf/camel/blob/3c6769db/components/camel-google-mail/src/test/resources/test-options.properties
----------------------------------------------------------------------
diff --git a/components/camel-google-mail/src/test/resources/test-options.properties b/components/camel-google-mail/src/test/resources/test-options.properties
new file mode 100644
index 0000000..0c10369
--- /dev/null
+++ b/components/camel-google-mail/src/test/resources/test-options.properties
@@ -0,0 +1,26 @@
+#
+# 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.
+#
+
+#####################################
+## Login properties for Google Mail Component
+#####################################
+## Application client id and secret
+clientId=
+clientSecret=
+applicationName=camel-google-mail/1.0
+accessToken=
+refreshToken=
[3/5] camel git commit: Add camel-google-mail to build
Posted by ja...@apache.org.
Add camel-google-mail to build
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/16b07149
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/16b07149
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/16b07149
Branch: refs/heads/master
Commit: 16b071491e52db906c3617a981f0e814c9a42b29
Parents: 38c0a97
Author: Jonathan Anstey <ja...@gmail.com>
Authored: Tue Dec 2 17:17:31 2014 -0330
Committer: Jonathan Anstey <ja...@gmail.com>
Committed: Tue Dec 2 17:17:31 2014 -0330
----------------------------------------------------------------------
components/pom.xml | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/16b07149/components/pom.xml
----------------------------------------------------------------------
diff --git a/components/pom.xml b/components/pom.xml
index 6fba7c9..7cabf32 100644
--- a/components/pom.xml
+++ b/components/pom.xml
@@ -100,6 +100,7 @@
<module>camel-github</module>
<module>camel-google-calendar</module>
<module>camel-google-drive</module>
+ <module>camel-google-mail</module>
<module>camel-gora</module>
<module>camel-gson</module>
<module>camel-guava-eventbus</module>
[4/5] camel git commit: Add karaf feature for google mail component
Posted by ja...@apache.org.
Add karaf feature for google mail component
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/2696a973
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2696a973
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2696a973
Branch: refs/heads/master
Commit: 2696a973da528164e8b2c6e3e5757bea20bb053e
Parents: 16b0714
Author: Jonathan Anstey <ja...@gmail.com>
Authored: Tue Dec 2 17:24:11 2014 -0330
Committer: Jonathan Anstey <ja...@gmail.com>
Committed: Tue Dec 2 17:24:11 2014 -0330
----------------------------------------------------------------------
apache-camel/pom.xml | 4 ++++
.../src/main/descriptors/common-bin.xml | 1 +
components/camel-google-mail/pom.xml | 24 ++++++++++----------
parent/pom.xml | 5 ++++
.../features/src/main/resources/features.xml | 15 ++++++++++++
5 files changed, 37 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/2696a973/apache-camel/pom.xml
----------------------------------------------------------------------
diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml
index ad7500b..c0ca486 100644
--- a/apache-camel/pom.xml
+++ b/apache-camel/pom.xml
@@ -249,6 +249,10 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-google-mail</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-groovy</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/camel/blob/2696a973/apache-camel/src/main/descriptors/common-bin.xml
----------------------------------------------------------------------
diff --git a/apache-camel/src/main/descriptors/common-bin.xml b/apache-camel/src/main/descriptors/common-bin.xml
index f5422c7..d5d2e1b 100644
--- a/apache-camel/src/main/descriptors/common-bin.xml
+++ b/apache-camel/src/main/descriptors/common-bin.xml
@@ -75,6 +75,7 @@
<include>org.apache.camel:camel-github</include>
<include>org.apache.camel:camel-google-calendar</include>
<include>org.apache.camel:camel-google-drive</include>
+ <include>org.apache.camel:camel-google-mail</include>
<include>org.apache.camel:camel-gora</include>
<include>org.apache.camel:camel-groovy</include>
<include>org.apache.camel:camel-guava-eventbus</include>
http://git-wip-us.apache.org/repos/asf/camel/blob/2696a973/components/camel-google-mail/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-google-mail/pom.xml b/components/camel-google-mail/pom.xml
index f7c0272..3735310 100644
--- a/components/camel-google-mail/pom.xml
+++ b/components/camel-google-mail/pom.xml
@@ -68,18 +68,18 @@
<version>${google-api-services-mail-version}</version>
</dependency>
- <dependency>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
- <version>${javax-mail-version}</version>
- <exclusions>
- <!-- javax activation is part of the JDK now -->
- <exclusion>
- <groupId>javax.activation</groupId>
- <artifactId>activation</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
+ <dependency>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ <version>${javax-mail-version}</version>
+ <exclusions>
+ <!-- javax activation is part of the JDK now -->
+ <exclusion>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<!-- Camel annotations in provided scope to avoid compile errors in IDEs -->
<dependency>
http://git-wip-us.apache.org/repos/asf/camel/blob/2696a973/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 7e61552..8d68457 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -808,6 +808,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-google-mail</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-gora</artifactId>
<version>${project.version}</version>
</dependency>
http://git-wip-us.apache.org/repos/asf/camel/blob/2696a973/platforms/karaf/features/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/platforms/karaf/features/src/main/resources/features.xml b/platforms/karaf/features/src/main/resources/features.xml
index e665774..d335618 100644
--- a/platforms/karaf/features/src/main/resources/features.xml
+++ b/platforms/karaf/features/src/main/resources/features.xml
@@ -443,6 +443,21 @@
<bundle dependency='true'>wrap:mvn:com.google.oauth-client/google-oauth-client-jetty/${google-api-client-version}</bundle>
<bundle>mvn:org.apache.camel/camel-google-drive/${project.version}</bundle>
</feature>
+ <feature name='camel-google-mail' version='${project.version}' resolver='(obr)' start-level='50'>
+ <feature version='${project.version}'>camel-core</feature>
+ <bundle dependency='true'>mvn:commons-codec/commons-codec/${commons-codec-version}</bundle>
+ <bundle dependency='true'>mvn:com.fasterxml.jackson.core/jackson-core/${jackson2-version}</bundle>
+ <bundle dependency='true'>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient/${commons-httpclient-bundle-version}</bundle>
+ <bundle dependency='true'>wrap:mvn:com.google.api-client/google-api-client/${google-api-client-version}</bundle>
+ <bundle dependency='true'>mvn:javax.mail/mail/${javax-mail-version}</bundle>
+ <bundle dependency='true'>wrap:mvn:com.google.apis/google-api-services-gmail/${google-api-services-mail-version}</bundle>
+ <bundle dependency='true'>wrap:mvn:com.google.http-client/google-http-client/${google-api-client-version}</bundle>
+ <bundle dependency='true'>wrap:mvn:com.google.http-client/google-http-client-jackson2/${google-api-client-version}</bundle>
+ <bundle dependency='true'>wrap:mvn:com.google.oauth-client/google-oauth-client/${google-api-client-version}</bundle>
+ <bundle dependency='true'>wrap:mvn:com.google.oauth-client/google-oauth-client-java6/${google-api-client-version}</bundle>
+ <bundle dependency='true'>wrap:mvn:com.google.oauth-client/google-oauth-client-jetty/${google-api-client-version}</bundle>
+ <bundle>mvn:org.apache.camel/camel-google-mail/${project.version}</bundle>
+ </feature>
<feature name='camel-groovy' version='${project.version}' resolver='(obr)' start-level='50'>
<feature version='${project.version}'>camel-core</feature>
<bundle dependency='true'>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.ant/${ant-bundle-version}</bundle>
[5/5] camel git commit: Add karaf itest for camel-google-mail
Posted by ja...@apache.org.
Add karaf itest for camel-google-mail
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/4b45630f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/4b45630f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/4b45630f
Branch: refs/heads/master
Commit: 4b45630f6ca11dfb5bca1cf346378c7e1fea5f69
Parents: 2696a97
Author: Jonathan Anstey <ja...@gmail.com>
Authored: Tue Dec 2 17:36:04 2014 -0330
Committer: Jonathan Anstey <ja...@gmail.com>
Committed: Tue Dec 2 17:36:04 2014 -0330
----------------------------------------------------------------------
.../camel/itest/karaf/CamelGoogleMailTest.java | 40 ++++++++++++++++++++
1 file changed, 40 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/4b45630f/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelGoogleMailTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelGoogleMailTest.java b/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelGoogleMailTest.java
new file mode 100644
index 0000000..c518625
--- /dev/null
+++ b/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelGoogleMailTest.java
@@ -0,0 +1,40 @@
+/**
+ * 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.itest.karaf;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+
+@RunWith(PaxExam.class)
+public class CamelGoogleMailTest extends AbstractFeatureTest {
+
+ public static final String COMPONENT = extractName(CamelGoogleMailTest.class);
+
+ @Test
+ public void test() throws Exception {
+ testComponent(COMPONENT);
+ }
+
+ @Configuration
+ public static Option[] configure() {
+ return configure(COMPONENT);
+ }
+
+}