You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ra...@apache.org on 2015/09/13 19:06:21 UTC
[1/3] camel git commit: CAMEL-9129. Add OptionsVerbDefinition. Extend
Rest & VerbDefintion to include OPTIONS. Create unit test
Repository: camel
Updated Branches:
refs/heads/camel-2.15.x 1e2f7dc07 -> 55889c39c
refs/heads/master 36fdb1e5a -> 9c5395b15
CAMEL-9129. Add OptionsVerbDefinition. Extend Rest & VerbDefintion to include OPTIONS. Create unit test
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d307ff12
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d307ff12
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d307ff12
Branch: refs/heads/camel-2.15.x
Commit: d307ff126ac3d4955c1eb804f3d3bce8deeefcff
Parents: 1e2f7dc
Author: Charles Moulliard <cm...@apache.org>
Authored: Sun Sep 13 17:57:34 2015 +0200
Committer: Raul Kripalani <ra...@apache.org>
Committed: Sun Sep 13 17:59:37 2015 +0100
----------------------------------------------------------------------
.../camel/model/rest/OptionsVerbDefinition.java | 33 +++++++++
.../apache/camel/model/rest/RestDefinition.java | 10 +++
.../apache/camel/model/rest/VerbDefinition.java | 2 +
.../component/rest/FromRestOptionsTest.java | 71 ++++++++++++++++++++
4 files changed, 116 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/d307ff12/camel-core/src/main/java/org/apache/camel/model/rest/OptionsVerbDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/OptionsVerbDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/OptionsVerbDefinition.java
new file mode 100644
index 0000000..11a121c
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/OptionsVerbDefinition.java
@@ -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.model.rest;
+
+import org.apache.camel.spi.Metadata;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * Rest OPTIONS command
+ */
+@Metadata(label = "rest")
+@XmlRootElement(name = "options")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class OptionsVerbDefinition extends VerbDefinition {
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/d307ff12/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
index 82633ca..5fcaa21 100644
--- a/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
@@ -208,6 +208,14 @@ public class RestDefinition extends OptionalIdentifiedDefinition<RestDefinition>
return addVerb("head", uri);
}
+ public RestDefinition options() {
+ return addVerb("options", null);
+ }
+
+ public RestDefinition options(String uri) {
+ return addVerb("options", uri);
+ }
+
public RestDefinition verb(String verb) {
return addVerb(verb, null);
}
@@ -412,6 +420,8 @@ public class RestDefinition extends OptionalIdentifiedDefinition<RestDefinition>
answer = new HeadVerbDefinition();
} else if ("put".equals(verb)) {
answer = new PutVerbDefinition();
+ } else if ("options".equals(verb)) {
+ answer = new OptionsVerbDefinition();
} else {
answer = new VerbDefinition();
answer.setMethod(verb);
http://git-wip-us.apache.org/repos/asf/camel/blob/d307ff12/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java
index df053fd..965e43c 100644
--- a/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java
@@ -313,6 +313,8 @@ public class VerbDefinition extends OptionalIdentifiedDefinition<VerbDefinition>
return "delete";
} else if (this instanceof HeadVerbDefinition) {
return "head";
+ } else if (this instanceof OptionsVerbDefinition) {
+ return "options";
} else {
return method;
}
http://git-wip-us.apache.org/repos/asf/camel/blob/d307ff12/camel-core/src/test/java/org/apache/camel/component/rest/FromRestOptionsTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/rest/FromRestOptionsTest.java b/camel-core/src/test/java/org/apache/camel/component/rest/FromRestOptionsTest.java
new file mode 100644
index 0000000..2bff7fc
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/component/rest/FromRestOptionsTest.java
@@ -0,0 +1,71 @@
+/**
+ * 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.rest;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.model.rest.OptionsVerbDefinition;
+import org.apache.camel.model.rest.RestDefinition;
+
+public class FromRestOptionsTest extends ContextTestSupport {
+
+ final static String ALLOWS = "HEAD,GET,PUT,POST,DELETE,OPTIONS";
+
+ @Override
+ protected JndiRegistry createRegistry() throws Exception {
+ JndiRegistry jndi = super.createRegistry();
+ jndi.bind("dummy-rest", new DummyRestConsumerFactory());
+ return jndi;
+ }
+
+ public void testRestOptionsModel() throws Exception {
+
+ RestDefinition rest = context.getRestDefinitions().get(0);
+ assertNotNull(rest);
+ assertEquals("/say/hello", rest.getPath());
+ assertEquals(1, rest.getVerbs().size());
+ assertIsInstanceOf(OptionsVerbDefinition.class, rest.getVerbs().get(0));
+
+ Exchange out = template.request("seda:options-say-hello", new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ exchange.getIn().setBody("Me");
+ }
+ });
+ assertMockEndpointsSatisfied();
+ assertNotNull(out);
+ assertEquals(out.getOut().getHeader("Allow"), ALLOWS);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ restConfiguration().host("localhost");
+ rest("/say/hello")
+ .options()
+ .route()
+ .setHeader(Exchange.HTTP_RESPONSE_CODE, constant(200))
+ .setHeader("Allow", constant(ALLOWS));
+ }
+ };
+ }
+}
[2/3] camel git commit: Fix checkstyle.
Posted by ra...@apache.org.
Fix checkstyle.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/55889c39
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/55889c39
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/55889c39
Branch: refs/heads/camel-2.15.x
Commit: 55889c39cd0b10fc41a9deaae33446499da0287a
Parents: d307ff1
Author: Raul Kripalani <ra...@apache.org>
Authored: Sun Sep 13 18:02:40 2015 +0100
Committer: Raul Kripalani <ra...@apache.org>
Committed: Sun Sep 13 18:02:40 2015 +0100
----------------------------------------------------------------------
.../apache/camel/model/rest/OptionsVerbDefinition.java | 4 ++--
.../camel/component/rest/FromRestOptionsTest.java | 12 ++++++------
2 files changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/55889c39/camel-core/src/main/java/org/apache/camel/model/rest/OptionsVerbDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/OptionsVerbDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/OptionsVerbDefinition.java
index 11a121c..2c4afa3 100644
--- a/camel-core/src/main/java/org/apache/camel/model/rest/OptionsVerbDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/OptionsVerbDefinition.java
@@ -16,12 +16,12 @@
*/
package org.apache.camel.model.rest;
-import org.apache.camel.spi.Metadata;
-
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
+import org.apache.camel.spi.Metadata;
+
/**
* Rest OPTIONS command
*/
http://git-wip-us.apache.org/repos/asf/camel/blob/55889c39/camel-core/src/test/java/org/apache/camel/component/rest/FromRestOptionsTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/rest/FromRestOptionsTest.java b/camel-core/src/test/java/org/apache/camel/component/rest/FromRestOptionsTest.java
index 2bff7fc..7485cb1 100644
--- a/camel-core/src/test/java/org/apache/camel/component/rest/FromRestOptionsTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/rest/FromRestOptionsTest.java
@@ -26,7 +26,7 @@ import org.apache.camel.model.rest.RestDefinition;
public class FromRestOptionsTest extends ContextTestSupport {
- final static String ALLOWS = "HEAD,GET,PUT,POST,DELETE,OPTIONS";
+ static final String ALLOWS = "HEAD,GET,PUT,POST,DELETE,OPTIONS";
@Override
protected JndiRegistry createRegistry() throws Exception {
@@ -44,11 +44,11 @@ public class FromRestOptionsTest extends ContextTestSupport {
assertIsInstanceOf(OptionsVerbDefinition.class, rest.getVerbs().get(0));
Exchange out = template.request("seda:options-say-hello", new Processor() {
- @Override
- public void process(Exchange exchange) throws Exception {
- exchange.getIn().setBody("Me");
- }
- });
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ exchange.getIn().setBody("Me");
+ }
+ });
assertMockEndpointsSatisfied();
assertNotNull(out);
assertEquals(out.getOut().getHeader("Allow"), ALLOWS);
[3/3] camel git commit: Fix checkstyle.
Posted by ra...@apache.org.
Fix checkstyle.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9c5395b1
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9c5395b1
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9c5395b1
Branch: refs/heads/master
Commit: 9c5395b1577e817a5dd2fcc42347a5f174e860f3
Parents: 36fdb1e
Author: Raul Kripalani <ra...@apache.org>
Authored: Sun Sep 13 18:02:40 2015 +0100
Committer: Raul Kripalani <ra...@apache.org>
Committed: Sun Sep 13 18:03:07 2015 +0100
----------------------------------------------------------------------
.../apache/camel/model/rest/OptionsVerbDefinition.java | 4 ++--
.../camel/component/rest/FromRestOptionsTest.java | 12 ++++++------
2 files changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/9c5395b1/camel-core/src/main/java/org/apache/camel/model/rest/OptionsVerbDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/OptionsVerbDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/OptionsVerbDefinition.java
index 11a121c..2c4afa3 100644
--- a/camel-core/src/main/java/org/apache/camel/model/rest/OptionsVerbDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/OptionsVerbDefinition.java
@@ -16,12 +16,12 @@
*/
package org.apache.camel.model.rest;
-import org.apache.camel.spi.Metadata;
-
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
+import org.apache.camel.spi.Metadata;
+
/**
* Rest OPTIONS command
*/
http://git-wip-us.apache.org/repos/asf/camel/blob/9c5395b1/camel-core/src/test/java/org/apache/camel/component/rest/FromRestOptionsTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/rest/FromRestOptionsTest.java b/camel-core/src/test/java/org/apache/camel/component/rest/FromRestOptionsTest.java
index b8409c3..07e03a8 100644
--- a/camel-core/src/test/java/org/apache/camel/component/rest/FromRestOptionsTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/rest/FromRestOptionsTest.java
@@ -32,7 +32,7 @@ import java.util.List;
public class FromRestOptionsTest extends ContextTestSupport {
- final static String ALLOWS = "HEAD,GET,PUT,POST,DELETE,OPTIONS";
+ static final String ALLOWS = "HEAD,GET,PUT,POST,DELETE,OPTIONS";
@Override
protected JndiRegistry createRegistry() throws Exception {
@@ -50,11 +50,11 @@ public class FromRestOptionsTest extends ContextTestSupport {
assertIsInstanceOf(OptionsVerbDefinition.class, rest.getVerbs().get(0));
Exchange out = template.request("seda:options-say-hello", new Processor() {
- @Override
- public void process(Exchange exchange) throws Exception {
- exchange.getIn().setBody("Me");
- }
- });
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ exchange.getIn().setBody("Me");
+ }
+ });
assertMockEndpointsSatisfied();
assertNotNull(out);
assertEquals(out.getOut().getHeader("Allow"), ALLOWS);