Skip to content

Commit

Permalink
[resolves wildfly-extras#846] Add support for spring-jdbc XML namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesnetherton committed Nov 3, 2015
1 parent 2c1502c commit 9dad9fb
Show file tree
Hide file tree
Showing 13 changed files with 172 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@

<dependencies>
<module name="org.apache.camel.core" export="true" services="export" />
<module name="org.apache.camel.spring" export="true" services="export" />
<module name="org.apache.camel.spring" export="true" services="export">
<imports>
<include path="META-INF" />
</imports>
<exports>
<include path="META-INF" />
</exports>
</module>
<module name="org.springframework.context" export="true">
<imports>
<include path="META-INF" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@
</module>
<module name="org.springframework.context" />
<module name="org.springframework.core" />
<module name="org.springframework.jdbc" export="true">
<imports>
<include path="META-INF" />
</imports>
<exports>
<include path="META-INF" />
<include path="org/springframework/jdbc/config" />
<exclude path="org/springframework/jdbc**" />
</exports>
</module>
<module name="org.springframework.tx" export="true">
<exports>
<exclude path="org/springframework/dao**" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
<artifact name="${org.springframework:spring-jdbc}" />
</resources>
<dependencies>
<module name="com.h2database.h2" />
<module name="javax.api" />
<module name="org.apache.commons.logging" />
<module name="org.springframework.context" />
<module name="org.springframework.beans" />
<module name="org.springframework.core" />
<module name="org.springframework.tx" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* #%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.spring;

import java.util.concurrent.TimeUnit;

import org.apache.camel.CamelContext;
import org.apache.camel.component.mock.MockEndpoint;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.wildfly.extension.camel.CamelContextRegistry;

@RunWith(Arquillian.class)
public class SpringJdbcNamespaceTest {

@ArquillianResource
CamelContextRegistry contextRegistry;

@Deployment
public static JavaArchive createDeployment() {
final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "camel-jdbc-tests");
archive.addAsResource("spring/jdbc-namespace-camel-context.xml");
archive.addAsResource("spring/sql/db-schema.sql", "db-schema.sql");
archive.addAsResource("spring/sql/db-data.sql", "db-data.sql");
return archive;
}

@Test
public void testSpringJdbcNamespace() throws Exception {
CamelContext camelctx = contextRegistry.getCamelContext("spring-jdbc");
Assert.assertNotNull(camelctx);

MockEndpoint resultEndpoint = camelctx.getEndpoint("mock:result", MockEndpoint.class);
resultEndpoint.expectedMessageCount(1);

MockEndpoint.assertWait(1, TimeUnit.SECONDS, resultEndpoint);
resultEndpoint.assertIsSatisfied();

String result = resultEndpoint.getExchanges().get(0).getIn().getBody(String.class);

Assert.assertEquals("Hello kermit", result);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!--
#%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%
-->
<spring:beans xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns="http://camel.apache.org/schema/spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.1.xsd">

<jdbc:embedded-database id="datasource" type="H2">
<jdbc:script location="db-schema.sql"/>
</jdbc:embedded-database>

<jdbc:initialize-database data-source="datasource">
<jdbc:script location="classpath:db-data.sql"/>
</jdbc:initialize-database>

<camelContext id="spring-jdbc">
<route>
<from uri="sql:select name from jdbc_test?dataSource=#datasource"/>
<transform>
<simple>Hello ${body['NAME']}</simple>
</transform>
<to uri="mock:result" />
</route>
</camelContext>

</spring:beans>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
INSERT INTO jdbc_test VALUES (1, 'kermit');
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DROP SCHEMA IF EXISTS jdbc_test;
CREATE TABLE jdbc_test (
id INT,
name VARCHAR(6)
);
1 change: 1 addition & 0 deletions modules/etc/baseline/exported-paths.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ org/springframework/instrument/classloading/jboss
org/springframework/instrument/classloading/tomcat
org/springframework/instrument/classloading/weblogic
org/springframework/instrument/classloading/websphere
org/springframework/jdbc/config
org/springframework/jmx
org/springframework/jmx/access
org/springframework/jmx/export
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@
</module>
<module name="org.springframework.context" />
<module name="org.springframework.core" />
<module name="org.springframework.jdbc" export="true">
<imports>
<include path="META-INF" />
</imports>
<exports>
<include path="META-INF" />
<include path="org/springframework/jdbc/config" />
<exclude path="org/springframework/jdbc**" />
</exports>
</module>
<module name="org.springframework.tx" export="true">
<exports>
<exclude path="org/springframework/dao**" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
<resource-root path="spring-jdbc-4.1.6.RELEASE.jar" />
</resources>
<dependencies>
<module name="com.h2database.h2" />
<module name="javax.api" />
<module name="org.apache.commons.logging" />
<module name="org.springframework.context" />
<module name="org.springframework.beans" />
<module name="org.springframework.core" />
<module name="org.springframework.tx" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@

<dependencies>
<module name="org.apache.camel.core" export="true" services="export" />
<module name="org.apache.camel.spring" export="true" services="export" />
<module name="org.apache.camel.spring" export="true" services="export">
<imports>
<include path="META-INF" />
</imports>
<exports>
<include path="META-INF" />
</exports>
</module>
<module name="org.springframework.context" export="true">
<imports>
<include path="META-INF" />
Expand Down
10 changes: 10 additions & 0 deletions modules/etc/smartics/camel-modules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@
</module>
<module name="org.springframework.context" />
<module name="org.springframework.core" />
<module name="org.springframework.jdbc" export="true">
<imports>
<include path="META-INF" />
</imports>
<exports>
<include path="META-INF" />
<include path="org/springframework/jdbc/config" />
<exclude path="org/springframework/jdbc**" />
</exports>
</module>
<module name="org.springframework.tx" export="true">
<exports>
<exclude path="org/springframework/dao**" />
Expand Down
2 changes: 2 additions & 0 deletions modules/etc/smartics/spring-modules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@
<module name="org.springframework.jdbc">
<include artifact=":spring-jdbc" />
<dependencies>
<module name="com.h2database.h2" />
<module name="javax.api" />
<module name="org.apache.commons.logging" />
<module name="org.springframework.context" />
</dependencies>
</module>

Expand Down

0 comments on commit 9dad9fb

Please sign in to comment.