[webbeans-commits] Webbeans SVN: r1237 - ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean and 1 other directories.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Mon Jan 26 16:58:51 EST 2009
Author: dallen6
Date: 2009-01-26 16:58:50 -0500 (Mon, 26 Jan 2009)
New Revision: 1237
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BeanValidator.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/passivating/Jamsa_Broken.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/passivating/PassivatingContextTest.java
Log:
Fixed a few broken producer field tests.
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BeanValidator.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BeanValidator.java 2009-01-26 20:19:11 UTC (rev 1236)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BeanValidator.java 2009-01-26 21:58:50 UTC (rev 1237)
@@ -22,8 +22,10 @@
import java.util.List;
import java.util.Set;
+import javax.context.Dependent;
import javax.inject.AmbiguousDependencyException;
import javax.inject.DefinitionException;
+import javax.inject.IllegalProductException;
import javax.inject.InconsistentSpecializationException;
import javax.inject.New;
import javax.inject.NullableDependencyException;
@@ -34,8 +36,10 @@
import javax.inject.manager.InjectionPoint;
import org.jboss.webbeans.bean.AbstractBean;
+import org.jboss.webbeans.bean.AbstractProducerBean;
import org.jboss.webbeans.bean.NewEnterpriseBean;
import org.jboss.webbeans.bean.NewSimpleBean;
+import org.jboss.webbeans.bean.ProducerMethodBean;
import org.jboss.webbeans.util.Beans;
import org.jboss.webbeans.util.ListComparator;
import org.jboss.webbeans.util.Proxies;
@@ -45,13 +49,13 @@
* Checks a list of beans for DeploymentExceptions and their subclasses
*
* @author Nicklas Karlsson
- *
+ *
*/
public class BeanValidator
{
-
+
private final ManagerImpl manager;
-
+
public BeanValidator(ManagerImpl manager)
{
this.manager = manager;
@@ -62,6 +66,7 @@
*
* @param beans The beans to validate
*/
+ @SuppressWarnings("unchecked")
public void validate(List<Bean<?>> beans)
{
final List<Bean<?>> specializedBeans = new ArrayList<Bean<?>>();
@@ -95,6 +100,17 @@
{
throw new NullableDependencyException("The injection point " + injectionPoint + " has nullable dependencies");
}
+ if (bean instanceof ProducerMethodBean)
+ {
+ if (resolvedBean instanceof AbstractProducerBean)
+ {
+ AbstractProducerBean producerBean = (AbstractProducerBean) resolvedBean;
+ if (producerBean.getScopeType().equals(Dependent.class) && !Reflections.isSerializable(producerBean.getType()))
+ {
+ throw new IllegalProductException("Cannot inject @Depedent non-serializable type into " + injectionPoint);
+ }
+ }
+ }
}
else
{
@@ -116,7 +132,7 @@
}
specializedBeans.add(abstractBean.getSpecializedBean());
}
- }
+ }
if (Beans.isPassivatingBean(bean) && !bean.isSerializable())
{
throw new UnserializableDependencyException("The bean " + bean + " declares a passivating scopes but has non-serializable dependencies");
@@ -129,12 +145,11 @@
}
}
-
+
private boolean hasHigherPrecedence(Class<? extends Annotation> deploymentType, Class<? extends Annotation> otherDeploymentType)
{
Comparator<Class<? extends Annotation>> comparator = new ListComparator<Class<? extends Annotation>>(manager.getEnabledDeploymentTypes());
return comparator.compare(deploymentType, otherDeploymentType) > 0;
}
-
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-01-26 20:19:11 UTC (rev 1236)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-01-26 21:58:50 UTC (rev 1237)
@@ -52,7 +52,7 @@
*
* @author Pete Muir
*
- * @param <T>
+ * @param <T> The type (class) of the bean
*/
public class SimpleBean<T> extends AbstractClassBean<T>
{
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/passivating/Jamsa_Broken.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/passivating/Jamsa_Broken.java 2009-01-26 20:19:11 UTC (rev 1236)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/passivating/Jamsa_Broken.java 2009-01-26 21:58:50 UTC (rev 1237)
@@ -17,8 +17,8 @@
@Produces
@SessionScoped
- public Violation create(@Current Violation violation)
+ public Violation2 create(@Current Violation violation)
{
- return violation;
+ return new Violation2();
}
}
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/passivating/PassivatingContextTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/passivating/PassivatingContextTest.java 2009-01-26 20:19:11 UTC (rev 1236)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/passivating/PassivatingContextTest.java 2009-01-26 21:58:50 UTC (rev 1237)
@@ -15,10 +15,11 @@
/**
*
- * @author Nicklas Karlsson
+ * @author Nicklas Karlsson
+ * @author David Allen
*
*/
- at SpecVersion("20081206")
+ at SpecVersion("PRD2")
public class PassivatingContextTest extends AbstractTest
{
@@ -29,7 +30,7 @@
* initialization time.
*/
@Test(groups = { "contexts", "passivation" }, expectedExceptions = DefinitionException.class)
- @SpecAssertion(section = "9.5")
+ @SpecAssertion(section = "8.4")
public void testSimpleWebBeanWithNonSerializableImplementationClassFails()
{
deployBeans(Hamina_Broken.class);
@@ -41,8 +42,8 @@
* serializable, a DefinitionException is thrown by the Web Bean manager at
* initialization time.
*/
- @Test(groups = {"contexts", "passivation" })
- @SpecAssertion(section = "9.5")
+ @Test(groups = { "contexts", "passivation" })
+ @SpecAssertion(section = "8.4")
public void testSimpleWebBeanWithSerializableImplementationClassOK()
{
createSimpleBean(Jyvaskyla.class);
@@ -55,8 +56,8 @@
* @throws IOException
* @throws ClassNotFoundException
*/
- @Test(groups = { "contexts", "passivation" , "stub" })
- @SpecAssertion(section = "9.5")
+ @Test(groups = { "contexts", "passivation", "stub" })
+ @SpecAssertion(section = "8.4")
public void testSimpleWebBeanDeclaringPassivatingScopeIsSerializedWhenContextIsPassivated() throws IOException, ClassNotFoundException
{
assert false;
@@ -81,7 +82,7 @@
*/
// TODO requires an EJB instance
@Test(groups = { "contexts", "passivation", "broken", "stub" })
- @SpecAssertion(section = "9.5")
+ @SpecAssertion(section = "8.4")
public void testStatefulEJBIsSerializedWhenPassivatedByEJBContainer() throws IOException, ClassNotFoundException
{
assert false;
@@ -94,7 +95,7 @@
* with their owner
*/
@Test(groups = { "stub", "contexts", "passivation" }, expectedExceptions = UnserializableDependencyException.class)
- @SpecAssertion(section = "9.5")
+ @SpecAssertion(section = "8.4")
public void testDependentInterceptorsOfStatefulEnterpriseBeanMustBeSerializable()
{
deployBeans(Kaarina_Broken.class);
@@ -107,7 +108,7 @@
* with their owner
*/
@Test(groups = { "stub", "contexts", "passivation" }, expectedExceptions = UnserializableDependencyException.class)
- @SpecAssertion(section = "9.5")
+ @SpecAssertion(section = "8.4")
public void testDependentDecoratorsOfStatefulEnterpriseBeanMustBeSerializable()
{
deployBeans(Porvoo_Broken.class);
@@ -120,7 +121,7 @@
* with their owner
*/
@Test(groups = { "stub", "contexts", "passivation" }, expectedExceptions = UnserializableDependencyException.class)
- @SpecAssertion(section = "9.5")
+ @SpecAssertion(section = "8.4")
public void testDependentInterceptorsOfWebBeanWithPassivatingScopeMustBeSerializable()
{
deployBeans(Kotka_Broken.class);
@@ -133,7 +134,7 @@
* with their owner
*/
@Test(groups = { "stub", "contexts", "passivation" }, expectedExceptions = UnserializableDependencyException.class)
- @SpecAssertion(section = "9.5")
+ @SpecAssertion(section = "8.4")
public void testDependentDecoratorsOfWebBeansWithPassivatingScopeMustBeSerializable()
{
deployBeans(Raisio_Broken.class);
@@ -147,7 +148,7 @@
* @throws IOException
*/
@Test(groups = { "contexts", "passivation" })
- @SpecAssertion(section = "9.5")
+ @SpecAssertion(section = "8.4")
public void testDependentEJBsAreSerializable() throws IOException, ClassNotFoundException
{
deployBeans(Vaasa.class, Helsinki.class);
@@ -166,7 +167,7 @@
* at initialization time.
*/
@Test(groups = { "stub", "contexts", "passivation" }, expectedExceptions = UnserializableDependencyException.class)
- @SpecAssertion(section = "9.5")
+ @SpecAssertion(section = "8.4")
public void testSimpleDependentWebBeanWithNonSerializableImplementationInjectedIntoStatefulSessionBeanFails()
{
deployBeans(Violation.class, Espoo_Broken.class);
@@ -183,7 +184,7 @@
* at initialization time.
*/
@Test(groups = { "contexts", "passivation" }, expectedExceptions = UnserializableDependencyException.class)
- @SpecAssertion(section = "9.5")
+ @SpecAssertion(section = "8.4")
public void testSimpleDependentWebBeanWithNonSerializableImplementationInjectedIntoNonTransientFieldOfWebBeanWithPassivatingScopeFails()
{
deployBeans(Vantaa_Broken.class, Violation.class);
@@ -199,7 +200,7 @@
* at initialization time.
*/
@Test(groups = { "contexts", "passivation" })
- @SpecAssertion(section = "9.5")
+ @SpecAssertion(section = "8.4")
public void testSimpleDependentWebBeanWithNonSerializableImplementationInjectedIntoTransientFieldOK()
{
createSimpleBean(Joensuu.class);
@@ -215,7 +216,7 @@
* at initialization time.
*/
@Test(groups = { "contexts", "passivation" }, expectedExceptions = UnserializableDependencyException.class)
- @SpecAssertion(section = "9.5")
+ @SpecAssertion(section = "8.4")
public void testSimpleDependentWebBeanWithNonSerializableImplementationInjectedIntoConstructorParameterOfWebBeanWithPassivatingScopeFails()
{
deployBeans(Loviisa_Broken.class, Violation.class);
@@ -231,7 +232,7 @@
* at initialization time.
*/
@Test(groups = { "contexts", "passivation" }, expectedExceptions = UnserializableDependencyException.class)
- @SpecAssertion(section = "9.5")
+ @SpecAssertion(section = "8.4")
public void testSimpleDependentWebBeanWithNonSerializableImplementationInjectedIntoInitializerParameterOfWebBeanWithPassivatingScopeFails()
{
deployBeans(Forssa_Broken.class, Violation.class);
@@ -247,10 +248,10 @@
* at initialization time.
*/
@Test(groups = { "contexts", "passivation" }, expectedExceptions = UnserializableDependencyException.class)
- @SpecAssertion(section = "9.5")
+ @SpecAssertion(section = "8.4")
public void testSimpleDependentWebBeanWithNonSerializableImplementationInjectedIntoProducerMethodParameterWithPassivatingScopeFails()
{
- deployBeans(Peraseinajoki.class, Violation.class, Violation2.class);
+ deployBeans(Peraseinajoki.class, Violation.class, Violation2.class);
}
/**
@@ -265,7 +266,7 @@
* @throws SecurityException
*/
@Test(groups = { "contexts", "passivation", "integration", "broken" }, expectedExceptions = IllegalProductException.class)
- @SpecAssertion(section = "9.5")
+ @SpecAssertion(section = "8.4")
public void testDependentScopedProducerMethodReturnsNonSerializableObjectForInjectionIntoStatefulSessionBeanFails() throws SecurityException, NoSuchMethodException
{
deployBeans(CityProducer2.class, Maarianhamina_Broken.class);
@@ -281,7 +282,7 @@
* IllegalProductException is thrown by the Web Bean manager.
*/
@Test(groups = { "contexts", "passivation" }, expectedExceptions = IllegalProductException.class)
- @SpecAssertion(section = "9.5")
+ @SpecAssertion(section = "8.4")
public void testDependentScopedProducerMethodReturnsNonSerializableObjectForInjectionIntoNonTransientFieldOfWebBeanWithPassivatingScopeFails()
{
deployBeans(CityProducer2.class, Nokia_Broken.class);
@@ -297,7 +298,7 @@
* IllegalProductException is thrown by the Web Bean manager.
*/
@Test(groups = { "contexts", "passivation" })
- @SpecAssertion(section = "9.5")
+ @SpecAssertion(section = "8.4")
public void testDependentScopedProducerMethodReturnsNonSerializableObjectForInjectionIntoTransientFieldOfWebBeanWithPassivatingScopeOK()
{
createSimpleBean(CityProducer2.class);
@@ -313,7 +314,7 @@
* IllegalProductException is thrown by the Web Bean manager.
*/
@Test(groups = { "contexts", "passivation" }, expectedExceptions = IllegalProductException.class)
- @SpecAssertion(section = "9.5")
+ @SpecAssertion(section = "8.4")
public void testDependentScopedProducerMethodReturnsNonSerializableObjectForInjectionIntoConstructorParameterOfWebBeanWithPassivatingScopeFails()
{
deployBeans(CityProducer2.class, Loviisa_Broken.class);
@@ -329,7 +330,7 @@
* IllegalProductException is thrown by the Web Bean manager.
*/
@Test(groups = { "contexts", "passivation" }, expectedExceptions = IllegalProductException.class)
- @SpecAssertion(section = "9.5")
+ @SpecAssertion(section = "8.4")
public void testDependentScopedProducerMethodReturnsNonSerializableObjectForInjectionIntoInitializerParameterOfWebBeanWithPassivatingScopeFails()
{
deployBeans(CityProducer2.class, Kuopio_Broken.class);
@@ -344,14 +345,12 @@
* parameter of a producer method which declares a passivating scope type, an
* IllegalProductException is thrown by the Web Bean manager.
*/
- @Test(groups = { "contexts", "passivation" , "broken"}, expectedExceptions = IllegalProductException.class)
- @SpecAssertion(section = "9.5")
+ @Test(groups = { "contexts", "passivation" }, expectedExceptions = IllegalProductException.class)
+ @SpecAssertion(section = "8.4")
public void testDependentScopedProducerMethodReturnsNonSerializableObjectForInjectionIntoProducerMethodParameterWithPassivatingScopeFails()
{
- // TODO Not quite sure what this test is doing
- //deployBeans(CityProducer3.class, Jamsa_Broken.class);
- //manager.getInstanceByType(Jamsa_Broken.class).ping();
- assert false;
+ deployBeans(CityProducer2.class, Jamsa_Broken.class);
+ manager.getInstanceByType(Jamsa_Broken.class).ping();
}
/**
@@ -363,13 +362,13 @@
* IllegalProductException is thrown by the Web Bean manager.
*
*/
- @Test(groups = { "contexts", "passivation", "stub"}, expectedExceptions = IllegalProductException.class)
- @SpecAssertion(section = "9.5")
+ @Test(groups = { "contexts", "passivation", "stub" }, expectedExceptions = IllegalProductException.class)
+ @SpecAssertion(section = "8.4")
public void testDependentScopedProducerFieldReturnsNonSerializableObjectForInjectionIntoStatefulSessionBeanFails() throws Exception
{
// TODO This doesn't test injction in a SFSB, but into a Enterprise bean
- //deployBeans(CityProducer.class, Pietarsaari_Broken.class);
- //manager.getInstanceByType(Pietarsaari_Broken.class);
+ // deployBeans(CityProducer.class, Pietarsaari_Broken.class);
+ // manager.getInstanceByType(Pietarsaari_Broken.class);
assert false;
}
@@ -382,7 +381,7 @@
* IllegalProductException is thrown by the Web Bean manager.
*/
@Test(groups = { "contexts", "passivation" }, expectedExceptions = IllegalProductException.class)
- @SpecAssertion(section = "9.5")
+ @SpecAssertion(section = "8.4")
public void testDependentScopedProducerFieldReturnsNonSerializableObjectForInjectionIntoNonTransientFieldOfWebBeanWithPassivatingScopeFails()
{
deployBeans(CityProducer.class, Uusikaupunki_Broken.class);
@@ -397,8 +396,8 @@
* parameter of a producer method which declares a passivating scope type, an
* IllegalProductException is thrown by the Web Bean manager.
*/
- @Test(groups = { "contexts", "passivation"})
- @SpecAssertion(section = "9.5")
+ @Test(groups = { "contexts", "passivation" })
+ @SpecAssertion(section = "8.4")
public void testDependentScopedProducerFieldReturnsNonSerializableObjectForInjectionIntoTransientFieldOfWebBeanWithPassivatingScopeOK()
{
deployBeans(CityProducer.class, Salo_Broken.class);
@@ -414,7 +413,7 @@
* IllegalProductException is thrown by the Web Bean manager.
*/
@Test(groups = { "contexts", "passivation" }, expectedExceptions = IllegalProductException.class)
- @SpecAssertion(section = "9.5")
+ @SpecAssertion(section = "8.4")
public void testDependentScopedProducerFieldReturnsNonSerializableObjectForInjectionIntoConstructorParameterOfWebBeanWithPassivatingScopeFails()
{
deployBeans(CityProducer.class, Loviisa_Broken.class);
@@ -430,7 +429,7 @@
* IllegalProductException is thrown by the Web Bean manager.
*/
@Test(groups = { "contexts", "passivation" }, expectedExceptions = IllegalProductException.class)
- @SpecAssertion(section = "9.5")
+ @SpecAssertion(section = "8.4")
public void testDependentScopedProducerFieldReturnsNonSerializableObjectForInjectionIntoInitializerParameterOfWebBeanWithPassivatingScopeFails()
{
deployBeans(CityProducer.class, Mikkeli_Broken.class);
@@ -445,13 +444,12 @@
* parameter of a producer method which declares a passivating scope type, an
* IllegalProductException is thrown by the Web Bean manager.
*/
- @Test(groups = { "contexts", "passivation", "broken" }, expectedExceptions = IllegalProductException.class)
- @SpecAssertion(section = "9.5")
+ @Test(groups = { "contexts", "passivation" }, expectedExceptions = IllegalProductException.class)
+ @SpecAssertion(section = "8.4")
public void testDependentScopedProducerFieldReturnsNonSerializableObjectForInjectionIntoProducerMethodParameterWithPassivatingScopeFails()
{
// TODO Not quite sure what this test is doing
deployBeans(CityProducer.class, Jamsa_Broken.class);
manager.getInstanceByType(Jamsa_Broken.class).ping();
- assert false;
}
}
More information about the weld-commits
mailing list