Skip to content

Commit

Permalink
Stub out remaining tests for Chapter 4
Browse files Browse the repository at this point in the history
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@178 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
pmuir committed Oct 27, 2008
1 parent 099167c commit 268fda5
Show file tree
Hide file tree
Showing 11 changed files with 317 additions and 31 deletions.
3 changes: 1 addition & 2 deletions webbeans-ri/src/main/java/org/jboss/webbeans/BeanImpl.java
Expand Up @@ -68,8 +68,7 @@ public Set<Class<?>> getTypes()
@Override
public boolean isNullable()
{
// TODO Auto-generated method stub
return false;
return !beanModel.isPrimitive();
}

@Override
Expand Down
Expand Up @@ -24,6 +24,7 @@
import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.model.MergedStereotypesModel;
import org.jboss.webbeans.util.LoggerUtil;
import org.jboss.webbeans.util.Reflections;

public abstract class AbstractBeanModel<T, E> implements BeanModel<T, E>
{
Expand All @@ -41,11 +42,13 @@ public abstract class AbstractBeanModel<T, E> implements BeanModel<T, E>
protected InjectableMethod<?> removeMethod;
private Set<Class<?>> apiTypes;
protected Set<Injectable<?, ?>> injectionPoints;
private boolean primitive;

protected void init(ManagerImpl container)
{
mergedStereotypes = new MergedStereotypesModel<T, E>(getAnnotatedItem(), getXmlAnnotatedItem(), container);
initType();
initPrimitive();
log.fine("Building Web Bean bean metadata for " + getType());
initBindingTypes();
initName();
Expand Down Expand Up @@ -74,6 +77,11 @@ protected void initApiTypes()
apiTypes = getTypeHierachy(getType());
}

protected void initPrimitive()
{
this.primitive = Reflections.isPrimitive(getType());
}

protected Set<Class<?>> getTypeHierachy(Class<?> clazz)
{
Set<Class<?>> classes = new HashSet<Class<?>>();
Expand Down Expand Up @@ -328,4 +336,9 @@ public boolean isAssignableFrom(AnnotatedItem<?, ?> annotatedItem)
return this.getAnnotatedItem().isAssignableFrom(annotatedItem);
}

public boolean isPrimitive()
{
return primitive;
}

}
Expand Up @@ -38,6 +38,8 @@ public interface BeanModel<T, E>

public boolean isAssignableFrom(AnnotatedItem<?, ?> annotatedItem);

public boolean isPrimitive();

public MergedStereotypesModel<T, E> getMergedStereotypes();

}
@@ -0,0 +1,53 @@
package org.jboss.webbeans.test;

import javax.webbeans.UnproxyableDependencyException;

import org.testng.annotations.Test;

@SpecVersion("PDR")
public class ClientProxyTest
{


@Test(groups="clientProxy") @SpecAssertion(section={"4.4", "4.8"})
public void testClientProxyUsedForNormalScope()
{
assert false;
}

@Test(groups="clientProxy") @SpecAssertion(section={"4.4", "4.8"})
public void testClientProxyNotUsedForPseudoScope()
{
assert false;
}

@Test(groups="clientProxy") @SpecAssertion(section="4.4")
public void testClientProxyIsSerializable()
{
assert false;
}

@Test(groups="clientProxy", expectedExceptions=UnproxyableDependencyException.class) @SpecAssertion(section="4.4.1")
public void testInjectionPointWithUnproxyableTypeResolvesToNormalScopedWebBean()
{
assert false;
}

@Test(groups="clientProxy") @SpecAssertion(section="4.4.2")
public void testClientProxyInvocation()
{
assert false;
}

/*
@Test(groups="clientProxy") @SpecAssertion(section="4.4")
public void test
{
assert false;
}
*/


}
Expand Up @@ -48,4 +48,10 @@ public void testHasDeploymentType()
assert model.getDeploymentType().equals(Production.class);
}

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

}
@@ -0,0 +1,57 @@
package org.jboss.webbeans.test;

import javax.webbeans.ContextNotActiveException;
import javax.webbeans.NullableDependencyException;

import org.testng.annotations.Test;

@SpecVersion("PDR")
public class InjectionTests extends AbstractTest
{

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

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

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

@Test(groups="injection", expectedExceptions=NullableDependencyException.class) @SpecAssertion(section="4.2")
public void testPrimitiveInjectionPointResolvesToNullableWebBean()
{
assert false;
}

@Test(groups="injection", expectedExceptions=ContextNotActiveException.class) @SpecAssertion(section="4.3")
public void testInvokeNormalInjectedWebBeanWhenContextNotActive()
{
assert false;
}

@Test(groups="injection") @SpecAssertion(section="4.3")
public void testInovkeDependentScopeWhenContextNotActive()
{
assert false;
}

/*
@Test(groups="injection") @SpecAssertion(section="4.2")
public void test
{
assert false;
}
*/
}
Expand Up @@ -3,7 +3,6 @@
import static org.jboss.webbeans.test.util.Util.getEmptyAnnotatedType;

import javax.webbeans.AmbiguousDependencyException;
import javax.webbeans.UnsatisfiedDependencyException;
import javax.webbeans.manager.Bean;

