camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krass...@apache.org
Subject svn commit: r880672 [2/3] - in /camel/trunk: components/ components/camel-gae/ components/camel-gae/src/ components/camel-gae/src/main/ components/camel-gae/src/main/java/ components/camel-gae/src/main/java/org/ components/camel-gae/src/main/java/org/a...
Date Mon, 16 Nov 2009 08:46:50 GMT
Added: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskEndpoint.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskEndpoint.java (added)
+++ camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskEndpoint.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,126 @@
+/**
+ * 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.gae.task;
+
+import java.lang.reflect.Proxy;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.google.appengine.api.labs.taskqueue.Queue;
+import com.google.appengine.api.labs.taskqueue.TaskOptions;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Producer;
+import org.apache.camel.component.gae.bind.HttpBindingInvocationHandler;
+import org.apache.camel.component.gae.bind.InboundBinding;
+import org.apache.camel.component.gae.bind.OutboundBinding;
+import org.apache.camel.component.gae.bind.OutboundBindingSupport;
+import org.apache.camel.component.http.HttpBinding;
+import org.apache.camel.component.http.HttpClientConfigurer;
+import org.apache.camel.component.servlet.ServletComponent;
+import org.apache.camel.component.servlet.ServletEndpoint;
+import org.apache.commons.httpclient.HttpConnectionManager;
+import org.apache.commons.httpclient.params.HttpClientParams;
+
+/**
+ * Represents a <a href="http://camel.apache.org/todo.html">Google App Engine Task Queueing endpoint</a>.
+ */
+public class GTaskEndpoint extends ServletEndpoint implements OutboundBindingSupport<GTaskEndpoint, TaskOptions, Void> {
+
+    private OutboundBinding<GTaskEndpoint, TaskOptions, Void> outboundBinding;
+    private InboundBinding<GTaskEndpoint, HttpServletRequest, HttpServletResponse> inboundBinding;
+
+    private String workerRoot;
+    
+    private Queue queue;
+    
+    public GTaskEndpoint(String endpointUri, ServletComponent component,
+            URI httpUri, HttpClientParams params,
+            HttpConnectionManager httpConnectionManager,
+            HttpClientConfigurer clientConfigurer) throws URISyntaxException {
+        super(endpointUri, component, httpUri, params, httpConnectionManager, clientConfigurer);
+    }
+
+    public OutboundBinding<GTaskEndpoint, TaskOptions, Void> getOutboundBinding() {
+        return outboundBinding;
+    }
+
+    public void setOutboundBinding(OutboundBinding<GTaskEndpoint, TaskOptions, Void> outboundBinding) {
+        this.outboundBinding = outboundBinding;
+    }
+    
+    public InboundBinding<GTaskEndpoint, HttpServletRequest, HttpServletResponse> getInboundBinding() {
+        return inboundBinding;
+    }
+
+    public void setInboundBinding(
+            InboundBinding<GTaskEndpoint, HttpServletRequest, HttpServletResponse> inboundBinding) {
+        this.inboundBinding = inboundBinding;
+    }
+
+    /**
+     * Proxies the {@link HttpBinding} returned by {@link super#getBinding()}
+     * with a dynamic proxy. The proxy's invocation handler further delegates to
+     * {@link InboundBinding#readRequest(org.apache.camel.Endpoint, Exchange, Object)}
+     * .
+     * 
+     * @return proxied {@link HttpBinding}.
+     */
+    @Override
+    public HttpBinding getBinding() {
+        return (HttpBinding)Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] {HttpBinding.class}, 
+                new HttpBindingInvocationHandler<GTaskEndpoint, HttpServletRequest, HttpServletResponse>(
+                        this, super.getBinding(), getInboundBinding()));
+    }
+
+    /**
+     * @see #setWorkerRoot(String)
+     */
+    public String getWorkerRoot() {
+        return workerRoot;
+    }
+
+    /**
+     * Sets the web hook path root. 
+     *
+     * @param workerRoot
+     *            the assumed web hook path root. The default is
+     *            <code>worker</code>. The servlet handling the callback from
+     *            the task queueing service should have a <code>/worker/*</code>
+     *            servlet mapping in this case. If another servlet mapping is
+     *            used it must be set here accordingly.
+     */
+    public void setWorkerRoot(String workerRoot) {
+        this.workerRoot = workerRoot;
+    }
+
+    public Queue getQueue() {
+        return queue;
+    }
+    
+    public void setQueue(Queue queue) {
+        this.queue = queue;
+    }
+    
+    public Producer createProducer() throws Exception {
+        return new GTaskProducer(this);
+    }
+
+}

Propchange: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskEndpoint.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskEndpointInfo.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskEndpointInfo.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskEndpointInfo.java (added)
+++ camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskEndpointInfo.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,63 @@
+/**
+ * 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.gae.task;
+
+import java.net.URI;
+
+import org.apache.camel.util.UnsafeUriCharactersEncoder;
+
+/**
+ * Encapsulates the required canonicalization logic for <code>gtask</code>
+ * endpoint URIs.
+ */
+class GTaskEndpointInfo {
+
+    private static final String SLASH = "/";
+    private static final String COLON = ":";
+    
+    private String uri;
+    
+    private String uriPath;
+
+    private URI uriObject;
+    
+    public GTaskEndpointInfo(String uri, String uriPath) throws Exception {
+        this.uri = uri;
+        this.uriPath = uriPath;
+        this.uriObject = new URI(UnsafeUriCharactersEncoder.encode(uri));
+    }
+    
+    public String getUri() {
+        return uri;
+    }
+
+    public String getUriPath() {
+        return uriPath;
+    }
+
+    public String getCanonicalUri() {
+        return uriObject.getScheme() + COLON + getCanonicalUriPath();
+    }
+    
+    public String getCanonicalUriPath() {
+        if (uriPath.startsWith(SLASH)) {
+            return uriPath;
+        }
+        return SLASH + uriPath;
+    }
+    
+}

