openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1562723 [2/3] - in /openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test: managed/ managed/generic/ managed/instance/ managed/instance/beans/ managed/multipleinterfaces/ managed/newcomp/ managed/specialized/ producer/ pr...
Date Thu, 30 Jan 2014 08:33:57 GMT
Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/producer/beans/PrivateProducedBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/producer/beans/PrivateProducedBean.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/producer/beans/PrivateProducedBean.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/producer/beans/PrivateProducedBean.java Thu Jan 30 08:33:55 2014
@@ -0,0 +1,33 @@
+/*
+ * 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.webbeans.test.producer.beans;
+
+import javax.enterprise.inject.Typed;
+
+/**
+ * A sample bean which gets produced by a producer method with modifier 'private'
+ */
+@Typed()
+public class PrivateProducedBean
+{
+    public int getMeaningOfLife()
+    {
+        return 42;
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/producer/beans/PrivateProducedBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/producer/beans/ProtectedProducedBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/producer/beans/ProtectedProducedBean.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/producer/beans/ProtectedProducedBean.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/producer/beans/ProtectedProducedBean.java Thu Jan 30 08:33:55 2014
@@ -0,0 +1,33 @@
+/*
+ * 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.webbeans.test.producer.beans;
+
+import javax.enterprise.inject.Typed;
+
+/**
+ * A sample bean which gets produced by a producer method with modifier 'protected'
+ */
+@Typed()
+public class ProtectedProducedBean
+{
+    public int getMeaningOfLife()
+    {
+        return 42;
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/producer/beans/ProtectedProducedBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/producer/beans/SampleProducerOwner.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/producer/beans/SampleProducerOwner.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/producer/beans/SampleProducerOwner.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/producer/beans/SampleProducerOwner.java Thu Jan 30 08:33:55 2014
@@ -0,0 +1,54 @@
+/*
+ * 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.webbeans.test.producer.beans;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+
+import org.junit.Assert;
+
+/**
+ * The bean which contains a few producer methods which are protected and private.
+ * We use a NormalScope which means the container gets a proxy which it needs to
+ * unwrap on the fly.
+ */
+@RequestScoped
+public class SampleProducerOwner
+{
+    private @Inject SomeUserBean user;
+
+    @Produces
+    protected ProtectedProducedBean createProtected()
+    {
+        // this is only available if proper injection got performed
+        Assert.assertEquals("Hans", user.getName());
+
+        return new ProtectedProducedBean();
+    }
+
+    @Produces
+    private PrivateProducedBean createPrivate()
+    {
+        // this is only available if proper injection got performed
+        Assert.assertEquals("Hans", user.getName());
+
+        return new PrivateProducedBean();
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/producer/beans/SampleProducerOwner.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/producer/beans/SomeUserBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/producer/beans/SomeUserBean.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/producer/beans/SomeUserBean.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/producer/beans/SomeUserBean.java Thu Jan 30 08:33:55 2014
@@ -0,0 +1,33 @@
+/*
+ * 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.webbeans.test.producer.beans;
+
+import javax.enterprise.context.RequestScoped;
+
+/**
+ * Just a dummy user bean which gets injected in to the producermethod owner bean.
+ */
+@RequestScoped
+public class SomeUserBean
+{
+    public String getName()
+    {
+        return "Hans";
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/producer/beans/SomeUserBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/producer/specializes/SpecializesProducer1Test.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/producer/specializes/SpecializesProducer1Test.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/producer/specializes/SpecializesProducer1Test.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/producer/specializes/SpecializesProducer1Test.java Thu Jan 30 08:33:55 2014
@@ -0,0 +1,71 @@
+/*
+ * 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.webbeans.test.producer.specializes;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.util.AnnotationLiteral;
+
+import org.apache.webbeans.test.AbstractUnitTest;
+import org.apache.webbeans.test.annotation.binding.Binding1;
+import org.apache.webbeans.test.annotation.binding.Binding2;
+import org.apache.webbeans.test.component.producer.specializes.SpecializesProducer1;
+import org.apache.webbeans.test.component.producer.specializes.superclazz.SpecializesProducer1SuperClazz;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class SpecializesProducer1Test extends AbstractUnitTest
+{
+
+    @Test
+    public void testSpecializedProducer1()
+    {
+        Collection<String> beanXmls = new ArrayList<String>();
+        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+
+        beanClasses.add(SpecializesProducer1SuperClazz.class);
+        beanClasses.add(SpecializesProducer1.class);
+        
+        startContainer(beanClasses, beanXmls);        
+        
+        Annotation binding1 = new AnnotationLiteral<Binding1>()
+        {
+        };
+        Annotation binding2 = new AnnotationLiteral<Binding2>()
+        {
+        };
+
+        Set beans = getBeanManager().getBeans(int.class, new Annotation[] { binding1, binding2 });
+        System.out.print("Size of the bean set is " + beans.size());
+        Assert.assertTrue(beans.size() == 1);
+        Bean<Integer> bean = (Bean<Integer>)beans.iterator().next();
+        CreationalContext<Integer> cc = getBeanManager().createCreationalContext(bean);
+        Integer number = (Integer) getBeanManager().getReference(bean, int.class, cc);
+        
+        Assert.assertEquals(10000, number.intValue());
+        
+        shutDownContainer();       
+        
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/producer/specializes/SpecializesProducer1Test.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/DecoratorInterceptorProxySerializationTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/DecoratorInterceptorProxySerializationTest.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/DecoratorInterceptorProxySerializationTest.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/DecoratorInterceptorProxySerializationTest.java Thu Jan 30 08:33:55 2014
@@ -0,0 +1,174 @@
+/*
+ * 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.webbeans.test.proxy;
+
+import org.apache.webbeans.test.AbstractUnitTest;
+import org.junit.Test;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.inject.Inject;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InterceptorBinding;
+import javax.interceptor.InvocationContext;
+import java.io.Serializable;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.util.ArrayList;
+
+import static org.apache.webbeans.test.util.Serializations.deserialize;
+import static org.apache.webbeans.test.util.Serializations.serialize;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class DecoratorInterceptorProxySerializationTest extends AbstractUnitTest
+{
+    @Inject
+    private Main client;
+
+    @Test
+    public void testProxyMappingConfig() throws Exception
+    {
+        addDecorator(MyDecorator.class);
+        addInterceptor(IBInterceptor.class);
+        startContainer(new ArrayList<Class<?>>() {{ add(Main.class); }}, null, true);
+
+        try
+        {
+            final Main deserializeInit = Main.class.cast(deserialize(serialize(client)));
+            assertFalse(deserializeInit.isCalled());
+            assertFalse(deserializeInit.isDecoratorCalled());
+            assertFalse(deserializeInit.isInterceptorCalled());
+
+            client.aMethod();
+
+            final Main deserializeState = Main.class.cast(deserialize(serialize(client)));
+            assertTrue(deserializeState.isCalled());
+            assertTrue(deserializeState.isDecoratorCalled());
+            assertTrue(deserializeState.isInterceptorCalled());
+        }
+        finally
+        {
+            shutDownContainer();
+        }
+    }
+
+    public static interface StupidClass
+    {
+        void aMethod();
+        boolean isCalled();
+        boolean isDecoratorCalled();
+        boolean isInterceptorCalled();
+    }
+
+    @InterceptorBinding
+    @Target({ElementType.METHOD, ElementType.TYPE})
+    @Retention(RetentionPolicy.RUNTIME)
+    public static @interface IB
+    {
+    }
+
+    @Interceptor
+    @IB
+    public static class IBInterceptor implements Serializable
+    {
+        private boolean called = false; // just here to represent a state in the serialization
+
+        @AroundInvoke
+        public Object intercept(final InvocationContext ctx) throws Exception
+        {
+            final String name = ctx.getMethod().getName();
+
+            if (name.equals("isInterceptorCalled"))
+            {
+                return called;
+            }
+            else if (!name.startsWith("is"))
+            {
+                called = true;
+            }
+
+            return ctx.proceed();
+        }
+    }
+
+    @Decorator
+    public static class MyDecorator implements Serializable, StupidClass
+    {
+        private boolean called = false; // just here to represent a state in the serialization
+
+        @Inject @Delegate
+        private StupidClass delegate;
+
+        @Override
+        public void aMethod() {
+            called = true;
+            delegate.aMethod();
+        }
+
+        @Override
+        public boolean isCalled() {
+            return delegate.isCalled();
+        }
+
+        @Override
+        public boolean isDecoratorCalled() {
+            return called;
+        }
+
+        @Override
+        public boolean isInterceptorCalled()
+        {
+            return false;
+        }
+    }
+
+    @IB
+    public static class Main implements StupidClass, Serializable
+    {
+        private boolean called = false; // just here to represent a state in the serialization
+
+        @Override
+        public void aMethod()
+        {
+            called = true;
+        }
+
+        @Override
+        public boolean isCalled()
+        {
+            return called;
+        }
+
+        @Override
+        public boolean isDecoratorCalled()
+        {
+            return false;
+        }
+
+        @Override
+        public boolean isInterceptorCalled()
+        {
+            return false;
+        }
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/DecoratorInterceptorProxySerializationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/DecoratorProxySerializationTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/DecoratorProxySerializationTest.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/DecoratorProxySerializationTest.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/DecoratorProxySerializationTest.java Thu Jan 30 08:33:55 2014
@@ -0,0 +1,118 @@
+/*
+ * 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.webbeans.test.proxy;
+
+import org.apache.webbeans.test.AbstractUnitTest;
+import org.junit.Test;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.inject.Inject;
+import java.io.Serializable;
+import java.util.ArrayList;
+
+import static org.apache.webbeans.test.util.Serializations.deserialize;
+import static org.apache.webbeans.test.util.Serializations.serialize;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class DecoratorProxySerializationTest extends AbstractUnitTest
+{
+    @Inject
+    private Main client;
+
+    @Test
+    public void testProxyMappingConfig() throws Exception
+    {
+        addDecorator(MyDecorator.class);
+        startContainer(new ArrayList<Class<?>>() {{ add(Main.class); }}, null, true);
+
+        try
+        {
+            final Main deserializeInit = Main.class.cast(deserialize(serialize(client)));
+            assertFalse(deserializeInit.isCalled());
+            assertFalse(deserializeInit.isDecoratorCalled());
+
+            client.aMethod();
+
+            final Main deserializeState = Main.class.cast(deserialize(serialize(client)));
+            assertTrue(deserializeState.isCalled());
+            assertTrue(deserializeState.isDecoratorCalled());
+        }
+        finally
+        {
+            shutDownContainer();
+        }
+    }
+
+    public static interface StupidClass
+    {
+        void aMethod();
+        boolean isCalled();
+        boolean isDecoratorCalled();
+    }
+
+    @Decorator
+    public static class MyDecorator implements Serializable, StupidClass
+    {
+        private boolean called = false; // just here to represent a state in the serialization
+
+        @Inject @Delegate
+        private StupidClass delegate;
+
+        @Override
+        public void aMethod() {
+            called = true;
+            delegate.aMethod();
+        }
+
+        @Override
+        public boolean isCalled() {
+            return delegate.isCalled();
+        }
+
+        @Override
+        public boolean isDecoratorCalled() {
+            return called;
+        }
+    }
+
+    public static class Main implements StupidClass, Serializable
+    {
+        private boolean called = false; // just here to represent a state in the serialization
+
+        @Override
+        public void aMethod()
+        {
+            called = true;
+        }
+
+        @Override
+        public boolean isCalled()
+        {
+            return called;
+        }
+
+        @Override
+        public boolean isDecoratorCalled()
+        {
+            return false;
+        }
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/DecoratorProxySerializationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/InnerClassProxyTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/InnerClassProxyTest.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/InnerClassProxyTest.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/InnerClassProxyTest.java Thu Jan 30 08:33:55 2014
@@ -0,0 +1,99 @@
+/*
+ * 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.webbeans.test.proxy;
+
+import org.apache.webbeans.test.AbstractUnitTest;
+import org.junit.Test;
+
+import javax.inject.Inject;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InterceptorBinding;
+import javax.interceptor.InvocationContext;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.util.Arrays;
+import java.util.Collections;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+public class InnerClassProxyTest extends AbstractUnitTest {
+    @Inject
+    private Foo foo;
+
+    @Test
+    public void proxy() throws IllegalAccessException, InstantiationException {
+        addInterceptor(InInterceptor.class);
+        startContainer(Arrays.asList(Foo.class, Inner.class), Collections.<String>emptyList(), true);
+        assertNotNull(foo);
+        try {
+            assertEquals("ok", foo.bar(false));
+        } catch (final Exception e) {
+            fail();
+        }
+        try {
+            foo.bar(true);
+            fail();
+        } catch (final Exception e) {
+            // no-op: ok
+        }
+        shutDownContainer();
+    }
+
+    @In
+    public static class Foo {
+        public String bar(final boolean b) throws Inner {
+            if (b) {
+                throw new Inner("fail");
+            }
+            return "ok";
+        }
+    }
+
+    @Interceptor
+    @In
+    public static class InInterceptor
+    {
+        @AroundInvoke
+        public Object invoke(InvocationContext context) throws Exception
+        {
+            return context.proceed();
+        }
+    }
+
+    @InterceptorBinding
+    @Retention(RetentionPolicy.RUNTIME)
+    @Target( { ElementType.TYPE, ElementType.METHOD })
+    public static @interface In {
+    }
+
+    public static class Inner extends RuntimeException {
+        public Inner() {
+            // no-op
+        }
+
+        public Inner(final String message) {
+            super(message);
+        }
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/InnerClassProxyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/InterceptorProxySerializationTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/InterceptorProxySerializationTest.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/InterceptorProxySerializationTest.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/InterceptorProxySerializationTest.java Thu Jan 30 08:33:55 2014
@@ -0,0 +1,174 @@
+/*
+ * 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.webbeans.test.proxy;
+
+import org.apache.webbeans.test.AbstractUnitTest;
+import org.junit.Test;
+
+import javax.inject.Inject;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InterceptorBinding;
+import javax.interceptor.InvocationContext;
+import java.io.Serializable;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.util.Arrays;
+
+import static org.apache.webbeans.test.util.Serializations.deserialize;
+import static org.apache.webbeans.test.util.Serializations.serialize;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class InterceptorProxySerializationTest extends AbstractUnitTest
+{
+    @Inject
+    private Intercepted client;
+
+    @Inject
+    private AutoIntercepted auto;
+
+    @Test
+    public void testProxyMappingConfig() throws Exception
+    {
+        addInterceptor(IBInterceptor.class);
+        startContainer(Arrays.<Class<?>>asList(Intercepted.class, AutoIntercepted.class, InjectMeInInterceptor.class), null, true);
+
+        try
+        {
+            final Intercepted deserializeInit = Intercepted.class.cast(deserialize(serialize(client)));
+            assertFalse(deserializeInit.isCalled());
+            assertFalse(deserializeInit.isInterceptorCalled());
+
+            client.intercepted();
+
+            final Intercepted deserializeState = Intercepted.class.cast(deserialize(serialize(client)));
+            assertTrue(deserializeState.isCalled());
+            assertTrue(deserializeState.isInterceptorCalled());
+        }
+        finally
+        {
+            shutDownContainer();
+        }
+    }
+
+    @Test
+    public void testSerializableEvenIfAutoIntercepted() throws Exception
+    {
+        addInterceptor(IBInterceptor.class);
+        startContainer(Arrays.<Class<?>>asList(Intercepted.class, AutoIntercepted.class, InjectMeInInterceptor.class), null, true);
+
+        try
+        {
+            AutoIntercepted.called = false;
+            auto.touch();
+            assertTrue(AutoIntercepted.called);
+
+            final AutoIntercepted deserializeInit = AutoIntercepted.class.cast(deserialize(serialize(auto)));
+            AutoIntercepted.called = false;
+            deserializeInit.touch();
+            assertTrue(AutoIntercepted.called);
+
+            final AutoIntercepted deserializeState = AutoIntercepted.class.cast(deserialize(serialize(deserializeInit)));
+            AutoIntercepted.called = false;
+            deserializeState.touch();
+            assertTrue(AutoIntercepted.called);
+        }
+        finally
+        {
+            shutDownContainer();
+        }
+    }
+
+    @InterceptorBinding
+    @Target({ElementType.METHOD, ElementType.TYPE})
+    @Retention(RetentionPolicy.RUNTIME)
+    public static @interface IB
+    {
+    }
+
+    public static class InjectMeInInterceptor implements Serializable {
+        public void touch() {}
+    }
+
+    @Interceptor @IB
+    public static class IBInterceptor implements Serializable
+    {
+        private boolean called = false; // just here to represent a state in the serialization
+
+        @Inject
+        private InjectMeInInterceptor injected;
+
+        @AroundInvoke
+        public Object intercept(final InvocationContext ctx) throws Exception
+        {
+            injected.touch(); // will throw NPE if wrongly serialized
+
+            final String name = ctx.getMethod().getName();
+
+            if (name.equals("isInterceptorCalled"))
+            {
+                return called;
+            }
+            else if (!name.startsWith("is"))
+            {
+                called = true;
+            }
+
+            return ctx.proceed();
+        }
+    }
+
+    @IB
+    public static class Intercepted implements Serializable
+    {
+        private boolean called = false; // just here to represent a state in the serialization
+
+        public void intercepted()
+        {
+            called = true;
+        }
+
+        public boolean isCalled()
+        {
+            return called;
+        }
+
+        public boolean isInterceptorCalled()
+        {
+            return false;
+        }
+    }
+
+    @IB
+    public static class AutoIntercepted implements Serializable
+    {
+        public static boolean called = false;
+
+        @AroundInvoke
+        public Object auto(final InvocationContext ic)  throws Exception {
+            called = true;
+            return ic.proceed();
+        }
+
+        public void touch() {}
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/InterceptorProxySerializationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/ProxyMappingTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/ProxyMappingTest.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/ProxyMappingTest.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/ProxyMappingTest.java Thu Jan 30 08:33:55 2014
@@ -0,0 +1,71 @@
+/*
+ * 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.webbeans.test.proxy;
+
+
+import javax.inject.Provider;
+
+import org.apache.webbeans.intercept.ApplicationScopedBeanInterceptorHandler;
+import org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler;
+import org.apache.webbeans.test.AbstractUnitTest;
+import org.apache.webbeans.test.proxy.beans.ApplicationBean;
+import org.apache.webbeans.test.proxy.beans.ConversationBean;
+import org.apache.webbeans.test.proxy.beans.DummyScopedExtension;
+import org.apache.webbeans.proxy.OwbNormalScopeProxy;
+import org.junit.Test;
+import org.junit.Assert;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * Test the mapping of scopes to proxy MethodHandler implementations.
+ */
+public class ProxyMappingTest extends AbstractUnitTest
+{
+
+    @Test
+    public void testProxyMappingConfig()
+    {
+        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+
+        addExtension(new DummyScopedExtension());
+        beanClasses.add(ConversationBean.class);
+        beanClasses.add(ApplicationBean.class);
+        startContainer(beanClasses, null);
+
+        ConversationBean conversationBean = getInstance(ConversationBean.class);
+        Assert.assertNotNull(conversationBean);
+        Assert.assertTrue(conversationBean instanceof OwbNormalScopeProxy);
+
+        Provider instanceProvider = getWebBeansContext().getNormalScopeProxyFactory().getInstanceProvider((OwbNormalScopeProxy) conversationBean);
+        Assert.assertNotNull(instanceProvider);
+        Assert.assertEquals(instanceProvider.getClass(), NormalScopedBeanInterceptorHandler.class);
+
+
+        ApplicationBean applicationBean = getInstance(ApplicationBean.class);
+        Assert.assertNotNull(applicationBean);
+        Assert.assertTrue(applicationBean instanceof OwbNormalScopeProxy);
+        instanceProvider = getWebBeansContext().getNormalScopeProxyFactory().getInstanceProvider((OwbNormalScopeProxy) applicationBean);
+        Assert.assertNotNull(instanceProvider);
+        Assert.assertEquals(instanceProvider.getClass(), ApplicationScopedBeanInterceptorHandler.class);
+
+    }
+
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/ProxyMappingTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/beans/ApplicationBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/beans/ApplicationBean.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/beans/ApplicationBean.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/beans/ApplicationBean.java Thu Jan 30 08:33:55 2014
@@ -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.webbeans.test.proxy.beans;
+
+
+import javax.enterprise.context.ApplicationScoped;
+
+/**
+ * To test the proxy for application scoped beans.
+ */
+@ApplicationScoped
+public class ApplicationBean
+{
+    public DummyBean.SomeInnerClass getValueHolder() throws DummyBean.SomeInnerException
+    {
+        return new DummyBean.SomeInnerClass("hola");
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/beans/ApplicationBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/beans/ConversationBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/beans/ConversationBean.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/beans/ConversationBean.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/beans/ConversationBean.java Thu Jan 30 08:33:55 2014
@@ -0,0 +1,31 @@
+/*
+ * 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.webbeans.test.proxy.beans;
+
+
+import javax.enterprise.context.ConversationScoped;
+import java.io.Serializable;
+
+/**
+ * To test the proxy for conversation scoped beans.
+ */
+@ConversationScoped
+public class ConversationBean implements Serializable
+{
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/beans/ConversationBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/beans/DummyBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/beans/DummyBean.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/beans/DummyBean.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/beans/DummyBean.java Thu Jan 30 08:33:55 2014
@@ -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.webbeans.test.proxy.beans;
+
+/**
+ * This class just exists as container for some inner classes.
+ */
+public class DummyBean {
+    public static class SomeInnerClass
+    {
+        private String val;
+
+        public SomeInnerClass(String val) {
+            this.val = val;
+        }
+
+        public String getVal()
+        {
+            return val;
+        }
+    }
+
+    public static class SomeInnerException extends Exception
+    {
+        public SomeInnerException() {
+            super();
+        }
+
+        public SomeInnerException(String message) {
+            super(message);
+        }
+
+        public SomeInnerException(String message, Throwable cause) {
+            super(message, cause);
+        }
+
+        public SomeInnerException(Throwable cause) {
+            super(cause);
+        }
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/beans/DummyBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/beans/DummyScoped.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/beans/DummyScoped.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/beans/DummyScoped.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/beans/DummyScoped.java Thu Jan 30 08:33:55 2014
@@ -0,0 +1,42 @@
+/*
+ * 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.webbeans.test.proxy.beans;
+
+import javax.enterprise.context.NormalScope;
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Dummy Scope implementation for testing the proxy methodhandler mapping
+ */
+@Target( { TYPE, METHOD, FIELD })
+@Retention(RUNTIME)
+@Documented
+@NormalScope
+@Inherited
+public @interface DummyScoped
+{
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/beans/DummyScoped.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/beans/DummyScopedContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/beans/DummyScopedContext.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/beans/DummyScopedContext.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/beans/DummyScopedContext.java Thu Jan 30 08:33:55 2014
@@ -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.webbeans.test.proxy.beans;
+
+import javax.enterprise.context.spi.Context;
+import javax.enterprise.context.spi.Contextual;
+import javax.enterprise.context.spi.CreationalContext;
+import java.lang.annotation.Annotation;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Context for the DummyScope
+ */
+public class DummyScopedContext implements Context
+{
+    private Map<Contextual<?>, Object> map = new HashMap<Contextual<?>, Object>();
+
+    @Override
+    public <T> T get(Contextual<T> component)
+    {
+        return (T) map.get(component);
+    }
+
+    @Override
+    public Class<? extends Annotation> getScope()
+    {
+        return DummyScoped.class;
+    }
+
+    @Override
+    public <T> T get(Contextual<T> component, CreationalContext<T> creationalContext)
+    {
+        Object obj = map.get(component);
+        if (obj == null)
+        {
+            obj = component.create(creationalContext);
+            map.put(component, obj);
+        }
+        return (T) obj;
+    }
+
+    @Override
+    public boolean isActive()
+    {
+        return true;
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/beans/DummyScopedContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/beans/DummyScopedExtension.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/beans/DummyScopedExtension.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/beans/DummyScopedExtension.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/beans/DummyScopedExtension.java Thu Jan 30 08:33:55 2014
@@ -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.webbeans.test.proxy.beans;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.Extension;
+
+/**
+ * Register the DummyScopedContext
+ */
+public class DummyScopedExtension implements Extension
+{
+    public void registerDummyScopedContext(@Observes AfterBeanDiscovery afterBeanDiscovery)
+    {
+        afterBeanDiscovery.addContext(new DummyScopedContext());
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/proxy/beans/DummyScopedExtension.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/AdvancedPenProducer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/AdvancedPenProducer.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/AdvancedPenProducer.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/AdvancedPenProducer.java Thu Jan 30 08:33:55 2014
@@ -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.webbeans.test.specalization;
+
+import javax.enterprise.inject.Alternative;
+import javax.enterprise.inject.New;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.Specializes;
+
+@Alternative
+public class AdvancedPenProducer extends DefaultPenProducer {
+
+   @Override
+   @Produces
+   @Alternative
+   @Specializes
+   @QualifierSpecialized IPen makeMeAPen(@New Pen pen) {
+      pen.str = "An advanced ";
+      return pen;
+   }
+
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/AdvancedPenProducer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/AlternativeSpecializesProducerTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/AlternativeSpecializesProducerTest.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/AlternativeSpecializesProducerTest.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/AlternativeSpecializesProducerTest.java Thu Jan 30 08:33:55 2014
@@ -0,0 +1,71 @@
+/*
+ * 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.webbeans.test.specalization;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.util.AnnotationLiteral;
+
+import junit.framework.Assert;
+
+import org.apache.webbeans.test.AbstractUnitTest;
+import org.junit.Test;
+
+public class AlternativeSpecializesProducerTest extends AbstractUnitTest
+{
+
+    private static final String PACKAGE_NAME = AlternativeSpecializesProducerTest.class.getPackage().getName();
+
+    @Test
+    @SuppressWarnings("unchecked")
+    public void testAlternativeSpecializeBean()
+    {
+        Collection<String> beanXmls = new ArrayList<String>();
+        beanXmls.add(getXmlPath(PACKAGE_NAME, "AlternativeSpecializesProducer"));
+        
+        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+        beanClasses.add(Pen.class);
+        beanClasses.add(DefaultPenProducer.class);
+        beanClasses.add(AdvancedPenProducer.class);
+        beanClasses.add(PremiumPenProducer.class);
+
+        startContainer(beanClasses, beanXmls);        
+
+        Annotation[] anns = new Annotation[1];
+        anns[0] = new AnnotationLiteral<QualifierSpecialized>()
+        {
+        };
+
+
+        Set<Bean<?>> beans = getBeanManager().getBeans(IPen.class, anns);
+        Assert.assertTrue(beans.size() == 1);
+        Bean<IPen> bean = (Bean<IPen>)beans.iterator().next();
+        CreationalContext<IPen> cc = getBeanManager().createCreationalContext(bean);
+        IPen pen = (IPen) getBeanManager().getReference(bean, IPen.class, cc);
+        Assert.assertTrue(pen.getID().contains("premium"));
+        
+        shutDownContainer();
+    }
+
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/AlternativeSpecializesProducerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/DefaultPenProducer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/DefaultPenProducer.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/DefaultPenProducer.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/DefaultPenProducer.java Thu Jan 30 08:33:55 2014
@@ -0,0 +1,32 @@
+/*
+ * 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.webbeans.test.specalization;
+
+import javax.enterprise.inject.New;
+import javax.enterprise.inject.Produces;
+
+public class DefaultPenProducer {
+
+   @Produces @QualifierSpecialized IPen makeMeAPen(@New Pen pen) {
+      pen.str = "An default ";
+      return pen;
+   }
+
+
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/DefaultPenProducer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/IPen.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/IPen.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/IPen.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/IPen.java Thu Jan 30 08:33:55 2014
@@ -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.webbeans.test.specalization;
+
+public interface IPen {
+
+   public String getID();
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/IPen.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/Pen.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/Pen.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/Pen.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/Pen.java Thu Jan 30 08:33:55 2014
@@ -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.webbeans.test.specalization;
+
+import javax.inject.Inject;
+
+public class Pen implements IPen {
+
+   String str;
+
+   @Inject
+   public Pen() {
+      this.str = "";
+   }
+
+   @Override
+   public String getID() {
+      return str + " Pen";
+   }
+
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/Pen.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/PremiumPenProducer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/PremiumPenProducer.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/PremiumPenProducer.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/PremiumPenProducer.java Thu Jan 30 08:33:55 2014
@@ -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.webbeans.test.specalization;
+
+import javax.enterprise.inject.Alternative;
+import javax.enterprise.inject.New;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.Specializes;
+
+@Alternative
+public class PremiumPenProducer extends AdvancedPenProducer {
+
+   @Override
+   @Produces
+   @Alternative
+   @Specializes
+   @QualifierSpecialized IPen makeMeAPen(@New Pen pen) {
+      pen.str = "An premium ";
+      return pen;
+   }
+
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/PremiumPenProducer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/QualifierSpecialized.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/QualifierSpecialized.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/QualifierSpecialized.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/QualifierSpecialized.java Thu Jan 30 08:33:55 2014
@@ -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.webbeans.test.specalization;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE, ElementType.PARAMETER, ElementType.METHOD,ElementType.CONSTRUCTOR,ElementType.FIELD})
+
+public @interface QualifierSpecialized {
+
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/QualifierSpecialized.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/disabledspecialization/DisabledSpecializationTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/disabledspecialization/DisabledSpecializationTest.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/disabledspecialization/DisabledSpecializationTest.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/disabledspecialization/DisabledSpecializationTest.java Thu Jan 30 08:33:55 2014
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.test.specalization.disabledspecialization;
+
+import org.apache.webbeans.test.AbstractUnitTest;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Test that &#064;Specializes on disabled beans is no problem.
+ */
+public class DisabledSpecializationTest extends AbstractUnitTest
+{
+
+    @Test
+    public void testSpecialization() throws Exception{
+        addExtension(new VetoMeExtension());
+        startContainer(LoginService.class, MockLoginService.class);
+
+        LoginService loginService = getInstance(LoginService.class);
+        Assert.assertNotNull(loginService);
+
+        Assert.assertFalse(loginService.login("dummy"));
+    }
+
+
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/disabledspecialization/DisabledSpecializationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/disabledspecialization/LoginService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/disabledspecialization/LoginService.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/disabledspecialization/LoginService.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/disabledspecialization/LoginService.java Thu Jan 30 08:33:55 2014
@@ -0,0 +1,33 @@
+/*
+ * 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.webbeans.test.specalization.disabledspecialization;
+
+import javax.enterprise.context.Dependent;
+
+/**
+ * This dummy login service always denies the login attempt.
+ */
+@Dependent
+public class LoginService
+{
+    public boolean login(String userId)
+    {
+        return false;
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/disabledspecialization/LoginService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/disabledspecialization/MockLoginService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/disabledspecialization/MockLoginService.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/disabledspecialization/MockLoginService.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/disabledspecialization/MockLoginService.java Thu Jan 30 08:33:55 2014
@@ -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.webbeans.test.specalization.disabledspecialization;
+
+import javax.enterprise.context.Dependent;
+import javax.enterprise.inject.Specializes;
+
+/**
+ * And this version always logs in.
+ *
+ * The important point is that this version is always
+ * disabled via a veto Extension through ProcessAnnotatedType.
+ */
+@Dependent
+@Specializes
+@VetoMe
+public class MockLoginService extends LoginService
+{
+    @Override
+    public boolean login(String userId)
+    {
+        return true;
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/disabledspecialization/MockLoginService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/disabledspecialization/VetoMe.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/disabledspecialization/VetoMe.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/disabledspecialization/VetoMe.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/disabledspecialization/VetoMe.java Thu Jan 30 08:33:55 2014
@@ -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.webbeans.test.specalization.disabledspecialization;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Veto all beans annotated with this marker.
+ */
+@Target( { ElementType.METHOD, ElementType.TYPE, ElementType.FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Documented
+public @interface VetoMe
+{
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/disabledspecialization/VetoMe.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/disabledspecialization/VetoMeExtension.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/disabledspecialization/VetoMeExtension.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/disabledspecialization/VetoMeExtension.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/disabledspecialization/VetoMeExtension.java Thu Jan 30 08:33:55 2014
@@ -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.webbeans.test.specalization.disabledspecialization;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.ProcessAnnotatedType;
+
+/**
+ * A CDI Extension which handles the {@link VetoMe} annotations.
+ */
+public class VetoMeExtension implements Extension
+{
+    public void vetoTheBeans(@Observes ProcessAnnotatedType pat)
+    {
+        if (pat.getAnnotatedType().isAnnotationPresent(VetoMe.class))
+        {
+            pat.veto();
+        }
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/disabledspecialization/VetoMeExtension.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/multiple/BeanA.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/multiple/BeanA.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/multiple/BeanA.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/multiple/BeanA.java Thu Jan 30 08:33:55 2014
@@ -0,0 +1,32 @@
+/*
+ * 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.webbeans.test.specalization.multiple;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Named;
+
+@Named
+@RequestScoped
+public class BeanA
+{
+    public Class getBeanClass()
+    {
+        return BeanA.class;
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/multiple/BeanA.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/multiple/BeanB.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/multiple/BeanB.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/multiple/BeanB.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/multiple/BeanB.java Thu Jan 30 08:33:55 2014
@@ -0,0 +1,31 @@
+/*
+ * 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.webbeans.test.specalization.multiple;
+
+import javax.enterprise.inject.Specializes;
+
+@Specializes
+public class BeanB extends BeanA
+{
+    @Override
+    public Class getBeanClass()
+    {
+        return BeanB.class;
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/multiple/BeanB.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/multiple/BeanC.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/multiple/BeanC.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/multiple/BeanC.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/multiple/BeanC.java Thu Jan 30 08:33:55 2014
@@ -0,0 +1,31 @@
+/*
+ * 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.webbeans.test.specalization.multiple;
+
+import javax.enterprise.inject.Specializes;
+
+@Specializes
+public class BeanC extends BeanB
+{
+    @Override
+    public Class getBeanClass()
+    {
+        return BeanC.class;
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/multiple/BeanC.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/multiple/BeanD.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/multiple/BeanD.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/multiple/BeanD.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/multiple/BeanD.java Thu Jan 30 08:33:55 2014
@@ -0,0 +1,33 @@
+/*
+ * 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.webbeans.test.specalization.multiple;
+
+import javax.enterprise.inject.Specializes;
+import javax.inject.Named;
+
+@Named
+@Specializes
+public class BeanD extends BeanC
+{
+    @Override
+    public Class getBeanClass()
+    {
+        return BeanD.class;
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/multiple/BeanD.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/multiple/MultipleSpecializationTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/multiple/MultipleSpecializationTest.java?rev=1562723&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/multiple/MultipleSpecializationTest.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/multiple/MultipleSpecializationTest.java Thu Jan 30 08:33:55 2014
@@ -0,0 +1,86 @@
+/*
+ * 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.webbeans.test.specalization.multiple;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import junit.framework.Assert;
+import org.apache.webbeans.exception.WebBeansConfigurationException;
+import javax.enterprise.inject.spi.DefinitionException;
+
+import org.apache.webbeans.test.AbstractUnitTest;
+import org.junit.Test;
+
+public class MultipleSpecializationTest extends AbstractUnitTest
+{
+    /**
+     * Tests that multiple specialization must be possible
+     */
+    @Test
+    public void testMultipleSpecialization()
+    {
+        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+        beanClasses.add(BeanA.class);
+        beanClasses.add(BeanB.class);
+        beanClasses.add(BeanC.class);
+
+        startContainer(beanClasses, null);
+
+        BeanA beanA = getInstance(BeanA.class);
+        Assert.assertEquals(BeanC.class, beanA.getBeanClass());
+
+        beanA = getInstance("beanA");
+        Assert.assertEquals(BeanC.class, beanA.getBeanClass());
+
+        BeanB beanB = getInstance(BeanB.class);
+        Assert.assertEquals(BeanC.class, beanB.getBeanClass());
+
+        shutDownContainer();
+    }
+    
+    /**
+     * Tests that a specialization must not have a @Named annotation
+     */
+    @Test
+    public void testFailMultipleSpecializationWithNamed()
+    {
+        Exception occuredException = null;
+        
+        try
+        {
+            Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+            beanClasses.add(BeanA.class);
+            beanClasses.add(BeanB.class);
+            beanClasses.add(BeanC.class);
+            beanClasses.add(BeanD.class);
+
+            startContainer(beanClasses, null);
+        }
+        catch (Exception e)
+        {
+            occuredException = e;
+        }
+
+        Assert.assertNotNull(occuredException);
+        Assert.assertEquals(WebBeansConfigurationException.class.getName(), occuredException.getClass().getName());
+        Assert.assertEquals(DefinitionException.class.getName(), occuredException.getCause().getClass().getName());
+        
+        shutDownContainer();
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/multiple/MultipleSpecializationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message