You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by cm...@apache.org on 2012/01/17 16:09:10 UTC

svn commit: r1232434 - in /camel/trunk/components: camel-cdi/ camel-cdi/src/ camel-cdi/src/main/ camel-cdi/src/main/java/ camel-cdi/src/main/java/org/ camel-cdi/src/main/java/org/apache/ camel-cdi/src/main/java/org/apache/camel/ camel-cdi/src/main/java...

Author: cmoulliard
Date: Tue Jan 17 15:09:09 2012
New Revision: 1232434

URL: http://svn.apache.org/viewvc?rev=1232434&view=rev
Log:
CAMEL-3924: First input containing unit test with OpenWebbeans and CdiRegistry

Added:
    camel/trunk/components/camel-cdi/
    camel/trunk/components/camel-cdi/pom.xml
    camel/trunk/components/camel-cdi/src/
    camel/trunk/components/camel-cdi/src/main/
    camel/trunk/components/camel-cdi/src/main/java/
    camel/trunk/components/camel-cdi/src/main/java/org/
    camel/trunk/components/camel-cdi/src/main/java/org/apache/
    camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/
    camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/component/
    camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/component/cdi/
    camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/component/cdi/CdiBeanRegistry.java
    camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/component/cdi/CdiContainer.java
    camel/trunk/components/camel-cdi/src/main/resources/
    camel/trunk/components/camel-cdi/src/test/
    camel/trunk/components/camel-cdi/src/test/java/
    camel/trunk/components/camel-cdi/src/test/java/org/
    camel/trunk/components/camel-cdi/src/test/java/org/apache/
    camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/
    camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/
    camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/CdiContainerBeanManagerTest.java
    camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/
    camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/Item.java
    camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/Products.java
    camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/ShoppingBean.java
    camel/trunk/components/camel-cdi/src/test/resources/
    camel/trunk/components/camel-cdi/src/test/resources/META-INF/
    camel/trunk/components/camel-cdi/src/test/resources/META-INF/beans.xml
    camel/trunk/components/camel-cdi/src/test/resources/log4j.properties
Modified:
    camel/trunk/components/camel-websocket/   (props changed)
    camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentServletTest.java

Added: camel/trunk/components/camel-cdi/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cdi/pom.xml?rev=1232434&view=auto
==============================================================================
--- camel/trunk/components/camel-cdi/pom.xml (added)
+++ camel/trunk/components/camel-cdi/pom.xml Tue Jan 17 15:09:09 2012
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>camel-parent</artifactId>
+        <version>2.10-SNAPSHOT</version>
+        <relativePath>../../parent</relativePath>
+    </parent>
+
+    <artifactId>camel-cdi</artifactId>
+    <packaging>bundle</packaging>
+    <name>Camel :: CDI</name>
+    <description>Camel CDI</description>
+
+    <properties>
+        <camel.osgi.export.pkg>
+            org.apache.camel.component.cdi.*;${camel.osgi.version}
+        </camel.osgi.export.pkg>
+        <camel.osgi.import.pkg>
+            !org.apache.camel.component.cdi.*,
+            ${camel.osgi.import.defaults},
+            *
+        </camel.osgi.import.pkg>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-spring</artifactId>
+        </dependency>
+
+        <!-- JSR-299 Impl -->
+        <dependency>
+            <groupId>org.apache.openwebbeans</groupId>
+            <artifactId>openwebbeans-impl</artifactId>
+            <version>1.1.4-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
+
+        <!-- SPI API -->
+        <dependency>
+            <groupId>org.apache.openwebbeans</groupId>
+            <artifactId>openwebbeans-spi</artifactId>
+            <version>1.1.4-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
+
+        <!-- Interceptor API -->
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-interceptor_1.1_spec</artifactId>
+            <version>1.0</version>
+        </dependency>
+
+        <!-- EL Plugin -->
+        <dependency>
+            <groupId>org.apache.openwebbeans</groupId>
+            <artifactId>openwebbeans-el10</artifactId>
+            <version>1.1.4-SNAPSHOT</version>
+        </dependency>
+
+        <!-- JSR-299 API -->
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-jcdi_1.0_spec</artifactId>
+            <version>1.0</version>
+        </dependency>
+
+        <!-- JSR-330 API -->
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-atinject_1.0_spec</artifactId>
+            <version>1.0</version>
+        </dependency>
+
+        <!-- logging -->
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+        </dependency>
+
+        <!-- Test -->
+        <dependency>
+            <groupId>org.apache.openwebbeans.test</groupId>
+            <artifactId>cditest</artifactId>
+            <version>1.1.4-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.openwebbeans.test</groupId>
+            <artifactId>cditest-owb</artifactId>
+            <version>1.1.4-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-servlet_2.5_spec</artifactId>
+            <version>1.2</version>
+            <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <defaultGoal>install</defaultGoal>
+    </build>
+</project>

