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 2015/04/28 02:38:51 UTC
[1/2] camel git commit: CAMEL-8710 - make auth pluggable for Google
app components
Repository: camel
Updated Branches:
refs/heads/camel-2.15.x d6553d23d -> 3cb822056
refs/heads/master 795cd7d61 -> d57437c66
CAMEL-8710 - make auth pluggable for Google app components
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d57437c6
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d57437c6
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d57437c6
Branch: refs/heads/master
Commit: d57437c663e4218ce2525e0ce6082411e37b00b9
Parents: 795cd7d
Author: Jonathan Anstey <ja...@gmail.com>
Authored: Mon Apr 27 22:07:05 2015 -0230
Committer: Jonathan Anstey <ja...@gmail.com>
Committed: Mon Apr 27 22:07:10 2015 -0230
----------------------------------------------------------------------
.../google/calendar/GoogleCalendarEndpoint.java | 9 +++
.../google/drive/GoogleDriveEndpoint.java | 6 ++
.../google/drive/CustomClientFactoryTest.java | 60 ++++++++++++++++++++
.../component/google/drive/MyClientFactory.java | 34 +++++++++++
.../google/mail/GoogleMailEndpoint.java | 8 +++
5 files changed, 117 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/d57437c6/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/GoogleCalendarEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/GoogleCalendarEndpoint.java b/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/GoogleCalendarEndpoint.java
index 838415c..13c3c87 100644
--- a/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/GoogleCalendarEndpoint.java
+++ b/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/GoogleCalendarEndpoint.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.google.calendar;
import java.util.Map;
import com.google.api.services.calendar.Calendar;
+
import org.apache.camel.Consumer;
import org.apache.camel.Processor;
import org.apache.camel.Producer;
@@ -117,4 +118,12 @@ public class GoogleCalendarEndpoint extends AbstractApiEndpoint<GoogleCalendarAp
public Object getApiProxy(ApiMethod method, Map<String, Object> args) {
return apiProxy;
}
+
+ public GoogleCalendarClientFactory getClientFactory() {
+ return ((GoogleCalendarComponent)getComponent()).getClientFactory();
+ }
+
+ public void setClientFactory(GoogleCalendarClientFactory clientFactory) {
+ ((GoogleCalendarComponent)getComponent()).setClientFactory(clientFactory);
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/d57437c6/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveEndpoint.java b/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveEndpoint.java
index fe2fc92..d6e509c 100644
--- a/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveEndpoint.java
+++ b/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveEndpoint.java
@@ -129,5 +129,11 @@ public class GoogleDriveEndpoint extends AbstractApiEndpoint<GoogleDriveApiName,
return apiProxy;
}
+ public GoogleDriveClientFactory getClientFactory() {
+ return ((GoogleDriveComponent)getComponent()).getClientFactory();
+ }
+ public void setClientFactory(GoogleDriveClientFactory clientFactory) {
+ ((GoogleDriveComponent)getComponent()).setClientFactory(clientFactory);
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/d57437c6/components/camel-google-drive/src/test/java/org/apache/camel/component/google/drive/CustomClientFactoryTest.java
----------------------------------------------------------------------
diff --git a/components/camel-google-drive/src/test/java/org/apache/camel/component/google/drive/CustomClientFactoryTest.java b/components/camel-google-drive/src/test/java/org/apache/camel/component/google/drive/CustomClientFactoryTest.java
new file mode 100644
index 0000000..c009b07
--- /dev/null
+++ b/components/camel-google-drive/src/test/java/org/apache/camel/component/google/drive/CustomClientFactoryTest.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.drive;
+
+
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.google.drive.internal.DriveFilesApiMethod;
+import org.apache.camel.component.google.drive.internal.GoogleDriveApiCollection;
+import org.apache.camel.impl.JndiRegistry;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test class for com.google.api.services.drive.Drive$Files APIs.
+ */
+public class CustomClientFactoryTest extends AbstractGoogleDriveTestSupport {
+
+ private static final Logger LOG = LoggerFactory.getLogger(CustomClientFactoryTest.class);
+ private static final String PATH_PREFIX = GoogleDriveApiCollection.getCollection().getApiName(DriveFilesApiMethod.class).getName();
+
+ @Test
+ public void testClientFactoryUpdated() throws Exception {
+ Endpoint endpoint = context.getEndpoint("google-drive://drive-files/list?clientFactory=#myAuth");
+ assertTrue(endpoint instanceof GoogleDriveEndpoint);
+ assertTrue(((GoogleDriveEndpoint)endpoint).getClientFactory() instanceof MyClientFactory);
+ }
+
+ @Override
+ protected JndiRegistry createRegistry() throws Exception {
+ JndiRegistry registry = super.createRegistry();
+ registry.bind("myAuth", new MyClientFactory());
+ return registry;
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ from("google-drive://drive-files/list?clientFactory=#myAuth").to("mock:result");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/d57437c6/components/camel-google-drive/src/test/java/org/apache/camel/component/google/drive/MyClientFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-google-drive/src/test/java/org/apache/camel/component/google/drive/MyClientFactory.java b/components/camel-google-drive/src/test/java/org/apache/camel/component/google/drive/MyClientFactory.java
new file mode 100644
index 0000000..78d4f32
--- /dev/null
+++ b/components/camel-google-drive/src/test/java/org/apache/camel/component/google/drive/MyClientFactory.java
@@ -0,0 +1,34 @@
+/**
+ * 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.drive;
+
+import java.util.Collection;
+
+import com.google.api.client.http.javanet.NetHttpTransport;
+import com.google.api.client.json.jackson2.JacksonFactory;
+import com.google.api.services.drive.Drive;
+
+public class MyClientFactory implements GoogleDriveClientFactory {
+
+ public MyClientFactory() {
+ }
+
+ @Override
+ public Drive makeClient(String clientId, String clientSecret, Collection<String> scopes, String applicationName, String refreshToken, String accessToken) {
+ return new Drive(new NetHttpTransport(), new JacksonFactory(), null);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/d57437c6/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 fc6e789..55a580a 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
@@ -114,4 +114,12 @@ public class GoogleMailEndpoint extends AbstractApiEndpoint<GoogleMailApiName, G
public Object getApiProxy(ApiMethod method, Map<String, Object> args) {
return apiProxy;
}
+
+ public GoogleMailClientFactory getClientFactory() {
+ return ((GoogleMailComponent)getComponent()).getClientFactory();
+ }
+
+ public void setClientFactory(GoogleMailClientFactory clientFactory) {
+ ((GoogleMailComponent)getComponent()).setClientFactory(clientFactory);
+ }
}
[2/2] camel git commit: CAMEL-8710 - make auth pluggable for Google
app components
Posted by ja...@apache.org.
CAMEL-8710 - make auth pluggable for Google app components
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/3cb82205
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/3cb82205
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/3cb82205
Branch: refs/heads/camel-2.15.x
Commit: 3cb822056ee20142ff6db4ab10f8c341743917df
Parents: d6553d2
Author: Jonathan Anstey <ja...@gmail.com>
Authored: Mon Apr 27 22:07:05 2015 -0230
Committer: Jonathan Anstey <ja...@gmail.com>
Committed: Mon Apr 27 22:08:33 2015 -0230
----------------------------------------------------------------------
.../google/calendar/GoogleCalendarEndpoint.java | 9 +++
.../google/drive/GoogleDriveEndpoint.java | 6 ++
.../google/drive/CustomClientFactoryTest.java | 60 ++++++++++++++++++++
.../component/google/drive/MyClientFactory.java | 34 +++++++++++
.../google/mail/GoogleMailEndpoint.java | 8 +++
5 files changed, 117 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/3cb82205/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/GoogleCalendarEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/GoogleCalendarEndpoint.java b/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/GoogleCalendarEndpoint.java
index 838415c..13c3c87 100644
--- a/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/GoogleCalendarEndpoint.java
+++ b/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/GoogleCalendarEndpoint.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.google.calendar;
import java.util.Map;
import com.google.api.services.calendar.Calendar;
+
import org.apache.camel.Consumer;
import org.apache.camel.Processor;
import org.apache.camel.Producer;
@@ -117,4 +118,12 @@ public class GoogleCalendarEndpoint extends AbstractApiEndpoint<GoogleCalendarAp
public Object getApiProxy(ApiMethod method, Map<String, Object> args) {
return apiProxy;
}
+
+ public GoogleCalendarClientFactory getClientFactory() {
+ return ((GoogleCalendarComponent)getComponent()).getClientFactory();
+ }
+
+ public void setClientFactory(GoogleCalendarClientFactory clientFactory) {
+ ((GoogleCalendarComponent)getComponent()).setClientFactory(clientFactory);
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/3cb82205/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveEndpoint.java b/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveEndpoint.java
index fe2fc92..d6e509c 100644
--- a/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveEndpoint.java
+++ b/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveEndpoint.java
@@ -129,5 +129,11 @@ public class GoogleDriveEndpoint extends AbstractApiEndpoint<GoogleDriveApiName,
return apiProxy;
}
+ public GoogleDriveClientFactory getClientFactory() {
+ return ((GoogleDriveComponent)getComponent()).getClientFactory();
+ }
+ public void setClientFactory(GoogleDriveClientFactory clientFactory) {
+ ((GoogleDriveComponent)getComponent()).setClientFactory(clientFactory);
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/3cb82205/components/camel-google-drive/src/test/java/org/apache/camel/component/google/drive/CustomClientFactoryTest.java
----------------------------------------------------------------------
diff --git a/components/camel-google-drive/src/test/java/org/apache/camel/component/google/drive/CustomClientFactoryTest.java b/components/camel-google-drive/src/test/java/org/apache/camel/component/google/drive/CustomClientFactoryTest.java
new file mode 100644
index 0000000..c009b07
--- /dev/null
+++ b/components/camel-google-drive/src/test/java/org/apache/camel/component/google/drive/CustomClientFactoryTest.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.drive;
+
+
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.google.drive.internal.DriveFilesApiMethod;
+import org.apache.camel.component.google.drive.internal.GoogleDriveApiCollection;
+import org.apache.camel.impl.JndiRegistry;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test class for com.google.api.services.drive.Drive$Files APIs.
+ */
+public class CustomClientFactoryTest extends AbstractGoogleDriveTestSupport {
+
+ private static final Logger LOG = LoggerFactory.getLogger(CustomClientFactoryTest.class);
+ private static final String PATH_PREFIX = GoogleDriveApiCollection.getCollection().getApiName(DriveFilesApiMethod.class).getName();
+
+ @Test
+ public void testClientFactoryUpdated() throws Exception {
+ Endpoint endpoint = context.getEndpoint("google-drive://drive-files/list?clientFactory=#myAuth");
+ assertTrue(endpoint instanceof GoogleDriveEndpoint);
+ assertTrue(((GoogleDriveEndpoint)endpoint).getClientFactory() instanceof MyClientFactory);
+ }
+
+ @Override
+ protected JndiRegistry createRegistry() throws Exception {
+ JndiRegistry registry = super.createRegistry();
+ registry.bind("myAuth", new MyClientFactory());
+ return registry;
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ from("google-drive://drive-files/list?clientFactory=#myAuth").to("mock:result");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/3cb82205/components/camel-google-drive/src/test/java/org/apache/camel/component/google/drive/MyClientFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-google-drive/src/test/java/org/apache/camel/component/google/drive/MyClientFactory.java b/components/camel-google-drive/src/test/java/org/apache/camel/component/google/drive/MyClientFactory.java
new file mode 100644
index 0000000..78d4f32
--- /dev/null
+++ b/components/camel-google-drive/src/test/java/org/apache/camel/component/google/drive/MyClientFactory.java
@@ -0,0 +1,34 @@
+/**
+ * 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.drive;
+
+import java.util.Collection;
+
+import com.google.api.client.http.javanet.NetHttpTransport;
+import com.google.api.client.json.jackson2.JacksonFactory;
+import com.google.api.services.drive.Drive;
+
+public class MyClientFactory implements GoogleDriveClientFactory {
+
+ public MyClientFactory() {
+ }
+
+ @Override
+ public Drive makeClient(String clientId, String clientSecret, Collection<String> scopes, String applicationName, String refreshToken, String accessToken) {
+ return new Drive(new NetHttpTransport(), new JacksonFactory(), null);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/3cb82205/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 fc6e789..55a580a 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
@@ -114,4 +114,12 @@ public class GoogleMailEndpoint extends AbstractApiEndpoint<GoogleMailApiName, G
public Object getApiProxy(ApiMethod method, Map<String, Object> args) {
return apiProxy;
}
+
+ public GoogleMailClientFactory getClientFactory() {
+ return ((GoogleMailComponent)getComponent()).getClientFactory();
+ }
+
+ public void setClientFactory(GoogleMailClientFactory clientFactory) {
+ ((GoogleMailComponent)getComponent()).setClientFactory(clientFactory);
+ }
}