Skip to content

Commit

Permalink
Enable producer method tests
Browse files Browse the repository at this point in the history
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@267 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
pmuir committed Nov 6, 2008
1 parent b3e2017 commit e6dc5fb
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 31 deletions.
@@ -1,14 +1,21 @@
package org.jboss.webbeans.test;

import static org.jboss.webbeans.test.util.Util.createProducerMethodBean;
import static org.jboss.webbeans.test.util.Util.createSimpleWebBean;

import java.lang.reflect.Method;

import javax.webbeans.ContextNotActiveException;
import javax.webbeans.Dependent;
import javax.webbeans.manager.Bean;

import org.jboss.webbeans.bean.ProducerMethodBean;
import org.jboss.webbeans.bean.SimpleBean;
import org.jboss.webbeans.contexts.DependentContext;
import org.jboss.webbeans.test.beans.Fox;
import org.jboss.webbeans.test.beans.FoxRun;
import org.jboss.webbeans.test.beans.SpiderProducer;
import org.jboss.webbeans.test.beans.Tarantula;
import org.testng.annotations.Test;

@SpecVersion("PDR")
Expand All @@ -32,9 +39,17 @@ public void testInstanceUsedForElEvalutionNotShared()
}

@Test(groups={"contexts", "producerMethod"}) @SpecAssertion(section="8.3")
public void testInstanceUsedForProducerMethodNotShared()
public void testInstanceUsedForProducerMethodNotShared() throws Exception
{
assert false;
SimpleBean<SpiderProducer> spiderProducer = createSimpleWebBean(SpiderProducer.class, manager);
manager.addBean(spiderProducer);
Method method = SpiderProducer.class.getMethod("produceTarantula");
ProducerMethodBean<Tarantula> tarantulaBean = createProducerMethodBean(Tarantula.class, method, manager, spiderProducer);
Tarantula tarantula = tarantulaBean.create();
Tarantula tarantula2 = tarantulaBean.create();
assert tarantula != null;
assert tarantula2 != null;
assert tarantula != tarantula2;
}

@Test(groups={"contexts", "observerMethod"}) @SpecAssertion(section="8.3")
Expand Down Expand Up @@ -70,12 +85,6 @@ public void testContextIsInactive()
manager.getContext(Dependent.class).isActive();
}

@Test(groups={"contexts", "producerMethod"}) @SpecAssertion(section="8.3")
public void testContextIsActiveWhenInvokingProducerMethod()
{
assert false;
}

@Test(groups={"contexts", "observerMethod"}) @SpecAssertion(section="8.3")
public void testContextIsActiveWhenInvokingObserverMethod()
{
Expand Down Expand Up @@ -164,12 +173,6 @@ public void testDependentsDestroyedWhenElEvaluationCompletes()
assert false;
}

@Test(groups={"contexts", "producerMethod"}) @SpecAssertion(section="8.3")
public void testDependentsDestroyedWhenProducerMethodEvaluationCompletes()
{
assert false;
}

@Test(groups={"contexts", "observerMethod"}) @SpecAssertion(section="8.3")
public void testDependentsDestroyedWhenObserverMethodEvaluationCompletes()
{
Expand Down
Expand Up @@ -13,6 +13,8 @@
import org.jboss.webbeans.bean.SimpleBean;
import org.jboss.webbeans.test.beans.Fox;
import org.jboss.webbeans.test.beans.FoxRun;
import org.jboss.webbeans.test.beans.SpiderNest;
import org.jboss.webbeans.test.beans.SpiderProducer;
import org.jboss.webbeans.test.beans.Tuna;
import org.jboss.webbeans.test.beans.broken.BeanWithFinalBoundField;
import org.jboss.webbeans.test.beans.broken.BeanWithStaticBoundField;
Expand All @@ -25,29 +27,23 @@ public class InjectionTests extends AbstractTest
{

@Test(groups={"injection", "producerMethod"}) @SpecAssertion(section="4.2")
public void testPrimitiveTypesEquivalentToBoxedTypes()
public void testInjectionPerformsBoxingIfNecessary() throws Exception
{
assert false;
}

@Test(groups={"injection", "producerMethod"}) @SpecAssertion(section="4.2")
public void testInjectionPerformsBoxingIfNecessary()
{
assert false;
}

@Test(groups={"injection", "producerMethod"}) @SpecAssertion(section="4.2")
public void testInjectionPerformsUnboxingIfNecessary()
{
assert false;
SimpleBean<SpiderProducer> spiderProducer = createSimpleWebBean(SpiderProducer.class, manager);
manager.addBean(spiderProducer);
Bean<SpiderNest> spiderNestBean = createSimpleWebBean(SpiderNest.class, manager);
manager.addBean(createProducerMethodBean(Integer.class, SpiderProducer.class.getMethod("getWolfSpiderSize"), manager, spiderProducer));
SpiderNest spiderNest = spiderNestBean.create();
assert spiderNest.numberOfSpiders != null;
assert spiderNest.numberOfSpiders.equals(4);
}

@Test(groups={"injection", "producerMethod"}, expectedExceptions=NullableDependencyException.class) @SpecAssertion(section="4.2")
public void testPrimitiveInjectionPointResolvesToNullableWebBean() throws Exception
{
Bean<FarmHouse> farmHouseBean = createSimpleWebBean(FarmHouse.class, manager);
manager.addBean(createProducerMethodBean(Integer.class, FarmHouseProducer.class.getMethod("getNumberOfBedrooms"), manager));
FarmHouse farmHouse = farmHouseBean.create();
farmHouseBean.create();
}

@Test(groups={"injection", "clientProxy"}, expectedExceptions=ContextNotActiveException.class) @SpecAssertion(section="4.3")
Expand Down
Expand Up @@ -51,7 +51,7 @@ public void testDisposalMethodHasParametersInjected()
}


@Test(groups="producerMethod") @SpecAssertion(section={"3.4", "5.6"})
@Test(groups="producerMethod") @SpecAssertion(section={"3.4", "5.6", "8.3"})
public void testProducerMethodReturnsNullIsDependent() throws Exception
{
SimpleBean<SpiderProducer> spiderProducer = createSimpleWebBean(SpiderProducer.class, manager);
Expand Down
@@ -0,0 +1,16 @@
package org.jboss.webbeans.test.beans;

import javax.webbeans.Initializer;

public class SpiderNest
{

public Integer numberOfSpiders;

@Initializer
public SpiderNest(Integer numberOfSpiders)
{
this.numberOfSpiders = numberOfSpiders;
}

}
2 changes: 1 addition & 1 deletion webbeans-ri/testng.xml
Expand Up @@ -8,7 +8,7 @@
<exclude name="specialization" />
<exclude name="deployment" />
<exclude name="disposalMethod" />
<exclude name="producerMethod" />

<exclude name="observerMethod" />
<exclude name="deferredEvent" />
<exclude name="ejb3" />
Expand Down

0 comments on commit e6dc5fb

Please sign in to comment.