Added: camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/component/cdi/CdiBeanRegistry.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/component/cdi/CdiBeanRegistry.java?rev=1232434&view=auto
==============================================================================
--- camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/component/cdi/CdiBeanRegistry.java (added)
+++ camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/component/cdi/CdiBeanRegistry.java Tue Jan 17 15:09:09 2012
@@ -0,0 +1,146 @@
+/**
+ * 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.component.cdi;
+
+import org.apache.camel.spi.Registry;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * CdiBeanRegistry used by Camel to perform lookup into the
+ * Cdi BeanManager. The BeanManager must be passed as argument
+ * to the CdiRegistry constructor.
+ */
+public class CdiBeanRegistry implements Registry {
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    BeanManager delegate;
+
+    /**
+     * @param delegate
+     * @throws IllegalArgumentException
+     */
+    public CdiBeanRegistry(final BeanManager delegate)
+            throws IllegalArgumentException {
+        ObjectHelper.notNull(delegate, "delegate");
+        this.delegate = delegate;
+    }
+
+    /**
+     * @see org.apache.camel.spi.Registry#lookup(java.lang.String)
+     */
+    @Override
+    public Object lookup(final String name) {
+        ObjectHelper.notEmpty(name, "name");
+        log.trace("Looking up bean using name = [{}] in CDI registry ...", name);
+
+        final Set<Bean<?>> beans = getDelegate().getBeans(name);
+        if (beans.isEmpty()) {
+            log.debug(
+                    "Found no bean matching name = [{}] in CDI registry.", name);
+            return null;
+        }
+        if (beans.size() > 1) {
+            throw new IllegalStateException(
+                    "Expected to find exactly one bean having name [" + name
+                            + "], but got [" + beans.size() + "]");
+        }
+        final Bean<?> bean = beans.iterator().next();
+        log.debug("Found bean [{}] matching name = [{}] in CDI registry.",
+                bean, name);
+
+        final CreationalContext<?> creationalContext = getDelegate()
+                .createCreationalContext(null);
+
+        return getDelegate().getReference(bean, bean.getBeanClass(),
+                creationalContext);
+    }
+
+    /**
+     * @see org.apache.camel.spi.Registry#lookup(java.lang.String,
+     *      java.lang.Class)
+     */
+    @Override
+    public <T> T lookup(final String name, final Class<T> type) {
+        ObjectHelper.notEmpty(name, "name");
+        ObjectHelper.notNull(type, "type");
+        log.trace(
+                "Looking up bean using name = [{}] having expected type = [{}] in CDI registry ...",
+                name, type.getName());
+
+        return type.cast(lookup(name));
+    }
+
+    /**
+     * @see org.apache.camel.spi.Registry#lookupByType(java.lang.Class)
+     */
+    @Override
+    public <T> Map<String, T> lookupByType(final Class<T> type) {
+        ObjectHelper.notNull(type, "type");
+        log.trace(
+                "Looking up all beans having expected type = [{}] in CDI registry ...",
+                type.getName());
+
+        final Set<Bean<?>> beans = getDelegate().getBeans(type);
+        if (beans.isEmpty()) {
+            log.debug(
+                    "Found no beans having expected type = [{}] in CDI registry.",
+                    type.getName());
+
+            return Collections.emptyMap();
+        }
+        log.debug(
+                "Found [{}] beans having expected type = [{}] in CDI registry.",
+                Integer.valueOf(beans.size()), type.getName());
+
+        final Map<String, T> beansByName = new HashMap<String, T>(beans.size());
+        final CreationalContext<?> creationalContext = getDelegate()
+                .createCreationalContext(null);
+        for (final Bean<?> bean : beans) {
+            beansByName.put(
+                    bean.getName(),
+                    type.cast(getDelegate().getReference(bean, type,
+                            creationalContext)));
+        }
+
+        return beansByName;
+    }
+
+    @Override
+    public String toString() {
+        return "CdiRegistry@" + this.hashCode() + "[delegate = "
+                + this.delegate + "]";
+    }
+
+    private Logger getLog() {
+        return this.log;
+    }
+
+    private BeanManager getDelegate() {
+        return this.delegate;
+    }
+}