Propchange: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskEndpointInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskProducer.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskProducer.java (added)
+++ camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskProducer.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,54 @@
+/**
+ * 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.gae.task;
+
+import com.google.appengine.api.labs.taskqueue.Queue;
+import com.google.appengine.api.labs.taskqueue.TaskOptions;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.gae.bind.OutboundBinding;
+import org.apache.camel.impl.DefaultProducer;
+
+public class GTaskProducer extends DefaultProducer {
+
+    public GTaskProducer(GTaskEndpoint endpoint) {
+        super(endpoint);
+    }
+
+    @Override
+    public GTaskEndpoint getEndpoint() {
+        return (GTaskEndpoint)super.getEndpoint();
+    }
+    
+    public OutboundBinding<GTaskEndpoint, TaskOptions, Void> getOutboundBinding() {
+        return getEndpoint().getOutboundBinding();
+    }
+    
+    public Queue getQueue() {
+        return getEndpoint().getQueue();
+    }
+    
+    /**
+     * Adds a the <code>exchange</code>'s in-message data to a task queue.
+     * 
+     * @see GTaskBinding
+     */
+    public void process(Exchange exchange) throws Exception {
+        getQueue().add(getOutboundBinding().writeRequest(getEndpoint(), exchange, null));
+    }
+
+}

Propchange: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskProducer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/main/resources/META-INF/services/org/apache/camel/component/ghttp
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/main/resources/META-INF/services/org/apache/camel/component/ghttp?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/main/resources/META-INF/services/org/apache/camel/component/ghttp (added)
+++ camel/trunk/components/camel-gae/src/main/resources/META-INF/services/org/apache/camel/component/ghttp Mon Nov 16 08:45:58 2009
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+class=org.apache.camel.component.gae.http.GHttpComponent

Added: camel/trunk/components/camel-gae/src/main/resources/META-INF/services/org/apache/camel/component/ghttps
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/main/resources/META-INF/services/org/apache/camel/component/ghttps?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/main/resources/META-INF/services/org/apache/camel/component/ghttps (added)
+++ camel/trunk/components/camel-gae/src/main/resources/META-INF/services/org/apache/camel/component/ghttps Mon Nov 16 08:45:58 2009
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+class=org.apache.camel.component.gae.http.GHttpComponent

Added: camel/trunk/components/camel-gae/src/main/resources/META-INF/services/org/apache/camel/component/gmail
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/main/resources/META-INF/services/org/apache/camel/component/gmail?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/main/resources/META-INF/services/org/apache/camel/component/gmail (added)
+++ camel/trunk/components/camel-gae/src/main/resources/META-INF/services/org/apache/camel/component/gmail Mon Nov 16 08:45:58 2009
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+class=org.apache.camel.component.gae.mail.GMailComponent

Added: camel/trunk/components/camel-gae/src/main/resources/META-INF/services/org/apache/camel/component/gtask
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/main/resources/META-INF/services/org/apache/camel/component/gtask?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/main/resources/META-INF/services/org/apache/camel/component/gtask (added)
+++ camel/trunk/components/camel-gae/src/main/resources/META-INF/services/org/apache/camel/component/gtask Mon Nov 16 08:45:58 2009
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+class=org.apache.camel.component.gae.task.GTaskComponent

