Author: nickarls
Date: 2008-10-27 09:09:50 -0400 (Mon, 27 Oct 2008)
New Revision: 179
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ApplicationContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ConversationContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/RequestContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionContext.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/CommonContextTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/SpiderProducer.java
Log:
Minor. toString for contexts, test for producer method returning null in context
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ApplicationContext.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ApplicationContext.java 2008-10-27
12:07:27 UTC (rev 178)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ApplicationContext.java 2008-10-27
13:09:50 UTC (rev 179)
@@ -8,5 +8,11 @@
{
super(ApplicationScoped.class);
}
+
+ @Override
+ public String toString()
+ {
+ return "Application context";
+ }
}
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ConversationContext.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ConversationContext.java 2008-10-27
12:07:27 UTC (rev 178)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ConversationContext.java 2008-10-27
13:09:50 UTC (rev 179)
@@ -9,5 +9,11 @@
{
super(ConversationScoped.class);
}
+
+ @Override
+ public String toString()
+ {
+ return "Conversation context";
+ }
}
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/RequestContext.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/RequestContext.java 2008-10-27
12:07:27 UTC (rev 178)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/RequestContext.java 2008-10-27
13:09:50 UTC (rev 179)
@@ -9,4 +9,9 @@
super(RequestScoped.class);
}
+ @Override
+ public String toString()
+ {
+ return "Request context";
+ }
}
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionContext.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionContext.java 2008-10-27
12:07:27 UTC (rev 178)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionContext.java 2008-10-27
13:09:50 UTC (rev 179)
@@ -9,4 +9,9 @@
super(SessionScoped.class);
}
+ @Override
+ public String toString()
+ {
+ return "Session context";
+ }
}
Modified:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/CommonContextTest.java
===================================================================
---
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/CommonContextTest.java 2008-10-27
12:07:27 UTC (rev 178)
+++
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/CommonContextTest.java 2008-10-27
13:09:50 UTC (rev 179)
@@ -1,11 +1,24 @@
package org.jboss.webbeans.test;
+import static org.jboss.webbeans.test.util.Util.getEmptyAnnotatedType;
+
+import java.lang.reflect.Method;
+
import javax.webbeans.ContextNotActiveException;
import javax.webbeans.RequestScoped;
import javax.webbeans.manager.Bean;
import javax.webbeans.manager.Context;
+import org.jboss.webbeans.BeanImpl;
import org.jboss.webbeans.contexts.AbstractContext;
+import org.jboss.webbeans.contexts.RequestContext;
+import org.jboss.webbeans.introspector.SimpleAnnotatedMethod;
+import org.jboss.webbeans.introspector.SimpleAnnotatedType;
+import org.jboss.webbeans.model.bean.ProducerMethodBeanModel;
+import org.jboss.webbeans.model.bean.SimpleBeanModel;
+import org.jboss.webbeans.test.beans.BlackWidow;
+import org.jboss.webbeans.test.beans.SpiderProducer;
+import org.jboss.webbeans.test.beans.Tarantula;
import org.jboss.webbeans.test.beans.Tuna;
import org.jboss.webbeans.test.util.Util;
import org.testng.annotations.BeforeMethod;
@@ -26,7 +39,7 @@
@BeforeMethod
public void initContext() {
- context = new AbstractContext(RequestScoped.class) {};
+ context = new RequestContext();
}
@Test(groups="contexts") @SpecAssertion(section="8.1")
@@ -57,9 +70,13 @@
}
@Test(groups={"contexts", "producerMethod"})
@SpecAssertion(section="8.1")
- public void testProducerMethodReturningNullOK() {
- // TODO
- assert false;
+ public void testProducerMethodReturningNullOK() throws SecurityException,
NoSuchMethodException {
+ SimpleBeanModel<SpiderProducer> producer = new
SimpleBeanModel<SpiderProducer>(new
SimpleAnnotatedType<SpiderProducer>(SpiderProducer.class),
getEmptyAnnotatedType(SpiderProducer.class), manager);
+ manager.getModelManager().addBeanModel(producer);
+ Method nullProducer = SpiderProducer.class.getMethod("produceShelob");
+ ProducerMethodBeanModel<Tarantula> producerModel = new
ProducerMethodBeanModel<Tarantula>(new
SimpleAnnotatedMethod<Tarantula>(nullProducer), manager);
+ Bean<Tarantula> shelobBean = new BeanImpl<Tarantula>(producerModel,
manager);
+ assert context.get(shelobBean, true) == null;
}
@Test(groups="contexts")
Modified:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/SpiderProducer.java
===================================================================
---
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/SpiderProducer.java 2008-10-27
12:07:27 UTC (rev 178)
+++
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/SpiderProducer.java 2008-10-27
13:09:50 UTC (rev 179)
@@ -41,4 +41,8 @@
return new LadybirdSpider();
}
+ @Produces @Named("Shelob") public Tarantula produceShelob() {
+ return null;
+ }
+
}