Skip to content

Commit

Permalink
Minor. toString for contexts, test for producer method returning null…
Browse files Browse the repository at this point in the history
… in context

git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@179 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
nickarls committed Oct 27, 2008
1 parent 268fda5 commit 1df5252
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 4 deletions.
Expand Up @@ -8,5 +8,11 @@ public ApplicationContext()
{
super(ApplicationScoped.class);
}

@Override
public String toString()
{
return "Application context";
}

}
Expand Up @@ -9,5 +9,11 @@ public ConversationContext()
{
super(ConversationScoped.class);
}

@Override
public String toString()
{
return "Conversation context";
}

}
Expand Up @@ -9,4 +9,9 @@ public RequestContext()
super(RequestScoped.class);
}

@Override
public String toString()
{
return "Request context";
}
}
Expand Up @@ -9,4 +9,9 @@ public SessionContext()
super(SessionScoped.class);
}

@Override
public String toString()
{
return "Session context";
}
}
@@ -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;
Expand All @@ -26,7 +39,7 @@ public class CommonContextTest extends AbstractTest

@BeforeMethod
public void initContext() {
context = new AbstractContext(RequestScoped.class) {};
context = new RequestContext();
}

@Test(groups="contexts") @SpecAssertion(section="8.1")
Expand Down Expand Up @@ -57,9 +70,13 @@ public void testReturnsCorrectExistingBean() {
}

@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")
Expand Down
Expand Up @@ -41,4 +41,8 @@ public class SpiderProducer
return new LadybirdSpider();
}

@Produces @Named("Shelob") public Tarantula produceShelob() {
return null;
}

}

0 comments on commit 1df5252

Please sign in to comment.