Added: camel/trunk/components/camel-gae/src/test/java/com/google/appengine/api/labs/taskqueue/TaskOptionsAccessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/test/java/com/google/appengine/api/labs/taskqueue/TaskOptionsAccessor.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/test/java/com/google/appengine/api/labs/taskqueue/TaskOptionsAccessor.java (added)
+++ camel/trunk/components/camel-gae/src/test/java/com/google/appengine/api/labs/taskqueue/TaskOptionsAccessor.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,55 @@
+/**
+ * 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 com.google.appengine.api.labs.taskqueue;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.Map;
+
+public class TaskOptionsAccessor {
+
+    private TaskOptions taskOptions;
+    
+    public TaskOptionsAccessor(TaskOptions taskOptions) {
+        this.taskOptions = taskOptions;
+    }
+    
+    public TaskOptions getTaskOptions() {
+        return taskOptions;
+    }
+    
+    public String getUrl() {
+        return "http://localhost" + getPath();
+    }
+    
+    public String getPath() {
+        return taskOptions.getUrl();
+    }
+    
+    public Map<String, String> getHeaders() {
+        return taskOptions.getHeaders();
+    }
+    
+    public InputStream getPayload() {
+        return new ByteArrayInputStream(taskOptions.getPayload());
+    }
+
+    public String getTaskName() {
+        return taskOptions.getTaskName();
+    }
+    
+}

Propchange: camel/trunk/components/camel-gae/src/test/java/com/google/appengine/api/labs/taskqueue/TaskOptionsAccessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/test/java/com/google/appengine/api/urlfetch/MockHttpResponse.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/test/java/com/google/appengine/api/urlfetch/MockHttpResponse.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/test/java/com/google/appengine/api/urlfetch/MockHttpResponse.java (added)
+++ camel/trunk/components/camel-gae/src/test/java/com/google/appengine/api/urlfetch/MockHttpResponse.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,57 @@
+/**
+ * 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 com.google.appengine.api.urlfetch;
+
+import java.util.List;
+
+@SuppressWarnings("serial")
+public class MockHttpResponse extends HTTPResponse {
+
+    public MockHttpResponse(int responseCode) {
+        super(responseCode);
+    }
+
+    @Override
+    public void addHeader(String name, String value) {
+        super.addHeader(name, value);
+    }
+
+    @Override
+    public byte[] getContent() {
+        return super.getContent();
+    }
+
+    @Override
+    public List<HTTPHeader> getHeaders() {
+        return super.getHeaders();
+    }
+
+    public HTTPHeader getHeader(String name) {
+        for (HTTPHeader header : getHeaders()) {
+            if (header.getName().equalsIgnoreCase(name)) {
+                return header;
+            }
+        }
+        return null;
+    }
+    
+    @Override
+    public void setContent(byte[] content) {
+        super.setContent(content);
+    }
+
+}

Propchange: camel/trunk/components/camel-gae/src/test/java/com/google/appengine/api/urlfetch/MockHttpResponse.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpBindingTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpBindingTest.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpBindingTest.java (added)
+++ camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpBindingTest.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,171 @@
+/**
+ * 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.gae.http;
+
+import java.io.InputStream;
+
+import com.google.appengine.api.urlfetch.HTTPMethod;
+import com.google.appengine.api.urlfetch.HTTPRequest;
+import com.google.appengine.api.urlfetch.MockHttpResponse;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultExchange;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.apache.camel.component.gae.http.GHttpTestUtils.createEndpoint;
+import static org.apache.camel.component.gae.http.GHttpTestUtils.createRequest;
+import static org.apache.camel.component.gae.http.GHttpTestUtils.getCamelContext;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class GHttpBindingTest {
+
+    private static GHttpBinding binding;
+
+    private Exchange exchange;
+    
+    
+    @BeforeClass
+    public static void setUpClass() {
+        binding = new GHttpBinding();
+    }
+    
+    @Before
+    public void setUp() throws Exception {
+        exchange = new DefaultExchange(getCamelContext());
+    }
+
+    @Test
+    public void testGetRequestMethod() {
+        assertEquals(HTTPMethod.GET, binding.getRequestMethod(null, exchange));
+        exchange.getIn().setBody("test");
+        assertEquals(HTTPMethod.POST, binding.getRequestMethod(null, exchange));
+        exchange.getIn().setHeader(Exchange.HTTP_METHOD, "DELETE");
+        assertEquals(HTTPMethod.DELETE, binding.getRequestMethod(null, exchange));
+    }
+    
+    @Test
+    public void testGetRequestUrl() throws Exception {
+        GHttpEndpoint endpoint = createEndpoint("ghttp://somewhere.com:9090/path");
+        assertEquals("http://somewhere.com:9090/path", binding.getRequestUrl(endpoint, exchange).toString());
+        exchange.getIn().setHeader(Exchange.HTTP_URI, "http://custom.org:8080/path");
+        assertEquals("http://somewhere.com:9090/path", binding.getRequestUrl(endpoint, exchange).toString());
+        endpoint = createEndpoint("ghttp://somewhere.com:9090/path?bridgeEndpoint=false");
+        assertEquals("http://custom.org:8080/path", binding.getRequestUrl(endpoint, exchange).toString());
+        exchange.getIn().setHeader(Exchange.HTTP_URI, "ghttp://another.org:8080/path");
+        assertEquals("http://another.org:8080/path", binding.getRequestUrl(endpoint, exchange).toString());
+        exchange.getIn().removeHeader(Exchange.HTTP_URI);
+        exchange.getIn().setHeader(Exchange.HTTP_QUERY, "a=b");
+        assertEquals("http://somewhere.com:9090/path?a=b", binding.getRequestUrl(endpoint, exchange).toString());
+        exchange.getIn().setHeader(Exchange.HTTP_URI, "http://custom.org:8080/path");
+        assertEquals("http://custom.org:8080/path?a=b", binding.getRequestUrl(endpoint, exchange).toString());
+    }
+    
+    @Test
+    public void testGetRequestUrlEncoding() throws Exception {
+        GHttpEndpoint endpoint = createEndpoint("ghttp://somewhere.com:9090/path?bridgeEndpoint=false&a=b c");
+        assertEquals("http://somewhere.com:9090/path?a=b+c", binding.getRequestUrl(endpoint, exchange).toString());
+        exchange.getIn().setHeader(Exchange.HTTP_QUERY, "x=y z");
+        assertEquals("http://somewhere.com:9090/path?x=y+z", binding.getRequestUrl(endpoint, exchange).toString());
+        exchange.getIn().removeHeader(Exchange.HTTP_QUERY);
+        exchange.getIn().setHeader(Exchange.HTTP_URI, "http://custom.org:8080/path?d=e f");
+        assertEquals("http://custom.org:8080/path?d=e+f", binding.getRequestUrl(endpoint, exchange).toString());
+        exchange.getIn().setHeader(Exchange.HTTP_QUERY, "x=y z");
+        assertEquals("http://custom.org:8080/path?x=y+z", binding.getRequestUrl(endpoint, exchange).toString());
+    }
+    
+    @Test
+    public void testWriteRequestHeaders() throws Exception {
+        GHttpEndpoint endpoint = createEndpoint("ghttp://somewhere.com:9090/path");
+        HTTPRequest request = createRequest();
+        // Shouldn't be filtered out
+        exchange.getIn().setHeader("test", "abc");
+        // Should be filtered out
+        exchange.getIn().setHeader("org.apache.camel.whatever", "xyz");
+        exchange.getIn().setHeader("CamelWhatever", "xyz");
+        exchange.getIn().setHeader(Exchange.HTTP_QUERY, "x=y");
+        binding.writeRequestHeaders(endpoint, exchange, request);
+        assertEquals(1, request.getHeaders().size());
+        assertEquals("test", request.getHeaders().get(0).getName());
+        assertEquals("abc", request.getHeaders().get(0).getValue());
+    }
+
+    @Test
+    public void testWriteRequestBody() throws Exception {
+        HTTPRequest request = createRequest();
+        String body = "abc";
+        exchange.getIn().setBody(body);
+        binding.writeRequestBody(null, exchange, request);
+        assertArrayEquals(body.getBytes(), request.getPayload());
+    }
+    
+    @Test
+    public void testWriteRequest() throws Exception {
+        GHttpEndpoint endpoint = createEndpoint("ghttp://somewhere.com:9090/path");
+        HTTPRequest request = binding.writeRequest(endpoint, exchange, null);
+        assertEquals("http://somewhere.com:9090/path", request.getURL().toString());
+        assertEquals(HTTPMethod.GET, request.getMethod());
+    }
+    
+    @Test
+    public void testReadResponseHeaders() throws Exception {
+        GHttpEndpoint endpoint = createEndpoint("ghttp://somewhere.com:9090/path");
+        MockHttpResponse response = new MockHttpResponse(200);
+        response.addHeader("test", "abc");
+        response.addHeader("content-type", "text/plain");
+        binding.readResponseHeaders(endpoint, exchange, response);
+        assertEquals(200, exchange.getOut().getHeader(Exchange.HTTP_RESPONSE_CODE));
+        assertEquals("abc", exchange.getOut().getHeader("test"));
+        assertEquals("text/plain", exchange.getOut().getHeader("content-type"));
+    }
+    
+    @Test
+    public void testReadResponseBody() throws Exception {
+        MockHttpResponse response = new MockHttpResponse(200);
+        response.setContent("abc".getBytes());
+        binding.readResponseBody(null, exchange, response);
+        InputStream stream = exchange.getOut().getBody(InputStream.class);
+        assertEquals("abc".getBytes()[0], stream.read());
+    }
+    
+    @Test
+    public void testReadNullResponseBody() throws Exception {
+        MockHttpResponse response = new MockHttpResponse(200);
+        binding.readResponseBody(null, exchange, response);
+        InputStream stream = exchange.getOut().getBody(InputStream.class);
+        assertNull(stream);
+    }
+    
+    @Test(expected = GHttpException.class)
+    public void testFailureException() throws Exception {
+        GHttpEndpoint endpoint = createEndpoint("ghttp://somewhere.com:9090/path");
+        MockHttpResponse response = new MockHttpResponse(500);
+        binding.readResponse(endpoint, exchange, response);
+    }
+    
+    @Test
+    public void testFailureNoException() throws Exception {
+        GHttpEndpoint endpoint = createEndpoint("ghttp://somewhere.com:9090/path?throwExceptionOnFailure=false");
+        MockHttpResponse response = new MockHttpResponse(500);
+        binding.readResponse(endpoint, exchange, response);
+        assertEquals(500, exchange.getOut().getHeader(Exchange.HTTP_RESPONSE_CODE));
+    }
+    
+}

Propchange: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpBindingTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpCombinedRouteBuilder.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpCombinedRouteBuilder.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpCombinedRouteBuilder.java (added)
+++ camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpCombinedRouteBuilder.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,35 @@
+/**
+ * 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.gae.http;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+
+public class GHttpCombinedRouteBuilder extends RouteBuilder {
+
+    @Override
+    public void configure() throws Exception {
+        
+        from("ghttp:///test1")
+            .to("ghttp://somewhere.com/test?urlFetchServiceRef=#mockUrlFetchService");
+        
+        from("ghttp:///test2")
+            .setHeader(Exchange.HTTP_URI).constant("http://another.org:1234/abc")
+            .to("ghttp://somewhere.com/test?bridgeEndpoint=false&urlFetchServiceRef=#mockUrlFetchService");
+    }
+
+}

Propchange: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpCombinedRouteBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpCombinedRouteBuilderTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpCombinedRouteBuilderTest.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpCombinedRouteBuilderTest.java (added)
+++ camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpCombinedRouteBuilderTest.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,72 @@
+/**
+ * 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.gae.http;
+
+import java.io.InputStream;
+
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.HttpUnitOptions;
+import com.meterware.httpunit.PostMethodWebRequest;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+import com.meterware.servletunit.ServletRunner;
+import com.meterware.servletunit.ServletUnitClient;
+
+import org.apache.camel.component.gae.support.ServletTestSupport;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.springframework.core.io.ClassPathResource;
+
+import static org.junit.Assert.assertEquals;
+
+public class GHttpCombinedRouteBuilderTest extends ServletTestSupport {
+
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+        String webxml = "org/apache/camel/component/gae/http/web-combined.xml";
+        InputStream is = new ClassPathResource(webxml).getInputStream();
+        servletRunner = new ServletRunner(is, CTX_PATH);
+        HttpUnitOptions.setExceptionsThrownOnErrorStatus(true);
+        is.close();
+    }
+    
+    @Test
+    public void testGet() throws Exception {
+        WebRequest req = new GetMethodWebRequest(createUrl("/test1?test=input1"));
+        ServletUnitClient client = newClient();
+        WebResponse response = client.getResponse(req);
+        assertEquals(200, response.getResponseCode());
+        assertEquals("input1", response.getHeaderField("test"));
+    }
+    
+    @Test
+    public void testPost() throws Exception {
+        WebRequest req = new PostMethodWebRequest(createUrl("/test1"), createInput("input2"), getContentType()); 
+        ServletUnitClient client = newClient();
+        WebResponse response = client.getResponse(req);
+        assertEquals("input2", response.getText());
+    }
+    
+    @Test
+    public void testCustomUrl() throws Exception {
+        WebRequest req = new GetMethodWebRequest(createUrl("/test2"));
+        ServletUnitClient client = newClient();
+        WebResponse response = client.getResponse(req);
+        assertEquals("http://another.org:1234/abc", response.getHeaderField("testUrl"));
+    }
+    
+}

Propchange: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpCombinedRouteBuilderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpEndpointTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpEndpointTest.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpEndpointTest.java (added)
+++ camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpEndpointTest.java Mon Nov 16 08:45:58 2009
@@ -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.gae.http;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.apache.camel.component.gae.http.GHttpTestUtils.createEndpoint;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class GHttpEndpointTest {
+
+    private static final String AMP = "&";
+    
+    @Before
+    public void setUp() throws Exception {
+    }
+
+    @Test
+    public void testGetEndpointUrl() throws Exception {
+        GHttpEndpoint endpoint1 = createEndpoint("ghttp://somewhere.com/path?a=b");
+        GHttpEndpoint endpoint2 = createEndpoint("ghttps://somewhere.com/path?a=b");
+        GHttpEndpoint endpoint3 = createEndpoint("xhttps://somewhere.com/path?a=b");
+        
+        assertEquals("http://somewhere.com/path?a=b", endpoint1.getEndpointUrl().toString());
+        assertEquals("https://somewhere.com/path?a=b", endpoint2.getEndpointUrl().toString());
+        assertEquals("http://somewhere.com/path?a=b", endpoint3.getEndpointUrl().toString());
+    }
+    
+    @Test
+    public void testPropertiesDefault() throws Exception {
+        GHttpEndpoint endpoint = createEndpoint("ghttp://somewhere.com/path?a=b");
+        assertTrue(endpoint.getOutboundBinding().getClass().equals(GHttpBinding.class));
+        assertFalse(endpoint.getUrlFetchService() instanceof MockUrlFetchService);
+    }
+    
+    @Test
+    public void testPropertiesCustom() throws Exception {
+        StringBuffer buffer = new StringBuffer("ghttp://somewhere.com/path")
+            .append("?").append("a=b")
+            .append(AMP).append("bridgeEndpoint=false")
+            .append(AMP).append("urlFetchServiceRef=#mockUrlFetchService")
+            .append(AMP).append("outboundBindingRef=#customBinding")
+            .append(AMP).append("throwExceptionOnFailure=false");
+        GHttpEndpoint endpoint = createEndpoint(buffer.toString());
+        assertFalse(endpoint.getOutboundBinding().getClass().equals(GHttpBinding.class));
+        assertTrue(endpoint.getOutboundBinding() instanceof GHttpBinding);
+        assertTrue(endpoint.getUrlFetchService() instanceof MockUrlFetchService);
+        assertEquals("ghttp://somewhere.com/path?a=b", endpoint.getEndpointUri());
+    }
+    
+}

Propchange: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpEndpointTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpInboundRouteBuilder.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpInboundRouteBuilder.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpInboundRouteBuilder.java (added)
+++ camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpInboundRouteBuilder.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,33 @@
+/**
+ * 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.gae.http;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class GHttpInboundRouteBuilder extends RouteBuilder {
+
+    @Override
+    public void configure() throws Exception {
+        
+        // use for GET
+        from("ghttp:///test1").transform().header("test");
+        // use for POST
+        from("ghttp:///test2").transform().body();
+        
+    }
+
+}

Propchange: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpInboundRouteBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpInboundRouteBuilderTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpInboundRouteBuilderTest.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpInboundRouteBuilderTest.java (added)
+++ camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpInboundRouteBuilderTest.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,63 @@
+/**
+ * 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.gae.http;
+
+import java.io.InputStream;
+
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.HttpUnitOptions;
+import com.meterware.httpunit.PostMethodWebRequest;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+import com.meterware.servletunit.ServletRunner;
+import com.meterware.servletunit.ServletUnitClient;
+
+import org.apache.camel.component.gae.support.ServletTestSupport;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.springframework.core.io.ClassPathResource;
+
+import static org.junit.Assert.assertEquals;
+
+public class GHttpInboundRouteBuilderTest extends ServletTestSupport {
+
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+        String webxml = "org/apache/camel/component/gae/http/web-inbound.xml";
+        InputStream is = new ClassPathResource(webxml).getInputStream();
+        servletRunner = new ServletRunner(is, CTX_PATH);
+        HttpUnitOptions.setExceptionsThrownOnErrorStatus(true);
+        is.close();
+    }
+    
+    @Test
+    public void testGet() throws Exception {
+        WebRequest req = new GetMethodWebRequest(createUrl("/test1?test=input1"));
+        ServletUnitClient client = newClient();
+        WebResponse response = client.getResponse(req);
+        assertEquals("input1", response.getText());
+    }
+    
+    @Test
+    public void testPost() throws Exception {
+        WebRequest req = new PostMethodWebRequest(createUrl("/test2"), createInput("input2"), getContentType()); 
+        ServletUnitClient client = newClient();
+        WebResponse response = client.getResponse(req);
+        assertEquals("input2", response.getText());
+    }
+    
+}

Propchange: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpInboundRouteBuilderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpOutboundRouteBuilder.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpOutboundRouteBuilder.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpOutboundRouteBuilder.java (added)
+++ camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpOutboundRouteBuilder.java Mon Nov 16 08:45:58 2009
@@ -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.
+ */
+package org.apache.camel.component.gae.http;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class GHttpOutboundRouteBuilder extends RouteBuilder {
+
+    @Override
+    public void configure() throws Exception {
+
+        from("direct:input1").to("ghttp://somewhere.com/test?a=b&urlFetchServiceRef=#mockUrlFetchService");
+        
+    }
+
+}

