deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject [1/2] DELTASPIKE-593 support for mocked cdi-beans
Date Thu, 15 May 2014 14:11:36 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 59f8c0cd5 -> b47375cac


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b47375ca/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc005/ProducedBeanProducer.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc005/ProducedBeanProducer.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc005/ProducedBeanProducer.java
new file mode 100644
index 0000000..de8ab79
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc005/ProducedBeanProducer.java
@@ -0,0 +1,34 @@
+/*
+ * 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.deltaspike.test.testcontrol.mock.uc005;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.Typed;
+
+@Typed() //exclude it for the cdi type-check
+public class ProducedBeanProducer
+{
+    @Produces
+    @RequestScoped
+    public ProducedBean produceBean()
+    {
+        return new ProducedBean();
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b47375ca/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc006/MockedRequestScopedQualifiedBeanTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc006/MockedRequestScopedQualifiedBeanTest.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc006/MockedRequestScopedQualifiedBeanTest.java
new file mode 100644
index 0000000..72abe5e
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc006/MockedRequestScopedQualifiedBeanTest.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.deltaspike.test.testcontrol.mock.uc006;
+
+import org.apache.deltaspike.core.util.metadata.AnnotationInstanceProvider;
+import org.apache.deltaspike.test.category.SeCategory;
+import org.apache.deltaspike.test.testcontrol.mock.shared.MyQualifier;
+import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
+import org.apache.deltaspike.testcontrol.api.mock.DynamicMockManager;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import javax.inject.Inject;
+
+//Usually NOT needed! Currently only needed due to our arquillian-setup
+@Category(SeCategory.class)
+
+@RunWith(CdiTestRunner.class)
+public class MockedRequestScopedQualifiedBeanTest
+{
+    @Inject
+    @MyQualifier
+    private QualifiedBean qualifiedBean;
+
+    @Inject
+    private DynamicMockManager mockManager;
+
+    @Test
+    public void manualMockWithQualifier()
+    {
+        mockManager.addMock(new QualifiedBean()
+        {
+            @Override
+            public int getCount()
+            {
+                return 7;
+            }
+        }, AnnotationInstanceProvider.of(MyQualifier.class));
+
+        Assert.assertEquals(7, qualifiedBean.getCount());
+        qualifiedBean.increaseCount();
+        Assert.assertEquals(7, qualifiedBean.getCount());
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b47375ca/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc006/QualifiedBean.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc006/QualifiedBean.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc006/QualifiedBean.java
new file mode 100644
index 0000000..a4d7c3e
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc006/QualifiedBean.java
@@ -0,0 +1,40 @@
+/*
+ * 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.deltaspike.test.testcontrol.mock.uc006;
+
+import org.apache.deltaspike.test.testcontrol.mock.shared.MyQualifier;
+
+import javax.enterprise.context.RequestScoped;
+
+@RequestScoped
+@MyQualifier
+public class QualifiedBean
+{
+    private int count = 0;
+
+    public int getCount()
+    {
+        return count;
+    }
+
+    public void increaseCount()
+    {
+        this.count++;
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b47375ca/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc007/MockedProducedQualifiedBeanTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc007/MockedProducedQualifiedBeanTest.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc007/MockedProducedQualifiedBeanTest.java
new file mode 100644
index 0000000..e2c9a5b
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc007/MockedProducedQualifiedBeanTest.java
@@ -0,0 +1,77 @@
+/*
+ * 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.deltaspike.test.testcontrol.mock.uc007;
+
+import org.apache.deltaspike.core.util.metadata.AnnotationInstanceProvider;
+import org.apache.deltaspike.test.category.SeCategory;
+import org.apache.deltaspike.test.testcontrol.mock.shared.MyQualifier;
+import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
+import org.apache.deltaspike.testcontrol.api.mock.DynamicMockManager;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import javax.inject.Inject;
+
+//Usually NOT needed! Currently only needed due to our arquillian-setup
+@Category(SeCategory.class)
+
+@RunWith(CdiTestRunner.class)
+public class MockedProducedQualifiedBeanTest
+{
+    @Inject
+    @MyQualifier
+    private ProducedBean producedBean;
+
+    @Inject
+    private DynamicMockManager mockManager;
+
+    @Test
+    public void manualMockWithQualifierForProducedBean1()
+    {
+        mockManager.addMock(new ProducedBean()
+        {
+            @Override
+            public int getCount()
+            {
+                return 7;
+            }
+        }, AnnotationInstanceProvider.of(MyQualifier.class));
+        Assert.assertEquals(7, producedBean.getCount());
+        producedBean.increaseCount();
+        Assert.assertEquals(7, producedBean.getCount());
+    }
+
+    @Test
+    public void manualMockWithQualifierForProducedBean2()
+    {
+        mockManager.addMock(new ProducedBean()
+        {
+            @Override
+            public int getCount()
+            {
+                return 14;
+            }
+        }, AnnotationInstanceProvider.of(MyQualifier.class));
+        Assert.assertEquals(14, producedBean.getCount());
+        producedBean.increaseCount();
+        Assert.assertEquals(14, producedBean.getCount());
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b47375ca/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc007/ProducedBean.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc007/ProducedBean.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc007/ProducedBean.java
new file mode 100644
index 0000000..db1a9a5
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc007/ProducedBean.java
@@ -0,0 +1,37 @@
+/*
+ * 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.deltaspike.test.testcontrol.mock.uc007;
+
+import javax.enterprise.inject.Typed;
+
+@Typed() //exclude it for the cdi type-check
+public class ProducedBean
+{
+    private int count = 0;
+
+    public int getCount()
+    {
+        return count;
+    }
+
+    public void increaseCount()
+    {
+        this.count++;
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b47375ca/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc007/ProducedBeanProducer.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc007/ProducedBeanProducer.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc007/ProducedBeanProducer.java
new file mode 100644
index 0000000..769beff
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc007/ProducedBeanProducer.java
@@ -0,0 +1,37 @@
+/*
+ * 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.deltaspike.test.testcontrol.mock.uc007;
+
+import org.apache.deltaspike.test.testcontrol.mock.shared.MyQualifier;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.Typed;
+
+@Typed() //exclude it for the cdi type-check
+public class ProducedBeanProducer
+{
+    @Produces
+    @RequestScoped
+    @MyQualifier
+    public ProducedBean produceBean()
+    {
+        return new ProducedBean();
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b47375ca/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc008/MockedTypedBeanTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc008/MockedTypedBeanTest.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc008/MockedTypedBeanTest.java
new file mode 100644
index 0000000..c113c06
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc008/MockedTypedBeanTest.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.deltaspike.test.testcontrol.mock.uc008;
+
+import org.apache.deltaspike.test.category.SeCategory;
+import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
+import org.apache.deltaspike.testcontrol.api.mock.DynamicMockManager;
+import org.apache.deltaspike.testcontrol.api.mock.TypedMock;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import javax.enterprise.inject.Typed;
+import javax.inject.Inject;
+
+//Usually NOT needed! Currently only needed due to our arquillian-setup
+@Category(SeCategory.class)
+
+@RunWith(CdiTestRunner.class)
+public class MockedTypedBeanTest
+{
+    @Inject
+    private T1 t1;
+
+    @Inject
+    private T2 t2;
+
+    @Inject
+    private T3 t3;
+
+    @Inject
+    private DynamicMockManager mockManager;
+
+    @Test
+    public void manualMockForTypedBeans()
+    {
+        mockManager.addMock(new MockedTypedBean1and2(7));
+        mockManager.addMock(new MockedTypedBean3(14));
+        Assert.assertEquals(7, t1.getCount());
+        Assert.assertEquals(7, t2.getCount());
+        Assert.assertEquals(14, t3.getCount());
+    }
+
+    @Typed() //exclude it for the cdi type-check
+    private static class MockedTypedBean1and2 extends TypedBean1and2
+    {
+        private final int mockedCount;
+
+        private MockedTypedBean1and2(int mockedCount)
+        {
+            this.mockedCount = mockedCount;
+        }
+
+        @Override
+        public int getCount()
+        {
+            return mockedCount;
+        }
+    }
+
+    @Typed() //exclude it for the cdi type-check
+    @TypedMock(T3.class) //optional - only needed in case of producers
+    private static class MockedTypedBean3 extends TypedBean3
+    {
+        private final int mockedCount;
+
+        private MockedTypedBean3(int mockedCount)
+        {
+            this.mockedCount = mockedCount;
+        }
+
+        @Override
+        public int getCount()
+        {
+            return mockedCount;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b47375ca/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc008/T1.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc008/T1.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc008/T1.java
new file mode 100644
index 0000000..88dc003
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc008/T1.java
@@ -0,0 +1,24 @@
+/*
+ * 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.deltaspike.test.testcontrol.mock.uc008;
+
+public interface T1
+{
+    int getCount();
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b47375ca/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc008/T2.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc008/T2.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc008/T2.java
new file mode 100644
index 0000000..7508acb
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc008/T2.java
@@ -0,0 +1,24 @@
+/*
+ * 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.deltaspike.test.testcontrol.mock.uc008;
+
+public interface T2
+{
+    int getCount();
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b47375ca/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc008/T3.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc008/T3.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc008/T3.java
new file mode 100644
index 0000000..12bb51d
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc008/T3.java
@@ -0,0 +1,24 @@
+/*
+ * 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.deltaspike.test.testcontrol.mock.uc008;
+
+public interface T3
+{
+    int getCount();
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b47375ca/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc008/TypedBean1and2.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc008/TypedBean1and2.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc008/TypedBean1and2.java
new file mode 100644
index 0000000..6b3e27b
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc008/TypedBean1and2.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.deltaspike.test.testcontrol.mock.uc008;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Typed;
+
+@RequestScoped
+@Typed({T1.class, T2.class})
+public class TypedBean1and2 implements T1, T2, T3
+{
+    private int count = 0;
+
+    public int getCount()
+    {
+        return count;
+    }
+
+    public void increaseCount()
+    {
+        this.count++;
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b47375ca/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc008/TypedBean3.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc008/TypedBean3.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc008/TypedBean3.java
new file mode 100644
index 0000000..b5007cd
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc008/TypedBean3.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.deltaspike.test.testcontrol.mock.uc008;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Typed;
+
+@RequestScoped
+@Typed({T3.class})
+public class TypedBean3 implements T1, T2, T3
+{
+    private int count = 0;
+
+    public int getCount()
+    {
+        return count;
+    }
+
+    public void increaseCount()
+    {
+        this.count++;
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b47375ca/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc009/MockedTypedProducedBeanTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc009/MockedTypedProducedBeanTest.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc009/MockedTypedProducedBeanTest.java
new file mode 100644
index 0000000..7e066c3
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc009/MockedTypedProducedBeanTest.java
@@ -0,0 +1,96 @@
+/*
+ * 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.deltaspike.test.testcontrol.mock.uc009;
+
+import org.apache.deltaspike.test.category.SeCategory;
+import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
+import org.apache.deltaspike.testcontrol.api.mock.DynamicMockManager;
+import org.apache.deltaspike.testcontrol.api.mock.TypedMock;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import javax.enterprise.inject.Typed;
+import javax.inject.Inject;
+
+//Usually NOT needed! Currently only needed due to our arquillian-setup
+@Category(SeCategory.class)
+
+@RunWith(CdiTestRunner.class)
+public class MockedTypedProducedBeanTest
+{
+    @Inject
+    private T1 t1;
+
+    @Inject
+    private T2 t2;
+
+    @Inject
+    private T3 t3;
+
+    @Inject
+    private DynamicMockManager mockManager;
+
+    @Test
+    public void manualMockT1()
+    {
+        mockManager.addMock(new MockedTypedBean1and2(7));
+        mockManager.addMock(new MockedTypedBean3(14));
+        Assert.assertEquals(7, t1.getCount());
+        Assert.assertEquals(7, t2.getCount());
+        Assert.assertEquals(14, t3.getCount());
+    }
+
+    @Typed() //exclude it for the cdi type-check
+    @TypedMock({T1.class, T2.class}) //specify the types for mocking (to replace the producer)
+    private static class MockedTypedBean1and2 extends TypedBean1and2
+    {
+        private final int mockedCount;
+
+        private MockedTypedBean1and2(int mockedCount)
+        {
+            this.mockedCount = mockedCount;
+        }
+
+        @Override
+        public int getCount()
+        {
+            return mockedCount;
+        }
+    }
+
+    @Typed() //exclude it for the cdi type-check
+    @TypedMock(T3.class)
+    private static class MockedTypedBean3 extends TypedBean3
+    {
+        private final int mockedCount;
+
+        private MockedTypedBean3(int mockedCount)
+        {
+            this.mockedCount = mockedCount;
+        }
+
+        @Override
+        public int getCount()
+        {
+            return mockedCount;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b47375ca/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc009/T1.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc009/T1.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc009/T1.java
new file mode 100644
index 0000000..3cf523d
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc009/T1.java
@@ -0,0 +1,24 @@
+/*
+ * 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.deltaspike.test.testcontrol.mock.uc009;
+
+public interface T1
+{
+    int getCount();
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b47375ca/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc009/T2.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc009/T2.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc009/T2.java
new file mode 100644
index 0000000..9028f3d
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc009/T2.java
@@ -0,0 +1,24 @@
+/*
+ * 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.deltaspike.test.testcontrol.mock.uc009;
+
+public interface T2
+{
+    int getCount();
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b47375ca/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc009/T3.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc009/T3.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc009/T3.java
new file mode 100644
index 0000000..4ba62bf
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc009/T3.java
@@ -0,0 +1,24 @@
+/*
+ * 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.deltaspike.test.testcontrol.mock.uc009;
+
+public interface T3
+{
+    int getCount();
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b47375ca/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc009/TypedBean1and2.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc009/TypedBean1and2.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc009/TypedBean1and2.java
new file mode 100644
index 0000000..76b4b39
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc009/TypedBean1and2.java
@@ -0,0 +1,37 @@
+/*
+ * 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.deltaspike.test.testcontrol.mock.uc009;
+
+import javax.enterprise.inject.Typed;
+
+@Typed() //exclude it for the cdi type-check
+public class TypedBean1and2 implements T1, T2, T3
+{
+    private int count = 0;
+
+    public int getCount()
+    {
+        return count;
+    }
+
+    public void increaseCount()
+    {
+        this.count++;
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b47375ca/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc009/TypedBean3.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc009/TypedBean3.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc009/TypedBean3.java
new file mode 100644
index 0000000..4ab9db4
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc009/TypedBean3.java
@@ -0,0 +1,37 @@
+/*
+ * 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.deltaspike.test.testcontrol.mock.uc009;
+
+import javax.enterprise.inject.Typed;
+
+@Typed() //exclude it for the cdi type-check
+public class TypedBean3 implements T1, T2, T3
+{
+    private int count = 0;
+
+    public int getCount()
+    {
+        return count;
+    }
+
+    public void increaseCount()
+    {
+        this.count++;
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b47375ca/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc009/TypedBeanProducer.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc009/TypedBeanProducer.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc009/TypedBeanProducer.java
new file mode 100644
index 0000000..886ce2a
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc009/TypedBeanProducer.java
@@ -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.
+ */
+package org.apache.deltaspike.test.testcontrol.mock.uc009;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.Typed;
+
+@Typed() //exclude it for the cdi type-check
+public class TypedBeanProducer
+{
+    @Produces
+    @RequestScoped
+    @Typed({T1.class, T2.class})
+    public TypedBean1and2 produce1and2()
+    {
+        return new TypedBean1and2();
+    }
+
+    @Produces
+    @RequestScoped
+    @Typed(T3.class)
+    public TypedBean3 produce3()
+    {
+        return new TypedBean3();
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b47375ca/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc010/MockedRequestScopedBeanTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc010/MockedRequestScopedBeanTest.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc010/MockedRequestScopedBeanTest.java
new file mode 100644
index 0000000..e8339c3
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc010/MockedRequestScopedBeanTest.java
@@ -0,0 +1,69 @@
+/*
+ * 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.deltaspike.test.testcontrol.mock.uc010;
+
+import org.apache.deltaspike.test.category.SeCategory;
+import org.apache.deltaspike.test.testcontrol.mock.shared.RequestScopedBean;
+import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
+import org.apache.deltaspike.testcontrol.api.mock.DynamicMockManager;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import javax.inject.Inject;
+
+import static org.mockito.Mockito.*;
+
+//Usually NOT needed! Currently only needed due to our arquillian-setup
+@Category(SeCategory.class)
+
+@RunWith(CdiTestRunner.class)
+public class MockedRequestScopedBeanTest
+{
+    @Inject
+    private RequestScopedBean requestScopedBean;
+
+    @Inject
+    private DynamicMockManager mockManager;
+
+    @Test
+    public void mockitoMock1()
+    {
+        RequestScopedBean mockedRequestScopedBean = mock(RequestScopedBean.class);
+        when(mockedRequestScopedBean.getCount()).thenReturn(7);
+        mockManager.addMock(mockedRequestScopedBean);
+
+        Assert.assertEquals(7, requestScopedBean.getCount());
+        requestScopedBean.increaseCount();
+        Assert.assertEquals(7, requestScopedBean.getCount());
+    }
+
+    @Test
+    public void mockitoMock2() //same test with different mock
+    {
+        RequestScopedBean mockedRequestScopedBean = mock(RequestScopedBean.class);
+        when(mockedRequestScopedBean.getCount()).thenReturn(14);
+        mockManager.addMock(mockedRequestScopedBean);
+
+        Assert.assertEquals(14, requestScopedBean.getCount());
+        requestScopedBean.increaseCount();
+        Assert.assertEquals(14, requestScopedBean.getCount());
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b47375ca/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc011/MockedRequestScopedBeanWithInjection.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc011/MockedRequestScopedBeanWithInjection.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc011/MockedRequestScopedBeanWithInjection.java
new file mode 100644
index 0000000..a334ccc
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc011/MockedRequestScopedBeanWithInjection.java
@@ -0,0 +1,38 @@
+/*
+ * 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.deltaspike.test.testcontrol.mock.uc011;
+
+import org.apache.deltaspike.test.testcontrol.mock.shared.RequestScopedBean;
+import org.apache.deltaspike.test.testcontrol.mock.shared.SessionScopedBean;
+
+import javax.enterprise.inject.Typed;
+import javax.inject.Inject;
+
+@Typed() //exclude it for the cdi type-check
+public class MockedRequestScopedBeanWithInjection extends RequestScopedBean
+{
+    @Inject
+    private SessionScopedBean sessionScopedBean;
+
+    @Override
+    public int getCount()
+    {
+        return sessionScopedBean.getCount();
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b47375ca/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc011/MockedRequestScopedBeanWithInjectionTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc011/MockedRequestScopedBeanWithInjectionTest.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc011/MockedRequestScopedBeanWithInjectionTest.java
new file mode 100644
index 0000000..c8fcfea
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc011/MockedRequestScopedBeanWithInjectionTest.java
@@ -0,0 +1,63 @@
+/*
+ * 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.deltaspike.test.testcontrol.mock.uc011;
+
+import org.apache.deltaspike.core.api.provider.BeanProvider;
+import org.apache.deltaspike.test.category.SeCategory;
+import org.apache.deltaspike.test.testcontrol.mock.shared.RequestScopedBean;
+import org.apache.deltaspike.test.testcontrol.mock.shared.SessionScopedBean;
+import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
+import org.apache.deltaspike.testcontrol.api.mock.DynamicMockManager;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import javax.inject.Inject;
+
+//Usually NOT needed! Currently only needed due to our arquillian-setup
+@Category(SeCategory.class)
+
+@RunWith(CdiTestRunner.class)
+public class MockedRequestScopedBeanWithInjectionTest
+{
+    @Inject
+    private RequestScopedBean requestScopedBean;
+
+    @Inject
+    private SessionScopedBean sessionScopedBean;
+
+    @Inject
+    private DynamicMockManager mockManager;
+
+    @Test
+    public void manualMockWithInjection()
+    {
+        RequestScopedBean mockedRequestScopedBean = new MockedRequestScopedBeanWithInjection();
+        BeanProvider.injectFields(mockedRequestScopedBean);
+        mockManager.addMock(mockedRequestScopedBean);
+
+        Assert.assertEquals(0, requestScopedBean.getCount());
+        requestScopedBean.increaseCount(); //not delegated
+        Assert.assertEquals(0, requestScopedBean.getCount());
+        sessionScopedBean.increaseCount();
+        Assert.assertEquals(1, sessionScopedBean.getCount());
+        Assert.assertEquals(1, requestScopedBean.getCount());
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b47375ca/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc012/MockedRequestScopedBeanWithInjection.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc012/MockedRequestScopedBeanWithInjection.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc012/MockedRequestScopedBeanWithInjection.java
new file mode 100644
index 0000000..a4056ad
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc012/MockedRequestScopedBeanWithInjection.java
@@ -0,0 +1,38 @@
+/*
+ * 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.deltaspike.test.testcontrol.mock.uc012;
+
+import org.apache.deltaspike.test.testcontrol.mock.shared.RequestScopedBean;
+import org.apache.deltaspike.test.testcontrol.mock.shared.SessionScopedBean;
+
+import javax.enterprise.inject.Typed;
+import javax.inject.Inject;
+
+@Typed() //exclude it for the cdi type-check
+public class MockedRequestScopedBeanWithInjection extends RequestScopedBean
+{
+    @Inject
+    private SessionScopedBean sessionScopedBean;
+
+    @Override
+    public int getCount()
+    {
+        return sessionScopedBean.getCount();
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b47375ca/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc012/MockedRequestScopedBeanWithInjectionTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc012/MockedRequestScopedBeanWithInjectionTest.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc012/MockedRequestScopedBeanWithInjectionTest.java
new file mode 100644
index 0000000..a649a55
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/mock/uc012/MockedRequestScopedBeanWithInjectionTest.java
@@ -0,0 +1,88 @@
+/*
+ * 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.deltaspike.test.testcontrol.mock.uc012;
+
+import org.apache.deltaspike.core.api.provider.BeanProvider;
+import org.apache.deltaspike.test.category.SeCategory;
+import org.apache.deltaspike.test.testcontrol.mock.shared.RequestScopedBean;
+import org.apache.deltaspike.test.testcontrol.mock.shared.SessionScopedBean;
+import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
+import org.apache.deltaspike.testcontrol.api.mock.DynamicMockManager;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import javax.inject.Inject;
+
+import static org.mockito.Mockito.*;
+
+//Usually NOT needed! Currently only needed due to our arquillian-setup
+@Category(SeCategory.class)
+
+@RunWith(CdiTestRunner.class)
+public class MockedRequestScopedBeanWithInjectionTest
+{
+    @Inject
+    private RequestScopedBean requestScopedBean;
+
+    @Inject
+    private SessionScopedBean sessionScopedBean;
+
+    @Inject
+    private DynamicMockManager mockManager;
+
+    @Test
+    public void mixedMocksWithInjection1()
+    {
+        SessionScopedBean mockedSessionScopedBean = mock(SessionScopedBean.class);
+        when(mockedSessionScopedBean.getCount()).thenReturn(7);
+        mockManager.addMock(mockedSessionScopedBean);
+
+        RequestScopedBean mockedRequestScopedBean = new MockedRequestScopedBeanWithInjection();
+        BeanProvider.injectFields(mockedRequestScopedBean);
+        mockManager.addMock(mockedRequestScopedBean);
+
+        Assert.assertEquals(7, requestScopedBean.getCount());
+        requestScopedBean.increaseCount(); //not delegated
+        Assert.assertEquals(7, requestScopedBean.getCount());
+        sessionScopedBean.increaseCount();
+        Assert.assertEquals(7, sessionScopedBean.getCount()); //still mocked
+        Assert.assertEquals(7, requestScopedBean.getCount()); //still mocked
+    }
+
+    @Test
+    public void mixedMocksWithInjection2()
+    {
+        SessionScopedBean mockedSessionScopedBean = mock(SessionScopedBean.class);
+        when(mockedSessionScopedBean.getCount()).thenReturn(14);
+        mockManager.addMock(mockedSessionScopedBean);
+
+        RequestScopedBean mockedRequestScopedBean = new MockedRequestScopedBeanWithInjection();
+        BeanProvider.injectFields(mockedRequestScopedBean);
+        mockManager.addMock(mockedRequestScopedBean);
+
+        Assert.assertEquals(14, requestScopedBean.getCount());
+        requestScopedBean.increaseCount(); //not delegated
+        Assert.assertEquals(14, requestScopedBean.getCount());
+        sessionScopedBean.increaseCount();
+        Assert.assertEquals(14, sessionScopedBean.getCount()); //still mocked
+        Assert.assertEquals(14, requestScopedBean.getCount()); //still mocked
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b47375ca/deltaspike/modules/test-control/impl/src/test/resources/META-INF/services/org.apache.deltaspike.testcontrol.spi.mock.MockFilter
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/resources/META-INF/services/org.apache.deltaspike.testcontrol.spi.mock.MockFilter b/deltaspike/modules/test-control/impl/src/test/resources/META-INF/services/org.apache.deltaspike.testcontrol.spi.mock.MockFilter
new file mode 100644
index 0000000..8bd801f
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/test/resources/META-INF/services/org.apache.deltaspike.testcontrol.spi.mock.MockFilter
@@ -0,0 +1,18 @@
+# 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.
+
+org.apache.deltaspike.test.testcontrol.InternalTestMockFilter
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b47375ca/deltaspike/parent/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/parent/pom.xml b/deltaspike/parent/pom.xml
index 7b03071..34730b6 100644
--- a/deltaspike/parent/pom.xml
+++ b/deltaspike/parent/pom.xml
@@ -665,6 +665,13 @@
                 <version>1.1.1</version>
                 <scope>provided</scope>
             </dependency>
+
+            <dependency>
+                <groupId>org.mockito</groupId>
+                <artifactId>mockito-all</artifactId>
+                <version>1.9.5</version>
+                <scope>test</scope>
+            </dependency>
         </dependencies>
 
     </dependencyManagement>


Mime
View raw message