Added: camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/component/cdi/CdiContainer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/component/cdi/CdiContainer.java?rev=1232434&view=auto
==============================================================================
--- camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/component/cdi/CdiContainer.java (added)
+++ camel/trunk/components/camel-cdi/src/main/java/org/apache/camel/component/cdi/CdiContainer.java Tue Jan 17 15:09:09 2012
@@ -0,0 +1,57 @@
+/**
+ * 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.component.cdi;
+
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.spi.ContainerLifecycle;
+
+import javax.enterprise.inject.spi.BeanManager;
+
+/**
+ * OpenWebBeans CDI container. It can be used in a Camel standalone project to start
+ * and stop container. The container exposes a Bean?Manager that we can use to instantiate the
+ * CdiRegistry used by Camel
+ */
+public class CdiContainer {
+
+    private static ContainerLifecycle lifecycle = null;
+
+    public static void start() throws Exception {
+        try {
+            lifecycle = WebBeansContext.currentInstance().getService(ContainerLifecycle.class);
+            lifecycle.startApplication(null);
+
+        } catch (Exception e) {
+            throw e;
+        }
+    }
+
+    public static void shutdown() throws Exception {
+        try {
+            lifecycle.stopApplication(null);
+
+        } catch (Exception e) {
+            throw e;
+        }
+    }
+
+    public static BeanManager getBeanManager() {
+        return lifecycle.getBeanManager();
+    }
+
+}

