[webbeans-commits] Webbeans SVN: r1075 - in tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/tests/lookup: typesafe and 1 other directory.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Mon Jan 19 04:59:38 EST 2009
Author: shane.bryzak at jboss.com
Date: 2009-01-19 04:59:38 -0500 (Mon, 19 Jan 2009)
New Revision: 1075
Modified:
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/tests/lookup/byname/ResolutionByNameTest.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/tests/lookup/typesafe/ResolutionByTypeTest.java
Log:
stub tests
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/tests/lookup/byname/ResolutionByNameTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/tests/lookup/byname/ResolutionByNameTest.java 2009-01-19 08:37:59 UTC (rev 1074)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/tests/lookup/byname/ResolutionByNameTest.java 2009-01-19 09:59:38 UTC (rev 1075)
@@ -3,6 +3,7 @@
import java.lang.annotation.Annotation;
import java.util.List;
+import javax.webbeans.AmbiguousDependencyException;
import javax.webbeans.manager.Bean;
import org.jboss.webbeans.tck.impl.SpecAssertion;
@@ -22,10 +23,47 @@
return deploymentTypes;
}
+ /**
+ * The getInstanceByName() method must:
+ *
+ * Identify the Web Bean by calling Manager.resolveByName(), passing the name.
+ * If resolveByName() returned an empty set, return a null value.
+ * Otherwise, if resolveByName() returned more than one Web Bean, throw an
+ * AmbiguousDependencyException.
+ * Otherwise, if exactly one Web Bean was returned, obtain an instance of the
+ * Web Bean by calling Manager.getInstance(), passing the Bean instance representing
+ * the Web Bean
+ */
@Test(groups={"stub", "el"}) @SpecAssertion(section="5.11")
public void testELResolver()
- {
- assert false;
+ {
+ assert manager.getInstanceByName("nonexistant") == null;
+
+ activateDependentContext();
+ try
+ {
+ try
+ {
+ // Both Cod and Plaice are named "whitefish"
+ Bean<Cod> codBean = createSimpleBean(Cod.class);
+ Bean<Plaice> plaiceBean = createSimpleBean(Plaice.class);
+ manager.addBean(codBean);
+ manager.addBean(plaiceBean);
+
+ // Should throw AmbiguousDependencyException because two beans have the same name
+ manager.getInstanceByName("whitefish");
+ assert false;
+ }
+ catch (AmbiguousDependencyException ex) { }
+
+ Bean<Salmon> salmonBean = createSimpleBean(Salmon.class);
+ manager.addBean(salmonBean);
+ assert manager.getInstanceByName("salmon") instanceof Salmon;
+ }
+ finally
+ {
+ deactivateDependentContext();
+ }
}
@Test(groups={"stub", "el"}) @SpecAssertion(section="5.11.2")
@@ -84,10 +122,27 @@
assert manager.resolveByName("foo").size() == 0;
}
+ /**
+ * The following algorithm must be used by the Web Bean manager when resolving a Web Bean by name:
+ *
+ * The Web Bean manager identifies the set of matching enabled Web Beans which have the given name.
+ * Next, the Web Bean manager examines the deployment types of the matching Web Beans, as defined
+ * in Section 2.5.7, Deployment type precedence, and returns the set of Web Beans with the
+ * highest precedence deployment type that occurs in the set. If there are no matching Web Beans,
+ * an empty set is returned.
+ */
@Test(groups="stub") @SpecAssertion(section="5.11.1")
- public void testOnlyHigestPrecedenceResolved()
+ public void testOnlyHighestPrecedenceResolved()
{
- assert false;
+ // Both Cod and Plaice are named "whitefish" - Plaice has the highest deployment type (AnotherDeploymentType)
+ Bean<Cod> codBean = createSimpleBean(Cod.class);
+ Bean<Plaice> plaiceBean = createSimpleBean(Plaice.class);
+ manager.addBean(codBean);
+ manager.addBean(plaiceBean);
+
+ assert manager.resolveByName("whitefish").size() == 1;
+ assert !manager.resolveByName("whitefish").contains(codBean);
+ assert manager.resolveByName("whitefish").contains(plaiceBean);
}
/*
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/tests/lookup/typesafe/ResolutionByTypeTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/tests/lookup/typesafe/ResolutionByTypeTest.java 2009-01-19 08:37:59 UTC (rev 1074)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/tests/lookup/typesafe/ResolutionByTypeTest.java 2009-01-19 09:59:38 UTC (rev 1075)
@@ -150,7 +150,7 @@
}
@Test @SpecAssertion(section="5.9.2")
- public void testOnlyHighestEnabledPreecedenceWebBeansResolved() throws Exception
+ public void testOnlyHighestEnabledPrecedenceWebBeansResolved() throws Exception
{
Bean<Cod> codBean = createSimpleBean(Cod.class);
Bean<Sole> soleBean = createSimpleBean(Sole.class);
More information about the weld-commits
mailing list