import org.jboss.webbeans.BeanImpl;
Expand All @@ -21,7 +20,13 @@
public class InstantiationByNameTest extends AbstractTest
{

@Test(expectedExceptions=AmbiguousDependencyException.class)
@Test(groups="resolution") @SpecAssertion(section="4.10")
public void testNoWebBeansFound()
{
assert false;
}

@Test(expectedExceptions=AmbiguousDependencyException.class) @SpecAssertion(section="4.10.1")
public void testAmbiguousDependencies() throws Exception
{
InjectableField<ScottishFish> whiteScottishFishField = new InjectableField<ScottishFish>(FishFarm.class.getDeclaredField("whiteScottishFish"));
Expand All @@ -38,19 +43,26 @@ public void testAmbiguousDependencies() throws Exception
manager.getInstanceByName("whitefish");
}

@Test(expectedExceptions=UnsatisfiedDependencyException.class)
public void testUnsatisfiedDependencies() throws Exception
@Test(groups="resolution") @SpecAssertion(section="4.10.1")
public void testGetInstanceByName()
{
InjectableField<ScottishFish> whiteScottishFishField = new InjectableField<ScottishFish>(FishFarm.class.getDeclaredField("whiteScottishFish"));
Bean<Cod> codBean = new BeanImpl<Cod>(new SimpleBeanModel<Cod>(new SimpleAnnotatedType<Cod>(Cod.class), getEmptyAnnotatedType(Cod.class), super.manager), manager);
Bean<Salmon> salmonBean = new BeanImpl<Salmon>(new SimpleBeanModel<Salmon>(new SimpleAnnotatedType<Salmon>(Salmon.class), getEmptyAnnotatedType(Salmon.class), super.manager), manager);
manager.addBean(codBean);
manager.addBean(salmonBean);

ResolutionManager resolutionManager = manager.getResolutionManager();
resolutionManager.addInjectionPoint(whiteScottishFishField);

manager.getInstanceByName("foo");
assert false;
}

@Test(groups="resolution") @SpecAssertion(section="4.10")
public void testGetInstanceByNameCalledOncePerDistinctNameInElExpression()
{
assert false;
}

/*
@Test(groups="el") @SpecAssertion(section="4.10")
public void test
{
assert false;
}
*/

}
Expand Up @@ -4,6 +4,7 @@

import javax.webbeans.AmbiguousDependencyException;
import javax.webbeans.AnnotationLiteral;
import javax.webbeans.DuplicateBindingTypeException;
import javax.webbeans.UnproxyableDependencyException;
import javax.webbeans.UnsatisfiedDependencyException;
import javax.webbeans.manager.Bean;
Expand All @@ -25,10 +26,29 @@
import org.jboss.webbeans.test.beans.broken.PlaiceFarm;
import org.testng.annotations.Test;

@SpecVersion("PDR")
public class InstantiationByTypeTest extends AbstractTest
{

@Test(expectedExceptions=AmbiguousDependencyException.class)
@Test(groups="resolution") @SpecAssertion(section="4.9")
public void testCurrentBindingTypeAssumed()
{
assert false;
}

@Test(groups="resolution", expectedExceptions=DuplicateBindingTypeException.class) @SpecAssertion(section="4.9")
public void testDuplicateBindingTypesUsed()
{
assert false;
}

@Test(groups="resolution", expectedExceptions=IllegalArgumentException.class) @SpecAssertion(section="4.9")
public void testNonBindingTypeUsed()
{
assert false;
}

@Test(expectedExceptions=AmbiguousDependencyException.class) @SpecAssertion(section="4.9")
public void testAmbiguousDependencies() throws Exception
{
InjectableField<ScottishFish> whiteScottishFishField = new InjectableField<ScottishFish>(FishFarm.class.getDeclaredField("whiteScottishFish"));
Expand All @@ -45,7 +65,7 @@ public void testAmbiguousDependencies() throws Exception
manager.getInstanceByType(ScottishFish.class, new AnnotationLiteral<Whitefish>(){});
}

@Test(expectedExceptions=UnsatisfiedDependencyException.class)
@Test(expectedExceptions=UnsatisfiedDependencyException.class) @SpecAssertion(section="4.9")
public void testUnsatisfiedDependencies() throws Exception
{
InjectableField<ScottishFish> whiteScottishFishField = new InjectableField<ScottishFish>(FishFarm.class.getDeclaredField("whiteScottishFish"));
Expand All @@ -62,7 +82,7 @@ public void testUnsatisfiedDependencies() throws Exception
manager.getInstanceByType(Tuna.class, new CurrentAnnotationLiteral());
}

@Test(expectedExceptions=UnproxyableDependencyException.class)
@Test(expectedExceptions=UnproxyableDependencyException.class) @SpecAssertion(section="4.9")
public void testUnproxyableDependencies() throws Exception
{
InjectableField<Plaice> plaiceField = new InjectableField<Plaice>(PlaiceFarm.class.getDeclaredField("plaice"));
Expand All @@ -75,4 +95,14 @@ public void testUnproxyableDependencies() throws Exception
manager.getInstanceByType(Plaice.class, new AnnotationLiteral<Whitefish>(){});
}

/*
@Test(groups="resolution") @SpecAssertion(section="4.9")
public void test
{
assert false;
}
*/

}
30 changes: 30 additions & 0 deletions webbeans-ri/src/test/java/org/jboss/webbeans/test/ManagerTest.java
@@ -0,0 +1,30 @@
package org.jboss.webbeans.test;

import org.testng.annotations.Test;

@SpecVersion("PDR")
public class ManagerTest
{

@Test(groups={"manager", "injection"}) @SpecAssertion(section="4.8")
public void testInjectingManager()
{
assert false;
}

@Test(groups={"manager", "ejb3"}) @SpecAssertion(section="4.8")
public void testManagerLookupInJndi()
{
assert false;
}

/*
@Test(groups="manager") @SpecAssertion(section="4.8")
public void test
{
assert false;
}
*/
}

0 comments on commit 268fda5

Please sign in to comment.