Author: pete.muir(a)jboss.org
Date: 2009-01-09 19:44:42 -0500 (Fri, 09 Jan 2009)
New Revision: 869
Added:
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/SpecAssertion.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/SpecVersion.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/tests/
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/tests/AbstractTest.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/tests/BindingTypeTest.java
tck/trunk/impl/src/main/resources/tck-unit-tests.xml
tck/trunk/impl/src/test/
tck/trunk/impl/src/test/java/
tck/trunk/impl/src/test/resources/
Removed:
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/test/AbstractTest.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/test/BindingTypeTest.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/test/SpecAssertion.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/test/SpecVersion.java
tck/trunk/impl/src/main/resources/unit-tests.xml
Modified:
tck/trunk/
tck/trunk/api/
tck/trunk/api/src/main/java/org/jboss/webbeans/tck/api/Beans.java
tck/trunk/api/src/main/java/org/jboss/webbeans/tck/api/Contexts.java
tck/trunk/api/src/main/java/org/jboss/webbeans/tck/api/Managers.java
tck/trunk/api/src/main/java/org/jboss/webbeans/tck/api/TCKConfiguration.java
tck/trunk/api/src/main/java/org/jboss/webbeans/tck/api/TestSuite.java
tck/trunk/impl/pom.xml
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/WebBeansTCKImpl.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/util/DeploymentProperties.java
Log:
slight package changes, add reading configuration from properties
Property changes on: tck/trunk
___________________________________________________________________
Name: svn:ignore
- target
+ target
test-output
Property changes on: tck/trunk/api
___________________________________________________________________
Name: svn:ignore
- target
.classpath
.project
.settings
+ target
.classpath
.project
.settings
test-output
Modified: tck/trunk/api/src/main/java/org/jboss/webbeans/tck/api/Beans.java
===================================================================
--- tck/trunk/api/src/main/java/org/jboss/webbeans/tck/api/Beans.java 2009-01-10 00:41:41
UTC (rev 868)
+++ tck/trunk/api/src/main/java/org/jboss/webbeans/tck/api/Beans.java 2009-01-10 00:44:42
UTC (rev 869)
@@ -13,6 +13,8 @@
public interface Beans
{
+ public static final String PROPERTY_NAME = Beans.class.getName();
+
/**
* Create a new simple bean from the given class
*
Modified: tck/trunk/api/src/main/java/org/jboss/webbeans/tck/api/Contexts.java
===================================================================
--- tck/trunk/api/src/main/java/org/jboss/webbeans/tck/api/Contexts.java 2009-01-10
00:41:41 UTC (rev 868)
+++ tck/trunk/api/src/main/java/org/jboss/webbeans/tck/api/Contexts.java 2009-01-10
00:44:42 UTC (rev 869)
@@ -11,6 +11,9 @@
*/
public interface Contexts<T extends Context>
{
+
+ public static final String PROPERTY_NAME = Contexts.class.getName();
+
/**
* Sets the specified context as active
*
Modified: tck/trunk/api/src/main/java/org/jboss/webbeans/tck/api/Managers.java
===================================================================
--- tck/trunk/api/src/main/java/org/jboss/webbeans/tck/api/Managers.java 2009-01-10
00:41:41 UTC (rev 868)
+++ tck/trunk/api/src/main/java/org/jboss/webbeans/tck/api/Managers.java 2009-01-10
00:44:42 UTC (rev 869)
@@ -15,6 +15,9 @@
*/
public interface Managers
{
+
+ public static final String PROPERTY_NAME = Managers.class.getName();
+
/**
*
* @param enabledDeploymentTypes
Modified: tck/trunk/api/src/main/java/org/jboss/webbeans/tck/api/TCKConfiguration.java
===================================================================
---
tck/trunk/api/src/main/java/org/jboss/webbeans/tck/api/TCKConfiguration.java 2009-01-10
00:41:41 UTC (rev 868)
+++
tck/trunk/api/src/main/java/org/jboss/webbeans/tck/api/TCKConfiguration.java 2009-01-10
00:44:42 UTC (rev 869)
@@ -3,6 +3,11 @@
public class TCKConfiguration
{
+ public static final TCKConfiguration newInstance(Beans beans, Contexts<?>
contexts, Managers managers, TestSuite testSuite)
+ {
+ return new TCKConfiguration(beans, contexts, managers, testSuite);
+ }
+
private Beans beans;
private Contexts<?> contexts;
@@ -11,13 +16,20 @@
private TestSuite testSuite;
- public TCKConfiguration(Beans beans, Contexts<?> contexts, Managers managers,
TestSuite testSuite)
+ protected TCKConfiguration(Beans beans, Contexts<?> contexts, Managers managers,
TestSuite testSuite)
{
super();
this.beans = beans;
this.contexts = contexts;
this.managers = managers;
- this.testSuite = testSuite;
+ if (testSuite == null)
+ {
+ this.testSuite = testSuite;
+ }
+ else
+ {
+ this.testSuite = new TestSuite(null);
+ }
}
public Beans getBeans()
Modified: tck/trunk/api/src/main/java/org/jboss/webbeans/tck/api/TestSuite.java
===================================================================
--- tck/trunk/api/src/main/java/org/jboss/webbeans/tck/api/TestSuite.java 2009-01-10
00:41:41 UTC (rev 868)
+++ tck/trunk/api/src/main/java/org/jboss/webbeans/tck/api/TestSuite.java 2009-01-10
00:44:42 UTC (rev 869)
@@ -3,6 +3,8 @@
public class TestSuite
{
+ public static final String PROPERTY_NAME = TestSuite.class.getName();
+
private String outputDirectory;
public TestSuite(String outputDirectory)
Modified: tck/trunk/impl/pom.xml
===================================================================
--- tck/trunk/impl/pom.xml 2009-01-10 00:41:41 UTC (rev 868)
+++ tck/trunk/impl/pom.xml 2009-01-10 00:44:42 UTC (rev 869)
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<project
xmlns="http://maven.apache.org/POM/4.0.0"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>parent</artifactId>
<groupId>org.jboss.webbeans.tck</groupId>
@@ -17,7 +17,7 @@
<groupId>org.jboss.webbeans</groupId>
<artifactId>webbeans-api</artifactId>
</dependency>
-
+
<dependency>
<groupId>org.jboss.webbeans.tck</groupId>
<artifactId>webbeans-tck-api</artifactId>
@@ -28,7 +28,7 @@
<artifactId>testng</artifactId>
<classifier>jdk15</classifier>
</dependency>
-
+
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
@@ -58,26 +58,40 @@
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
</dependency>
-
+
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
</dependency>
-
+
</dependencies>
<build>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.4.2</version>
- <configuration>
- <suiteXmlFiles>
- <suiteXmlFile>testng.xml</suiteXmlFile>
- </suiteXmlFiles>
- </configuration>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.2</version>
+ <executions>
+ <execution>
+ <id>attach-artifacts</id>
+ <phase>package</phase>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <configuration>
+ <artifacts>
+ <artifact>
+
<file>${basedir}/src/main/resources/tck-unit-tests.xml</file>
+ <type>xml</type>
+ <classifier>suite</classifier>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
</plugin>
+
</plugins>
</build>
Copied: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/SpecAssertion.java (from
rev 858,
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/test/SpecAssertion.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/SpecAssertion.java
(rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/SpecAssertion.java 2009-01-10
00:44:42 UTC (rev 869)
@@ -0,0 +1,16 @@
+package org.jboss.webbeans.tck.impl;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
+(a)Target(ElementType.METHOD)
+@Documented
+public @interface SpecAssertion
+{
+
+ public String[] section();
+
+ public String note() default "";
+
+}
Copied: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/SpecVersion.java (from
rev 858, tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/test/SpecVersion.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/SpecVersion.java
(rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/SpecVersion.java 2009-01-10
00:44:42 UTC (rev 869)
@@ -0,0 +1,13 @@
+package org.jboss.webbeans.tck.impl;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
+@Documented
+(a)Target(ElementType.TYPE)
+public @interface SpecVersion {
+
+ String value();
+
+}
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/WebBeansTCKImpl.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/WebBeansTCKImpl.java 2009-01-10
00:41:41 UTC (rev 868)
+++
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/WebBeansTCKImpl.java 2009-01-10
00:44:42 UTC (rev 869)
@@ -4,11 +4,17 @@
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
import javax.xml.parsers.ParserConfigurationException;
+import org.jboss.webbeans.tck.api.Beans;
+import org.jboss.webbeans.tck.api.Contexts;
+import org.jboss.webbeans.tck.api.Managers;
import org.jboss.webbeans.tck.api.TCKConfiguration;
+import org.jboss.webbeans.tck.api.TestSuite;
import org.jboss.webbeans.tck.api.WebBeansTCK;
+import org.jboss.webbeans.tck.impl.util.DeploymentProperties;
import org.testng.TestNG;
import org.testng.xml.Parser;
import org.testng.xml.XmlSuite;
@@ -17,8 +23,17 @@
public class WebBeansTCKImpl extends WebBeansTCK
{
- public static TCKConfiguration configuration;
+ private static TCKConfiguration configuration;
+ public static TCKConfiguration configuration()
+ {
+ if (configuration == null)
+ {
+ configuration = createTCKConfiguration();
+ }
+ return configuration;
+ }
+
public WebBeansTCKImpl()
{
super();
@@ -39,7 +54,7 @@
private static void setXmlSuitePath(TestNG testNG)
{
- InputStream is =
WebBeansTCKImpl.class.getResourceAsStream("/unit-tests.xml");
+ InputStream is =
WebBeansTCKImpl.class.getResourceAsStream("/tck-unit-tests.xml");
if (is == null)
{
throw new IllegalStateException("Unable to load testng.xml");
@@ -68,15 +83,55 @@
@Override
protected void configure(TCKConfiguration configuration)
{
- if (configuration == null)
+ if (configuration != null)
{
- // TODO load configuration from properties
+ WebBeansTCKImpl.configuration = configuration;
}
+ }
+
+
+ public static final TCKConfiguration createTCKConfiguration()
+ {
+ DeploymentProperties deploymentProperties = new DeploymentProperties();
+ Managers managers = create(deploymentProperties.getClasses(Managers.PROPERTY_NAME,
Managers.class), Managers.class, true);
+ Beans beans = create(deploymentProperties.getClasses(Beans.PROPERTY_NAME,
Beans.class), Beans.class, true);
+ Contexts<?> contexts =
create(deploymentProperties.getClasses(Contexts.PROPERTY_NAME, Contexts.class),
Contexts.class, true);
+ TestSuite testSuite =
create(deploymentProperties.getClasses(TestSuite.PROPERTY_NAME, TestSuite.class),
TestSuite.class, false);
+ return TCKConfiguration.newInstance(beans, contexts, managers, testSuite);
+ }
+
+ private static <T> T create(Set<Class<? extends T>> classes,
Class<T> expectedType, boolean required)
+ {
+ if (classes.size() == 0)
+ {
+ if (required)
+ {
+ throw new IllegalArgumentException("Cannot find any implementations of
" + expectedType.getSimpleName() + ", check that " + expectedType.getName()
+ " is specified");
+ }
+ else
+ {
+ return null;
+ }
+ }
+ else if (classes.size() > 1)
+ {
+ throw new IllegalArgumentException("More than one implementation of "
+ expectedType.getSimpleName() + " specified, not sure which one to use!");
+ }
else
{
- WebBeansTCKImpl.configuration = configuration;
+ Class<? extends T> clazz = classes.iterator().next();
+ try
+ {
+ return clazz.newInstance();
+ }
+ catch (InstantiationException e)
+ {
+ throw new IllegalStateException("Unable to instantiate " + clazz,
e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new IllegalStateException("Unable to instantiate " + clazz,
e);
+ }
}
}
-
-
}
Deleted: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/test/AbstractTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/test/AbstractTest.java 2009-01-10
00:41:41 UTC (rev 868)
+++
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/test/AbstractTest.java 2009-01-10
00:44:42 UTC (rev 869)
@@ -1,109 +0,0 @@
-package org.jboss.webbeans.tck.impl.test;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-
-import javax.webbeans.Production;
-import javax.webbeans.Standard;
-import javax.webbeans.manager.Bean;
-import javax.webbeans.manager.Manager;
-
-import org.jboss.webbeans.tck.impl.WebBeansTCKImpl;
-import org.jboss.webbeans.tck.impl.test.annotations.AnotherDeploymentType;
-import org.testng.annotations.BeforeMethod;
-
-public class AbstractTest
-{
- protected static final int BUILT_IN_BEANS = 3;
-
- protected Manager manager;
-
- public static boolean visited = false;
-
- @BeforeMethod
- public final void before()
- {
- manager = WebBeansTCKImpl.configuration.getManagers().createManager();
-
WebBeansTCKImpl.configuration.getManagers().setEnabledDeploymentTypes(Arrays.asList(Standard.class,
Production.class, AnotherDeploymentType.class));
- }
-
- public <T> Bean<T> getSimpleBean(Class<T> beanClass)
- {
- return WebBeansTCKImpl.configuration.getBeans().createSimpleBean(beanClass);
- }
-
- public <T> Bean<?> getProducerMethodBean(Method method, Bean<?>
producerBean)
- {
- return WebBeansTCKImpl.configuration.getBeans().createProducerMethodBean(method,
producerBean);
- }
-
- /*
- protected <T> AbstractClassBean<T> registerBean(Class<T> clazz)
- {
- AbstractClassBean<T> bean = null;
- if (CurrentManager.rootManager().getEjbDescriptorCache().containsKey(clazz))
- {
- bean = EnterpriseBean.of(clazz, manager);
- }
- else
- {
- bean = SimpleBean.of(clazz, manager);
- }
- CurrentManager.rootManager().addBean(bean);
- return bean;
- }
- */
-
-/*
- protected void registerBeans(Class<?>[] classes)
- {
- for (Class<?> clazz : classes)
- {
- registerBean(clazz);
- }
- }
- */
-
- /*
- @SuppressWarnings("unchecked")
- protected void addStandardDeploymentTypesForTests()
- {
- manager.setEnabledDeploymentTypes(Arrays.asList(Standard.class, Production.class,
AnotherDeploymentType.class, HornedAnimalDeploymentType.class));
- }
-
- protected <T> void addToEjbCache(Class<T> clazz)
- {
- manager.getEjbDescriptorCache().add(new MockEjbDescriptor<T>(clazz));
- }
- */
-
- protected byte[] serialize(Object instance) throws IOException
- {
- ByteArrayOutputStream bytes = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream(bytes);
- out.writeObject(instance);
- return bytes.toByteArray();
- }
-
- protected Object deserialize(byte[] bytes) throws IOException, ClassNotFoundException
- {
- ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes));
- return in.readObject();
- }
-
-/* protected void activateDependentContext()
- {
- DependentContext.INSTANCE.setActive(true);
- }
-
- protected void deactivateDependentContext()
- {
- DependentContext.INSTANCE.setActive(false);
- }
- */
-}
\ No newline at end of file
Deleted:
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/test/BindingTypeTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/test/BindingTypeTest.java 2009-01-10
00:41:41 UTC (rev 868)
+++
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/test/BindingTypeTest.java 2009-01-10
00:44:42 UTC (rev 869)
@@ -1,167 +0,0 @@
-package org.jboss.webbeans.tck.impl.test;
-
-import java.lang.reflect.Method;
-
-import javax.webbeans.Current;
-import javax.webbeans.manager.Bean;
-
-import org.jboss.webbeans.tck.impl.test.annotations.Synchronous;
-import org.jboss.webbeans.tck.impl.test.beans.Barn;
-import org.jboss.webbeans.tck.impl.test.beans.Cat;
-import org.jboss.webbeans.tck.impl.test.beans.Cod;
-import org.jboss.webbeans.tck.impl.test.beans.DefangedTarantula;
-import org.jboss.webbeans.tck.impl.test.beans.Order;
-import org.jboss.webbeans.tck.impl.test.beans.Spider;
-import org.jboss.webbeans.tck.impl.test.beans.SpiderProducer;
-import org.jboss.webbeans.tck.impl.test.beans.Tarantula;
-import org.jboss.webbeans.tck.impl.test.beans.Tuna;
-import org.jboss.webbeans.tck.impl.test.binding.CurrentBinding;
-import org.jboss.webbeans.tck.impl.util.Reflections;
-import org.testng.annotations.Test;
-
-@SpecVersion("20081206")
-public class BindingTypeTest extends AbstractTest
-{
-
- @SuppressWarnings("unchecked")
- @Test @SpecAssertion(section={"2.3.3", "2.3.1"})
- public void testDefaultBindingTypeDeclaredInJava()
- {
- Bean<Order> order = getSimpleBean(Order.class);
- assert order.getBindingTypes().size() == 1;
- order.getBindingTypes().iterator().next().annotationType().equals(Current.class);
- }
-
- @Test(groups={"stub", "annotationDefinition"})
@SpecAssertion(section="2.3.2")
- public void testBindingTypeHasCorrectTarget()
- {
- assert false;
- }
-
- @Test(groups={"stub", "annotationDefinition"})
@SpecAssertion(section="2.3.2")
- public void testBindingTypeHasCorrectRetention()
- {
- assert false;
- }
-
- @Test(groups={"stub", "annotationDefinition"})
@SpecAssertion(section="2.3.2")
- public void testBindingTypeDeclaresBindingTypeAnnotation()
- {
- assert false;
- }
-
- @SuppressWarnings("unchecked")
- @Test @SpecAssertion(section="2.3.3")
- public void testBindingTypesDeclaredInJava()
- {
- Bean<Cat> cat = getSimpleBean(Cat.class);
- assert cat.getBindingTypes().size() == 1;
- assert Reflections.annotationSetMatches(cat.getBindingTypes(), Synchronous.class);
- }
-
- @Test @SpecAssertion(section="2.3.3")
- public void testMultipleBindingTypes()
- {
- Bean<?> model = getSimpleBean(Cod.class);
- assert model.getBindingTypes().size() == 2;
- }
-
- @SuppressWarnings("unchecked")
- @Test(groups={"stub", "webbeansxml"})
@SpecAssertion(section="2.3.4")
- public void testBindingTypesDeclaredInXml()
- {
- //Map<Class<? extends Annotation>, Annotation> annotations = new
HashMap<Class<? extends Annotation>, Annotation>();
- //annotations.put(Asynchronous.class, new AsynchronousAnnotationLiteral());
- //AnnotatedClass annotatedItem = new SimpleAnnotatedClass(Antelope.class,
annotations);
-
- //SimpleBean<Antelope> antelope = createSimpleBean(Antelope.class,
annotatedItem, manager);
- // assert Reflections.annotationSetMatches(antelope.getBindingTypes(),
Asynchronous.class);
- assert false;
- }
-
- @Test(groups={"stub", "webbeansxml"})
@SpecAssertion(section="2.3.4")
- public void testXmlBindingTypeOverridesAndIgnoresJava()
- {
- //Map<Class<? extends Annotation>, Annotation> annotations = new
HashMap<Class<? extends Annotation>, Annotation>();
- //annotations.put(Asynchronous.class, new AsynchronousAnnotationLiteral());
- //AnnotatedClass<Cat> annotatedItem = new
SimpleAnnotatedClass<Cat>(Cat.class, annotations);
-
- //SimpleBean<Cat> cat = createSimpleBean(Cat.class, annotatedItem, manager);
- //assert cat.getBindingTypes().size() == 1;
- //assert cat.getBindingTypes().contains(new AnnotationLiteral<Asynchronous>()
{});
- assert false;
- }
-
- @Test(groups={"stub", "webbeansxml"})
@SpecAssertion(section="2.3.4")
- public void testNoBindingTypesDeclaredInXml()
- {
- //Map<Class<? extends Annotation>, Annotation> annotations = new
HashMap<Class<? extends Annotation>, Annotation>();
- //AnnotatedClass<Cat> annotatedItem = new
SimpleAnnotatedClass<Cat>(Cat.class, annotations);
-
- //SimpleBean<Cat> cat = createSimpleBean(Cat.class, annotatedItem, manager);
- //assert cat.getBindingTypes().size() == 1;
- //assert cat.getBindingTypes().contains(new AnnotationLiteral<Synchronous>()
{});
- assert false;
- }
-
- @Test(groups={"stub", "webbeansxml"})
@SpecAssertion(section={"2.3.4", "2.3.1"})
- public void testDefaultBindingTypeDeclaredInXml()
- {
- Bean<?> model = getSimpleBean(Tuna.class);
- assert model.getBindingTypes().size() == 1;
- assert model.getBindingTypes().contains(new CurrentBinding());
- assert false;
- }
-
- @Test(groups={"injection", "producerMethod"})
@SpecAssertion(section="2.3.5")
- public void testFieldInjectedFromProducerMethod() throws Exception
- {
- Bean<SpiderProducer> spiderProducer = getSimpleBean(SpiderProducer.class);
- manager.addBean(spiderProducer);
- Method method = SpiderProducer.class.getMethod("produceTameTarantula");
- manager.addBean(getProducerMethodBean(method, spiderProducer));
- Barn barn = getSimpleBean(Barn.class).create();
- assert barn.petSpider != null;
- assert barn.petSpider instanceof DefangedTarantula;
- }
-
- @Test(groups={"stub", "injection", "webbeansxml"})
@SpecAssertion(section="2.3.5")
- public void testFieldWithBindingTypeInXml()
- {
- assert false;
- }
-
- @Test(groups={"stub", "injection", "webbeansxml"})
@SpecAssertion(section="2.3.5")
- public void testFieldWithBindingTypeInXmlIgnoresAnnotations()
- {
- assert false;
- }
-
- @SuppressWarnings("unchecked")
- @Test(groups={"injection", "producerMethod"})
- public void testMethodWithBindingAnnotationsOnParametersAreInjected() throws
Exception
- {
- Bean<SpiderProducer> spiderProducer = getSimpleBean(SpiderProducer.class);
- manager.addBean(spiderProducer);
- Method method = SpiderProducer.class.getMethod("produceTameTarantula");
- manager.addBean(getProducerMethodBean(method, spiderProducer));
- method = SpiderProducer.class.getMethod("produceSpiderFromInjection",
Tarantula.class);
- Bean<Spider> spiderBean = (Bean<Spider>) getProducerMethodBean(method,
spiderProducer);
- Spider spider = spiderBean.create();
- assert spider != null;
- assert spider instanceof DefangedTarantula;
- }
-
- @Test(groups={"stub", "injection", "webbeansxml"})
@SpecAssertion(section="2.3.6")
- public void testMethodWithBindingAnnotationsOnParametersDeclaredInXml()
- {
- assert false;
- }
-
- @Test(groups={"stub", "injection", "webbeansxml"})
@SpecAssertion(section="2.3.6")
- public void
testMethodWithBindingAnnotationsOnParametersDeclaredInXmlIgnoresAnnotations()
- {
- assert false;
- }
-
-}
\ No newline at end of file
Deleted: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/test/SpecAssertion.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/test/SpecAssertion.java 2009-01-10
00:41:41 UTC (rev 868)
+++
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/test/SpecAssertion.java 2009-01-10
00:44:42 UTC (rev 869)
@@ -1,16 +0,0 @@
-package org.jboss.webbeans.tck.impl.test;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Target;
-
-(a)Target(ElementType.METHOD)
-@Documented
-public @interface SpecAssertion
-{
-
- public String[] section();
-
- public String note() default "";
-
-}
Deleted: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/test/SpecVersion.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/test/SpecVersion.java 2009-01-10
00:41:41 UTC (rev 868)
+++
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/test/SpecVersion.java 2009-01-10
00:44:42 UTC (rev 869)
@@ -1,13 +0,0 @@
-package org.jboss.webbeans.tck.impl.test;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Target;
-
-@Documented
-(a)Target(ElementType.TYPE)
-public @interface SpecVersion {
-
- String value();
-
-}
Modified:
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/util/DeploymentProperties.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/util/DeploymentProperties.java 2009-01-10
00:41:41 UTC (rev 868)
+++
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/util/DeploymentProperties.java 2009-01-10
00:44:42 UTC (rev 869)
@@ -17,7 +17,7 @@
public class DeploymentProperties
{
// The resource bundle used to control Web Beans RI deployment
- public static final String RESOURCE_BUNDLE =
"META-INF/web-beans-ri.properties";
+ public static final String RESOURCE_BUNDLE =
"META-INF/web-beans-tck.properties";
// The class to work from
private SimpleResourceLoader resourceLoader;
Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/tests/AbstractTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/tests/AbstractTest.java
(rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/tests/AbstractTest.java 2009-01-10
00:44:42 UTC (rev 869)
@@ -0,0 +1,110 @@
+package org.jboss.webbeans.tck.tests;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+
+import javax.webbeans.Production;
+import javax.webbeans.Standard;
+import javax.webbeans.manager.Bean;
+import javax.webbeans.manager.Manager;
+
+import org.jboss.webbeans.tck.impl.WebBeansTCKImpl;
+import org.jboss.webbeans.tck.impl.test.annotations.AnotherDeploymentType;
+import org.testng.annotations.BeforeMethod;
+
+public class AbstractTest
+{
+ protected static final int BUILT_IN_BEANS = 3;
+
+ protected Manager manager;
+
+ public static boolean visited = false;
+
+ @BeforeMethod
+ public final void before()
+ {
+ manager = WebBeansTCKImpl.configuration().getManagers().createManager();
+
WebBeansTCKImpl.configuration().getManagers().setEnabledDeploymentTypes(Arrays.asList(Standard.class,
Production.class, AnotherDeploymentType.class));
+ }
+
+ public <T> Bean<T> getSimpleBean(Class<T> beanClass)
+ {
+ return WebBeansTCKImpl.configuration().getBeans().createSimpleBean(beanClass);
+ }
+
+ public <T> Bean<?> getProducerMethodBean(Method method, Bean<?>
producerBean)
+ {
+ return WebBeansTCKImpl.configuration().getBeans().createProducerMethodBean(method,
producerBean);
+ }
+
+ /*
+ protected <T> AbstractClassBean<T> registerBean(Class<T> clazz)
+ {
+ AbstractClassBean<T> bean = null;
+ if (CurrentManager.rootManager().getEjbDescriptorCache().containsKey(clazz))
+ {
+ bean = EnterpriseBean.of(clazz, manager);
+ }
+ else
+ {
+ bean = SimpleBean.of(clazz, manager);
+ }
+ CurrentManager.rootManager().addBean(bean);
+ return bean;
+ }
+ */
+
+/*
+ protected void registerBeans(Class<?>[] classes)
+ {
+ for (Class<?> clazz : classes)
+ {
+ registerBean(clazz);
+ }
+ }
+ */
+
+ /*
+ @SuppressWarnings("unchecked")
+ protected void addStandardDeploymentTypesForTests()
+ {
+ manager.setEnabledDeploymentTypes(Arrays.asList(Standard.class, Production.class,
AnotherDeploymentType.class, HornedAnimalDeploymentType.class));
+ }
+
+ protected <T> void addToEjbCache(Class<T> clazz)
+ {
+ manager.getEjbDescriptorCache().add(new MockEjbDescriptor<T>(clazz));
+ }
+ */
+
+ protected byte[] serialize(Object instance) throws IOException
+ {
+ ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream(bytes);
+ out.writeObject(instance);
+ return bytes.toByteArray();
+ }
+
+ protected Object deserialize(byte[] bytes) throws IOException, ClassNotFoundException
+ {
+ ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes));
+ return in.readObject();
+ }
+
+/* protected void activateDependentContext()
+ {
+ DependentContext.INSTANCE.setActive(true);
+ }
+
+ protected void deactivateDependentContext()
+ {
+ DependentContext.INSTANCE.setActive(false);
+ }
+ */
+}
\ No newline at end of file
Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/tests/BindingTypeTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/tests/BindingTypeTest.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/tests/BindingTypeTest.java 2009-01-10
00:44:42 UTC (rev 869)
@@ -0,0 +1,170 @@
+package org.jboss.webbeans.tck.tests;
+
+
+import java.lang.reflect.Method;
+
+import javax.webbeans.Current;
+import javax.webbeans.manager.Bean;
+
+import org.jboss.webbeans.tck.impl.SpecAssertion;
+import org.jboss.webbeans.tck.impl.SpecVersion;
+import org.jboss.webbeans.tck.impl.test.annotations.Synchronous;
+import org.jboss.webbeans.tck.impl.test.beans.Barn;
+import org.jboss.webbeans.tck.impl.test.beans.Cat;
+import org.jboss.webbeans.tck.impl.test.beans.Cod;
+import org.jboss.webbeans.tck.impl.test.beans.DefangedTarantula;
+import org.jboss.webbeans.tck.impl.test.beans.Order;
+import org.jboss.webbeans.tck.impl.test.beans.Spider;
+import org.jboss.webbeans.tck.impl.test.beans.SpiderProducer;
+import org.jboss.webbeans.tck.impl.test.beans.Tarantula;
+import org.jboss.webbeans.tck.impl.test.beans.Tuna;
+import org.jboss.webbeans.tck.impl.test.binding.CurrentBinding;
+import org.jboss.webbeans.tck.impl.util.Reflections;
+import org.testng.annotations.Test;
+
+@SpecVersion("20081206")
+public class BindingTypeTest extends AbstractTest
+{
+
+ @SuppressWarnings("unchecked")
+ @Test @SpecAssertion(section={"2.3.3", "2.3.1"})
+ public void testDefaultBindingTypeDeclaredInJava()
+ {
+ Bean<Order> order = getSimpleBean(Order.class);
+ assert order.getBindingTypes().size() == 1;
+ order.getBindingTypes().iterator().next().annotationType().equals(Current.class);
+ }
+
+ @Test(groups={"stub", "annotationDefinition"})
@SpecAssertion(section="2.3.2")
+ public void testBindingTypeHasCorrectTarget()
+ {
+ assert false;
+ }
+
+ @Test(groups={"stub", "annotationDefinition"})
@SpecAssertion(section="2.3.2")
+ public void testBindingTypeHasCorrectRetention()
+ {
+ assert false;
+ }
+
+ @Test(groups={"stub", "annotationDefinition"})
@SpecAssertion(section="2.3.2")
+ public void testBindingTypeDeclaresBindingTypeAnnotation()
+ {
+ assert false;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test @SpecAssertion(section="2.3.3")
+ public void testBindingTypesDeclaredInJava()
+ {
+ Bean<Cat> cat = getSimpleBean(Cat.class);
+ assert cat.getBindingTypes().size() == 1;
+ assert Reflections.annotationSetMatches(cat.getBindingTypes(), Synchronous.class);
+ }
+
+ @Test @SpecAssertion(section="2.3.3")
+ public void testMultipleBindingTypes()
+ {
+ Bean<?> model = getSimpleBean(Cod.class);
+ assert model.getBindingTypes().size() == 2;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test(groups={"stub", "webbeansxml"})
@SpecAssertion(section="2.3.4")
+ public void testBindingTypesDeclaredInXml()
+ {
+ //Map<Class<? extends Annotation>, Annotation> annotations = new
HashMap<Class<? extends Annotation>, Annotation>();
+ //annotations.put(Asynchronous.class, new AsynchronousAnnotationLiteral());
+ //AnnotatedClass annotatedItem = new SimpleAnnotatedClass(Antelope.class,
annotations);
+
+ //SimpleBean<Antelope> antelope = createSimpleBean(Antelope.class,
annotatedItem, manager);
+ // assert Reflections.annotationSetMatches(antelope.getBindingTypes(),
Asynchronous.class);
+ assert false;
+ }
+
+ @Test(groups={"stub", "webbeansxml"})
@SpecAssertion(section="2.3.4")
+ public void testXmlBindingTypeOverridesAndIgnoresJava()
+ {
+ //Map<Class<? extends Annotation>, Annotation> annotations = new
HashMap<Class<? extends Annotation>, Annotation>();
+ //annotations.put(Asynchronous.class, new AsynchronousAnnotationLiteral());
+ //AnnotatedClass<Cat> annotatedItem = new
SimpleAnnotatedClass<Cat>(Cat.class, annotations);
+
+ //SimpleBean<Cat> cat = createSimpleBean(Cat.class, annotatedItem, manager);
+ //assert cat.getBindingTypes().size() == 1;
+ //assert cat.getBindingTypes().contains(new AnnotationLiteral<Asynchronous>()
{});
+ assert false;
+ }
+
+ @Test(groups={"stub", "webbeansxml"})
@SpecAssertion(section="2.3.4")
+ public void testNoBindingTypesDeclaredInXml()
+ {
+ //Map<Class<? extends Annotation>, Annotation> annotations = new
HashMap<Class<? extends Annotation>, Annotation>();
+ //AnnotatedClass<Cat> annotatedItem = new
SimpleAnnotatedClass<Cat>(Cat.class, annotations);
+
+ //SimpleBean<Cat> cat = createSimpleBean(Cat.class, annotatedItem, manager);
+ //assert cat.getBindingTypes().size() == 1;
+ //assert cat.getBindingTypes().contains(new AnnotationLiteral<Synchronous>()
{});
+ assert false;
+ }
+
+ @Test(groups={"stub", "webbeansxml"})
@SpecAssertion(section={"2.3.4", "2.3.1"})
+ public void testDefaultBindingTypeDeclaredInXml()
+ {
+ Bean<?> model = getSimpleBean(Tuna.class);
+ assert model.getBindingTypes().size() == 1;
+ assert model.getBindingTypes().contains(new CurrentBinding());
+ assert false;
+ }
+
+ @Test(groups={"injection", "producerMethod"})
@SpecAssertion(section="2.3.5")
+ public void testFieldInjectedFromProducerMethod() throws Exception
+ {
+ Bean<SpiderProducer> spiderProducer = getSimpleBean(SpiderProducer.class);
+ manager.addBean(spiderProducer);
+ Method method = SpiderProducer.class.getMethod("produceTameTarantula");
+ manager.addBean(getProducerMethodBean(method, spiderProducer));
+ Barn barn = getSimpleBean(Barn.class).create();
+ assert barn.petSpider != null;
+ assert barn.petSpider instanceof DefangedTarantula;
+ }
+
+ @Test(groups={"stub", "injection", "webbeansxml"})
@SpecAssertion(section="2.3.5")
+ public void testFieldWithBindingTypeInXml()
+ {
+ assert false;
+ }
+
+ @Test(groups={"stub", "injection", "webbeansxml"})
@SpecAssertion(section="2.3.5")
+ public void testFieldWithBindingTypeInXmlIgnoresAnnotations()
+ {
+ assert false;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test(groups={"injection", "producerMethod"})
+ public void testMethodWithBindingAnnotationsOnParametersAreInjected() throws
Exception
+ {
+ Bean<SpiderProducer> spiderProducer = getSimpleBean(SpiderProducer.class);
+ manager.addBean(spiderProducer);
+ Method method = SpiderProducer.class.getMethod("produceTameTarantula");
+ manager.addBean(getProducerMethodBean(method, spiderProducer));
+ method = SpiderProducer.class.getMethod("produceSpiderFromInjection",
Tarantula.class);
+ Bean<Spider> spiderBean = (Bean<Spider>) getProducerMethodBean(method,
spiderProducer);
+ Spider spider = spiderBean.create();
+ assert spider != null;
+ assert spider instanceof DefangedTarantula;
+ }
+
+ @Test(groups={"stub", "injection", "webbeansxml"})
@SpecAssertion(section="2.3.6")
+ public void testMethodWithBindingAnnotationsOnParametersDeclaredInXml()
+ {
+ assert false;
+ }
+
+ @Test(groups={"stub", "injection", "webbeansxml"})
@SpecAssertion(section="2.3.6")
+ public void
testMethodWithBindingAnnotationsOnParametersDeclaredInXmlIgnoresAnnotations()
+ {
+ assert false;
+ }
+
+}
\ No newline at end of file
Copied: tck/trunk/impl/src/main/resources/tck-unit-tests.xml (from rev 862,
tck/trunk/impl/src/main/resources/unit-tests.xml)
===================================================================
--- tck/trunk/impl/src/main/resources/tck-unit-tests.xml (rev 0)
+++ tck/trunk/impl/src/main/resources/tck-unit-tests.xml 2009-01-10 00:44:42 UTC (rev
869)
@@ -0,0 +1,40 @@
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
+
+<suite name="WebBeans TCK" verbose="2" >
+
+ <test name="Web Beans TCK" >
+ <groups >
+ <run>
+<!--
+ <exclude name="specialization" />
+ <exclude name="deployment" />
+ <exclude name="disposalMethod" />
+
+ <exclude name="observerMethod" />
+ <exclude name="deferredEvent" />
+ <exclude name="ejb3" />
+ <exclude name="webservice" />
+ <exclude name="annotationDefinition" />
+ <exclude name="webbeansxml" />
+ <exclude name="el" />
+ <exclude name="jms" />
+ <exclude name="interceptors" />
+ <exclude name="decorators" />
+ <exclude name="servlet" />
+
+ <exclude name="passivation" />
+ <exclude name="singletons" />
+ <exclude name="ejbjarxml" />
+ <exclude name="beanDestruction" />
+ <exclude name="commonAnnotations" />
+-->
+ <exclude name="stub" />
+ <exclude name="broken" />
+ </run>
+ </groups>
+ <packages >
+ <package name="org.jboss.webbeans.tck.tests" />
+ </packages>
+ </test>
+
+</suite>
\ No newline at end of file
Deleted: tck/trunk/impl/src/main/resources/unit-tests.xml
===================================================================
--- tck/trunk/impl/src/main/resources/unit-tests.xml 2009-01-10 00:41:41 UTC (rev 868)
+++ tck/trunk/impl/src/main/resources/unit-tests.xml 2009-01-10 00:44:42 UTC (rev 869)
@@ -1,40 +0,0 @@
-<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
-
-<suite name="WebBeans TCK" verbose="2" >
-
- <test name="Web Beans TCK" >
- <groups >
- <run>
-<!--
- <exclude name="specialization" />
- <exclude name="deployment" />
- <exclude name="disposalMethod" />
-
- <exclude name="observerMethod" />
- <exclude name="deferredEvent" />
- <exclude name="ejb3" />
- <exclude name="webservice" />
- <exclude name="annotationDefinition" />
- <exclude name="webbeansxml" />
- <exclude name="el" />
- <exclude name="jms" />
- <exclude name="interceptors" />
- <exclude name="decorators" />
- <exclude name="servlet" />
-
- <exclude name="passivation" />
- <exclude name="singletons" />
- <exclude name="ejbjarxml" />
- <exclude name="beanDestruction" />
- <exclude name="commonAnnotations" />
--->
- <exclude name="stub" />
- <exclude name="broken" />
- </run>
- </groups>
- <packages >
- <package name="org.jboss.webbeans.tck.impl" />
- </packages>
- </test>
-
-</suite>
\ No newline at end of file