You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by as...@apache.org on 2016/04/19 14:58:54 UTC

[2/6] camel git commit: CAMEL-9882: Support importing Camel XML configuration files in Camel CDI

http://git-wip-us.apache.org/repos/asf/camel/blob/ba1172ad/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/ServiceExporterDefinition.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/ServiceExporterDefinition.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/ServiceExporterDefinition.java
new file mode 100644
index 0000000..74b8cac
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/ServiceExporterDefinition.java
@@ -0,0 +1,75 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.xml;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.camel.model.IdentifiedType;
+
+/**
+ * The <export> tag element.
+ *
+*/
+// FIXME: to remove when getters are added to org.apache.camel.core.xml.CamelServiceExporterDefinition
+@XmlRootElement(name = "export")
+public class ServiceExporterDefinition extends IdentifiedType {
+
+    @XmlAttribute
+    private String uri;
+
+    @XmlAttribute
+    private String serviceRef;
+
+    @XmlAttribute
+    private Class<?> serviceInterface;
+
+    @XmlAttribute
+    private String camelContextId;
+
+    public String getUri() {
+        return uri;
+    }
+
+    public void setUri(String uri) {
+        this.uri = uri;
+    }
+
+    public String getServiceRef() {
+        return serviceRef;
+    }
+
+    public void setServiceRef(String serviceRef) {
+        this.serviceRef = serviceRef;
+    }
+
+    public Class<?> getServiceInterface() {
+        return serviceInterface;
+    }
+
+    public void setServiceInterface(Class<?> serviceInterface) {
+        this.serviceInterface = serviceInterface;
+    }
+
+    public String getCamelContextId() {
+        return camelContextId;
+    }
+
+    public void setCamelContextId(String camelContextId) {
+        this.camelContextId = camelContextId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ba1172ad/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/ThreadPoolFactoryBean.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/ThreadPoolFactoryBean.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/ThreadPoolFactoryBean.java
new file mode 100644
index 0000000..7bd6819
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/ThreadPoolFactoryBean.java
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.xml;
+
+import javax.enterprise.inject.spi.BeanManager;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.core.xml.AbstractCamelThreadPoolFactoryBean;
+
+/**
+ * A factory which instantiates {@link java.util.concurrent.ExecutorService} objects.
+ */
+@XmlRootElement(name = "threadPool")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class ThreadPoolFactoryBean extends AbstractCamelThreadPoolFactoryBean implements BeanManagerAware {
+
+    @XmlTransient
+    private BeanManager manager;
+
+    @Override
+    public void setBeanManager(BeanManager manager) {
+        this.manager = manager;
+    }
+
+    @Override
+    protected CamelContext getCamelContextWithId(String camelContextId) {
+        return BeanManagerHelper.getCamelContextById(manager, camelContextId);
+    }
+
+    @Override
+    protected CamelContext discoverDefaultCamelContext() {
+        return BeanManagerHelper.getDefaultCamelContext(manager);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/ba1172ad/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/package-info.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/package-info.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/package-info.java
new file mode 100644
index 0000000..235d097
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/package-info.java
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+/**
+ * The JAXB POJOs for the
+ * <a href="http://camel.apache.org/xml-configuration.html">XML Configuration</a>
+ * of the routing rules.
+ */
+@javax.xml.bind.annotation.XmlSchema(namespace = "http://camel.apache.org/schema/spring", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
+package org.apache.camel.cdi.xml;
+

http://git-wip-us.apache.org/repos/asf/camel/blob/ba1172ad/components/camel-cdi/src/main/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/resources/META-INF/beans.xml b/components/camel-cdi/src/main/resources/META-INF/beans.xml
index 1d948f8..c87dbfa 100644
--- a/components/camel-cdi/src/main/resources/META-INF/beans.xml
+++ b/components/camel-cdi/src/main/resources/META-INF/beans.xml
@@ -19,6 +19,13 @@
 
     <scan>
         <exclude name="org.apache.camel.cdi.Main"/>
+        <exclude name="org.apache.camel.cdi.xml.*"/>
+        <exclude name="org.apache.camel.cdi.XmlCdiBeanFactory"/>
+        <exclude name="org.apache.camel.cdi.XmlCdiJaxbContexts"/>
+        <exclude name="org.apache.camel.cdi.XmlErrorHandlerFactoryBean"/>
+        <exclude name="org.apache.camel.cdi.XmlFactoryBeanInjectionTarget"/>
+        <exclude name="org.apache.camel.cdi.XmlProxyFactoryBean"/>
+        <exclude name="org.apache.camel.cdi.XmlServiceExporterBean"/>
     </scan>
 
 </beans>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/ba1172ad/components/camel-cdi/src/main/resources/org/apache/camel/cdi/xml/jaxb.index
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/resources/org/apache/camel/cdi/xml/jaxb.index b/components/camel-cdi/src/main/resources/org/apache/camel/cdi/xml/jaxb.index
new file mode 100644
index 0000000..fa117ca
--- /dev/null
+++ b/components/camel-cdi/src/main/resources/org/apache/camel/cdi/xml/jaxb.index
@@ -0,0 +1,28 @@
+## ------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements.  See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You 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.
+## ------------------------------------------------------------------------
+ApplicationContextFactoryBean
+CamelContextFactoryBean
+ConsumerTemplateFactoryBean
+EndpointFactoryBean
+ErrorHandlerDefinition
+ErrorHandlerType
+ImportDefinition
+ProducerTemplateFactoryBean
+RedeliveryPolicyFactoryBean
+RestContextDefinition
+RouteContextDefinition
+ThreadPoolFactoryBean
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/ba1172ad/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/Service.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/Service.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/Service.java
new file mode 100644
index 0000000..9d20f63
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/Service.java
@@ -0,0 +1,23 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.bean;
+
+public interface Service {
+
+    String service(String request);
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ba1172ad/components/camel-cdi/src/test/java/org/apache/camel/cdi/mock/DummyRestConsumerFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/mock/DummyRestConsumerFactory.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/mock/DummyRestConsumerFactory.java
new file mode 100644
index 0000000..f76d8c8
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/mock/DummyRestConsumerFactory.java
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.mock;
+
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.component.seda.SedaEndpoint;
+import org.apache.camel.impl.ActiveMQUuidGenerator;
+import org.apache.camel.spi.RestApiConsumerFactory;
+import org.apache.camel.spi.RestConfiguration;
+import org.apache.camel.spi.RestConsumerFactory;
+
+public class DummyRestConsumerFactory implements RestConsumerFactory, RestApiConsumerFactory {
+
+    @Override
+    public Consumer createConsumer(CamelContext camelContext, Processor processor, String verb,
+                                   String basePath, String uriTemplate, String consumes,
+                                   String produces, RestConfiguration configuration,
+                                   Map<String, Object> parameters) throws Exception {
+        // just use a seda endpoint for testing purpose
+        String id;
+        if (uriTemplate != null) {
+            id = ActiveMQUuidGenerator.generateSanitizedId(basePath + uriTemplate);
+        } else {
+            id = ActiveMQUuidGenerator.generateSanitizedId(basePath);
+        }
+        // remove leading dash as we add that ourselves
+        if (id.startsWith("-")) {
+            id = id.substring(1);
+        }
+
+        SedaEndpoint seda = camelContext.getEndpoint("seda:" + verb + "-" + id, SedaEndpoint.class);
+        return seda.createConsumer(processor);
+    }
+
+    @Override
+    public Consumer createApiConsumer(CamelContext camelContext, Processor processor,
+                                      String contextPath, RestConfiguration configuration,
+                                      Map<String, Object> parameters) throws Exception {
+        // just use a seda endpoint for testing purpose
+        String id = ActiveMQUuidGenerator.generateSanitizedId(contextPath);
+        // remove leading dash as we add that ourselves
+        if (id.startsWith("-")) {
+            id = id.substring(1);
+        }
+        SedaEndpoint seda = camelContext.getEndpoint("seda:api:" + "-" + id, SedaEndpoint.class);
+        return seda.createConsumer(processor);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ba1172ad/components/camel-cdi/src/test/java/org/apache/camel/cdi/rule/LogEvent.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/rule/LogEvent.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/rule/LogEvent.java
new file mode 100644
index 0000000..3524c1b
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/rule/LogEvent.java
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.rule;
+
+public final class LogEvent {
+
+    private final String level;
+
+    private final String logger;
+
+    private final String message;
+
+    LogEvent(String level, String logger, String message) {
+        this.level = level;
+        this.logger = logger;
+        this.message = message;
+    }
+
+    public String getLevel() {
+        return level;
+    }
+
+    public String getLogger() {
+        return logger;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ba1172ad/components/camel-cdi/src/test/java/org/apache/camel/cdi/rule/LogEventMatcher.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/rule/LogEventMatcher.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/rule/LogEventMatcher.java
new file mode 100644
index 0000000..6aa0519
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/rule/LogEventMatcher.java
@@ -0,0 +1,98 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.rule;
+
+import java.util.Objects;
+
+import org.hamcrest.Description;
+import org.hamcrest.DiagnosingMatcher;
+import org.hamcrest.Matcher;
+
+public final class LogEventMatcher extends DiagnosingMatcher<LogEvent> {
+
+    private String level;
+
+    private String logger;
+
+    private Matcher<String> message;
+
+    private LogEventMatcher() {
+    }
+
+    public static LogEventMatcher logEvent() {
+        return new LogEventMatcher();
+    }
+
+    @Override
+    public boolean matches(Object item, Description description) {
+        LogEvent target = (LogEvent) item;
+
+        if (!match(target)) {
+            description.appendText(" was LogEvent with ")
+                .appendText("level [" + Objects.toString(target.getLevel(), "n/a") + "], ")
+                .appendText("logger [" + Objects.toString(target.getLogger(), "n/a") + "], ")
+                .appendText("message [" + Objects.toString(target.getMessage(), "n/a") + "]");
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public void describeTo(Description description) {
+        description.appendText("LogEvent with ")
+            .appendText("level [" + Objects.toString(level, "n/a") + "], ")
+            .appendText("logger [" + Objects.toString(logger, "n/a") + "], ")
+            .appendText("message [" + Objects.toString(message, "n/a") + "]");
+    }
+
+    public LogEventMatcher withLevel(String level) {
+        this.level = level;
+        return this;
+    }
+
+    public LogEventMatcher withLogger(String logger) {
+        this.logger = logger;
+        return this;
+    }
+
+    public LogEventMatcher withMessage(Matcher<String> message) {
+        this.message = message;
+        return this;
+    }
+
+    private boolean match(LogEvent target) {
+        if (level != null) {
+            if (!level.equals(target.getLevel())) {
+                return false;
+            }
+        }
+
+        if (logger != null) {
+            if (!logger.equals(target.getLogger())) {
+                return false;
+            }
+        }
+
+        if (message != null) {
+            if (!message.matches(target.getMessage())) {
+                return false;
+            }
+        }
+
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ba1172ad/components/camel-cdi/src/test/java/org/apache/camel/cdi/rule/LogEventVerifier.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/rule/LogEventVerifier.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/rule/LogEventVerifier.java
new file mode 100644
index 0000000..497cd40
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/rule/LogEventVerifier.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.rule;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.log4j.spi.LoggingEvent;
+
+public class LogEventVerifier extends LogVerifier {
+
+    private List<LogEvent> events = new ArrayList<>();
+
+    protected void append(LoggingEvent event) {
+        events.add(new LogEvent(
+            event.getLevel().toString(),
+            event.getLoggerName(),
+            event.getRenderedMessage()));
+    }
+
+    public List<LogEvent> getEvents() {
+        return Collections.unmodifiableList(events);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ba1172ad/components/camel-cdi/src/test/java/org/apache/camel/cdi/rule/LogVerifier.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/rule/LogVerifier.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/rule/LogVerifier.java
index 804ae2c..237c82a 100644
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/rule/LogVerifier.java
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/rule/LogVerifier.java
@@ -47,11 +47,15 @@ public class LogVerifier extends Verifier {
 
             @Override
             protected void append(LoggingEvent event) {
-                messages.add(event.getRenderedMessage());
+                LogVerifier.this.append(event);
             }
         };
     }
 
+    protected void append(LoggingEvent event) {
+        messages.add(event.getRenderedMessage());
+    }
+
     public List<String> getMessages() {
         return Collections.unmodifiableList(messages);
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/ba1172ad/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/RouteDefinitionsFromXmlTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/RouteDefinitionsFromXmlTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/RouteDefinitionsFromXmlTest.java
index 70e291c..b1b29e5 100644
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/RouteDefinitionsFromXmlTest.java
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/RouteDefinitionsFromXmlTest.java
@@ -52,7 +52,7 @@ public class RouteDefinitionsFromXmlTest {
 
     @Produces
     private RoutesDefinition routes(CamelContext context) throws Exception {
-        try (InputStream routes = getClass().getResourceAsStream("/routes.xml")) {
+        try (InputStream routes = getClass().getResourceAsStream("/camel-context-routes.xml")) {
             return ModelHelper.createModelFromXml(context, routes, RoutesDefinition.class);
         }
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/ba1172ad/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlBeansTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlBeansTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlBeansTest.java
new file mode 100644
index 0000000..fb4482c
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlBeansTest.java
@@ -0,0 +1,76 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.test;
+
+import java.nio.file.Paths;
+import java.util.concurrent.TimeUnit;
+
+import javax.inject.Inject;
+
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.ImportResource;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.component.mock.MockEndpoint;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+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 static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+
+@RunWith(Arquillian.class)
+@ImportResource("imported-routes.xml")
+public class XmlBeansTest {
+
+    @Inject
+    @Uri("direct:inbound")
+    private ProducerTemplate inbound;
+
+    @Inject
+    @Uri("mock:outbound")
+    private MockEndpoint outbound;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test Camel XML
+            .addAsResource(
+                Paths.get("src/test/resources/camel-context-beans.xml").toFile(),
+                "imported-routes.xml")
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void sendMessageToInbound() throws InterruptedException {
+        outbound.expectedMessageCount(1);
+        outbound.expectedBodiesReceived("message");
+
+        inbound.sendBody("message");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ba1172ad/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlConsumerTemplateTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlConsumerTemplateTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlConsumerTemplateTest.java
new file mode 100644
index 0000000..4449662
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlConsumerTemplateTest.java
@@ -0,0 +1,89 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.test;
+
+import java.nio.file.Paths;
+import java.util.concurrent.TimeUnit;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.camel.ConsumerTemplate;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.ImportResource;
+import org.apache.camel.cdi.Uri;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+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 static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+@ImportResource("imported-context.xml")
+public class XmlConsumerTemplateTest {
+
+    @Inject
+    @Uri("direct:inbound")
+    private ProducerTemplate inbound;
+
+    @Named
+    @Inject
+    private ConsumerTemplate consumer;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test Camel XML
+            .addAsResource(
+                Paths.get("src/test/resources/camel-context-consumer.xml").toFile(),
+                "imported-context.xml")
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void verifyConsumerTemplate() {
+        assertThat("Consumer template Camel context is incorrect!",
+            consumer.getCamelContext().getName(),
+            is(equalTo("test")));
+
+        assertThat("Consumer template cache size is incorrect!",
+            consumer.getMaximumCacheSize(),
+            is(equalTo(100)));
+    }
+
+    @Test
+    public void sendMessageToInbound() {
+        inbound.sendBody("seda:foo", "message");
+
+        String body = consumer.receiveBody("seda:foo", TimeUnit.SECONDS.toMillis(1L), String.class);
+
+        assertThat("Body is incorrect!", body, is(equalTo("message")));
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ba1172ad/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlEndpointTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlEndpointTest.java
new file mode 100644
index 0000000..e80f13b
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlEndpointTest.java
@@ -0,0 +1,111 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.test;
+
+import java.nio.file.Paths;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.ImportResource;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.seda.SedaEndpoint;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+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.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+@ImportResource("imported-context.xml")
+public class XmlEndpointTest {
+
+    @Inject
+    @Uri("seda:inbound")
+    private ProducerTemplate inbound;
+
+    @Inject
+    @Uri("mock:outbound")
+    private MockEndpoint outbound;
+
+    @Inject
+    @Named("bar")
+    private Endpoint endpoint;
+
+    @Produces
+    @Named("queue")
+    private static <T> BlockingQueue<T> queue() {
+        return new MyBlockingQueue<>();
+    }
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test Camel XML
+            .addAsResource(
+                Paths.get("src/test/resources/camel-context-endpoint.xml").toFile(),
+                "imported-context.xml")
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    @Ignore("@ApplicationScoped bean proxy cannot be casted to endpoint implementation")
+    public void verifyXmlEndpoint() {
+        assertThat("Endpoint type is incorrect!", endpoint, is(instanceOf(SedaEndpoint.class)));
+        SedaEndpoint seda = (SedaEndpoint) endpoint;
+        assertThat("Endpoint queue is incorrect!",
+            seda.getQueue(), is(instanceOf(MyBlockingQueue.class)));
+        assertThat("Endpoint concurrent consumers count is incorrect!",
+            seda.getConcurrentConsumers(), is(equalTo(10)));
+    }
+
+    @Test
+    public void sendMessageToInbound() throws InterruptedException {
+        outbound.expectedMessageCount(1);
+        outbound.expectedBodiesReceived("message");
+
+        inbound.sendBody("message");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
+    }
+}
+
+class MyBlockingQueue<E> extends LinkedBlockingQueue<E> {
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ba1172ad/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlErrorHandlerLoggingTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlErrorHandlerLoggingTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlErrorHandlerLoggingTest.java
new file mode 100644
index 0000000..8517ad4
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlErrorHandlerLoggingTest.java
@@ -0,0 +1,132 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.test;
+
+import java.nio.file.Paths;
+import java.util.concurrent.TimeUnit;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.camel.CamelException;
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.ImportResource;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.rule.LogEventVerifier;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+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.ClassRule;
+import org.junit.Test;
+import org.junit.rules.TestRule;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.cdi.rule.LogEventMatcher.logEvent;
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+import static org.hamcrest.Matchers.containsInRelativeOrder;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+
+@RunWith(Arquillian.class)
+@ImportResource("imported-context.xml")
+public class XmlErrorHandlerLoggingTest {
+
+    @ClassRule
+    public static TestRule verifier = new LogEventVerifier() {
+        @Override
+        protected void verify() {
+            assertThat("Log messages not found!", getEvents(),
+                containsInRelativeOrder(
+                    logEvent()
+                        .withLevel("INFO")
+                        .withMessage(containsString("Camel CDI is starting Camel context [test]")),
+                    logEvent()
+                        .withLevel("WARN")
+                        .withLogger("error")
+                        .withMessage(containsString(
+                            "Exhausted after delivery attempt: 1 "
+                                + "caught: org.apache.camel.CamelException: failure message!")),
+                    logEvent()
+                        .withLevel("INFO")
+                        .withMessage(containsString("Camel CDI is stopping Camel context [test]"))
+                )
+            );
+        }
+    };
+
+    @Named
+    @Produces
+    private Exception failure = new CamelException("failure message!");
+
+    @Inject
+    @Uri("direct:inbound")
+    private ProducerTemplate inbound;
+
+    @Inject
+    @Uri("mock:outbound")
+    private MockEndpoint outbound;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test Camel XML
+            .addAsResource(
+                Paths.get("src/test/resources/camel-context-errorHandler-logging.xml").toFile(),
+                "imported-context.xml")
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void sendMessageToInbound() throws InterruptedException {
+        outbound.expectedMessageCount(1);
+        outbound.expectedBodiesReceived("Response to message");
+
+        inbound.sendBody("message");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
+    }
+
+    @Test
+    public void sendExceptionToInbound() {
+        try {
+            inbound.sendBody("exception");
+        } catch (Exception exception) {
+            assertThat("Exception is incorrect!",
+                exception, is(instanceOf(CamelExecutionException.class)));
+            assertThat("Exception cause is incorrect!",
+                exception.getCause(), is(instanceOf(CamelException.class)));
+            assertThat("Exception message is incorrect!",
+                exception.getCause().getMessage(), is(equalTo("failure message!")));
+            return;
+        }
+        fail("No exception thrown!");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ba1172ad/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlErrorHandlerPolicyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlErrorHandlerPolicyTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlErrorHandlerPolicyTest.java
new file mode 100644
index 0000000..caf162c
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlErrorHandlerPolicyTest.java
@@ -0,0 +1,141 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.test;
+
+import java.nio.file.Paths;
+import java.util.concurrent.TimeUnit;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.camel.CamelException;
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.ImportResource;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.rule.LogEventVerifier;
+import org.apache.camel.component.mock.MockEndpoint;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+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.ClassRule;
+import org.junit.Test;
+import org.junit.rules.TestRule;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.cdi.rule.LogEventMatcher.logEvent;
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+import static org.hamcrest.Matchers.containsInRelativeOrder;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.matchesPattern;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+
+@RunWith(Arquillian.class)
+@ImportResource("imported-context.xml")
+public class XmlErrorHandlerPolicyTest {
+
+    @ClassRule
+    public static TestRule verifier = new LogEventVerifier() {
+        @Override
+        protected void verify() {
+            assertThat("Log messages not found!", getEvents(),
+                containsInRelativeOrder(
+                    logEvent()
+                        .withLevel("INFO")
+                        .withMessage(containsString("Camel CDI is starting Camel context [test]")),
+                    logEvent()
+                        .withLevel("WARN")
+                        .withMessage(matchesPattern(
+                            "Failed delivery for \\(MessageId: .+\\). "
+                                + "On delivery attempt: 3 "
+                                + "caught: org.apache.camel.CamelException: failure message!")),
+                    logEvent()
+                        .withLevel("ERROR")
+                        .withMessage(matchesPattern(
+                            "(?s)Failed delivery for \\(MessageId: .+\\). "
+                                + "Exhausted after delivery attempt: 4 "
+                                + "caught: org.apache.camel.CamelException: failure message!.*")),
+                    logEvent()
+                        .withLevel("INFO")
+                        .withMessage(containsString("Camel CDI is stopping Camel context [test]"))
+                )
+            );
+        }
+    };
+
+    @Named
+    @Produces
+    private Exception failure = new CamelException("failure message!");
+
+    @Inject
+    @Uri("direct:inbound")
+    private ProducerTemplate inbound;
+
+    @Inject
+    @Uri("mock:outbound")
+    private MockEndpoint outbound;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test Camel XML
+            .addAsResource(
+                Paths.get("src/test/resources/camel-context-errorHandler-policy.xml").toFile(),
+                "imported-context.xml")
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void sendMessageToInbound() throws InterruptedException {
+        outbound.expectedMessageCount(1);
+        outbound.expectedBodiesReceived("Response to message");
+
+        inbound.sendBody("message");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
+    }
+
+    @Test
+    public void sendExceptionToInbound() {
+        try {
+            inbound.sendBody("exception");
+        } catch (Exception exception) {
+            assertThat("Exception is incorrect!",
+                exception, is(instanceOf(CamelExecutionException.class)));
+            assertThat("Exception cause is incorrect!",
+                exception.getCause(), is(instanceOf(CamelException.class)));
+            assertThat("Exception message is incorrect!",
+                exception.getCause().getMessage(), is(equalTo("failure message!")));
+            return;
+        }
+        fail("No exception thrown!");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ba1172ad/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlErrorHandlerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlErrorHandlerTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlErrorHandlerTest.java
new file mode 100644
index 0000000..ec1c697
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlErrorHandlerTest.java
@@ -0,0 +1,105 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.test;
+
+import java.nio.file.Paths;
+import java.util.concurrent.TimeUnit;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.ImportResource;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.component.mock.MockEndpoint;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+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 static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+
+@RunWith(Arquillian.class)
+@ImportResource("imported-context.xml")
+public class XmlErrorHandlerTest {
+
+    @Named
+    @Produces
+    private Processor processor = exchange -> exchange.getIn()
+        .setHeader("header",
+            exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class).getMessage());
+
+    @Named
+    @Produces
+    private Exception failure = new Exception("failure message!");
+
+    @Inject
+    @Uri("direct:inbound")
+    private ProducerTemplate inbound;
+
+    @Inject
+    @Uri("mock:exception")
+    private MockEndpoint exception;
+
+    @Inject
+    @Uri("mock:outbound")
+    private MockEndpoint outbound;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test Camel XML
+            .addAsResource(
+                Paths.get("src/test/resources/camel-context-errorHandler.xml").toFile(),
+                "imported-context.xml")
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void sendMessageToInbound() throws InterruptedException {
+        outbound.expectedMessageCount(1);
+        outbound.expectedBodiesReceived("Response to message");
+
+        inbound.sendBody("message");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
+    }
+
+    @Test
+    public void sendExceptionToInbound() throws InterruptedException {
+        exception.expectedMessageCount(1);
+        exception.expectedBodiesReceived("exception");
+        exception.expectedHeaderReceived("header", "failure message!");
+
+        inbound.sendBody("exception");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, exception);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ba1172ad/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlMultiContextsTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlMultiContextsTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlMultiContextsTest.java
new file mode 100644
index 0000000..9903c98
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlMultiContextsTest.java
@@ -0,0 +1,142 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.test;
+
+import java.nio.file.Paths;
+import java.util.concurrent.TimeUnit;
+
+import javax.inject.Inject;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.ContextName;
+import org.apache.camel.cdi.ImportResource;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.SecondNamedCamelContextRoute;
+import org.apache.camel.component.mock.MockEndpoint;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+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 static org.apache.camel.cdi.expression.ExchangeExpression.fromCamelContext;
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+@ImportResource("imported-context.xml")
+public class XmlMultiContextsTest {
+
+    @Inject
+    @ContextName("first")
+    private CamelContext firstCamelContext;
+
+    @Inject
+    @ContextName("first")
+    @Uri("direct:inbound")
+    private ProducerTemplate firstInbound;
+
+    @Inject
+    @ContextName("first")
+    @Uri("mock:outbound")
+    private MockEndpoint firstOutbound;
+
+    @Inject
+    @ContextName("second")
+    private CamelContext secondCamelContext;
+
+    @Inject
+    @ContextName("second")
+    @Uri("direct:in")
+    private ProducerTemplate secondInbound;
+
+    @Inject
+    @ContextName("second")
+    @Uri("mock:outbound")
+    private MockEndpoint secondOutbound;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test Camel XML
+            .addAsResource(
+                Paths.get("src/test/resources/camel-context-multiples.xml").toFile(),
+                "imported-context.xml")
+            // Test class
+            .addClass(SecondNamedCamelContextRoute.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void verifyCamelContexts() {
+        assertThat("Camel context name is incorrect!",
+            firstCamelContext.getName(), is(equalTo("first")));
+        assertThat("Camel context name is incorrect!",
+            secondCamelContext.getName(), is(equalTo("second")));
+
+        assertThat("Producer template context is incorrect!",
+            firstOutbound.getCamelContext().getName(), is(equalTo(firstCamelContext.getName())));
+        assertThat("Producer template context is incorrect!",
+            secondOutbound.getCamelContext().getName(), is(equalTo(secondCamelContext.getName())));
+    }
+
+    @Test
+    public void sendMessageToFirstCamelContextInbound() throws InterruptedException {
+        firstOutbound.expectedMessageCount(1);
+        firstOutbound.expectedBodiesReceived("first-message");
+        firstOutbound.expectedHeaderReceived("context", "first");
+        firstOutbound.message(0).exchange().matches(fromCamelContext("first"));
+
+        firstInbound.sendBody("first-message");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, firstOutbound);
+    }
+
+    @Test
+    public void sendMessageToSecondCamelContextInbound() throws InterruptedException {
+        secondOutbound.expectedMessageCount(1);
+        secondOutbound.expectedBodiesReceived("second-message");
+        firstOutbound.expectedHeaderReceived("context", "second");
+        secondOutbound.message(0).exchange().matches(fromCamelContext("second"));
+
+        secondInbound.sendBody("message");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, secondOutbound);
+    }
+
+    @ContextName("second")
+    private static class TestRoute extends RouteBuilder {
+
+        @Override
+        public void configure() {
+            from("direct:out").setHeader("context").constant("second").to("mock:outbound");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ba1172ad/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlProducerTemplateTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlProducerTemplateTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlProducerTemplateTest.java
new file mode 100644
index 0000000..26ed2ce
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlProducerTemplateTest.java
@@ -0,0 +1,95 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.test;
+
+import java.nio.file.Paths;
+import java.util.concurrent.TimeUnit;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.ImportResource;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.component.mock.MockEndpoint;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+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 static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+@ImportResource("imported-context.xml")
+public class XmlProducerTemplateTest {
+
+    @Named
+    @Inject
+    private ProducerTemplate inbound;
+
+    @Inject
+    @Uri("mock:outbound")
+    private MockEndpoint outbound;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test Camel XML
+            .addAsResource(
+                Paths.get("src/test/resources/camel-context-producer.xml").toFile(),
+                "imported-context.xml")
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void verifyProducerTemplate() {
+        assertThat("Producer template Camel context is incorrect!",
+            inbound.getCamelContext().getName(),
+            is(equalTo("test")));
+
+        assertThat("Producer template cache size is incorrect!",
+            inbound.getMaximumCacheSize(),
+            is(equalTo(100)));
+
+        assertThat("Producer template default endpoint is incorrect!",
+            inbound.getDefaultEndpoint().getEndpointUri(),
+            is(equalTo("direct://inbound")));
+    }
+
+    @Test
+    public void sendMessageToInbound() throws InterruptedException {
+        outbound.expectedMessageCount(1);
+        outbound.expectedBodiesReceived("message");
+
+        inbound.sendBody("message");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ba1172ad/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlPropertyPlaceholderTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlPropertyPlaceholderTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlPropertyPlaceholderTest.java
new file mode 100644
index 0000000..57d77ff
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlPropertyPlaceholderTest.java
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.test;
+
+import java.nio.file.Paths;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.ImportResource;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+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 static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+@ImportResource("imported-context.xml")
+public class XmlPropertyPlaceholderTest {
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test Camel XML
+            .addAsResource(
+                Paths.get("src/test/resources/camel-context-properties.xml").toFile(),
+                "imported-context.xml")
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void resolvePropertyFromLocation(CamelContext context) throws Exception {
+        assertThat("Property from classpath location does not resolve!",
+            context.resolvePropertyPlaceholders("{{header.message}}"),
+            is(equalTo("message from file")));
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ba1172ad/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlProxyFactoryTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlProxyFactoryTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlProxyFactoryTest.java
new file mode 100644
index 0000000..eada963
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlProxyFactoryTest.java
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.test;
+
+import java.nio.file.Paths;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.ImportResource;
+import org.apache.camel.cdi.bean.Service;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+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 static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+@ImportResource("imported-context.xml")
+public class XmlProxyFactoryTest {
+
+    @Named
+    @Inject
+    private Service proxy;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test Camel XML
+            .addAsResource(
+                Paths.get("src/test/resources/camel-context-proxy.xml").toFile(),
+                "imported-context.xml")
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void sendMessageToProxy() {
+        String response = proxy.service("request");
+
+        assertThat("Proxy response is incorrect!",
+            response, is(equalTo("Service called with: [request]")));
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ba1172ad/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlRestContextTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlRestContextTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlRestContextTest.java
new file mode 100644
index 0000000..c6ff8a6
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlRestContextTest.java
@@ -0,0 +1,105 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.test;
+
+import java.nio.file.Paths;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.ImportResource;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.mock.DummyRestConsumerFactory;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.model.rest.RestDefinition;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+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 static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+@ImportResource({
+    "imported-context-restContext.xml",
+    "imported-context-restContextRef.xml"
+})
+public class XmlRestContextTest {
+
+    @Produces
+    private static DummyRestConsumerFactory rest = new DummyRestConsumerFactory();
+
+    @Inject
+    @Uri("seda:get-inbound")
+    private ProducerTemplate inbound;
+
+    @Inject
+    @Uri("mock:outbound")
+    private MockEndpoint outbound;
+
+    @Inject
+    @Named("rest")
+    private List<RestDefinition> rests;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test Camel XML
+            .addAsResource(
+                Paths.get("src/test/resources/camel-context-restContext.xml").toFile(),
+                "imported-context-restContext.xml")
+            .addAsResource(
+                Paths.get("src/test/resources/camel-context-restContextRef.xml").toFile(),
+                "imported-context-restContextRef.xml")
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void verifyRestContext() {
+        assertThat("Rest context is incorrect!", rests, hasSize(1));
+        RestDefinition rest = rests.get(0);
+        assertThat("Rest path is incorrect!", rest.getPath(), is(equalTo("/inbound")));
+    }
+
+    @Test
+    public void sendMessageToInbound() throws InterruptedException {
+        outbound.expectedMessageCount(1);
+        outbound.expectedBodiesReceived("Response to request");
+
+        inbound.sendBody("request");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ba1172ad/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlRouteContextImportTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlRouteContextImportTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlRouteContextImportTest.java
new file mode 100644
index 0000000..2dc0d68
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlRouteContextImportTest.java
@@ -0,0 +1,101 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.test;
+
+import java.nio.file.Paths;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.ImportResource;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.model.RouteDefinition;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+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 static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+@ImportResource("imported-context.xml")
+public class XmlRouteContextImportTest {
+
+    @Inject
+    @Uri("direct:inbound")
+    private ProducerTemplate inbound;
+
+    @Inject
+    @Uri("mock:outbound")
+    private MockEndpoint outbound;
+
+    @Inject
+    @Named("import")
+    private List<RouteDefinition> routes;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test Camel XML
+            .addAsResource(
+                Paths.get("src/test/resources/camel-context-routeContextRef-import.xml").toFile(),
+                "imported-context.xml")
+            .addAsResource(
+                Paths.get("src/test/resources/camel-context-routeContext.xml").toFile(),
+                "imported-route-context.xml")
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void verifyRouteContext() {
+        assertThat("Route context is incorrect!", routes, hasSize(1));
+        RouteDefinition route = routes.get(0);
+
+        assertThat("Route input is incorrect!", route.getInputs(), hasSize(1));
+
+        assertThat("Route is incorrect!",
+            route.getInputs().get(0).getEndpointUri(), is(equalTo("direct:inbound")));
+    }
+
+    @Test
+    public void sendMessageToInbound() throws InterruptedException {
+        outbound.expectedMessageCount(1);
+        outbound.expectedBodiesReceived("Response to message");
+
+        inbound.sendBody("message");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ba1172ad/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlRouteContextResourceTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlRouteContextResourceTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlRouteContextResourceTest.java
new file mode 100644
index 0000000..cc44321
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlRouteContextResourceTest.java
@@ -0,0 +1,80 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.test;
+
+import java.nio.file.Paths;
+import java.util.concurrent.TimeUnit;
+
+import javax.inject.Inject;
+
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.ImportResource;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+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 static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+
+@RunWith(Arquillian.class)
+@ImportResource({
+    "imported-context.xml",
+    "imported-route-context.xml"
+})
+public class XmlRouteContextResourceTest {
+
+    @Inject
+    @Uri("direct:inbound")
+    private ProducerTemplate inbound;
+
+    @Inject
+    @Uri("mock:outbound")
+    private MockEndpoint outbound;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test Camel XML
+            .addAsResource(
+                Paths.get("src/test/resources/camel-context-routeContextRef.xml").toFile(),
+                "imported-context.xml")
+            .addAsResource(
+                Paths.get("src/test/resources/camel-context-routeContext.xml").toFile(),
+                "imported-route-context.xml")
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void sendMessageToInbound() throws InterruptedException {
+        outbound.expectedMessageCount(1);
+        outbound.expectedBodiesReceived("Response to message");
+
+        inbound.sendBody("message");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ba1172ad/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlRoutesDefinitionTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlRoutesDefinitionTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlRoutesDefinitionTest.java
new file mode 100644
index 0000000..09164ae
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlRoutesDefinitionTest.java
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.test;
+
+import java.nio.file.Paths;
+import java.util.concurrent.TimeUnit;
+
+import javax.inject.Inject;
+
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.ImportResource;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+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 static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+
+@RunWith(Arquillian.class)
+@ImportResource("imported-routes.xml")
+public class XmlRoutesDefinitionTest {
+
+    @Inject
+    @Uri("direct:inbound")
+    private ProducerTemplate inbound;
+
+    @Inject
+    @Uri("mock:outbound")
+    private MockEndpoint outbound;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test Camel XML
+            .addAsResource(
+                Paths.get("src/test/resources/camel-context-routes.xml").toFile(),
+                "imported-routes.xml")
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void sendMessageToInbound() throws InterruptedException {
+        outbound.expectedMessageCount(1);
+        outbound.expectedBodiesReceived("message");
+
+        inbound.sendBody("message");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ba1172ad/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlServiceExporterTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlServiceExporterTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlServiceExporterTest.java
new file mode 100644
index 0000000..036a37b
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlServiceExporterTest.java
@@ -0,0 +1,81 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.test;
+
+import java.nio.file.Paths;
+
+import javax.inject.Named;
+
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.ImportResource;
+import org.apache.camel.cdi.bean.Service;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+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 static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+@ImportResource("imported-context.xml")
+public class XmlServiceExporterTest {
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test Camel XML
+            .addAsResource(
+                Paths.get("src/test/resources/camel-context-export.xml").toFile(),
+                "imported-context.xml")
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void sendMessageToService(ProducerTemplate service) {
+        String response = service.requestBody("direct:service", "request", String.class);
+        assertThat("Response is incorrect!", response,
+            is(equalTo("test response to [request]")));
+    }
+
+    @Test
+    public void invokeService(@Named("service") Service service) {
+        String response = service.service("request");
+        assertThat("Response is incorrect!", response,
+            is(equalTo("test response to [request]")));
+    }
+
+    @Named("implementation")
+    static class TestService implements Service {
+
+        @Override
+        public String service(String request) {
+            return "test response to [" + request + "]";
+        }
+    }
+}