-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for @RecipientList annotation
- Loading branch information
1 parent
7ab81fb
commit 90e75ab
Showing
2 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
envs/se/src/main/java/org/apache/camel/cdi/se/bean/RecipientListMethodBean.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,33 @@ | ||
/** | ||
* Copyright (C) 2014 Antonin Stefanutti (antonin.stefanutti@gmail.com) | ||
* | ||
* 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. | ||
*/ | ||
package org.apache.camel.cdi.se.bean; | ||
|
||
import org.apache.camel.Consume; | ||
import org.apache.camel.RecipientList; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
@ApplicationScoped | ||
public class RecipientListMethodBean { | ||
|
||
@RecipientList | ||
@Consume(uri = "direct:inbound") | ||
public List<String> route() { | ||
return Arrays.asList("mock:outbound1", "mock:outbound2"); | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
envs/se/src/test/java/org/apache/camel/cdi/se/RecipientListMethodTest.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,91 @@ | ||
/** | ||
* Copyright (C) 2014 Antonin Stefanutti (antonin.stefanutti@gmail.com) | ||
* | ||
* 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. | ||
*/ | ||
package org.apache.camel.cdi.se; | ||
|
||
import org.apache.camel.CamelContext; | ||
import org.apache.camel.ProducerTemplate; | ||
import org.apache.camel.cdi.CdiCamelExtension; | ||
import org.apache.camel.cdi.Uri; | ||
import org.apache.camel.cdi.se.bean.RecipientListMethodBean; | ||
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.junit.InSequence; | ||
import org.jboss.shrinkwrap.api.Archive; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.EmptyAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import javax.inject.Inject; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied; | ||
|
||
@RunWith(Arquillian.class) | ||
public class RecipientListMethodTest { | ||
|
||
@Deployment | ||
public static Archive<?> deployment() { | ||
return ShrinkWrap.create(JavaArchive.class) | ||
// Camel CDI | ||
.addPackage(CdiCamelExtension.class.getPackage()) | ||
// Test classes | ||
.addClass(RecipientListMethodBean.class) | ||
// Bean archive deployment descriptor | ||
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); | ||
} | ||
|
||
@Inject | ||
@Uri("direct:inbound") | ||
private ProducerTemplate inbound; | ||
|
||
@Inject | ||
@Uri("mock:outbound1") | ||
private MockEndpoint outbound1; | ||
|
||
@Inject | ||
@Uri("mock:outbound2") | ||
private MockEndpoint outbound2; | ||
|
||
@Test | ||
@InSequence(1) | ||
public void startCamelContext(CamelContext context) throws Exception { | ||
context.start(); | ||
} | ||
|
||
@Test | ||
@InSequence(2) | ||
public void consumeAnnotation() throws InterruptedException { | ||
outbound1.expectedMessageCount(1); | ||
outbound1.expectedBodiesReceived("test"); | ||
|
||
outbound2.expectedMessageCount(1); | ||
outbound2.expectedBodiesReceived("test"); | ||
|
||
inbound.sendBody("test"); | ||
|
||
assertIsSatisfied(2L, TimeUnit.SECONDS, outbound1); | ||
assertIsSatisfied(2L, TimeUnit.SECONDS, outbound2); | ||
} | ||
|
||
@Test | ||
@InSequence(3) | ||
public void stopCamelContext(CamelContext context) throws Exception { | ||
context.stop(); | ||
} | ||
} |