forked from wildfly-extras/wildfly-camel
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[resolves wildfly-extras#395] Provide camel-swagger support - WIP
- Loading branch information
Thomas Diesler
committed
May 4, 2015
1 parent
d386efc
commit a9b60e6
Showing
36 changed files
with
450 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 0 additions & 42 deletions
42
itests/common/src/main/java/org/wildfly/camel/test/common/HttpResponse.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
itests/standalone/src/test/java/org/wildfly/camel/test/swagger/SwaggerIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* #%L | ||
* Wildfly Camel :: Testsuite | ||
* %% | ||
* Copyright (C) 2013 - 2015 RedHat | ||
* %% | ||
* Licensed 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. | ||
* #L% | ||
*/ | ||
|
||
package org.wildfly.camel.test.swagger; | ||
|
||
import org.apache.camel.CamelContext; | ||
import org.apache.camel.builder.RouteBuilder; | ||
import org.apache.camel.impl.DefaultCamelContext; | ||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.wildfly.camel.test.common.HttpRequest; | ||
import org.wildfly.camel.test.common.HttpRequest.HttpResponse; | ||
|
||
@RunWith(Arquillian.class) | ||
public class SwaggerIntegrationTest { | ||
|
||
@Deployment | ||
public static WebArchive createDeployment() { | ||
final WebArchive archive = ShrinkWrap.create(WebArchive.class, "swagger-tests.war"); | ||
archive.addAsWebInfResource("swagger/web.xml", "web.xml"); | ||
archive.addClasses(HttpRequest.class); | ||
return archive; | ||
} | ||
|
||
@Test | ||
public void testRestDsl() throws Exception { | ||
CamelContext camelctx = new DefaultCamelContext(); | ||
camelctx.addRoutes(new RouteBuilder() { | ||
@Override | ||
public void configure() throws Exception { | ||
restConfiguration().component("servlet").contextPath("swagger-tests/rest").port(8080); | ||
rest("/hello").get("/{name}").to("direct:hello"); | ||
from("direct:hello").transform(simple("Hello ${header.name}")); | ||
} | ||
}); | ||
|
||
camelctx.start(); | ||
try { | ||
HttpResponse result = HttpRequest.get("http://localhost:8080/swagger-tests/rest/hello/Kermit").getResponse(); | ||
Assert.assertEquals("Hello Kermit", result.getBody()); | ||
|
||
result = HttpRequest.get("http://localhost:8080/swagger-tests/api-docs").getResponse(); | ||
System.out.println(result); | ||
System.out.println(result.getBody()); | ||
} finally { | ||
camelctx.stop(); | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
itests/standalone/src/test/resources/classloading/exported-path-patterns.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<web-app> | ||
|
||
<servlet> | ||
<servlet-name>CamelServlet</servlet-name> | ||
<servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class> | ||
<load-on-startup>1</load-on-startup> | ||
</servlet> | ||
|
||
<servlet> | ||
<servlet-name>ApiDeclarationServlet</servlet-name> | ||
<servlet-class>org.apache.camel.component.swagger.DefaultCamelSwaggerServlet</servlet-class> | ||
<init-param> | ||
<param-name>base.path</param-name> | ||
<param-value>rest</param-value> | ||
</init-param> | ||
<init-param> | ||
<param-name>api.path</param-name> | ||
<param-value>api-docs</param-value> | ||
</init-param> | ||
<init-param> | ||
<param-name>api.version</param-name> | ||
<param-value>1.2.3</param-value> | ||
</init-param> | ||
<init-param> | ||
<param-name>api.title</param-name> | ||
<param-value>User Services</param-value> | ||
</init-param> | ||
<init-param> | ||
<param-name>api.description</param-name> | ||
<param-value>Camel Rest Example with Swagger that provides an User REST service</param-value> | ||
</init-param> | ||
<load-on-startup>2</load-on-startup> | ||
</servlet> | ||
|
||
<servlet-mapping> | ||
<servlet-name>CamelServlet</servlet-name> | ||
<url-pattern>/rest/*</url-pattern> | ||
</servlet-mapping> | ||
<servlet-mapping> | ||
<servlet-name>ApiDeclarationServlet</servlet-name> | ||
<url-pattern>/api-docs/*</url-pattern> | ||
</servlet-mapping> | ||
</web-app> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.