Reputation: 21
I get the following Arquillian error : org.jboss.arquillian.container.test.impl.client.deployment.ValidationException: DeploymentScenario contains a target (DEFAULT) not matching any defined Container in the registry. Please include at least 1 Deployable Container on your Classpath.
This are my camel routes class
@Singleton public class App extends RouteBuilder {
@Inject
private CamelContext context;
@Override
public void configure() throws Exception {
from("file://src/main/resources/temp2/").routeId("camelmarian")
.onException(WrongFileException.class)
.handled(true)
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
System.out.println("Wrong File Name " + exchange.getIn().getHeader("CamelFileName"));
exchange.getIn().setBody("Wrong extension");
}
})
.id("mockerror")
.end()
.choice()
.when(header("CamelFileName").regex("data[0-9]*.xml"))
.process(new XmlProcessor())
.id("mockxml")
//.to("mock:xml")
.when(header("CamelFileName").regex("data[0-9]*.csv"))
.process(new CsvProcessor())
// .to("mock:csv")
.id("mockcsv")
.when(header("CamelFileName").regex("data[0-9]*.txt"))
.process(new TextProcessor())
//.to("mock:txt")
.id("mocktext")
.otherwise()
.throwException(new WrongFileException("Wrong file extension"));
}
}
This is the class with endpoints which i am going to mock:
@Singleton
public class CamelContextSetup {
@Inject
private CamelContext camelContext;
private MockEndpoint afterCSV;
private MockEndpoint afterXML;
private MockEndpoint afterTXT;
private MockEndpoint afterError;
@Before
public void setup() throws Exception {
afterCSV = new MockEndpoint("mockCSV");
afterXML = new MockEndpoint("mockXML");
afterTXT = new MockEndpoint("mockTXT");
afterError = new MockEndpoint("mockError");
camelContext.getRouteDefinition("camelmarian").adviceWith(((ModelCamelContext) camelContext), new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
weaveById("mockcsv").after().to(afterCSV);
}
});
camelContext.getRouteDefinition("camelmarian").adviceWith(((ModelCamelContext) camelContext), new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
weaveById("mockxml").after().to(afterXML);
}
});
camelContext.getRouteDefinition("camelmarian").adviceWith(((ModelCamelContext) camelContext), new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
weaveById("mocktext").after().to(afterTXT);
}
});
camelContext.getRouteDefinition("camelmarian").adviceWith(((ModelCamelContext) camelContext), new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
weaveById("mockerror").after().to(afterError);
}
});
camelContext.start();
}
@After
public void destroy() {
afterCSV.reset();
afterError.reset();
afterTXT.reset();
afterCSV.reset();
}
@PreDestroy
public void stopContext() throws Exception {
camelContext.stop();
}
public MockEndpoint getAfterCSV() {
return afterCSV;
}
public MockEndpoint getAfterXML() {
return afterXML;
}
public MockEndpoint getAfterTXT() {
return afterTXT;
}
public MockEndpoint getAfterError() {
return afterError;
}
}
This are the unit tests . When i run them i get that error
@RunWith(Arquillian.class)
public class TestFiles extends CamelTestSupport {
@Inject
CamelContextSetup camelContextSetup;
@Before
public void before() throws Exception {
camelContextSetup.setup();
}
@After
public void after() {
camelContextSetup.destroy();
}
@Deployment(testable = false)
public static Archive<?> createArchive() {
return ShrinkWrap.create(JavaArchive.class)
.addClass(App.class)
.addClass(CamelContextSetup.class);
}
@Test
public void testReceived() throws InterruptedException {
File tempFile = new File("src/main/resources/temp/data.xml");
if (tempFile.renameTo(new File("src/main/resources/temp2/" + tempFile.getName())))
System.out.println("failed to move file");
else {
camelContextSetup.getAfterXML().expectedMessageCount(1);
assertMockEndpointsSatisfied();
}
}
@Test
public void testError() throws InterruptedException {
File tempFile = new File("src/main/resources/temp/data4.pl");
if (tempFile.renameTo(new File("src/main/resources/temp2/" + tempFile.getName())))
System.out.println("failed to move file");
else {
camelContextSetup.getAfterError().expectedMessageCount(1);
assertMockEndpointsSatisfied();
}
}
}
Upvotes: 2
Views: 1109
Reputation: 2426
You have to add some dependencies in your pom. It would look like that:
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-weld-ee-embedded-1.1</artifactId>
<version>1.0.0.CR9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-core</artifactId>
<version>2.3.5.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.6.4</version>
<scope>test</scope>
</dependency>
Source: http://arquillian.org/guides/getting_started_pt/
Upvotes: 1