Propchange: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpOutboundRouteBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpOutboundRouteBuilderTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpOutboundRouteBuilderTest.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpOutboundRouteBuilderTest.java (added)
+++ camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpOutboundRouteBuilderTest.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,72 @@
+/**
+ * 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.gae.http;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.ProducerTemplate;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = {"/org/apache/camel/component/gae/http/context-outbound.xml"})
+public class GHttpOutboundRouteBuilderTest {
+
+    @Autowired
+    private ProducerTemplate producerTemplate;
+
+    @Before
+    public void setUp() throws Exception {
+    }
+
+    @Test
+    public void testPost() {
+        Exchange result = producerTemplate.request("direct:input1", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setBody("testBody1");
+                exchange.getIn().setHeader("test", "testHeader1");
+            }
+        });
+        assertEquals("testBody1", result.getOut().getBody(String.class));
+        assertEquals("testHeader1", result.getOut().getHeader("test"));
+        assertEquals("a=b", result.getOut().getHeader("testQuery"));
+        assertEquals("POST", result.getOut().getHeader("testMethod"));
+        assertEquals(200, result.getOut().getHeader(Exchange.HTTP_RESPONSE_CODE));
+    }
+    
+    @Test
+    public void testGet() {
+        Exchange result = producerTemplate.request("direct:input1", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader("test", "testHeader1");
+            }
+        });
+        assertNull(result.getOut().getBody());
+        assertEquals("testHeader1", result.getOut().getHeader("test"));
+        assertEquals("a=b", result.getOut().getHeader("testQuery"));
+        assertEquals("GET", result.getOut().getHeader("testMethod"));
+        assertEquals(200, result.getOut().getHeader(Exchange.HTTP_RESPONSE_CODE));
+    }
+    
+}

Propchange: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpOutboundRouteBuilderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpTestUtils.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpTestUtils.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpTestUtils.java (added)
+++ camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpTestUtils.java Mon Nov 16 08:45:58 2009
@@ -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.gae.http;
+
+import java.net.URL;
+
+import com.google.appengine.api.urlfetch.HTTPRequest;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.SimpleRegistry;
+
+public final class GHttpTestUtils {
+
+    private static CamelContext context;
+    private static GHttpComponent component;
+
+    static {
+        SimpleRegistry registry = new SimpleRegistry();
+        registry.put("mockUrlFetchService", new MockUrlFetchService());
+        registry.put("customBinding", new GHttpBinding() { }); // subclass
+        context = new DefaultCamelContext(registry);
+        component = new GHttpComponent();
+        component.setCamelContext(context);
+    }
+    
+    private GHttpTestUtils() {
+    }
+    
+    public static CamelContext getCamelContext() {
+        return context;
+    }
+    
+    public static GHttpEndpoint createEndpoint(String endpointUri) throws Exception {
+        return (GHttpEndpoint)component.createEndpoint(endpointUri);
+    }
+    
+    public static HTTPRequest createRequest() throws Exception {
+        return createRequest("http://localhost:8080");
+    }
+    
+    public static HTTPRequest createRequest(String url) throws Exception {
+        return new HTTPRequest(new URL(url));
+    }
+    
+}

Propchange: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpTestUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/MockUrlFetchService.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/MockUrlFetchService.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/MockUrlFetchService.java (added)
+++ camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/MockUrlFetchService.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,46 @@
+/**
+ * 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.gae.http;
+
+import java.io.IOException;
+import java.net.URL;
+
+import com.google.appengine.api.urlfetch.HTTPHeader;
+import com.google.appengine.api.urlfetch.HTTPRequest;
+import com.google.appengine.api.urlfetch.HTTPResponse;
+import com.google.appengine.api.urlfetch.MockHttpResponse;
+import com.google.appengine.api.urlfetch.URLFetchService;
+
+public class MockUrlFetchService implements URLFetchService {
+
+    public HTTPResponse fetch(URL url) throws IOException {
+        throw new UnsupportedOperationException("not impemented");
+    }
+
+    public HTTPResponse fetch(HTTPRequest request) throws IOException {
+        MockHttpResponse response = new MockHttpResponse(200);
+        response.setContent(request.getPayload());
+        response.addHeader("testUrl", request.getURL().toString());
+        response.addHeader("testQuery", request.getURL().getQuery());
+        response.addHeader("testMethod", request.getMethod().toString());
+        for (HTTPHeader header : request.getHeaders()) {
+            response.addHeader(header.getName(), header.getValue());
+        }
+        return response;
+    }
+
+}

Propchange: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/MockUrlFetchService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/GMailBindingTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/GMailBindingTest.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/GMailBindingTest.java (added)
+++ camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/GMailBindingTest.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,85 @@
+/**
+ * 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.gae.mail;
+
+import com.google.appengine.api.mail.MailService.Message;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultExchange;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.apache.camel.component.gae.mail.GMailTestUtils.createEndpoint;
+import static org.apache.camel.component.gae.mail.GMailTestUtils.createMessage;
+import static org.apache.camel.component.gae.mail.GMailTestUtils.getCamelContext;
+import static org.junit.Assert.assertEquals;
+
+public class GMailBindingTest {
+
+    private static GMailBinding binding;
+
+    private static GMailEndpoint endpoint;
+    
+    private Exchange exchange;
+    
+    private Message message;
+    
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+        binding = new GMailBinding();
+        endpoint = createEndpoint("gmail:user1@gmail.com?to=user2@gmail.com&subject=test");
+    }
+    
+    @Before
+    public void setUp() throws Exception {
+        exchange = new DefaultExchange(getCamelContext());
+        message = createMessage();
+    }
+
+    @Test
+    public void testWriteFrom() {
+        binding.writeFrom(endpoint, exchange, message);
+        assertEquals("user1@gmail.com", message.getSender());
+    }
+    
+    @Test
+    public void testWriteTo() {
+        binding.writeTo(endpoint, exchange, message);
+        assertEquals("user2@gmail.com", message.getTo().iterator().next());
+        exchange.getIn().setHeader(GMailBinding.GMAIL_TO, "user3@gmail.com");
+        binding.writeTo(endpoint, exchange, message);
+        assertEquals("user3@gmail.com", message.getTo().iterator().next());
+    }
+    
+    @Test
+    public void testWriteSubject() {
+        binding.writeSubject(endpoint, exchange, message);
+        assertEquals("test", message.getSubject());
+        exchange.getIn().setHeader(GMailBinding.GMAIL_SUBJECT, "another");
+        binding.writeSubject(endpoint, exchange, message);
+        assertEquals("another", message.getSubject());
+    }
+    
+    @Test
+    public void testWriteBody() {
+        exchange.getIn().setBody("test");
+        binding.writeBody(endpoint, exchange, message);
+        assertEquals("test", message.getTextBody());
+    }
+    
+}

Propchange: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/GMailBindingTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/GMailEndpointTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/GMailEndpointTest.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/GMailEndpointTest.java (added)
+++ camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/GMailEndpointTest.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,46 @@
+/**
+ * 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.gae.mail;
+
+import org.junit.Test;
+
+import static org.apache.camel.component.gae.mail.GMailTestUtils.createEndpoint;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class GMailEndpointTest {
+
+    private static final String AMP = "&";
+    
+    @Test
+    public void testPropertiesCustom() throws Exception {
+        StringBuffer buffer = new StringBuffer("gmail:user1@gmail.com")
+            .append("?").append("subject=test")
+            .append(AMP).append("to=user2@gmail.com")
+            .append(AMP).append("mailServiceRef=#mockMailService")
+            .append(AMP).append("outboundBindingRef=#customBinding");
+        GMailEndpoint endpoint = createEndpoint(buffer.toString());
+        assertEquals("test", endpoint.getSubject());
+        assertEquals("user1@gmail.com", endpoint.getSender());
+        assertEquals("user2@gmail.com", endpoint.getTo());
+        assertFalse(endpoint.getOutboundBinding().getClass().equals(GMailBinding.class));
+        assertTrue(endpoint.getOutboundBinding() instanceof GMailBinding);
+        assertTrue(endpoint.getMailService() instanceof MockMailService);
+    }
+
+}

Propchange: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/GMailEndpointTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/GMailOutboundRouteBuilder.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/GMailOutboundRouteBuilder.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/GMailOutboundRouteBuilder.java (added)
+++ camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/GMailOutboundRouteBuilder.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,31 @@
+/**
+ * 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.gae.mail;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class GMailOutboundRouteBuilder extends RouteBuilder {
+
+    @Override
+    public void configure() throws Exception {
+
+        from("direct:input1")
+            .to("gmail:test1@example.org?to=test2@example.org&subject=testSubject&mailServiceRef=#mockMailService");
+        
+    }
+
+}

Propchange: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/GMailOutboundRouteBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/GMailOutboundRouteBuilderTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/GMailOutboundRouteBuilderTest.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/GMailOutboundRouteBuilderTest.java (added)
+++ camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/GMailOutboundRouteBuilderTest.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,87 @@
+/**
+ * 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.gae.mail;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.ProducerTemplate;
+import org.junit.After;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import static org.apache.camel.component.gae.mail.GMailBinding.GMAIL_SUBJECT;
+import static org.apache.camel.component.gae.mail.GMailBinding.GMAIL_TO;
+import static org.junit.Assert.assertEquals;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = {"/org/apache/camel/component/gae/mail/context-outbound.xml"})
+public class GMailOutboundRouteBuilderTest {
+
+    
+    
+    @Autowired
+    private ProducerTemplate producerTemplate;
+    
+    @Autowired
+    private MockMailService mailService;
+    
+    @After
+    public void tearDown() throws Exception {
+        mailService.reset();
+    }
+
+    @Test
+    public void testSendDefault() {
+        producerTemplate.sendBody("direct:input1", "testBody"); 
+        assertEquals("testSubject", mailService.getFirstMessage().getSubject());
+        assertEquals("testBody", mailService.getFirstMessage().getTextBody());
+        assertEquals("test1@example.org", mailService.getFirstMessage().getSender());
+        assertEquals("test2@example.org", mailService.getFirstMessage().getTo().iterator().next());
+    }
+
+    @Test
+    public void testSendCustomTo() {
+        producerTemplate.send("direct:input1", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setBody("testBody");
+                exchange.getIn().setHeader(GMAIL_TO, "test3@example.org");
+            }
+        });
+        assertEquals("testSubject", mailService.getFirstMessage().getSubject());
+        assertEquals("testBody", mailService.getFirstMessage().getTextBody());
+        assertEquals("test1@example.org", mailService.getFirstMessage().getSender());
+        assertEquals("test3@example.org", mailService.getFirstMessage().getTo().iterator().next());
+    }
+    
+    @Test
+    public void testSendCustomSubject() {
+        producerTemplate.send("direct:input1", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setBody("testBody");
+                exchange.getIn().setHeader(GMAIL_SUBJECT, "anotherSubject");
+            }
+        });
+        assertEquals("anotherSubject", mailService.getFirstMessage().getSubject());
+        assertEquals("testBody", mailService.getFirstMessage().getTextBody());
+        assertEquals("test1@example.org", mailService.getFirstMessage().getSender());
+        assertEquals("test2@example.org", mailService.getFirstMessage().getTo().iterator().next());
+    }
+    
+}

Propchange: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/GMailOutboundRouteBuilderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/GMailTestUtils.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/GMailTestUtils.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/GMailTestUtils.java (added)
+++ camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/GMailTestUtils.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,54 @@
+/**
+ * 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.gae.mail;
+
+import com.google.appengine.api.mail.MailService.Message;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.SimpleRegistry;
+
+public final class GMailTestUtils {
+
+    private static CamelContext context;
+    private static GMailComponent component;
+
+    static {
+        SimpleRegistry registry = new SimpleRegistry();
+        registry.put("mockMailService", new MockMailService());
+        registry.put("customBinding", new GMailBinding() { });  // subclass
+        context = new DefaultCamelContext(registry);
+        component = new GMailComponent();
+        component.setCamelContext(context);
+    }
+
+    private GMailTestUtils() {
+    }
+    
+    public static CamelContext getCamelContext() {
+        return context;
+    }
+    
+    public static GMailEndpoint createEndpoint(String endpointUri) throws Exception {
+        return (GMailEndpoint)component.createEndpoint(endpointUri);
+    }
+    
+    public static Message createMessage() throws Exception {
+        return new Message();
+    }
+    
+}

Propchange: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/GMailTestUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/MockMailService.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/MockMailService.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/MockMailService.java (added)
+++ camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/MockMailService.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,51 @@
+/**
+ * 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.gae.mail;
+
+import java.io.IOException;
+import java.util.LinkedList;
+
+import com.google.appengine.api.mail.MailService;
+
+public class MockMailService implements MailService {
+
+    private LinkedList<Message> messages;
+    
+    public MockMailService() {
+        this.messages = new LinkedList<Message>();
+    }
+    
+    public void send(Message message) throws IOException {
+        messages.add(message);
+    }
+
+    public void sendToAdmins(Message message) throws IOException {
+        throw new UnsupportedOperationException("not implemented");
+    }
+
+    public Message getFirstMessage() {
+        return getMessage(0);
+    }
+    
+    public Message getMessage(int idx) {
+        return messages.get(idx);
+    }
+    
+    public void reset() {
+        messages.clear();
+    }
+}

Propchange: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/MockMailService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/support/ServletTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/support/ServletTestSupport.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/support/ServletTestSupport.java (added)
+++ camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/support/ServletTestSupport.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,65 @@
+/**
+ * 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.gae.support;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import com.meterware.servletunit.ServletRunner;
+import com.meterware.servletunit.ServletUnitClient;
+
+import org.junit.After;
+import org.junit.Before;
+
+public abstract class ServletTestSupport {
+
+    protected static final String CTX_PATH = "";
+    protected static final String CTX_URL = "http://localhost";
+    
+    protected static ServletRunner servletRunner;
+    
+    @Before
+    public void setUp() throws Exception {
+        // ...
+    }
+    
+    @After
+    public void tearDown() {
+        // ...
+    }
+    
+    protected String getContentType() {
+        return "text/plain; charset=UTF-8";
+    }
+
+    protected static String createUrl(String sub) {
+        return CTX_URL + "/camel" + sub; 
+    }
+    
+    protected static InputStream createInput(String data) {
+        return new ByteArrayInputStream(data.getBytes());
+    }
+    
+    protected static ServletUnitClient newClient() {
+        return servletRunner.newClient();
+    }
+
+    protected static void initServlet() throws Exception {
+        servletRunner.newClient().newInvocation(createUrl("")).getServlet();
+    }
+
+}

Propchange: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/support/ServletTestSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/task/GTaskBindingTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/task/GTaskBindingTest.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/task/GTaskBindingTest.java (added)
+++ camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/task/GTaskBindingTest.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,101 @@
+/**
+ * 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.gae.task;
+
+import com.google.appengine.api.labs.taskqueue.TaskOptionsAccessor;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.http.HttpMessage;
+import org.apache.camel.impl.DefaultExchange;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.springframework.mock.web.MockHttpServletRequest;
+
+import static org.apache.camel.component.gae.http.GHttpTestUtils.getCamelContext;
+import static org.apache.camel.component.gae.task.GTaskTestUtils.createEndpoint;
+import static org.apache.camel.component.gae.task.GTaskTestUtils.createTaskOptionsAccessor;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+public class GTaskBindingTest {
+
+    private static GTaskBinding binding;
+
+    private DefaultExchange exchange;
+
+    private GTaskEndpoint endpoint;
+    
+    private TaskOptionsAccessor accessor;
+    
+    @BeforeClass
+    public static void setUpClass() {
+        binding = new GTaskBinding();
+    }
+    
+    @Before
+    public void setUp() throws Exception {
+        exchange = new DefaultExchange(getCamelContext());
+        accessor = createTaskOptionsAccessor();
+        endpoint = createEndpoint("test");
+    }
+
+    @Test
+    public void testWriteRequestHeaders() throws Exception {
+        exchange.getIn().setHeader("test", "abc");
+        exchange.getIn().setHeader(Exchange.HTTP_QUERY, "x=y");
+        binding.writeRequestHeaders(endpoint, exchange, accessor.getTaskOptions());
+        assertEquals(1, accessor.getHeaders().size());
+        assertEquals("abc", accessor.getHeaders().get("test"));
+    }
+    
+    @Test
+    public void testWriteRequestBody() {
+        exchange.getIn().setBody("test");
+        binding.writeRequestBody(endpoint, exchange, accessor.getTaskOptions());
+        assertEquals("test", exchange.getContext().getTypeConverter().convertTo(String.class, accessor.getPayload()));
+    }
+    
+    @Test
+    public void testWriteRequest() throws Exception {
+        GTaskEndpoint custom = createEndpoint("test?workerRoot=lazy");
+        exchange.getIn().setBody("anything");
+        accessor = new TaskOptionsAccessor(binding.writeRequest(endpoint, exchange, null));
+        assertEquals("/worker/test", accessor.getPath());
+        accessor = new TaskOptionsAccessor(binding.writeRequest(custom, exchange, null));
+        assertEquals("/lazy/test", accessor.getPath());
+    }
+    
+    @Test
+    public void testReadRequest() {
+        exchange.setFromEndpoint(endpoint);
+        MockHttpServletRequest request = new MockHttpServletRequest();
+        HttpMessage message = new HttpMessage(exchange, request, null);
+        request.addHeader(GTaskBinding.GAE_QUEUE_NAME, "a");
+        request.addHeader(GTaskBinding.GAE_TASK_NAME, "b");
+        request.addHeader(GTaskBinding.GAE_RETRY_COUNT, "1");
+        // test invocation of inbound binding via dynamic proxy 
+        endpoint.getBinding().readRequest(request, message);
+        assertEquals("a", message.getHeader(GTaskBinding.GTASK_QUEUE_NAME));
+        assertEquals("b", message.getHeader(GTaskBinding.GTASK_TASK_NAME));
+        assertEquals(1, message.getHeader(GTaskBinding.GTASK_RETRY_COUNT));
+        assertFalse(message.getHeaders().containsKey(GTaskBinding.GAE_QUEUE_NAME));
+        assertFalse(message.getHeaders().containsKey(GTaskBinding.GAE_TASK_NAME));
+        assertFalse(message.getHeaders().containsKey(GTaskBinding.GAE_RETRY_COUNT));
+    }
+    
+}

Propchange: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/task/GTaskBindingTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/task/GTaskCombinedRouteBuilder.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/task/GTaskCombinedRouteBuilder.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/task/GTaskCombinedRouteBuilder.java (added)
+++ camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/task/GTaskCombinedRouteBuilder.java Mon Nov 16 08:45:58 2009
@@ -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.gae.task;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class GTaskCombinedRouteBuilder extends RouteBuilder {
+
+    @Override
+    public void configure() throws Exception {
+        from("direct:input").to("gtask:default?workerRoot=camel&queueRef=#mockQueue");
+        from("gtask:default").to("mock:mock");
+    }
+
+}

Propchange: camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/task/GTaskCombinedRouteBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message