forked from wildfly-extras/wildfly-camel
-
Notifications
You must be signed in to change notification settings - Fork 0
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#846] Add support for spring-jdbc XML namespace
- Loading branch information
1 parent
2c1502c
commit 9dad9fb
Showing
13 changed files
with
172 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
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
67 changes: 67 additions & 0 deletions
67
...standalone/basic/src/main/java/org/wildfly/camel/test/spring/SpringJdbcNamespaceTest.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,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); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
itests/standalone/basic/src/main/resources/spring/jdbc-namespace-camel-context.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,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> |
1 change: 1 addition & 0 deletions
1
itests/standalone/basic/src/main/resources/spring/sql/db-data.sql
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 @@ | ||
INSERT INTO jdbc_test VALUES (1, 'kermit'); |
5 changes: 5 additions & 0 deletions
5
itests/standalone/basic/src/main/resources/spring/sql/db-schema.sql
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,5 @@ | ||
DROP SCHEMA IF EXISTS jdbc_test; | ||
CREATE TABLE jdbc_test ( | ||
id INT, | ||
name VARCHAR(6) | ||
); |
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
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