Added: camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/CdiContainerBeanManagerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/CdiContainerBeanManagerTest.java?rev=1232434&view=auto
==============================================================================
--- camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/CdiContainerBeanManagerTest.java (added)
+++ camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/CdiContainerBeanManagerTest.java Tue Jan 17 15:09:09 2012
@@ -0,0 +1,114 @@
+package org.apache.camel.cdi;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.store.Item;
+import org.apache.camel.cdi.store.ShoppingBean;
+import org.apache.camel.component.cdi.CdiBeanRegistry;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.webbeans.cditest.CdiTestContainer;
+import org.apache.webbeans.cditest.CdiTestContainerLoader;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+import java.util.ArrayList;
+import java.util.List;
+
+public class CdiContainerBeanManagerTest extends CamelTestSupport {
+
+    private MockEndpoint resultEndpoint;
+
+    private ProducerTemplate template;
+
+    CdiTestContainer cdiContainer;
+    CamelContext camelContext;
+
+    @Inject
+    ShoppingBean shoppingBean;
+
+    @Before
+    public void setUp() throws Exception {
+        cdiContainer = CdiTestContainerLoader.getCdiContainer();
+        cdiContainer.bootContainer();
+        cdiContainer.startContexts();
+        BeanManager beanManager = cdiContainer.getBeanManager();
+
+        System.out.println(">> Container started and bean manager instantiated !");
+
+        // Camel
+        context = new DefaultCamelContext(new CdiBeanRegistry(beanManager));
+        context.addRoutes(createRouteBuilder());
+        context.setTracing(true);
+        context.start();
+        resultEndpoint = context.getEndpoint("mock:result", MockEndpoint.class);
+        template = context.createProducerTemplate();
+
+        System.out.println(">> Camel started !");
+    }
+
+    @After
+    public void shutDown() throws Exception {
+        cdiContainer.shutdownContainer();
+        context.stop();
+    }
+
+    @Test
+    public void testInjection() throws InterruptedException {
+        resultEndpoint.expectedMessageCount(1);
+        template.sendBody("direct:inject", "hello");
+
+        assertMockEndpointsSatisfied();
+
+        Exchange exchange = resultEndpoint.getExchanges().get(0);
+        List<Item> results = (List<Item>) exchange.getIn().getBody();
+
+        Object[] items = (Object[]) results.toArray();
+        Object[] itemsExpected = (Object[]) itemsExpected().toArray();
+        for(int i=0; i< items.length; ++i) {
+           Item itemExpected = (Item)items[i];
+           Item itemReceived = (Item)itemsExpected[i];
+           assertEquals(itemExpected.getName(), itemReceived.getName());
+           assertEquals(itemExpected.getPrice(), itemReceived.getPrice());
+        }
+
+        assertNotNull(results);
+    }
+
+    private ArrayList<Item> itemsExpected() {
+        ArrayList<Item> products = new ArrayList<Item>();
+        Item defaultItem = new Item();
+        defaultItem.setName("Default Item");
+        defaultItem.setPrice(1000L);
+
+        for (int i = 1; i < 10; i++) {
+            Item item = new Item("Item-" + i, i * 1500L);
+            products.add(item);
+        }
+
+        return products;
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+
+                from("direct:inject")
+                        .beanRef("shoppingBean", "listAllProducts")
+                        .to("mock:result");
+
+            }
+
+        };
+    }
+
+
+}

Added: camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/Item.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/Item.java?rev=1232434&view=auto
==============================================================================
--- camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/Item.java (added)
+++ camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/Item.java Tue Jan 17 15:09:09 2012
@@ -0,0 +1,68 @@
+/*
+ * 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.store;
+
+import java.io.Serializable;
+
+public class Item implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    private String name;
+
+    private long price;
+
+    public Item() {
+
+    }
+
+    public Item(String name, long price) {
+        this.name = name;
+        this.price = price;
+    }
+
+    /**
+     * @return the name
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * @param name the name to set
+     */
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    /**
+     * @return the price
+     */
+    public long getPrice() {
+        return price;
+    }
+
+    /**
+     * @param price the price to set
+     */
+    public void setPrice(long price) {
+        this.price = price;
+    }
+
+
+}

Added: camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/Products.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/Products.java?rev=1232434&view=auto
==============================================================================
--- camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/Products.java (added)
+++ camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/Products.java Tue Jan 17 15:09:09 2012
@@ -0,0 +1,59 @@
+/*
+ * 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.store;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.inject.Named;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+@Named
+public class Products implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    private List<Item> products = new ArrayList<Item>();
+
+    public Products() {
+
+    }
+
+    @PostConstruct
+    public void afterInit() {
+        for (int i = 1; i < 10; i++) {
+            Item item = new Item("Item-" + i, i * 1500L);
+            products.add(item);
+        }
+    }
+
+    @PreDestroy
+    public void preDestroy() {
+        products.clear();
+    }
+
+    /**
+     * @return the products
+     */
+    public List<Item> getProducts() {
+        return products;
+    }
+
+
+}

