Skip to content

Commit

Permalink
[SWITCHYARD-658] - Added Camel REST quickstart
Browse files Browse the repository at this point in the history
  • Loading branch information
mageshbk committed Mar 19, 2012
1 parent 8d9b5a8 commit 0ea261a
Show file tree
Hide file tree
Showing 9 changed files with 274 additions and 2 deletions.
8 changes: 8 additions & 0 deletions jboss-as7/modules/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,14 @@
<groupId>org.apache.camel</groupId>
<artifactId>camel-jms</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-cxf</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
</dependency>
<dependency>
<groupId>org.fusesource.commonman</groupId>
<artifactId>commons-management</artifactId>
Expand Down
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>
26 changes: 26 additions & 0 deletions jboss-as7/modules/src/main/resources/external/assembly.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@
<outputDirectory>/modules/org/jbpm/jbpm-human-task/main</outputDirectory>
<filtered>true</filtered>
</file>
<file>
<source>src/main/resources/external/apache/cxf/jaxrs/module.xml</source>
<outputDirectory>/modules/org/apache/cxf/jaxrs/main</outputDirectory>
<filtered>true</filtered>
</file>
<file>
<source>src/main/resources/external/apache/mina/mina-core/module.xml</source>
<outputDirectory>/modules/org/apache/mina/mina-core/main</outputDirectory>
Expand All @@ -116,6 +121,11 @@
<outputDirectory>/modules/org/apache/camel/core/main</outputDirectory>
<filtered>true</filtered>
</file>
<file>
<source>src/main/resources/external/camel/cxf/module.xml</source>
<outputDirectory>/modules/org/apache/camel/cxf/main</outputDirectory>
<filtered>true</filtered>
</file>
<file>
<source>src/main/resources/external/camel/spring/module.xml</source>
<outputDirectory>/modules/org/apache/camel/spring/main</outputDirectory>
Expand Down Expand Up @@ -302,6 +312,14 @@
<outputDirectory>/modules/org/jbpm/jbpm-persistence-jpa/main</outputDirectory>
<outputFileNameMapping>${artifact.artifactId}-${version.jbpm}.${artifact.extension}</outputFileNameMapping>
</dependencySet>
<dependencySet>
<useTransitiveDependencies>false</useTransitiveDependencies>
<includes>
<include>org.apache.cxf:cxf-rt-frontend-jaxrs</include>
</includes>
<outputDirectory>/modules/org/apache/cxf/jaxrs/main</outputDirectory>
<outputFileNameMapping>${artifact.artifactId}-${version.cxf}.${artifact.extension}</outputFileNameMapping>
</dependencySet>
<dependencySet>
<useTransitiveDependencies>false</useTransitiveDependencies>
<includes>
Expand All @@ -318,6 +336,14 @@
<outputDirectory>/modules/org/apache/camel/core/main</outputDirectory>
<outputFileNameMapping>${artifact.artifactId}-${version.camel}.${artifact.extension}</outputFileNameMapping>
</dependencySet>
<dependencySet>
<useTransitiveDependencies>false</useTransitiveDependencies>
<includes>
<include>org.apache.camel:camel-cxf</include>
</includes>
<outputDirectory>/modules/org/apache/camel/cxf/main</outputDirectory>
<outputFileNameMapping>${artifact.artifactId}-${version.camel}.${artifact.extension}</outputFileNameMapping>
</dependencySet>
<dependencySet>
<useTransitiveDependencies>false</useTransitiveDependencies>
<includes>
Expand Down
51 changes: 51 additions & 0 deletions jboss-as7/modules/src/main/resources/external/camel/cxf/module.xml
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>
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<dependencies>
<module name="javax.api"/>
<module name="javax.enterprise.api"/>
<module name="javax.ws.rs.api"/>
<module name="org.apache.log4j"/>
<module name="org.apache.camel.core" services="export" export="true"/>
<module name="org.apache.camel.spring" services="export" export="true"/>
Expand All @@ -44,6 +45,18 @@
<include path="META-INF/services/org/apache/camel/component"/>
</exports>
</module>
<module name="org.apache.camel.cxf" export="true" optional="true">
<imports>
<include path="META-INF/cxf"/>
<include path="META-INF/services/org/apache/camel"/>
<include path="META-INF/services/org/apache/camel/component"/>
</imports>
<exports>
<include path="META-INF/cxf"/>
<include path="META-INF/services/org/apache/camel"/>
<include path="META-INF/services/org/apache/camel/component"/>
</exports>
</module>
<module name="org.jboss.as.naming" export="true"/>
<module name="org.switchyard.api"/>
<module name="org.switchyard.common"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,11 @@
<socketAddr>$switchyard-ws</socketAddr>
</properties>
</module>
<module identifier="org.switchyard.component.camel" implClass="org.switchyard.component.camel.deploy.CamelComponent"/>
<module identifier="org.switchyard.component.camel" implClass="org.switchyard.component.camel.deploy.CamelComponent">
<properties>
<socketAddr>$switchyard-ws</socketAddr>
</properties>
</module>
<module identifier="org.switchyard.component.rules" implClass="org.switchyard.component.rules.deploy.RulesComponent"/>
<module identifier="org.switchyard.component.bpm" implClass="org.switchyard.component.bpm.deploy.BPMComponent"/>
<module identifier="org.switchyard.component.bpel" implClass="org.switchyard.component.bpel.deploy.BPELComponent"/>
Expand Down
5 changes: 5 additions & 0 deletions jboss-as7/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@
<artifactId>switchyard-quickstart-camel-jms-binding</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.switchyard.quickstarts</groupId>
<artifactId>switchyard-quickstart-camel-rest-binding</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.switchyard.quickstarts</groupId>
<artifactId>switchyard-quickstart-camel-soap-proxy</artifactId>
Expand Down
6 changes: 5 additions & 1 deletion jboss-as7/standalone/bundle/xsl/standalone.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ https://issues.jboss.org/browse/SWITCHYARD-548
<socketAddr>:18001</socketAddr>
</properties>
</module>
<module identifier="org.switchyard.component.camel" implClass="org.switchyard.component.camel.deploy.CamelComponent"/>
<module identifier="org.switchyard.component.camel" implClass="org.switchyard.component.camel.deploy.CamelComponent">
<properties>
<socketAddr>:18001</socketAddr>
</properties>
</module>
<module identifier="org.switchyard.component.rules" implClass="org.switchyard.component.rules.deploy.RulesComponent"/>
<module identifier="org.switchyard.component.bpm" implClass="org.switchyard.component.bpm.deploy.BPMComponent"/>
<module identifier="org.switchyard.component.bpel" implClass="org.switchyard.component.bpel.deploy.BPELComponent"/>
Expand Down
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>";
}

0 comments on commit 0ea261a

Please sign in to comment.