Repository: deltaspike Updated Branches: refs/heads/master 3d457b21c -> e90019fd9
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e90019fd/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc005/SuperInterface.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc005/SuperInterface.java b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc005/SuperInterface.java index 7dfc7a8..90de954 100644 --- a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc005/SuperInterface.java +++ b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc005/SuperInterface.java @@ -1,24 +1,24 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.deltaspike.test.core.api.partialbean.uc005; - -public interface SuperInterface -{ - String willFail(); -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.deltaspike.test.core.api.partialbean.uc005; + +public interface SuperInterface +{ + String willFail(); +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e90019fd/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc006/AbstractSuper.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc006/AbstractSuper.java b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc006/AbstractSuper.java index 9e09abf..8b1a8fd 100644 --- a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc006/AbstractSuper.java +++ b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc006/AbstractSuper.java @@ -1,31 +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.deltaspike.test.core.api.partialbean.uc006; - -public abstract class AbstractSuper<T> extends AbstractSuperSuper -{ - abstract T willFail2() throws ClassNotFoundException, NoSuchMethodException, NoSuchFieldException; - - @Override - public String willFail3() throws ClassNotFoundException, NoSuchMethodException, NoSuchFieldException - { - return "willFail3"; - } -} +/* +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.deltaspike.test.core.api.partialbean.uc006; + +public abstract class AbstractSuper<T> extends AbstractSuperSuper +{ + public abstract T willFail2() throws Throwable; + + @Override + public String willFail3() throws ClassNotFoundException, NoSuchMethodException, NoSuchFieldException + { + return "willFail3"; + } +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e90019fd/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc006/AbstractSuperSuper.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc006/AbstractSuperSuper.java b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc006/AbstractSuperSuper.java index 1a0233e..a095a02 100644 --- a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc006/AbstractSuperSuper.java +++ b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc006/AbstractSuperSuper.java @@ -1,25 +1,25 @@ -/* -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.deltaspike.test.core.api.partialbean.uc006; - -public abstract class AbstractSuperSuper -{ - public abstract String willFail3() throws ClassNotFoundException, NoSuchMethodException, NoSuchFieldException; -} +/* +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.deltaspike.test.core.api.partialbean.uc006; + +public abstract class AbstractSuperSuper +{ + public abstract String willFail3() throws Throwable; +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e90019fd/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc006/ApplicationScopedPartialBean.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc006/ApplicationScopedPartialBean.java b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc006/ApplicationScopedPartialBean.java index 35c5fe2..b6c045d 100644 --- a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc006/ApplicationScopedPartialBean.java +++ b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc006/ApplicationScopedPartialBean.java @@ -1,36 +1,36 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.deltaspike.test.core.api.partialbean.uc006; - -import org.apache.deltaspike.test.core.api.partialbean.shared.ThrowExceptionPartialBeanBinding; -import javax.enterprise.context.ApplicationScoped; - -@ThrowExceptionPartialBeanBinding -@ApplicationScoped -public abstract class ApplicationScopedPartialBean extends AbstractSuper<String> -{ - private int count; - - public abstract String getResult(); - - public int getManualResult() - { - return count++; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.deltaspike.test.core.api.partialbean.uc006; + +import org.apache.deltaspike.test.core.api.partialbean.shared.ThrowExceptionPartialBeanBinding; +import javax.enterprise.context.ApplicationScoped; + +@ThrowExceptionPartialBeanBinding +@ApplicationScoped +public abstract class ApplicationScopedPartialBean extends AbstractSuper<String> +{ + private int count; + + public abstract String getResult(); + + public int getManualResult() + { + return count++; + } +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e90019fd/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc006/ScopedPartialBeanTest.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc006/ScopedPartialBeanTest.java b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc006/ScopedPartialBeanTest.java index 0321e14..48b80e0 100644 --- a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc006/ScopedPartialBeanTest.java +++ b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc006/ScopedPartialBeanTest.java @@ -1,75 +1,75 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.deltaspike.test.core.api.partialbean.uc006; - -import org.apache.deltaspike.core.api.provider.BeanProvider; -import org.apache.deltaspike.test.core.api.partialbean.shared.TestPartialBeanBinding; -import org.apache.deltaspike.test.core.api.partialbean.util.ArchiveUtils; -import org.jboss.arquillian.container.test.api.Deployment; -import org.jboss.arquillian.junit.Arquillian; -import org.jboss.shrinkwrap.api.ShrinkWrap; -import org.jboss.shrinkwrap.api.asset.EmptyAsset; -import org.jboss.shrinkwrap.api.spec.JavaArchive; -import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(Arquillian.class) -public class ScopedPartialBeanTest -{ - @Deployment - public static WebArchive war() - { - final String simpleName = ScopedPartialBeanTest.class.getSimpleName(); - final String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1); - - final JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, archiveName + ".jar") - .addPackage(ScopedPartialBeanTest.class.getPackage()) - .addPackage(TestPartialBeanBinding.class.getPackage()) - .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); - - final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, archiveName + ".war") - .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndPartialBeanArchive()) - .addAsLibraries(testJar) - .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); - - return webArchive; - } - - @Test - public void testPartialBeanWithApplicationScope() throws Exception - { - ApplicationScopedPartialBean bean = BeanProvider.getContextualReference(ApplicationScopedPartialBean.class); - bean.getManualResult(); - - Assert.assertEquals("willFail3", bean.willFail3()); - - try - { - BeanProvider.getContextualReference(ApplicationScopedPartialBean.class).willFail2(); - - Assert.fail("#willFail2 should actually throw a ClassNotFoundException"); - } - catch (Exception e) - { - Assert.assertEquals(e.getClass(), ClassNotFoundException.class); - } - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.deltaspike.test.core.api.partialbean.uc006; + +import org.apache.deltaspike.core.api.provider.BeanProvider; +import org.apache.deltaspike.test.core.api.partialbean.shared.TestPartialBeanBinding; +import org.apache.deltaspike.test.core.api.partialbean.util.ArchiveUtils; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(Arquillian.class) +public class ScopedPartialBeanTest +{ + @Deployment + public static WebArchive war() + { + final String simpleName = ScopedPartialBeanTest.class.getSimpleName(); + final String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1); + + final JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, archiveName + ".jar") + .addPackage(ScopedPartialBeanTest.class.getPackage()) + .addPackage(TestPartialBeanBinding.class.getPackage()) + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); + + final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, archiveName + ".war") + .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndPartialBeanArchive()) + .addAsLibraries(testJar) + .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); + + return webArchive; + } + + @Test + public void testPartialBeanWithApplicationScope() throws Throwable + { + ApplicationScopedPartialBean bean = BeanProvider.getContextualReference(ApplicationScopedPartialBean.class); + bean.getManualResult(); + + Assert.assertEquals("willFail3", bean.willFail3()); + + try + { + bean.willFail2(); + + Assert.fail("#willFail2 should actually throw a ClassNotFoundException"); + } + catch (Exception e) + { + Assert.assertEquals(e.getClass(), ClassNotFoundException.class); + } + } +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e90019fd/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc006/TestPartialBeanHandler.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc006/TestPartialBeanHandler.java b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc006/TestPartialBeanHandler.java index e6f4ab5..abf0ce6 100644 --- a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc006/TestPartialBeanHandler.java +++ b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc006/TestPartialBeanHandler.java @@ -1,63 +1,63 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.deltaspike.test.core.api.partialbean.uc006; - -import org.apache.deltaspike.test.core.api.partialbean.shared.TestBean; -import org.apache.deltaspike.test.core.api.partialbean.shared.TestInterceptorAware; -import org.apache.deltaspike.test.core.api.partialbean.shared.TestPartialBeanBinding; - -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; -import javax.enterprise.context.Dependent; -import javax.inject.Inject; -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; - -@TestPartialBeanBinding -@Dependent //normal-scopes are possible as well -public class TestPartialBeanHandler implements InvocationHandler, /*just needed for testing interceptors: */TestInterceptorAware -{ - @Inject - private TestBean testBean; - - private String value; - private boolean intercepted; - - @PostConstruct - protected void onCreate() - { - this.value = "partial"; - } - - @PreDestroy - protected void onDestroy() - { - //TODO check in a test - } - - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable - { - return this.value + "-" + this.testBean.getValue() + "-" + this.intercepted; - } - - public void setIntercepted(boolean intercepted) - { - this.intercepted = intercepted; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.deltaspike.test.core.api.partialbean.uc006; + +import org.apache.deltaspike.test.core.api.partialbean.shared.TestBean; +import org.apache.deltaspike.test.core.api.partialbean.shared.TestPartialBeanBinding; + +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; +import javax.enterprise.context.Dependent; +import javax.inject.Inject; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import org.apache.deltaspike.test.core.api.partialbean.shared.TestInterceptorAware; + +@TestPartialBeanBinding +@Dependent //normal-scopes are possible as well +public class TestPartialBeanHandler implements InvocationHandler, /*just needed for testing interceptors: */TestInterceptorAware +{ + @Inject + private TestBean testBean; + + private String value; + private boolean intercepted; + + @PostConstruct + protected void onCreate() + { + this.value = "partial"; + } + + @PreDestroy + protected void onDestroy() + { + //TODO check in a test + } + + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable + { + return this.value + "-" + this.testBean.getValue() + "-" + this.intercepted; + } + + public void setIntercepted(boolean intercepted) + { + this.intercepted = intercepted; + } +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e90019fd/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc007/MethodLevelInterceptorTest.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc007/MethodLevelInterceptorTest.java b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc007/MethodLevelInterceptorTest.java new file mode 100644 index 0000000..6cd400d --- /dev/null +++ b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc007/MethodLevelInterceptorTest.java @@ -0,0 +1,101 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.deltaspike.test.core.api.partialbean.uc007; + +import org.apache.deltaspike.core.api.provider.BeanProvider; +import org.apache.deltaspike.test.core.api.partialbean.shared.CustomInterceptorImpl; +import org.apache.deltaspike.test.core.api.partialbean.shared.CustomInterceptorState; +import org.apache.deltaspike.test.core.api.partialbean.shared.TestPartialBeanBinding; +import org.apache.deltaspike.test.core.api.partialbean.util.ArchiveUtils; +import org.apache.deltaspike.test.utils.CdiContainerUnderTest; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.Asset; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(Arquillian.class) +public class MethodLevelInterceptorTest +{ + public static final String CONTAINER_WELD_2_0_0 = "weld-2\\.0\\.0\\..*"; + + @Deployment + public static WebArchive war() + { + Asset beansXml = new StringAsset( + "<beans><interceptors><class>" + + CustomInterceptorImpl.class.getName() + + "</class></interceptors></beans>" + ); + + String simpleName = MethodLevelInterceptorTest.class.getSimpleName(); + String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1); + + //don't create a completely empty web-archive + if (CdiContainerUnderTest.is(CONTAINER_WELD_2_0_0)) + { + return ShrinkWrap.create(WebArchive.class, archiveName + ".war") + .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndPartialBeanArchive()); + } + + JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, archiveName + ".jar") + .addPackage(MethodLevelInterceptorTest.class.getPackage()) + .addPackage(TestPartialBeanBinding.class.getPackage()) + .addAsManifestResource(beansXml, "beans.xml"); + + return ShrinkWrap.create(WebArchive.class, archiveName + ".war") + .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndPartialBeanArchive()) + .addAsLibraries(testJar) + .addAsWebInfResource(beansXml, "beans.xml"); + } + + @Test + public void testMethodLevelInterceptor() throws Exception + { + // this test is known to not work under weld-2.0.0.Final and weld-2.0.0.SP1 + Assume.assumeTrue(!CdiContainerUnderTest.is(CONTAINER_WELD_2_0_0)); + + PartialBean partialBean = BeanProvider.getContextualReference(PartialBean.class); + CustomInterceptorState state = BeanProvider.getContextualReference(CustomInterceptorState.class); + + Assert.assertNotNull(partialBean); + partialBean.doSomething(); + Assert.assertEquals(true, state.isIntercepted()); + } + + @Test + public void testMethodLevelInterceptorOnAbstractMethod() throws Exception + { + // this test is known to not work under weld-2.0.0.Final and weld-2.0.0.SP1 + Assume.assumeTrue(!CdiContainerUnderTest.is(CONTAINER_WELD_2_0_0)); + + PartialBean partialBean = BeanProvider.getContextualReference(PartialBean.class); + CustomInterceptorState state = BeanProvider.getContextualReference(CustomInterceptorState.class); + + Assert.assertNotNull(partialBean); + Assert.assertEquals("partial", partialBean.getResult()); + Assert.assertEquals(true, state.isIntercepted()); + } +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e90019fd/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc007/PartialBean.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc007/PartialBean.java b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc007/PartialBean.java index bc70f5c..b6a563b 100644 --- a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc007/PartialBean.java +++ b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc007/PartialBean.java @@ -1,66 +1,38 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.deltaspike.test.core.api.partialbean.uc007; - -import org.apache.deltaspike.test.core.api.partialbean.shared.CustomInterceptor; -import org.apache.deltaspike.test.core.api.partialbean.shared.TestPartialBeanBinding; -import org.apache.deltaspike.test.core.api.partialbean.shared.TestInterceptorAware; -import org.apache.deltaspike.test.core.api.partialbean.shared.TestBean; - -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; - -@TestPartialBeanBinding -@RequestScoped -@CustomInterceptor -public abstract class PartialBean implements /*just needed for testing interceptors: */ TestInterceptorAware -{ - @Inject - private TestBean testBean; - - private String value; - private boolean intercepted; - - public abstract String getResult(); - - @PostConstruct - protected void onCreate() - { - this.value = "manual"; - } - - @PreDestroy - protected void onDestroy() - { - //TODO check in a test - } - - public String getManualResult() - { - return this.value + "-" + this.testBean.getValue() + "-" + this.intercepted; - } - - @Override - public void setIntercepted(boolean intercepted) - { - this.intercepted = intercepted; - } +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.deltaspike.test.core.api.partialbean.uc007; + +import org.apache.deltaspike.test.core.api.partialbean.shared.TestPartialBeanBinding; + +import javax.enterprise.context.RequestScoped; +import org.apache.deltaspike.test.core.api.partialbean.shared.CustomInterceptor; + +@TestPartialBeanBinding +@RequestScoped +public abstract class PartialBean +{ + @CustomInterceptor + public abstract String getResult(); + + @CustomInterceptor + public void doSomething() + { + + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e90019fd/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc007/PartialBeanAsAbstractClassWithInterceptorTest.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc007/PartialBeanAsAbstractClassWithInterceptorTest.java b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc007/PartialBeanAsAbstractClassWithInterceptorTest.java deleted file mode 100644 index b570bcd..0000000 --- a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc007/PartialBeanAsAbstractClassWithInterceptorTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.deltaspike.test.core.api.partialbean.uc007; - -import org.apache.deltaspike.core.api.provider.BeanProvider; -import org.apache.deltaspike.partialbean.spi.PartialBeanProvider; -import org.apache.deltaspike.test.category.WebEE7ProfileCategory; -import org.apache.deltaspike.test.core.api.partialbean.shared.CustomInterceptorImpl; -import org.apache.deltaspike.test.core.api.partialbean.shared.TestPartialBeanBinding; -import org.apache.deltaspike.test.core.api.partialbean.util.ArchiveUtils; -import org.jboss.arquillian.container.test.api.Deployment; -import org.jboss.arquillian.junit.Arquillian; -import org.jboss.shrinkwrap.api.ShrinkWrap; -import org.jboss.shrinkwrap.api.asset.Asset; -import org.jboss.shrinkwrap.api.asset.StringAsset; -import org.jboss.shrinkwrap.api.spec.JavaArchive; -import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; - -@RunWith(Arquillian.class) -@Category(WebEE7ProfileCategory.class) -//weld creates synthetic BDAs for classes added via BeforeBeanDiscovery#addAnnotatedType -//-> only globally enabled interceptors will get active for such beans -//in case of ee7+ it works due to GlobalInterceptorExtension -public class PartialBeanAsAbstractClassWithInterceptorTest -{ - @Deployment - public static WebArchive war() - { - Asset beansXml = new StringAsset( - "<beans><interceptors><class>" + - CustomInterceptorImpl.class.getName() + - "</class></interceptors></beans>" - ); - - String simpleName = PartialBeanAsAbstractClassWithInterceptorTest.class.getSimpleName(); - String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1); - - JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, archiveName + ".jar") - .addPackage(PartialBeanAsAbstractClassWithInterceptorTest.class.getPackage()) - .addPackage(TestPartialBeanBinding.class.getPackage()) - .addAsServiceProvider(PartialBeanProvider.class, TestPartialBeanProvider.class) - .addAsManifestResource(beansXml, "beans.xml"); - - return ShrinkWrap.create(WebArchive.class, archiveName + ".war") - .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndPartialBeanArchive()) - .addAsLibraries(testJar) - .addAsWebInfResource(beansXml, "beans.xml"); - } - - @Test - public void testPartialBeanAsAbstractClassWithInterceptor() throws Exception - { - PartialBean partialBean = BeanProvider.getContextualReference(PartialBean.class); - Assert.assertNotNull(partialBean); - - String result = partialBean.getResult(); - - Assert.assertEquals("partial-test-true", result); - - result = partialBean.getManualResult(); - - Assert.assertEquals("manual-test-true", result); - - //TODO test pre-destroy callback - } -} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e90019fd/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc007/TestPartialBeanHandler.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc007/TestPartialBeanHandler.java b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc007/TestPartialBeanHandler.java index 0c4b700..9c44f94 100644 --- a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc007/TestPartialBeanHandler.java +++ b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc007/TestPartialBeanHandler.java @@ -1,65 +1,36 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.deltaspike.test.core.api.partialbean.uc007; - -import org.apache.deltaspike.test.core.api.partialbean.shared.CustomInterceptor; -import org.apache.deltaspike.test.core.api.partialbean.shared.TestBean; -import org.apache.deltaspike.test.core.api.partialbean.shared.TestInterceptorAware; -import org.apache.deltaspike.test.core.api.partialbean.shared.TestPartialBeanBinding; - -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; -import javax.enterprise.context.Dependent; -import javax.inject.Inject; -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; - -@TestPartialBeanBinding -@CustomInterceptor //for uc003 -@Dependent //normal-scopes are possible as well -public class TestPartialBeanHandler implements InvocationHandler, /*just needed for testing interceptors: */TestInterceptorAware -{ - @Inject - private TestBean testBean; - - private String value; - private boolean intercepted; - - @PostConstruct - protected void onCreate() - { - this.value = "partial"; - } - - @PreDestroy - protected void onDestroy() - { - //TODO check in a test - } - - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable - { - return this.value + "-" + this.testBean.getValue() + "-" + this.intercepted; - } - - public void setIntercepted(boolean intercepted) - { - this.intercepted = intercepted; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.deltaspike.test.core.api.partialbean.uc007; + +import org.apache.deltaspike.test.core.api.partialbean.shared.TestPartialBeanBinding; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import javax.enterprise.context.ApplicationScoped; + +@TestPartialBeanBinding +@ApplicationScoped +public class TestPartialBeanHandler implements InvocationHandler +{ + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable + { + return "partial"; + } +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e90019fd/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc007/TestPartialBeanProvider.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc007/TestPartialBeanProvider.java b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc007/TestPartialBeanProvider.java deleted file mode 100644 index 518896c..0000000 --- a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc007/TestPartialBeanProvider.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.deltaspike.test.core.api.partialbean.uc007; - -import org.apache.deltaspike.partialbean.spi.AbstractPartialBeanProvider; -import org.apache.deltaspike.partialbean.spi.PartialBeanBuilder; -import org.apache.deltaspike.test.core.api.partialbean.shared.TestPartialBeanBinding; - -public class TestPartialBeanProvider extends AbstractPartialBeanProvider -{ - public TestPartialBeanProvider() - { - add(new PartialBeanBuilder(TestPartialBeanBinding.class, TestPartialBeanHandler.class, PartialBean.class)); - } -} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e90019fd/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/ClassLevelInterceptorTest.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/ClassLevelInterceptorTest.java b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/ClassLevelInterceptorTest.java new file mode 100644 index 0000000..7fa54b9 --- /dev/null +++ b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/ClassLevelInterceptorTest.java @@ -0,0 +1,103 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.deltaspike.test.core.api.partialbean.uc008; + +import org.apache.deltaspike.test.core.api.partialbean.shared.CustomInterceptorImpl; +import org.apache.deltaspike.test.core.api.partialbean.shared.CustomInterceptorState; +import org.apache.deltaspike.core.api.provider.BeanProvider; +import org.apache.deltaspike.test.core.api.partialbean.shared.TestPartialBeanBinding; +import org.apache.deltaspike.test.core.api.partialbean.util.ArchiveUtils; +import org.apache.deltaspike.test.utils.CdiContainerUnderTest; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.Asset; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(Arquillian.class) +public class ClassLevelInterceptorTest +{ + public static final String CONTAINER_WELD_2_0_0 = "weld-2\\.0\\.0\\..*"; + + @Deployment + public static WebArchive war() + { + Asset beansXml = new StringAsset( + "<beans><interceptors><class>" + + CustomInterceptorImpl.class.getName() + + "</class></interceptors></beans>" + ); + + String simpleName = ClassLevelInterceptorTest.class.getSimpleName(); + String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1); + + //don't create a completely empty web-archive + if (CdiContainerUnderTest.is(CONTAINER_WELD_2_0_0)) + { + return ShrinkWrap.create(WebArchive.class, archiveName + ".war") + .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndPartialBeanArchive()); + } + + JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, archiveName + ".jar") + .addPackage(ClassLevelInterceptorTest.class.getPackage()) + .addPackage(TestPartialBeanBinding.class.getPackage()) + .addAsManifestResource(beansXml, "beans.xml"); + + return ShrinkWrap.create(WebArchive.class, archiveName + ".war") + .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndPartialBeanArchive()) + .addAsLibraries(testJar) + .addAsWebInfResource(beansXml, "beans.xml"); + } + + @Test + public void testClassLevelInterceptor() throws Exception + { + // this test is known to not work under weld-2.0.0.Final and weld-2.0.0.SP1 + Assume.assumeTrue(!CdiContainerUnderTest.is(CONTAINER_WELD_2_0_0)); + + PartialBean partialBean = BeanProvider.getContextualReference(PartialBean.class); + CustomInterceptorState state = BeanProvider.getContextualReference(CustomInterceptorState.class); + + Assert.assertNotNull(partialBean); + Assert.assertEquals("manual", partialBean.getManualResult()); + + Assert.assertTrue(state.isIntercepted()); + } + + @Test + public void testClassLevelInterceptorOnAbstractMethod() throws Exception + { + // this test is known to not work under weld-2.0.0.Final and weld-2.0.0.SP1 + Assume.assumeTrue(!CdiContainerUnderTest.is(CONTAINER_WELD_2_0_0)); + + PartialBean partialBean = BeanProvider.getContextualReference(PartialBean.class); + CustomInterceptorState state = BeanProvider.getContextualReference(CustomInterceptorState.class); + + Assert.assertNotNull(partialBean); + Assert.assertEquals("partial", partialBean.getResult()); + + Assert.assertTrue(state.isIntercepted()); + } +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e90019fd/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/PartialBean.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/PartialBean.java b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/PartialBean.java index 290e487..bb88445 100644 --- a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/PartialBean.java +++ b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/PartialBean.java @@ -1,29 +1,37 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.deltaspike.test.core.api.partialbean.uc008; - -import javax.enterprise.context.ApplicationScoped; -import org.apache.deltaspike.test.core.api.partialbean.shared.TestPartialBeanBinding; - -@TestPartialBeanBinding -@ApplicationScoped -public interface PartialBean extends SuperInterface<Object>, SuperInterface2<Object> -{ - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.deltaspike.test.core.api.partialbean.uc008; + +import org.apache.deltaspike.test.core.api.partialbean.shared.CustomInterceptor; +import org.apache.deltaspike.test.core.api.partialbean.shared.TestPartialBeanBinding; + +import javax.enterprise.context.RequestScoped; + +@CustomInterceptor +@TestPartialBeanBinding +@RequestScoped +public abstract class PartialBean +{ + public abstract String getResult(); + + public String getManualResult() + { + return "manual"; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e90019fd/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/PartialBeanTest.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/PartialBeanTest.java b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/PartialBeanTest.java deleted file mode 100644 index e260ae3..0000000 --- a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/PartialBeanTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.deltaspike.test.core.api.partialbean.uc008; - -import org.apache.deltaspike.core.api.provider.BeanProvider; -import org.apache.deltaspike.test.core.api.partialbean.shared.TestPartialBeanBinding; -import org.apache.deltaspike.test.core.api.partialbean.util.ArchiveUtils; -import org.apache.deltaspike.test.utils.CdiContainerUnderTest; -import org.jboss.arquillian.container.test.api.Deployment; -import org.jboss.arquillian.junit.Arquillian; -import org.jboss.shrinkwrap.api.ShrinkWrap; -import org.jboss.shrinkwrap.api.asset.EmptyAsset; -import org.jboss.shrinkwrap.api.spec.JavaArchive; -import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.Assume; -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(Arquillian.class) -public class PartialBeanTest -{ - private static final String CONTAINER_OWB_1_2_x_BEFORE_1_2_8 = "owb-1\\.2\\.[0-7]"; - private static final String CONTAINER_TOMEE_1_7_x = "tomee-1\\.7\\..*"; - - @Deployment - public static WebArchive war() - { - String simpleName = PartialBeanTest.class.getSimpleName(); - String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1); - - JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, archiveName + ".jar") - .addPackage(PartialBeanTest.class.getPackage()) - .addPackage(TestPartialBeanBinding.class.getPackage()) - .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); - - WebArchive webArchive = ShrinkWrap.create(WebArchive.class, archiveName + ".war") - .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndPartialBeanArchive()) - .addAsLibraries(testJar) - .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); - - return webArchive; - } - - @Test - public void testPartialBeanWithApplicationScope() throws Exception - { - // this test is known to not work under OWB 1.2.0 till 1.2.7 - see OWB #1036 - Assume.assumeTrue(!CdiContainerUnderTest.is(CONTAINER_OWB_1_2_x_BEFORE_1_2_8) - && !CdiContainerUnderTest.is(CONTAINER_TOMEE_1_7_x)); - - PartialBean bean = BeanProvider.getContextualReference(PartialBean.class); - bean.test(this); - } -} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e90019fd/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/SuperInterface.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/SuperInterface.java b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/SuperInterface.java deleted file mode 100644 index 5cd1c08..0000000 --- a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/SuperInterface.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.deltaspike.test.core.api.partialbean.uc008; - -public interface SuperInterface<E> -{ - E test(E entity); -} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e90019fd/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/SuperInterface2.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/SuperInterface2.java b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/SuperInterface2.java deleted file mode 100644 index 1f607a7..0000000 --- a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/SuperInterface2.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.deltaspike.test.core.api.partialbean.uc008; - -public interface SuperInterface2<E> -{ - E test(E entity); -} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e90019fd/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/TestPartialBeanHandler.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/TestPartialBeanHandler.java b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/TestPartialBeanHandler.java index 1d7db18..d11bb91 100644 --- a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/TestPartialBeanHandler.java +++ b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/TestPartialBeanHandler.java @@ -1,63 +1,36 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.deltaspike.test.core.api.partialbean.uc008; - -import org.apache.deltaspike.test.core.api.partialbean.shared.TestBean; -import org.apache.deltaspike.test.core.api.partialbean.shared.TestInterceptorAware; -import org.apache.deltaspike.test.core.api.partialbean.shared.TestPartialBeanBinding; - -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; -import javax.enterprise.context.Dependent; -import javax.inject.Inject; -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; - -@TestPartialBeanBinding -@Dependent //normal-scopes are possible as well -public class TestPartialBeanHandler implements InvocationHandler, /*just needed for testing interceptors: */TestInterceptorAware -{ - @Inject - private TestBean testBean; - - private String value; - private boolean intercepted; - - @PostConstruct - protected void onCreate() - { - this.value = "partial"; - } - - @PreDestroy - protected void onDestroy() - { - //TODO check in a test - } - - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable - { - return this.value + "-" + this.testBean.getValue() + "-" + this.intercepted; - } - - public void setIntercepted(boolean intercepted) - { - this.intercepted = intercepted; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.deltaspike.test.core.api.partialbean.uc008; + +import org.apache.deltaspike.test.core.api.partialbean.shared.TestPartialBeanBinding; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import javax.enterprise.context.ApplicationScoped; + +@TestPartialBeanBinding +@ApplicationScoped +public class TestPartialBeanHandler implements InvocationHandler +{ + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable + { + return "partial"; + } +}