Added: camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/ShoppingBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/ShoppingBean.java?rev=1232434&view=auto
==============================================================================
--- camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/ShoppingBean.java (added)
+++ camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/ShoppingBean.java Tue Jan 17 15:09:09 2012
@@ -0,0 +1,64 @@
+/*
+ * 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.store;
+
+import javax.enterprise.inject.New;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Named;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+@Named
+public class ShoppingBean implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    private
+    @Inject
+    Products products;
+
+    private List<Item> items = new ArrayList<Item>();
+
+    public ShoppingBean() {
+    }
+
+    @Inject
+    public ShoppingBean(@New Item defaultItem) {
+        defaultItem.setName("Default Item");
+        defaultItem.setPrice(1000L);
+
+        items.add(defaultItem);
+    }
+
+
+    @Produces
+    @Named("selectedItems")
+    public List<Item> listSelectedItems() {
+        return this.items;
+    }
+
+    @Produces
+    @Named("allProducts")
+    public List<Item> listAllProducts() {
+        return this.products.getProducts();
+    }
+
+
+}

Added: camel/trunk/components/camel-cdi/src/test/resources/META-INF/beans.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cdi/src/test/resources/META-INF/beans.xml?rev=1232434&view=auto
==============================================================================
--- camel/trunk/components/camel-cdi/src/test/resources/META-INF/beans.xml (added)
+++ camel/trunk/components/camel-cdi/src/test/resources/META-INF/beans.xml Tue Jan 17 15:09:09 2012
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<beans/>
\ No newline at end of file

Added: camel/trunk/components/camel-cdi/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cdi/src/test/resources/log4j.properties?rev=1232434&view=auto
==============================================================================
--- camel/trunk/components/camel-cdi/src/test/resources/log4j.properties (added)
+++ camel/trunk/components/camel-cdi/src/test/resources/log4j.properties Tue Jan 17 15:09:09 2012
@@ -0,0 +1,43 @@
+## ---------------------------------------------------------------------------
+## 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 logging properties used during tests..
+#
+log4j.rootLogger=DEBUG, file
+
+log4j.logger.org.apache.camel=DEBUG
+log4j.logger.org.apache.openwebbeans=DEBUG
+log4j.logger.com.mycompany=DEBUG
+
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+# MDC
+#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %-10.10X{breadcrumbId} - %-10.10X{exchangeId} - %-10.10X{correlationId} - %-10.10X{routeId} - %m%n
+
+# File appender
+log4j.appender.file=org.apache.log4j.FileAppender
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.file=target/camel-cdi-test.log
+log4j.appender.file.append=true
+log4j.appender.file.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+# MDC
+#log4j.appender.file.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %-10.10X{breadcrumbId} - %-10.10X{exchangeId} - %-10.10X{correlationId} - %-10.10X{routeId} - %m%n
+
+log4j.throwableRenderer=org.apache.log4j.EnhancedThrowableRenderer
\ No newline at end of file

Propchange: camel/trunk/components/camel-websocket/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Jan 17 15:09:09 2012
@@ -1,7 +1 @@
-.settings
-
-.classpath
-
-.project
-
-target
+*.iml

Modified: camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentServletTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentServletTest.java?rev=1232434&r1=1232433&r2=1232434&view=diff
==============================================================================
--- camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentServletTest.java (original)
+++ camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketComponentServletTest.java Tue Jan 17 15:09:09 2012
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.component.websocket;
 
-import javax.servlet.http.HttpServletRequest;
 import org.eclipse.jetty.websocket.WebSocket;
 import org.junit.Before;
 import org.junit.Test;
@@ -25,11 +24,11 @@ import org.mockito.InOrder;
 import org.mockito.Mock;
 import org.mockito.runners.MockitoJUnitRunner;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import javax.servlet.http.HttpServletRequest;
+
+import static org.junit.Assert.*;
 import static org.mockito.Mockito.inOrder;
-import static org.mockito.Mockito.times;;
+import static org.mockito.Mockito.times;
 
 /**
  *