-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SWITCHYARD-658] - Added Camel REST quickstart
- Loading branch information
Showing
9 changed files
with
274 additions
and
2 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
39 changes: 39 additions & 0 deletions
39
jboss-as7/modules/src/main/resources/external/apache/cxf/jaxrs/module.xml
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,39 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- | ||
~ JBoss, Home of Professional Open Source. | ||
~ Copyright 2010, Red Hat, Inc., and individual contributors | ||
~ as indicated by the @author tags. See the copyright.txt file in the | ||
~ distribution for a full listing of individual contributors. | ||
~ | ||
~ This is free software; you can redistribute it and/or modify it | ||
~ under the terms of the GNU Lesser General Public License as | ||
~ published by the Free Software Foundation; either version 2.1 of | ||
~ the License, or (at your option) any later version. | ||
~ | ||
~ This software is distributed in the hope that it will be useful, | ||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
~ Lesser General Public License for more details. | ||
~ | ||
~ You should have received a copy of the GNU Lesser General Public | ||
~ License along with this software; if not, write to the Free | ||
~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
--> | ||
|
||
<module xmlns="urn:jboss:module:1.0" name="org.apache.cxf.jaxrs"> | ||
|
||
<resources> | ||
<resource-root path="cxf-rt-frontend-jaxrs-${version.cxf}.jar"/> | ||
</resources> | ||
|
||
<dependencies> | ||
<module name="javax.api"/> | ||
<module name="javax.servlet.api"/> | ||
<module name="javax.annotation.api"/> | ||
<module name="javax.ws.rs.api"/> | ||
<module name="javax.xml.bind.api"/> | ||
<module name="org.apache.cxf"/> | ||
</dependencies> | ||
</module> |
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
51 changes: 51 additions & 0 deletions
51
jboss-as7/modules/src/main/resources/external/camel/cxf/module.xml
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,51 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- | ||
~ JBoss, Home of Professional Open Source. | ||
~ Copyright 2012, Red Hat, Inc., and individual contributors | ||
~ as indicated by the @author tags. See the copyright.txt file in the | ||
~ distribution for a full listing of individual contributors. | ||
~ | ||
~ This is free software; you can redistribute it and/or modify it | ||
~ under the terms of the GNU Lesser General Public License as | ||
~ published by the Free Software Foundation; either version 2.1 of | ||
~ the License, or (at your option) any later version. | ||
~ | ||
~ This software is distributed in the hope that it will be useful, | ||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
~ Lesser General Public License for more details. | ||
~ | ||
~ You should have received a copy of the GNU Lesser General Public | ||
~ License along with this software; if not, write to the Free | ||
~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
--> | ||
|
||
<module xmlns="urn:jboss:module:1.0" name="org.apache.camel.cxf"> | ||
|
||
<resources> | ||
<resource-root path="camel-cxf-${version.camel}.jar"/> | ||
</resources> | ||
|
||
<dependencies> | ||
<module name="javax.api"/> | ||
<module name="javax.ws.rs.api"/> | ||
<module name="javax.xml.soap.api"/> | ||
<module name="org.apache.camel.core"/> | ||
<module name="org.apache.cxf"/> | ||
<module name="org.apache.cxf.jaxrs"/> | ||
<module name="org.jboss.ws.cxf.jbossws-cxf-transports-httpserver" export="true"> | ||
<imports> | ||
<include path="META-INF/cxf"/> | ||
<include path="META-INF/"/> | ||
</imports> | ||
<exports> | ||
<include path="META-INF/cxf"/> | ||
<include path="META-INF/"/> | ||
</exports> | ||
</module> | ||
<module name="org.slf4j"/> | ||
<module name="org.springframework"/> | ||
</dependencies> | ||
</module> |
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
122 changes: 122 additions & 0 deletions
122
.../tests/src/test/java/org/switchyard/test/quickstarts/CamelCxfRsBindingQuickstartTest.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,122 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2012 Red Hat Inc. and/or its affiliates and other contributors | ||
* as indicated by the @authors tag. All rights reserved. | ||
* See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* This copyrighted material is made available to anyone wishing to use, | ||
* modify, copy, or redistribute it subject to the terms and conditions | ||
* of the GNU Lesser General Public License, v. 2.1. | ||
* This program is distributed in the hope that it will be useful, but WITHOUT A | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. | ||
* You should have received a copy of the GNU Lesser General Public License, | ||
* v.2.1 along with this distribution; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
* MA 02110-1301, USA. | ||
*/ | ||
package org.switchyard.test.quickstarts; | ||
|
||
import java.io.IOException; | ||
|
||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.switchyard.test.ArquillianUtil; | ||
import org.switchyard.test.SwitchYardTestKit; | ||
import org.switchyard.test.mixins.HTTPMixIn; | ||
|
||
/** | ||
* Tests for Camel CXFRS binding. | ||
* | ||
* @author Magesh Kumar B <mageshbk@jboss.com> (C) 2012 Red Hat Inc. | ||
*/ | ||
@RunWith(Arquillian.class) | ||
public class CamelCxfRsBindingQuickstartTest { | ||
|
||
@Deployment(testable = false) | ||
public static JavaArchive createDeployment() throws IOException { | ||
return ArquillianUtil.createJarQSDeployment("switchyard-quickstart-camel-rest-binding"); | ||
} | ||
|
||
@Test | ||
public void camelRestBinding() throws IOException { | ||
HTTPMixIn http = new HTTPMixIn(); | ||
http.initialize(); | ||
|
||
// Create our inventory | ||
String response = http.sendString(BASE_URL + "/order/inventory/create", "", HTTPMixIn.HTTP_OPTIONS); | ||
Assert.assertEquals(SUCCESS, response); | ||
|
||
// Create an order | ||
response = http.sendString(BASE_URL + "/order", "", HTTPMixIn.HTTP_POST); | ||
SwitchYardTestKit.compareXMLToString(response, ORDER); | ||
|
||
// Add items | ||
response = http.sendString(BASE_URL + "/order/item", ORDER2, HTTPMixIn.HTTP_PUT); | ||
Assert.assertEquals(SUCCESS, response); | ||
|
||
// Look at our order | ||
response = http.sendString(BASE_URL + "/order/1", "", HTTPMixIn.HTTP_GET); | ||
SwitchYardTestKit.compareXMLToString(response, ORDER3); | ||
|
||
// Delete item | ||
response = http.sendString(BASE_URL + "/order/1:4", ORDER2, HTTPMixIn.HTTP_DELETE); | ||
Assert.assertEquals(SUCCESS, response); | ||
} | ||
|
||
private static final String BASE_URL = "http://localhost:18001"; | ||
private static final String SUCCESS = "Order service is DUMB!"; | ||
private static final String ORDER = "<order>" | ||
+ " <orderId>1</orderId>" | ||
+ "</order>"; | ||
private static final String ORDER2 = "<order>" | ||
+ " <orderId>1</orderId>" | ||
+ " <orderItem>" | ||
+ " <item>" | ||
+ " <itemId>1</itemId>" | ||
+ " </item>" | ||
+ " <quantity>10</quantity>" | ||
+ " </orderItem>" | ||
+ " <orderItem>" | ||
+ " <item>" | ||
+ " <itemId>3</itemId>" | ||
+ " </item>" | ||
+ " <quantity>5</quantity>" | ||
+ " </orderItem>" | ||
+ " <orderItem>" | ||
+ " <item>" | ||
+ " <itemId>4</itemId>" | ||
+ " </item>" | ||
+ " <quantity>3</quantity>" | ||
+ " </orderItem>" | ||
+ "</order>"; | ||
private static final String ORDER3 = "<order>" | ||
+ " <orderId>1</orderId>" | ||
+ " <orderItem>" | ||
+ " <item>" | ||
+ " <itemId>1</itemId>" | ||
+ " <name>Hydrogen Atom - No, we are not kidding!</name>" | ||
+ " </item>" | ||
+ " <quantity>10</quantity>" | ||
+ " </orderItem>" | ||
+ " <orderItem>" | ||
+ " <item>" | ||
+ " <itemId>3</itemId>" | ||
+ " <name>Einstein's Bust - Talks about your future :)</name>" | ||
+ " </item>" | ||
+ " <quantity>5</quantity>" | ||
+ " </orderItem>" | ||
+ " <orderItem>" | ||
+ " <item>" | ||
+ " <itemId>4</itemId>" | ||
+ " <name>Time Machine</name>" | ||
+ " </item>" | ||
+ " <quantity>3</quantity>" | ||
+ " </orderItem>" | ||
+ "</order>"; | ||
} |