You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2015/05/06 10:02:22 UTC
camel git commit: CAMEL-8745 Fixed the issue of Swagger requires
context name with quotes
Repository: camel
Updated Branches:
refs/heads/master 3626a0391 -> c5fcfcc6c
CAMEL-8745 Fixed the issue of Swagger requires context name with quotes
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/c5fcfcc6
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c5fcfcc6
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c5fcfcc6
Branch: refs/heads/master
Commit: c5fcfcc6c86edf098d7c99f08e6fd09736f99f7f
Parents: 3626a03
Author: Willem Jiang <wi...@gmail.com>
Authored: Wed May 6 16:00:45 2015 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Wed May 6 16:01:03 2015 +0800
----------------------------------------------------------------------
.../swagger/DefaultCamelSwaggerServlet.scala | 5 +++-
.../swagger/DefaultCamelSwaggerServletTest.java | 26 ++++++++++++--------
2 files changed, 20 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/c5fcfcc6/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/DefaultCamelSwaggerServlet.scala
----------------------------------------------------------------------
diff --git a/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/DefaultCamelSwaggerServlet.scala b/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/DefaultCamelSwaggerServlet.scala
index 128cac2..77e9940 100644
--- a/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/DefaultCamelSwaggerServlet.scala
+++ b/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/DefaultCamelSwaggerServlet.scala
@@ -39,7 +39,10 @@ class DefaultCamelSwaggerServlet extends RestSwaggerApiDeclarationServlet {
val names = server.queryNames(new ObjectName("*:type=context,*"), null)
for (name <- names.asScala) {
val on = name.asInstanceOf[ObjectName]
- val id: String = on.getKeyProperty("name")
+ var id: String = on.getKeyProperty("name")
+ if (id.startsWith("\"") && id.endsWith("\"")) {
+ id = id.substring(1, id.length() - 1);
+ }
if (camelId == null || camelId.equals(id)) {
found = on
}
http://git-wip-us.apache.org/repos/asf/camel/blob/c5fcfcc6/components/camel-swagger/src/test/java/org/apache/camel/component/swagger/DefaultCamelSwaggerServletTest.java
----------------------------------------------------------------------
diff --git a/components/camel-swagger/src/test/java/org/apache/camel/component/swagger/DefaultCamelSwaggerServletTest.java b/components/camel-swagger/src/test/java/org/apache/camel/component/swagger/DefaultCamelSwaggerServletTest.java
index a58a4d7..64714ce 100644
--- a/components/camel-swagger/src/test/java/org/apache/camel/component/swagger/DefaultCamelSwaggerServletTest.java
+++ b/components/camel-swagger/src/test/java/org/apache/camel/component/swagger/DefaultCamelSwaggerServletTest.java
@@ -53,9 +53,25 @@ public class DefaultCamelSwaggerServletTest extends CamelTestSupport {
@Test
public void testServlet() throws Exception {
DefaultCamelSwaggerServlet servlet = new DefaultCamelSwaggerServlet();
+
Buffer<RestDefinition> list = servlet.getRestDefinitions(null);
assertEquals(1, list.size());
RestDefinition rest = list.iterator().next();
+ checkRestDefinition(rest);
+
+ // get the RestDefinition by using the camel context id
+ System.out.println(context.getName());
+ list = servlet.getRestDefinitions(context.getName());
+ assertEquals(1, list.size());
+ rest = list.iterator().next();
+ checkRestDefinition(rest);
+
+ RestDefinition rest2 = context.getRestDefinitions().get(0);
+ checkRestDefinition(rest2);
+ }
+
+ private void checkRestDefinition(RestDefinition rest) {
+ assertNotNull(rest);
assertEquals("/hello", rest.getPath());
assertEquals("/hi", rest.getVerbs().get(0).getUri());
assertEquals("get", rest.getVerbs().get(0).asVerb());
@@ -63,16 +79,6 @@ public class DefaultCamelSwaggerServletTest extends CamelTestSupport {
assertEquals("get", rest.getVerbs().get(1).asVerb());
assertEquals("/bye", rest.getVerbs().get(2).getUri());
assertEquals("post", rest.getVerbs().get(2).asVerb());
-
- RestDefinition rest2 = context.getRestDefinitions().get(0);
- assertNotNull(rest2);
- assertEquals("/hello", rest2.getPath());
- assertEquals("/hi", rest2.getVerbs().get(0).getUri());
- assertEquals("get", rest2.getVerbs().get(0).asVerb());
- assertEquals("/bye", rest2.getVerbs().get(1).getUri());
- assertEquals("get", rest2.getVerbs().get(1).asVerb());
- assertEquals("/bye", rest2.getVerbs().get(2).getUri());
- assertEquals("post", rest2.getVerbs().get(2).asVerb());
}
}