[webbeans-commits] Webbeans SVN: r1491 - ri/trunk/jboss-tck-runner/src/main/java/org/jboss/webbeans/tck/integration/jbossas and 9 other directories.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Wed Feb 11 19:29:02 EST 2009
Author: pete.muir at jboss.org
Date: 2009-02-11 19:29:02 -0500 (Wed, 11 Feb 2009)
New Revision: 1491
Added:
ri/trunk/jboss-tck-runner/tck-unit-tests.xml
tck/trunk/api/src/main/java/org/jboss/jsr299/tck/api/TestResult.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/runner/TestResultImpl.java
Removed:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/runner/TestSuiteLauncher.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/definition/bean/AnotherDeploymentType.java
Modified:
ri/trunk/jboss-tck-runner/pom.xml
ri/trunk/jboss-tck-runner/src/main/java/org/jboss/webbeans/tck/integration/jbossas/ContainersImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java
tck/trunk/api/src/main/java/org/jboss/jsr299/tck/api/TestLauncher.java
tck/trunk/api/src/main/java/org/jboss/jsr299/tck/spi/Containers.java
tck/trunk/api/src/main/java/org/jboss/jsr299/tck/spi/helpers/ForwardingContainers.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/AbstractTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/TCKImpl.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/runner/BufferedListener.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/runner/TestRunner.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/runner/servlet/ServletTestLauncher.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/runner/servlet/ServletTestRunner.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/definition/bean/BeanDefinitionTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/definition/bean/DependentFinalTuna.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/definition/bean/SpiderProducer.java
Log:
Working version of incontainer test runner :-)
Modified: ri/trunk/jboss-tck-runner/pom.xml
===================================================================
--- ri/trunk/jboss-tck-runner/pom.xml 2009-02-11 20:50:30 UTC (rev 1490)
+++ ri/trunk/jboss-tck-runner/pom.xml 2009-02-12 00:29:02 UTC (rev 1491)
@@ -86,7 +86,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<suiteXmlFiles>
- <suiteXmlFile>incontainer-tests.xml</suiteXmlFile>
+ <suiteXmlFile>tck-unit-tests.xml</suiteXmlFile>
</suiteXmlFiles>
<systemProperties>
<property>
@@ -101,38 +101,9 @@
<name>org.jboss.jsr299.tck.libraryDirectory</name>
<value>${project.build.directory}/dependency/lib</value>
</property>
- <property>
- <name>org.jboss.jsr299.tck.testClass</name>
- <value>org.jboss.jsr299.tck.unit.definition.bean.BeanDefinitionTest</value>
- </property>
</systemProperties>
</configuration>
</plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>test</id>
- <phase>test</phase>
- <configuration>
- <tasks>
- <!-- <java classname="org.jboss.jsr299.tck.api.TCK" classpathref="maven.test.classpath" failonerror="true" fork="true">
- <jvmarg line="-DrunSuite=true"/>
- <jvmarg line="-Dorg.jboss.jsr299.tck.standalone=false"/>
- <jvmarg line="-DjbossHome=/Applications/jboss-5.0.0.GA"/>
- <jvmarg line="-Dorg.jboss.jsr299.tck.testClass=org.jboss.jsr299.tck.unit.definition.bean.BeanDefinitionTest" />
- <jvmarg line="-DdumpConfiguration=true" />
- <jvmarg line="-Dorg.jboss.jsr299.tck.libraryDirectory=${project.build.directory}/dependency/lib"/>
- </java>-->
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
</plugins>
</build>
</profile>
Modified: ri/trunk/jboss-tck-runner/src/main/java/org/jboss/webbeans/tck/integration/jbossas/ContainersImpl.java
===================================================================
--- ri/trunk/jboss-tck-runner/src/main/java/org/jboss/webbeans/tck/integration/jbossas/ContainersImpl.java 2009-02-11 20:50:30 UTC (rev 1490)
+++ ri/trunk/jboss-tck-runner/src/main/java/org/jboss/webbeans/tck/integration/jbossas/ContainersImpl.java 2009-02-12 00:29:02 UTC (rev 1491)
@@ -79,7 +79,7 @@
- public void deploy(InputStream archive, String name) throws Exception
+ public void deploy(InputStream archive, String name) throws IOException
{
if (!validated)
{
@@ -109,14 +109,22 @@
}
}
- public void undeploy(String name) throws Exception
+ public void undeploy(String name) throws IOException
{
File file = new File(deployDir, name);
if (file.exists())
{
file.delete();
}
- Thread.sleep(1000);
+ try
+ {
+ // Give the app a chance to undeploy
+ Thread.sleep(1000);
+ }
+ catch (InterruptedException e)
+ {
+ Thread.currentThread().interrupt();
+ }
}
}
Added: ri/trunk/jboss-tck-runner/tck-unit-tests.xml
===================================================================
--- ri/trunk/jboss-tck-runner/tck-unit-tests.xml (rev 0)
+++ ri/trunk/jboss-tck-runner/tck-unit-tests.xml 2009-02-12 00:29:02 UTC (rev 1491)
@@ -0,0 +1,45 @@
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
+
+<suite name="JSR-299 TCK" verbose="2" >
+
+ <test name="JSR-299 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" />
+ <exclude name="underInvestigation" />
+ </run>
+ </groups>
+ <!-- <packages>
+ <package name="org.jboss.jsr299.tck.unit" />
+ <package name="org.jboss.jsr299.tck.integration" />
+ </packages>-->
+ <classes>
+ <class name="org.jboss.jsr299.tck.unit.definition.bean.BeanDefinitionTest" />
+ </classes>
+ </test>
+
+</suite>
\ No newline at end of file
Property changes on: ri/trunk/jboss-tck-runner/tck-unit-tests.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java 2009-02-11 20:50:30 UTC (rev 1490)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java 2009-02-12 00:29:02 UTC (rev 1491)
@@ -84,10 +84,10 @@
{
log.trace("Ending session " + session.getId());
SessionContext.INSTANCE.setBeanMap(new HttpSessionBeanMap(session));
+ ConversationManager conversationManager = CurrentManager.rootManager().getInstanceByType(ConversationManager.class);
+ conversationManager.destroyAllConversations();
SessionContext.INSTANCE.destroy();
SessionContext.INSTANCE.setBeanMap(null);
- ConversationManager conversationManager = CurrentManager.rootManager().getInstanceByType(ConversationManager.class);
- conversationManager.destroyAllConversations();
}
/**
Modified: tck/trunk/api/src/main/java/org/jboss/jsr299/tck/api/TestLauncher.java
===================================================================
--- tck/trunk/api/src/main/java/org/jboss/jsr299/tck/api/TestLauncher.java 2009-02-11 20:50:30 UTC (rev 1490)
+++ tck/trunk/api/src/main/java/org/jboss/jsr299/tck/api/TestLauncher.java 2009-02-12 00:29:02 UTC (rev 1491)
@@ -1,12 +1,14 @@
package org.jboss.jsr299.tck.api;
-import org.testng.ISuite;
+import java.io.IOException;
+import java.lang.reflect.Method;
+
public interface TestLauncher
{
public static final String PROPERTY_NAME = TestLauncher.class.getName();
- public ISuite launchTest(Configuration configuration, Class<?> testClass) throws Exception;
+ public TestResult launchTest(Configuration configuration, Method method) throws IOException;
}
Added: tck/trunk/api/src/main/java/org/jboss/jsr299/tck/api/TestResult.java
===================================================================
--- tck/trunk/api/src/main/java/org/jboss/jsr299/tck/api/TestResult.java (rev 0)
+++ tck/trunk/api/src/main/java/org/jboss/jsr299/tck/api/TestResult.java 2009-02-12 00:29:02 UTC (rev 1491)
@@ -0,0 +1,18 @@
+package org.jboss.jsr299.tck.api;
+
+
+public interface TestResult
+{
+
+ public enum Status
+ {
+ PASSED,
+ FAILED,
+ SKIPPED;
+ }
+
+ public Status getStatus();
+
+ public Throwable getThrowable();
+
+}
\ No newline at end of file
Property changes on: tck/trunk/api/src/main/java/org/jboss/jsr299/tck/api/TestResult.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: tck/trunk/api/src/main/java/org/jboss/jsr299/tck/spi/Containers.java
===================================================================
--- tck/trunk/api/src/main/java/org/jboss/jsr299/tck/spi/Containers.java 2009-02-11 20:50:30 UTC (rev 1490)
+++ tck/trunk/api/src/main/java/org/jboss/jsr299/tck/spi/Containers.java 2009-02-12 00:29:02 UTC (rev 1491)
@@ -1,5 +1,6 @@
package org.jboss.jsr299.tck.spi;
+import java.io.IOException;
import java.io.InputStream;
public interface Containers
@@ -15,8 +16,8 @@
* @param archive
* @return
*/
- public void deploy(InputStream archive, String name) throws Exception;
+ public void deploy(InputStream archive, String name) throws IOException;
- public void undeploy(String name) throws Exception;
+ public void undeploy(String name) throws IOException;
}
\ No newline at end of file
Modified: tck/trunk/api/src/main/java/org/jboss/jsr299/tck/spi/helpers/ForwardingContainers.java
===================================================================
--- tck/trunk/api/src/main/java/org/jboss/jsr299/tck/spi/helpers/ForwardingContainers.java 2009-02-11 20:50:30 UTC (rev 1490)
+++ tck/trunk/api/src/main/java/org/jboss/jsr299/tck/spi/helpers/ForwardingContainers.java 2009-02-12 00:29:02 UTC (rev 1491)
@@ -1,5 +1,6 @@
package org.jboss.jsr299.tck.spi.helpers;
+import java.io.IOException;
import java.io.InputStream;
import org.jboss.jsr299.tck.spi.Containers;
@@ -9,9 +10,14 @@
protected abstract Containers delegate();
- public void deploy(InputStream archive, String name) throws Exception
+ public void deploy(InputStream archive, String name) throws IOException
{
delegate().deploy(archive, name);
}
+ public void undeploy(String name) throws IOException
+ {
+ delegate().undeploy(name);
+ }
+
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/AbstractTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/AbstractTest.java 2009-02-11 20:50:30 UTC (rev 1490)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/AbstractTest.java 2009-02-12 00:29:02 UTC (rev 1491)
@@ -22,6 +22,8 @@
import javax.inject.manager.Manager;
import org.jboss.jsr299.tck.api.Configuration;
+import org.jboss.jsr299.tck.api.TestResult;
+import org.jboss.jsr299.tck.api.TestResult.Status;
import org.jboss.jsr299.tck.impl.ConfigurationImpl;
import org.jboss.jsr299.tck.impl.packaging.ArtifactGenerator;
import org.jboss.jsr299.tck.impl.packaging.jsr299.TCKArtifactDescriptor;
@@ -34,6 +36,7 @@
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.BeforeSuite;
@SuppressWarnings("unchecked")
public class AbstractTest implements IHookable
@@ -72,24 +75,61 @@
private static final List<Class<? extends Annotation>> STANDARD_DEPLOYMENT_TYPES = Collections.unmodifiableList(Arrays.asList(Standard.class, Production.class));
private static final Class<?>[] EMPTY_CLASS_ARRAY = new Class<?>[0];
+ private static boolean inContainer = false;
+
+ public static boolean isInContainer()
+ {
+ return inContainer;
+ }
+
+ public static void setInContainer(boolean inContainer)
+ {
+ AbstractTest.inContainer = inContainer;
+ }
+
protected Manager manager;
private StandaloneContainers containers;
private TCKArtifactDescriptor artifact;
- private ArtifactGenerator generator;
private Configuration configuration;
+ @BeforeSuite
+ public void beforeSuite()
+ {
+ // Check that assertions are enabled!
+ boolean assertionsEnabled = false;
+ try
+ {
+ assert false;
+ }
+ catch (AssertionError error)
+ {
+ assertionsEnabled = true;
+ }
+ if (!assertionsEnabled)
+ {
+ throw new IllegalArgumentException("Assertions must be enabled!");
+ }
+ }
+
@BeforeClass
- public final void beforeSuite()
+ public final void beforeClass() throws IOException
{
configuration = ConfigurationImpl.get();
- generator = new ArtifactGenerator(configuration);
+ if (!isInContainer())
+ {
+ ArtifactGenerator generator = new ArtifactGenerator(configuration);
+ artifact = generator.createArtifact(this.getClass());
+ if (!(configuration.isStandalone() && artifact.isUnit()))
+ {
+ configuration.getContainers().deploy(artifact.getJar(), artifact.getDefaultName());
+ }
+ }
}
@BeforeMethod
public final void beforeMethod(Method method)
- {
- artifact = generator.createArtifact(method.getDeclaringClass());
- if (configuration.isStandalone())
+ {
+ if (configuration.isStandalone() && !isInContainer())
{
containers = configuration.getStandaloneContainers();
if (artifact != null)
@@ -123,13 +163,16 @@
public void afterMethod()
{
manager = null;
- artifact = null;
}
@AfterClass
- public void afterClass()
+ public void afterClass() throws IOException
{
- this.generator = null;
+ if (!(configuration.isStandalone() && artifact.isUnit()) && !isInContainer())
+ {
+ configuration.getContainers().undeploy(artifact.getDefaultName());
+ }
+ this.artifact = null;
}
@Deprecated
@@ -250,13 +293,24 @@
public void run(IHookCallBack callback, ITestResult testResult)
{
- if (artifact== null || artifact.isUnit())
+ if (artifact== null || isInContainer() || (artifact.isUnit() && configuration.isStandalone()))
{
callback.runTestMethod(testResult);
}
else
{
- // Run the test in the container
+ try
+ {
+ TestResult result = configuration.getInContainerTestLauncher().launchTest(configuration, testResult.getMethod().getMethod());
+ if (result.getStatus().equals(Status.FAILED) || result.getStatus().equals(Status.SKIPPED))
+ {
+ testResult.setThrowable(result.getThrowable());
+ }
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException("Error connecting to the container", e);
+ }
}
}
}
\ No newline at end of file
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/TCKImpl.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/TCKImpl.java 2009-02-11 20:50:30 UTC (rev 1490)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/TCKImpl.java 2009-02-12 00:29:02 UTC (rev 1491)
@@ -11,7 +11,6 @@
import org.jboss.jsr299.tck.api.Configuration;
import org.jboss.jsr299.tck.api.TCK;
import org.jboss.jsr299.tck.impl.packaging.ArtifactGenerator;
-import org.jboss.jsr299.tck.impl.runner.TestSuiteLauncher;
import org.testng.TestNG;
import org.testng.xml.Parser;
import org.testng.xml.XmlSuite;
@@ -63,15 +62,7 @@
public void runInContainerTests()
{
- TestSuiteLauncher suiteLauncher = new TestSuiteLauncher(getConfiguration());
- try
- {
- suiteLauncher.run();
- }
- catch (Exception e)
- {
- log.error("Error executing in container tests", e);
- }
+
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/runner/BufferedListener.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/runner/BufferedListener.java 2009-02-11 20:50:30 UTC (rev 1490)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/runner/BufferedListener.java 2009-02-12 00:29:02 UTC (rev 1491)
@@ -1,5 +1,8 @@
package org.jboss.jsr299.tck.impl.runner;
+import java.util.ArrayList;
+import java.util.List;
+
import org.testng.ITestContext;
import org.testng.ITestListener;
import org.testng.ITestResult;
@@ -54,4 +57,22 @@
return context;
}
+ public List<ITestResult> getTestResults()
+ {
+ List<ITestResult> results = new ArrayList<ITestResult>();
+ results.addAll(context.getFailedTests().getAllResults());
+ results.addAll(context.getPassedTests().getAllResults());
+ results.addAll(context.getSkippedTests().getAllResults());
+ return results;
+ }
+
+ public List<ITestResult> getConfigurationResults()
+ {
+ List<ITestResult> results = new ArrayList<ITestResult>();
+ results.addAll(context.getFailedConfigurations().getAllResults());
+ results.addAll(context.getPassedConfigurations().getAllResults());
+ results.addAll(context.getSkippedConfigurations().getAllResults());
+ return results;
+ }
+
}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/runner/TestResultImpl.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/runner/TestResultImpl.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/runner/TestResultImpl.java 2009-02-12 00:29:02 UTC (rev 1491)
@@ -0,0 +1,55 @@
+package org.jboss.jsr299.tck.impl.runner;
+
+import java.io.Serializable;
+
+import org.jboss.jsr299.tck.api.TestResult;
+import org.testng.ITestResult;
+
+public class TestResultImpl implements Serializable, TestResult
+{
+
+ private static final long serialVersionUID = -6608901483105666644L;
+
+ private Throwable throwable;
+ private Status status;
+
+
+
+ public TestResultImpl(Status status, Throwable throwable)
+ {
+ super();
+ this.throwable = throwable;
+ this.status = status;
+ }
+
+ public Status getStatus()
+ {
+ return status;
+ }
+
+ public Throwable getThrowable()
+ {
+ return throwable;
+ }
+
+ public static TestResult of(ITestResult testNGResult)
+ {
+ if (testNGResult.getStatus() == 1)
+ {
+ return new TestResultImpl(Status.PASSED, null);
+ }
+ else if (testNGResult.getStatus() == 2)
+ {
+ return new TestResultImpl(Status.FAILED, testNGResult.getThrowable());
+ }
+ else if (testNGResult.getStatus() == 3)
+ {
+ return new TestResultImpl(Status.SKIPPED, testNGResult.getThrowable());
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/runner/TestResultImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/runner/TestRunner.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/runner/TestRunner.java 2009-02-11 20:50:30 UTC (rev 1490)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/runner/TestRunner.java 2009-02-12 00:29:02 UTC (rev 1491)
@@ -1,16 +1,13 @@
package org.jboss.jsr299.tck.impl.runner;
-import java.io.Serializable;
-import java.lang.reflect.Field;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
+import org.jboss.jsr299.tck.AbstractTest;
import org.jboss.jsr299.tck.impl.util.DeploymentProperties;
-import org.testng.ISuite;
import org.testng.ITestContext;
+import org.testng.ITestResult;
import org.testng.TestNG;
-import org.testng.internal.InvokedMethod;
import org.testng.xml.XmlClass;
import org.testng.xml.XmlSuite;
import org.testng.xml.XmlTest;
@@ -19,33 +16,49 @@
{
private List<String> classNames;
-
- public TestRunner(String className)
- {
- this.classNames = new ArrayList<String>();
- classNames.add(className);
- }
+ private List<String> methodNames;
+ private ITestContext context;
+ private List<ITestResult> testResults;
+ private List<ITestResult> configurationResults;
public TestRunner()
{
- DeploymentProperties deploymentProperties = new DeploymentProperties();
- this.classNames = deploymentProperties.getPropertyValues("className");
+ methodNames = new ArrayList<String>();
+ classNames = new ArrayList<String>();
+
}
- public ISuite run()
+ public List<String> getClassNames()
{
+ return classNames;
+ }
+
+ public List<String> getMethodNames()
+ {
+ return methodNames;
+ }
+
+ public void run()
+ {
+ AbstractTest.setInContainer(true);
+ if (classNames.size() == 0)
+ {
+ DeploymentProperties deploymentProperties = new DeploymentProperties();
+ this.classNames = deploymentProperties.getPropertyValues("className");
+ }
TestNG testNG = new TestNG(false);
testNG.setVerbose(0);
- testNG.run();
- //BufferedListener listener = new BufferedListener();
- //testNG.addListener(listener);
+ BufferedListener listener = new BufferedListener();
+ testNG.addListener(listener);
List<XmlSuite> xmlSuites = new ArrayList<XmlSuite>();
testNG.setXmlSuites(xmlSuites);
xmlSuites.add(createSuite());
- List<ISuite> suites = testNG.runSuitesLocally();
- return suites.get(0);
- //return makeITestContextSerializable(listener.getContext());
+ testNG.run();
+ this.context = listener.getContext();
+ this.testResults = listener.getTestResults();
+ this.configurationResults = listener.getConfigurationResults();
}
+
private XmlSuite createSuite()
{
@@ -56,57 +69,31 @@
{
XmlTest test = new XmlTest(suite);
test.setName("JSR-299 TCK" + className);
- List<XmlClass> testClasses = Arrays.asList(new XmlClass(className));
+ List<XmlClass> testClasses = new ArrayList<XmlClass>();
+ XmlClass testClass = new XmlClass(className);
+ for (String methodName : getMethodNames())
+ {
+ testClass.getIncludedMethods().add(methodName);
+ }
+ testClasses.add(testClass);
test.setXmlClasses(testClasses);
}
return suite;
}
- /**
- * Unfortunately ITestContext isn't really serializable...
- *
- */
- public static ITestContext makeITestContextSerializable(ITestContext context)
+ public ITestContext getContext()
{
- if (context instanceof org.testng.TestRunner)
- {
-
- try
- {
- Field methodInterceptorField = org.testng.TestRunner.class.getDeclaredField("m_methodInterceptor");
- methodInterceptorField.setAccessible(true);
- methodInterceptorField.set(context, null);
- Field testPlanField = org.testng.TestRunner.class.getDeclaredField("m_testPlan");
- testPlanField.setAccessible(true);
- testPlanField.set(context, null);
- Field invokedMethodsField = org.testng.TestRunner.class.getDeclaredField("m_invokedMethods");
- invokedMethodsField.setAccessible(true);
- List<InvokedMethod> methods = (List<InvokedMethod>) invokedMethodsField.get(context);
- for (InvokedMethod method : methods)
- {
- Field parametersField = InvokedMethod.class.getDeclaredField("m_parameters");
- parametersField.setAccessible(true);
- Object[] parameters = (Object[]) parametersField.get(method);
- if (parameters != null)
- {
- for (int i = 0; i < parameters.length; i++)
- {
- if (!(parameters instanceof Serializable) || !parameters.getClass().isPrimitive())
- {
- parameters[i] = null;
- }
- }
- }
- parametersField.set(method, parameters);
- }
- }
- catch (Exception e)
- {
- throw new RuntimeException("Error preparing ITestContext for serialization " + context, e);
- }
-
- }
return context;
}
+ public List<ITestResult> getTestResults()
+ {
+ return testResults;
+ }
+
+ public List<ITestResult> getConfigurationResults()
+ {
+ return configurationResults;
+ }
+
}
Deleted: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/runner/TestSuiteLauncher.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/runner/TestSuiteLauncher.java 2009-02-11 20:50:30 UTC (rev 1490)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/runner/TestSuiteLauncher.java 2009-02-12 00:29:02 UTC (rev 1491)
@@ -1,67 +0,0 @@
-package org.jboss.jsr299.tck.impl.runner;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-import org.jboss.jsr299.tck.api.Configuration;
-import org.jboss.jsr299.tck.impl.packaging.ArtifactDescriptor;
-import org.jboss.jsr299.tck.impl.packaging.ArtifactGenerator;
-import org.testng.ISuite;
-
-
-public class TestSuiteLauncher
-{
-
- private static final Logger log = Logger.getLogger(TestSuiteLauncher.class);
-
- private final Configuration configuration;
- private final List<ISuite> suites;
-
- public TestSuiteLauncher(Configuration configuration)
- {
- this.configuration = configuration;
- this.suites = new ArrayList<ISuite>();
- }
-
- public void run() throws Exception
- {
- ArtifactGenerator generator = new ArtifactGenerator(configuration);
- if (configuration.getTestClass() == null)
- {
- List<ArtifactDescriptor> artifacts = generator.createArtifacts();
- for (ArtifactDescriptor artifact : artifacts)
- {
- testArtifact(artifact);
- }
- }
- else
- {
- testArtifact(generator.createArtifact(configuration.getTestClass()));
- }
- }
-
- protected void testArtifact(ArtifactDescriptor artifact) throws Exception
- {
- try
- {
- InputStream jar = artifact.getJar();
- configuration.getContainers().deploy(jar, artifact.getDefaultName());
- jar.close();
- ISuite context = configuration.getInContainerTestLauncher().launchTest(configuration, artifact.getDeclaringClass());
- log.debug("Executed tests for " + artifact.getDefaultName());
- suites.add(context);
- }
- finally
- {
- configuration.getContainers().undeploy(artifact.getDefaultName());
- }
-
- }
-
- public List<ISuite> getSuites()
- {
- return suites;
- }
-
-}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/runner/servlet/ServletTestLauncher.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/runner/servlet/ServletTestLauncher.java 2009-02-11 20:50:30 UTC (rev 1490)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/runner/servlet/ServletTestLauncher.java 2009-02-12 00:29:02 UTC (rev 1491)
@@ -1,23 +1,26 @@
package org.jboss.jsr299.tck.impl.runner.servlet;
+import java.io.IOException;
import java.io.ObjectInputStream;
+import java.lang.reflect.Method;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import org.jboss.jsr299.tck.api.Configuration;
import org.jboss.jsr299.tck.api.TestLauncher;
-import org.testng.ISuite;
+import org.jboss.jsr299.tck.api.TestResult;
+import org.jboss.jsr299.tck.impl.runner.TestResultImpl;
public class ServletTestLauncher implements TestLauncher
{
- public ISuite launchTest(Configuration configuration, Class<?> testClass) throws Exception
+ public TestResultImpl launchTest(Configuration configuration, Method method) throws IOException
{
- String url = "http://" + configuration.getHost() + "/" + testClass.getName() + "/?outputMode=serializedObject";
+ Class<?> testClass = method.getDeclaringClass();
+ String url = "http://" + configuration.getHost() + "/" + testClass.getName() + "/?outputMode=serializedObject&methodName=" + method.getName();
for (int i = 0; i < configuration.getConnectRetries(); i++)
{
- Thread.sleep(configuration.getConnectDelay());
URLConnection connection = new URL(url).openConnection();
if (!(connection instanceof HttpURLConnection))
{
@@ -32,20 +35,36 @@
if (httpConnection.getResponseCode() == HttpURLConnection.HTTP_OK)
{
ObjectInputStream ois = new ObjectInputStream(httpConnection.getInputStream());
- Object o = ois.readObject();
+ Object o;
+ try
+ {
+ o = ois.readObject();
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new IOException(e);
+ }
ois.close();
- if (!(o instanceof ISuite))
+ if (!(o instanceof TestResult))
{
- throw new IllegalStateException("Error reading test results - expected a ISuite but got " + o);
+ throw new IllegalStateException("Error reading test results - expected a TestResult but got " + o);
}
- ISuite context = (ISuite) o;
+ TestResultImpl result = (TestResultImpl) o;
- return context;
+ return result;
}
else if (httpConnection.getResponseCode() != HttpURLConnection.HTTP_NOT_FOUND)
{
throw new IllegalStateException("Error launching test " + testClass.getName() + " at " + url + ". Got " + httpConnection.getResponseCode() + " ("+ httpConnection.getResponseMessage() + ")");
}
+ try
+ {
+ Thread.sleep(configuration.getConnectDelay());
+ }
+ catch (InterruptedException e)
+ {
+ Thread.currentThread().interrupt();
+ }
}
finally
{
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/runner/servlet/ServletTestRunner.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/runner/servlet/ServletTestRunner.java 2009-02-11 20:50:30 UTC (rev 1490)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/runner/servlet/ServletTestRunner.java 2009-02-12 00:29:02 UTC (rev 1491)
@@ -9,30 +9,43 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.jboss.jsr299.tck.api.TestResult;
import org.jboss.jsr299.tck.impl.ConfigurationImpl;
+import org.jboss.jsr299.tck.impl.runner.TestResultImpl;
import org.jboss.jsr299.tck.impl.runner.TestRunner;
-import org.testng.ISuite;
import org.testng.ITestResult;
public class ServletTestRunner extends HttpServlet
{
+
+
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
ConfigurationImpl.get().setStandalone(false);
TestRunner runner = new TestRunner();
- ISuite suite = runner.run();
+ String methodName = null;
+ if (req.getParameter("methodName") != null)
+ {
+ methodName = req.getParameter("methodName");
+ runner.getMethodNames().add(methodName);
+ }
String outputMode;
if (req.getParameter("outputMode") != null)
{
outputMode = (String) req.getParameter("outputMode");
- System.out.println("Outputting as " + outputMode);
}
else
{
outputMode = "html";
}
+ if (outputMode.equals("serializedObject") && methodName == null)
+ {
+ resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "No method name specified");
+ return;
+ }
+ runner.run();
if (outputMode.equals("html"))
{
resp.setContentType("text/html");
@@ -46,11 +59,11 @@
writer.write("<tr>\n");
writer.write("<td><b>Method</b></td><td><b>Status</b></td>\n");
writer.write("</tr>\n");
- for (ITestResult result : suite.getResults().get("JSR-299 TCK").getTestContext().getFailedConfigurations().getAllResults())
+ for (ITestResult result : runner.getContext().getFailedConfigurations().getAllResults())
{
writeResult(writer, result);
}
- for (ITestResult result : suite.getResults().get("JSR-299 TCK").getTestContext().getSkippedConfigurations().getAllResults())
+ for (ITestResult result : runner.getContext().getSkippedConfigurations().getAllResults())
{
writeResult(writer, result);
}
@@ -60,15 +73,15 @@
writer.write("<tr>\n");
writer.write("<td><b>Method</b></td><td><b>Status</b></td>\n");
writer.write("</tr>\n");
- for (ITestResult result : suite.getResults().get("JSR-299 TCK").getTestContext().getFailedTests().getAllResults())
+ for (ITestResult result : runner.getContext().getFailedTests().getAllResults())
{
writeResult(writer, result);
}
- for (ITestResult result : suite.getResults().get("JSR-299 TCK").getTestContext().getPassedTests().getAllResults())
+ for (ITestResult result : runner.getContext().getPassedTests().getAllResults())
{
writeResult(writer, result);
}
- for (ITestResult result : suite.getResults().get("JSR-299 TCK").getTestContext().getSkippedTests().getAllResults())
+ for (ITestResult result : runner.getContext().getSkippedTests().getAllResults())
{
writeResult(writer, result);
}
@@ -77,11 +90,31 @@
}
else if (outputMode.equals("serializedObject"))
{
- resp.setStatus(HttpServletResponse.SC_OK);
+
ObjectOutputStream oos = new ObjectOutputStream(resp.getOutputStream());
- oos.writeObject(suite);
- oos.flush();
- oos.close();
+ if (runner.getTestResults().size() == 1)
+ {
+ TestResult result;
+ if (runner.getTestResults().get(0).getStatus() == 3)
+ {
+ // This is a skip, so there was a configuration problem
+ // send that instead
+ result = TestResultImpl.of(runner.getConfigurationResults().get(0));
+ }
+ else
+ {
+ result = TestResultImpl.of(runner.getTestResults().get(0));
+ }
+ oos.writeObject(result);
+ resp.setStatus(HttpServletResponse.SC_OK);
+ oos.flush();
+ oos.close();
+ }
+ else
+ {
+ resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ">1 result!");
+ }
+
}
else
{
Deleted: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/definition/bean/AnotherDeploymentType.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/definition/bean/AnotherDeploymentType.java 2009-02-11 20:50:30 UTC (rev 1490)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/definition/bean/AnotherDeploymentType.java 2009-02-12 00:29:02 UTC (rev 1491)
@@ -1,20 +0,0 @@
-package org.jboss.jsr299.tck.unit.definition.bean;
-
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import javax.inject.DeploymentType;
-
- at Target( { TYPE, METHOD })
- at Retention(RUNTIME)
- at Documented
- at DeploymentType
- at interface AnotherDeploymentType
-{
-
-}
\ No newline at end of file
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/definition/bean/BeanDefinitionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/definition/bean/BeanDefinitionTest.java 2009-02-11 20:50:30 UTC (rev 1490)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/definition/bean/BeanDefinitionTest.java 2009-02-12 00:29:02 UTC (rev 1491)
@@ -1,8 +1,6 @@
package org.jboss.jsr299.tck.unit.definition.bean;
import java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.List;
import javax.context.RequestScoped;
import javax.inject.AnnotationLiteral;
@@ -28,15 +26,6 @@
private static Annotation TAME_LITERAL = new AnnotationLiteral<Tame>() {};
- @Override
- protected List<Class<? extends Annotation>> getEnabledDeploymentTypes()
- {
- List<Class<? extends Annotation>> deploymentTypes = new ArrayList<Class<? extends Annotation>>();
- deploymentTypes.addAll(super.getStandardDeploymentTypes());
- deploymentTypes.add(AnotherDeploymentType.class);
- return deploymentTypes;
- }
-
// TODO This should actually somehow test the reverse as well - that the container
// throws a definition exception if any of these occur
@@ -76,8 +65,8 @@
@SpecAssertion(section = "5.2", id = "b")
public void testIsNullable() throws Exception
{
- assert manager.resolveByType(Integer.class).size() == 1;
- Bean<Integer> bean = manager.resolveByType(Integer.class).iterator().next();
+ assert manager.resolveByType(int.class).size() == 1;
+ Bean<Integer> bean = manager.resolveByType(int.class).iterator().next();
assert !bean.isNullable();
assert manager.resolveByType(Animal.class, TAME_LITERAL).size() == 1;
Bean<Animal> animalBean = manager.resolveByType(Animal.class, TAME_LITERAL).iterator().next();
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/definition/bean/DependentFinalTuna.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/definition/bean/DependentFinalTuna.java 2009-02-11 20:50:30 UTC (rev 1490)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/definition/bean/DependentFinalTuna.java 2009-02-12 00:29:02 UTC (rev 1491)
@@ -1,6 +1,5 @@
package org.jboss.jsr299.tck.unit.definition.bean;
- at AnotherDeploymentType
final class DependentFinalTuna
{
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/definition/bean/SpiderProducer.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/definition/bean/SpiderProducer.java 2009-02-11 20:50:30 UTC (rev 1490)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/definition/bean/SpiderProducer.java 2009-02-12 00:29:02 UTC (rev 1491)
@@ -2,7 +2,6 @@
import javax.inject.Produces;
- at AnotherDeploymentType
class SpiderProducer
{
More information about the weld-commits
mailing list