/*
 * 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.unittests.intercept;

import java.util.List;

import junit.framework.Assert;

import org.apache.webbeans.component.AbstractOwbBean;
import org.apache.webbeans.component.ManagedBean;
import org.apache.webbeans.config.WebBeansContext;
import org.apache.webbeans.context.ContextFactory;
import org.apache.webbeans.intercept.InterceptorData;
import org.apache.webbeans.test.TestContext;
import org.apache.webbeans.test.component.CheckWithCheckPayment;
import org.apache.webbeans.test.component.PostConstructInterceptorComponent;
import org.junit.Before;
import org.junit.Test;

public class PostConstructInterceptorComponentTest extends TestContext
{
    public PostConstructInterceptorComponentTest()
    {
        super(PostConstructInterceptorComponentTest.class.getSimpleName());
    }

    @Before
    public void init()
    {
        super.init();
    }

    @SuppressWarnings("unchecked")
    @Test
    public void testTypedComponent() throws Throwable
    {
        clear();

        defineManagedBean(CheckWithCheckPayment.class);
        defineManagedBean(PostConstructInterceptorComponent.class);
        List<AbstractOwbBean<?>> comps = getComponents();

        ContextFactory contextFactory = WebBeansContext.getInstance().getContextFactory();
        contextFactory.initRequestContext(null);

        Assert.assertEquals(2, comps.size());

        Object object = getManager().getInstance(comps.get(0));
        Object object2 = getManager().getInstance(comps.get(1));

        Assert.assertTrue(object instanceof CheckWithCheckPayment);
        Assert.assertTrue(object2 instanceof PostConstructInterceptorComponent);

        PostConstructInterceptorComponent pcc = (PostConstructInterceptorComponent) object2;

        ManagedBean<PostConstructInterceptorComponent> s = (ManagedBean<PostConstructInterceptorComponent>) comps.get(1);

        Assert.assertNotNull(pcc.getP());

        List<InterceptorData> stack = s.getInterceptorStack();

        Assert.assertEquals(2, stack.size());

        contextFactory.destroyRequestContext(null);
    }

}

@@ -871,23 +871,27 @@
 til.
+Array
 List;%0A
-%0A
 import j
 unit
@@ -890,187 +890,62 @@
 rt j
-unit.framework.Assert;%0A%0Aimport org.apache.webbeans.component.AbstractOwbBean;%0Aimport org.apache.webbeans.component.ManagedBean;%0Aimport org.apache.webbeans.config.WebBeansContex
+ava.util.Collection;%0A%0Aimport junit.framework.Asser
 t;%0A
+%0A
 impo
@@ -971,128 +971,32 @@
 ans.
-context.ContextFactory;%0Aimport org.apache.webbeans.intercept.InterceptorData;%0Aimport org.apache.webbeans.test.TestContex
+newtests.AbstractUnitTes
 t;%0Ai
@@ -1140,33 +1140,8 @@
 nt;%0A
-import org.junit.Before;%0A
 impo
@@ -1223,900 +1223,193 @@
 nds 
-TestContext%0A%7B%0A    public PostConstructInterceptorComponentTest()%0A    %7B%0A        super(PostConstructInterceptorComponentTest.class.getSimpleName());%0A    %7D%0A%0A    @Before%0A    public void init()%0A    %7B%0A        super.init();%0A    %7D%0A%0A    @SuppressWarnings(%22unchecked%22)%0A    @Test%0A    public void testTypedComponent() throws Throwable%0A    %7B%0A        clear();%0A%0A        defineManagedBean(CheckWithCheckPayment.class);%0A        defineManagedBean(PostConstructInterceptorComponent.class);%0A        List%3CAbstractOwbBean%3C?%3E%3E comps = getComponents();%0A%0A        ContextFactory contextFactory = WebBeansContext.getInstance().getContextFactory();%0A        contextFactory.initRequestContext(null);%0A%0A        Assert.assertEquals(2, comps.size());%0A%0A        Object object = getManager().getInstance(comps.get(0));%0A        Object object2 = getManager().getInstance(comps.get(1));%0A%0A        Assert.assertTrue(object instanceof 
+AbstractUnitTest%0A%7B%0A%0A%0A    @Test%0A    public void testTypedComponent() throws Throwable%0A    %7B%0A        Collection%3CClass%3C?%3E%3E beanClasses = new ArrayList%3CClass%3C?%3E%3E();%0A        beanClasses.add(
 Chec
@@ -1425,16 +1425,22 @@
 kPayment
+.class
 );%0A     
@@ -1446,45 +1446,24 @@
     
-Assert.assertTrue(object2 instanceof 
+beanClasses.add(
 Post
@@ -1491,16 +1491,22 @@
 omponent
+.class
 );%0A%0A    
@@ -1513,114 +1513,52 @@
     
-PostConstructInterceptorComponent pcc = (PostConstructInterceptorComponent) object2;%0A%0A        ManagedBean%3C
+startContainer(beanClasses, null);%0A%0A        
 Post
@@ -1590,27 +1590,27 @@
 nent
-%3E s = (ManagedBean%3C
+ pcc = getInstance(
 Post
@@ -1642,22 +1642,14 @@
 nent
-%3E) comps.get(1
+.class
 );%0A%0A
@@ -1703,160 +1703,26 @@
     
-List%3CInterceptorData%3E stack = s.getInterceptorStack();%0A%0A        Assert.assertEquals(2, stack.size());%0A%0A        contextFactory.destroyRequestContext(null
+shutDownContainer(
 );%0A 

OWB-344 fix another broken test.