Revision: 9233
Author: [email protected]
Date: Mon Nov 15 10:52:58 2010
Log: Public: GWT version of the JSR 303 Bean Validation TCK
So far only one test is wrapped, One test passses and one fails,
but this shows the patern to use to get the tests going.
The test failure is expected, and represent code that needs to be
implemeted.
Review at http://gwt-code-reviews.appspot.com/1085801
Review by: [email protected]
http://code.google.com/p/google-web-toolkit/source/detail?r=9233
Added:
/trunk/samples/validationtck
/trunk/samples/validationtck/README.txt
/trunk/samples/validationtck/build.xml
/trunk/samples/validationtck/src
/trunk/samples/validationtck/src/com
/trunk/samples/validationtck/src/com/google
/trunk/samples/validationtck/src/com/google/gwt
/trunk/samples/validationtck/src/com/google/gwt/sample
/trunk/samples/validationtck/src/com/google/gwt/sample/validationtck
/trunk/samples/validationtck/src/com/google/gwt/sample/validationtck/Tck.java
/trunk/samples/validationtck/src/com/google/gwt/sample/validationtck/TckTestValidator.java
/trunk/samples/validationtck/src/com/google/gwt/sample/validationtck/TckValidator.java
/trunk/samples/validationtck/src/com/google/gwt/sample/validationtck/ValidationTck.gwt.xml
/trunk/samples/validationtck/src/org
/trunk/samples/validationtck/src/org/hibernate
/trunk/samples/validationtck/src/org/hibernate/jsr303
/trunk/samples/validationtck/src/org/hibernate/jsr303/tck
/trunk/samples/validationtck/src/org/hibernate/jsr303/tck/Jsr303Tck.gwt.xml
/trunk/samples/validationtck/src/org/hibernate/jsr303/tck/super
/trunk/samples/validationtck/src/org/hibernate/jsr303/tck/super/org
/trunk/samples/validationtck/src/org/hibernate/jsr303/tck/super/org/hibernate
/trunk/samples/validationtck/src/org/hibernate/jsr303/tck/super/org/hibernate/jsr303
/trunk/samples/validationtck/src/org/hibernate/jsr303/tck/super/org/hibernate/jsr303/tck
/trunk/samples/validationtck/src/org/hibernate/jsr303/tck/super/org/hibernate/jsr303/tck/util
/trunk/samples/validationtck/src/org/hibernate/jsr303/tck/super/org/hibernate/jsr303/tck/util/TestUtil.java
/trunk/samples/validationtck/src/org/jboss
/trunk/samples/validationtck/src/org/jboss/test
/trunk/samples/validationtck/src/org/jboss/test/audit
/trunk/samples/validationtck/src/org/jboss/test/audit/JbossTestAudit.gwt.xml
/trunk/samples/validationtck/src/org/jboss/testharness
/trunk/samples/validationtck/src/org/jboss/testharness/JbossTestHarness.gwt.xml
/trunk/samples/validationtck/src/org/jboss/testharness/super
/trunk/samples/validationtck/src/org/jboss/testharness/super/org
/trunk/samples/validationtck/src/org/jboss/testharness/super/org/jboss
/trunk/samples/validationtck/src/org/jboss/testharness/super/org/jboss/testharness
/trunk/samples/validationtck/src/org/jboss/testharness/super/org/jboss/testharness/AbstractTest.java
/trunk/samples/validationtck/src/org/jboss/testharness/super/org/jboss/testharness/api
/trunk/samples/validationtck/src/org/jboss/testharness/super/org/jboss/testharness/api/Configuration.java
/trunk/samples/validationtck/src/org/jboss/testharness/super/org/jboss/testharness/api/ResourceDescriptor.java
/trunk/samples/validationtck/src/org/jboss/testharness/super/org/jboss/testharness/impl
/trunk/samples/validationtck/src/org/jboss/testharness/super/org/jboss/testharness/impl/packaging
/trunk/samples/validationtck/src/org/jboss/testharness/super/org/jboss/testharness/impl/packaging/TCKArtifact.java
/trunk/samples/validationtck/src/org/jboss/testharness/super/org/jboss/testharness/spi
/trunk/samples/validationtck/src/org/jboss/testharness/super/org/jboss/testharness/spi/Containers.java
/trunk/samples/validationtck/src/org/jboss/testharness/super/org/jboss/testharness/spi/StandaloneContainers.java
/trunk/samples/validationtck/src/org/testng
/trunk/samples/validationtck/src/org/testng/TestNg.gwt.xml
/trunk/samples/validationtck/src/org/testng/super
/trunk/samples/validationtck/src/org/testng/super/org
/trunk/samples/validationtck/src/org/testng/super/org/testng
/trunk/samples/validationtck/src/org/testng/super/org/testng/Assert.java
/trunk/samples/validationtck/src/org/testng/super/org/testng/IClass.java
/trunk/samples/validationtck/src/org/testng/super/org/testng/ITestNGMethod.java
/trunk/samples/validationtck/src/org/testng/super/org/testng/collections
/trunk/samples/validationtck/src/org/testng/super/org/testng/collections/Maps.java
/trunk/samples/validationtck/test
/trunk/samples/validationtck/test/com
/trunk/samples/validationtck/test/com/google
/trunk/samples/validationtck/test/com/google/gwt
/trunk/samples/validationtck/test/com/google/gwt/sample
/trunk/samples/validationtck/test/com/google/gwt/sample/validationtck
/trunk/samples/validationtck/test/com/google/gwt/sample/validationtck/TckGwtSuite.java
/trunk/samples/validationtck/test/com/google/gwt/sample/validationtck/ValidationTckTest.gwt.xml
/trunk/samples/validationtck/test/com/google/gwt/sample/validationtck/constraints
/trunk/samples/validationtck/test/com/google/gwt/sample/validationtck/constraints/application
/trunk/samples/validationtck/test/com/google/gwt/sample/validationtck/constraints/application/ValidationRequirementTest.java
Modified:
/trunk/samples/build.xml
/trunk/samples/common.ant.xml
/trunk/user/src/com/google/gwt/validation/rebind/BeanHelper.java
/trunk/user/src/com/google/gwt/validation/rebind/GwtSpecificValidatorCreator.java
=======================================
--- /dev/null
+++ /trunk/samples/validationtck/README.txt Mon Nov 15 10:52:58 2010
@@ -0,0 +1,11 @@
+This is not actually a sample.
+It is a GWT HACK to run the JSR 303 Technology Compatibility Kit.
+
+See
+http://docs.jboss.org/hibernate/stable/beanvalidation/tck/reference/html_single/
+
+from this dir run
+ant tck
+
+A html report will be generated.
+
=======================================
--- /dev/null
+++ /trunk/samples/validationtck/build.xml Mon Nov 15 10:52:58 2010
@@ -0,0 +1,142 @@
+<project name="validationtck" default="build" basedir=".">
+ <property name="sample.root" value="validationtck" />
+ <property name="sample.module" value="ValidationTck" />
+ <property name="sample.path" value="src" />
+ <property name="test.args" value="-ea" />
+ <property name="test.jvmargs" value="-ea" />
+ <import file="../common.ant.xml" />
+
+ <!-- these are after the common.ant.xml so they have gwt.tools etc. -->
+ <path id="sample.extraclasspath">
+ <pathelement location="${gwt.tools.lib}/apache/log4j/log4j-1.2.16.jar"
/>
+ <pathelement
location="${gwt.tools.lib}/javax/validation/validation-api-1.0.0.GA.jar" />
+ <pathelement
location="${gwt.tools.lib}/javax/validation/validation-api-1.0.0.GA-sources.jar"
/>
+ <pathelement
location="${gwt.tools.lib}/hibernate/validator/hibernate-validator-4.1.0.Final.jar"
/>
+ <pathelement
location="${gwt.tools.lib}/hibernate/validator/hibernate-validator-4.1.0.Final-sources.jar"
/>
+ <pathelement
location="${gwt.tools.lib}/slf4j/slf4j-api/slf4j-api-1.6.1.jar" />
+ <pathelement
location="${gwt.tools.lib}/slf4j/slf4j-log4j12/slf4j-log4j12-1.6.1.jar" />
+ <!-- TCK jars -->
+ <pathelement
location="${gwt.tools.lib}/hibernate/validator/tck/jsr303-tck-1.0.3.GA-sources.jar"
/>
+ <pathelement
location="${gwt.tools.lib}/hibernate/validator/tck/jsr303-tck-1.0.3.GA.jar"
/>
+ <pathelement
location="${gwt.tools.lib}/jboss/test-audit/jboss-test-audit-api-1.0.0-sources.jar"
/>
+ <pathelement
location="${gwt.tools.lib}/jboss/test-audit/jboss-test-audit-api-1.0.0.jar"
/>
+ <pathelement
location="${gwt.tools.lib}/jboss/test-harness/jboss-test-harness-1.0.0-sources.jar"
/>
+ <pathelement
location="${gwt.tools.lib}/jboss/test-harness/jboss-test-harness-1.0.0.jar"
/>
+ <pathelement
location="${gwt.tools.lib}/jboss/test-harness/jboss-test-harness-api-1.0.0-sources.jar"
/>
+ <pathelement
location="${gwt.tools.lib}/jboss/test-harness/jboss-test-harness-api-1.0.0.jar"
/>
+ <pathelement
location="${gwt.tools.lib}/testng/testng-5.14.1-sources.jar" />
+ <pathelement location="${gwt.tools.lib}/testng/testng-5.14.1.jar" />
+ <!-- Needed for JDK 1.5-->
+ <pathelement
location="${gwt.tools.lib}/javax/activation/activation-1.1.jar" />
+ <pathelement
location="${gwt.tools.lib}/javax/xml/bind/jaxb-api-2.1.jar" />
+ <pathelement location="${gwt.tools.lib}/sun/jaxb/jaxb-impl-2.1.3.jar"
/>
+ <pathelement
location="${gwt.tools.lib}/javax/xml/stream/stax-api-1.0-2.jar" />
+ </path>
+ <fileset id="sample.server.libs" dir="${gwt.tools.lib}">
+ <include
name="hibernate/validator/hibernate-validator-4.1.0.Final.jar" />
+ <include name="apache/log4j/log4j-1.2.16.jar" />
+ <include name="slf4j/slf4j-api/slf4j-api-1.6.1.jar" />
+ <include name="slf4j/slf4j-log4j12/slf4j-log4j12-1.6.1.jar" />
+ <!-- Needed for JDK 1.5-->
+ <include name="javax/activation/activation-1.1.jar" />
+ <include name="javax/xml/bind/jaxb-api-2.1.jar" />
+ <include name="sun/jaxb/jaxb-impl-2.1.3.jar" />
+ <include name="javax/xml/stream/stax-api-1.0-2.jar" />
+ </fileset>
+
+
+ <!--
+ Classpaths added for test cases
+ -->
+ <path id="test.extraclasspath">
+ <pathelement location="${gwt.build}/out/dev/bin-test" />
+ <pathelement location="${gwt.dev.jar}" />
+ <pathelement location="${gwt.build.lib}/gwt-user.jar" />
+ <path refid="sample.extraclasspath" />
+ </path>
+
+
+ <property name="test.timeout" value="4" />
+ <property name="emma.merged.out" value="${junit.out}/emma-coverage" />
+ <property name="gwt.junit.testcase.web.includes"
value="${gwt.junit.testcase.includes}" />
+ <property name="gwt.junit.testcase.web.excludes" value="" />
+
+ <property name="gwt.junit.testcase.dev.includes"
value="${gwt.junit.testcase.includes}" />
+ <property name="gwt.junit.testcase.dev.excludes" value="" />
+
+ <!--
+ Compiles the test code for this project
+ -->
+ <target name="compile.tests"
+ depends="compile.emma.if.enabled"
+ unless="compile.tests.complete">
+ <mkdir dir="${javac.junit.out}" />
+ <gwt.javac srcdir="test" excludes="com/google/gwt/langtest/**"
+ destdir="${javac.junit.out}">
+ <classpath>
+ <pathelement location="${javac.out}" />
+ <pathelement location="${gwt.tools.lib}/junit/junit-3.8.1.jar" />
+ <pathelement
location="${gwt.tools.lib}/selenium/selenium-java-client-driver.jar" />
+ <path refid="sample.extraclasspath" />
+ <path refid="test.extraclasspath" />
+ </classpath>
+ </gwt.javac>
+ </target>
+
+
+ <target name="tck"
+ depends="compile, compile.tests"
+ description="Run all tests for this project.">
+ <!-- Prevent compilation for every target. -->
+ <property name="compile.complete" value="true"/>
+ <property name="compile.tests.complete" value="true"/>
+
+ <property.ensure name="distro.built" location="${gwt.dev.staging.jar}"
+ message="GWT must be built before performing any tests. This can
be fixed by running ant in the ${gwt.root} directory." />
+ <limit failonerror="true" hours="${test.timeout}">
+ <parallel threadsPerProcessor="${gwt.threadsPerProcessor}"
+ threadCount="${gwt.threadCount}">
+ <!--
+ The remote targets must be run sequentially or BrowserManager will
queue
+ requests, which will cause some tests to timeout while waiting.
+ -->
+ <!--sequential>
+ <antcall target="test.dev.remote"/>
+ <antcall target="test.emma.remote"/>
+ <antcall target="test.web.remote"/>
+ <antcall target="test.draft.remote"/>
+ <antcall target="test.nometa.remote"/>
+ </sequential>
+ <antcall target="test.dev.selenium"/>
+ <antcall target="test.emma.selenium"/>
+ <antcall target="test.web.selenium"/>
+ <antcall target="test.draft.selenium"/>
+ <antcall target="test.nometa.selenium"/-->
+ <antcall target="test.dev.htmlunit"/>
+ <!--antcall target="test.emma.htmlunit"/>
+ <antcall target="test.web.htmlunit"/>
+ <antcall target="test.draft.htmlunit"/>
+ <antcall target="test.nometa.htmlunit"/-->
+ </parallel>
+ </limit>
+ </target>
+
+ <target name="test.dev.htmlunit"
+ depends="compile, compile.tests"
+ description="Run dev-mode tests with HtmlUnit."
+ unless="test.dev.htmlunit.disable">
+ <fileset id="test.dev.htmlunit.tests" dir="${javac.junit.out}"
+ includes="${gwt.junit.testcase.dev.includes}"
+ excludes="${gwt.junit.testcase.dev.excludes}" />
+ <gwt.junit test.name="test.dev.htmlunit"
+ test.args="${test.args} -standardsMode "
+ test.jvmargs="${test.jvmargs}"
+ test.out="${junit.out}/dev-htmlunit"
+ test.cases="test.dev.htmlunit.tests" >
+ <extraclasspaths>
+ <path refid="test.extraclasspath" />
+ </extraclasspaths>
+ </gwt.junit>
+ </target>
+
+</project>
=======================================
--- /dev/null
+++
/trunk/samples/validationtck/src/com/google/gwt/sample/validationtck/Tck.java
Mon Nov 15 10:52:58 2010
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
not
+ * use this file except in compliance with the License. You may obtain a
copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
under
+ * the License.
+ */
+package com.google.gwt.sample.validationtck;
+
+import com.google.gwt.core.client.EntryPoint;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.RootPanel;
+
+import org.hibernate.jsr303.tck.tests.constraints.application.Woman;
+
+import javax.validation.Validator;
+
+/**
+ * Just a place holder Entry point.
+ */
+public class Tck implements EntryPoint {
+
+ public void onModuleLoad() {
+ Validator validator = GWT.create(Validator.class);
+ Woman w = new Woman();
+ validator.validate(w);
+ Label label = new Label("tck");
+ RootPanel.get("view").add(label);
+ }
+}
=======================================
--- /dev/null
+++
/trunk/samples/validationtck/src/com/google/gwt/sample/validationtck/TckTestValidator.java
Mon Nov 15 10:52:58 2010
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
not
+ * use this file except in compliance with the License. You may obtain a
copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
under
+ * the License.
+ */
+package com.google.gwt.sample.validationtck;
+
+import com.google.gwt.core.client.GWT;
+
+import java.util.Set;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.Validator;
+import javax.validation.metadata.BeanDescriptor;
+
+/**
+ * TCK implementation that uses
+ * {...@link com.google.gwt.validation.client.GwtValidation GwtValidation}
+ */
+public class TckTestValidator implements Validator {
+
+ TckValidator validator = GWT.create(TckValidator.class);
+
+ public BeanDescriptor getConstraintsForClass(Class<?> clazz) {
+ return validator.getConstraintsForClass(clazz);
+ }
+
+ public <T> T unwrap(Class<T> type) {
+ return validator.unwrap(type);
+ }
+
+ public <T> Set<ConstraintViolation<T>> validate(T object, Class<?>...
groups) {
+ return validator.validate(object, groups);
+ }
+
+ public <T> Set<ConstraintViolation<T>> validateProperty(T object,
+ String propertyName, Class<?>... groups) {
+ return validator.validateProperty(object, propertyName, groups);
+ }
+
+ public <T> Set<ConstraintViolation<T>> validateValue(Class<T> beanType,
+ String propertyName, Object value, Class<?>... groups) {
+ return validator.validateValue(beanType, propertyName, value, groups);
+ }
+}
=======================================
--- /dev/null
+++
/trunk/samples/validationtck/src/com/google/gwt/sample/validationtck/TckValidator.java
Mon Nov 15 10:52:58 2010
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
not
+ * use this file except in compliance with the License. You may obtain a
copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
under
+ * the License.
+ */
+package com.google.gwt.sample.validationtck;
+
+import com.google.gwt.validation.client.GwtValidation;
+
+import org.hibernate.jsr303.tck.tests.constraints.application.SuperWoman;
+import org.hibernate.jsr303.tck.tests.constraints.application.Woman;
+
+import javax.validation.Validator;
+
+/**
+ * Top Level validator for the TCK tests
+ */
+...@gwtvalidation(value = {
+ Woman.class,
+ SuperWoman.class
+ })
+public interface TckValidator extends Validator {
+}
=======================================
--- /dev/null
+++
/trunk/samples/validationtck/src/com/google/gwt/sample/validationtck/ValidationTck.gwt.xml
Mon Nov 15 10:52:58 2010
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit
2.0.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.0.1/distro-source/core/src/gwt-module.dtd">
+<!--
+ Copyright 2010 Google Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License"); you may
not
+ use this file except in compliance with the License. You may obtain a
copy of
+ the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ License for the specific language governing permissions and limitations
under
+ the License.
+-->
+<module rename-to="validationtck">
+ <inherits name="com.google.gwt.user.User" />
+ <inherits name="org.hibernate.jsr303.tck.Jsr303Tck" />
+ <inherits name="org.hibernate.validator.HibernateValidator" />
+ <source path="">
+ <exclude name="super" />
+ </source>
+ <entry-point class="com.google.gwt.sample.validationtck.Tck" />
+ <replace-with
class="com.google.gwt.sample.validationtck.TckTestValidator">
+ <when-type-is class="javax.validation.Validator"/>
+ </replace-with>
+</module>
=======================================
--- /dev/null
+++
/trunk/samples/validationtck/src/org/hibernate/jsr303/tck/Jsr303Tck.gwt.xml
Mon Nov 15 10:52:58 2010
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+This is a HACK, is not a complete Validation TCK solution.
+It is only enough to run the tests in the GWT Validation TCK.
+-->
+<module>
+ <inherits name='com.google.gwt.validation.Validation' />
+ <inherits name='org.jboss.test.audit.JbossTestAudit' />
+ <inherits name='org.jboss.testharness.JbossTestHarness' />
+ <inherits name='org.testng.TestNg' />
+ <source path="">
+ <exclude name="super/" />
+ <!-- things not used in any current test -->
+ <exclude name="common/" />
+ <exclude name="tests/bootstrap/" />
+ <exclude name="tests/constraints/builtinconstraints/" />
+ <exclude name="tests/messageinterpolation/" />
+ <exclude name="tests/validation/" />
+ <exclude name="tests/xmlconfiguration/" />
+ <exclude name="util/StandaloneContainersImpl.java" />
+ </source>
+ <super-source path="super" />
+</module>
=======================================
--- /dev/null
+++
/trunk/samples/validationtck/src/org/hibernate/jsr303/tck/super/org/hibernate/jsr303/tck/util/TestUtil.java
Mon Nov 15 10:52:58 2010
@@ -0,0 +1,409 @@
+// $Id: TestUtil.java 17620 2009-10-04 19:19:28Z hardy.ferentschik $
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat, Inc.
and/or
+ * its affiliates, and individual contributors by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of individual
+ * contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
not
+ * use this file except in compliance with the License. You may obtain a
copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless
required by
+ * applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS
+ * OF ANY KIND, either express or implied. See the License for the specific
+ * language governing permissions and limitations under the License.
+ */
+
+package org.hibernate.jsr303.tck.util;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.regexp.shared.MatchResult;
+import com.google.gwt.regexp.shared.RegExp;
+import com.google.gwt.sample.validationtck.TckTestValidator;
+import com.google.gwt.sample.validationtck.TckValidator;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.validation.Configuration;
+import javax.validation.ConstraintViolation;
+import javax.validation.MessageInterpolator;
+import javax.validation.Path;
+import javax.validation.Validator;
+import javax.validation.ValidatorFactory;
+import javax.validation.metadata.ConstraintDescriptor;
+import javax.validation.metadata.ElementDescriptor;
+import javax.validation.metadata.PropertyDescriptor;
+import javax.validation.spi.ValidationProvider;
+
+/**
+ * Modified by Google.
+ * <ul>
+ * <li>Use RegExp instead of Pattern</li>
+ * <li>Hard code the validator</li>
+ * </ul>
+ * @author Hardy Ferentschik
+ */
+public final class TestUtil {
+
+ private static String VALIDATION_PROVIDER_TEST_CLASS
= "validation.provider";
+
+ private static ValidationProvider<?> validationProviderUnderTest;
+
+ private TestUtil() {
+ }
+
+ public static Validator getValidatorUnderTest() {
+ // return getValidatorFactoryUnderTest().getValidator();
+ return GWT.create(Validator.class);
+ }
+
+ public static ValidationProvider<?> getValidationProviderUnderTest() {
+ if (validationProviderUnderTest == null) {
+ instantiateValidationProviderUnderTest();
+ }
+ return validationProviderUnderTest;
+ }
+
+ public static ValidatorFactory getValidatorFactoryUnderTest() {
+ Configuration<?> config = getConfigurationUnderTest();
+ return config.buildValidatorFactory();
+ }
+
+ public static Configuration<?> getConfigurationUnderTest() {
+ if (validationProviderUnderTest == null) {
+ instantiateValidationProviderUnderTest();
+ }
+
+ // ProviderSpecificBootstrap<?> bootstrap =
+ // Validation.byProvider(validationProviderUnderTest.getClass());
+ return null; // bootstrap.configure();
+ }
+
+ public static MessageInterpolator getDefaultMessageInterpolator() {
+ Configuration<?> config = getConfigurationUnderTest();
+ return config.getDefaultMessageInterpolator();
+ }
+
+ public static <T> void assertCorrectNumberOfViolations(
+ Set<ConstraintViolation<T>> violations, int expectedViolations) {
+ assertEquals(violations.size(), expectedViolations,
+ "Wrong number of constraint violations. Expected: "
+ + expectedViolations + " Actual: " + violations.size());
+ }
+
+ public static <T> void assertCorrectConstraintViolationMessages(
+ Set<ConstraintViolation<T>> violations, String... messages) {
+ List<String> actualMessages = new ArrayList<String>();
+ for (ConstraintViolation<?> violation : violations) {
+ actualMessages.add(violation.getMessage());
+ }
+
+ assertTrue(actualMessages.size() == messages.length,
+ "Wrong number or error messages. Expected: " + messages.length
+ + " Actual: " + actualMessages.size());
+
+ for (String expectedMessage : messages) {
+ assertTrue(actualMessages.contains(expectedMessage), "The message '"
+ + expectedMessage
+ + "' should have been in the list of actual messages: "
+ + actualMessages);
+ actualMessages.remove(expectedMessage);
+ }
+ assertTrue(actualMessages.isEmpty(),
+ "Actual messages contained more messages as specified expected
messages");
+ }
+
+ public static <T> void assertCorrectConstraintTypes(
+ Set<ConstraintViolation<T>> violations,
+ Class<?>... expectedConsraintTypes) {
+ List<String> actualConstraintTypes = new ArrayList<String>();
+ for (ConstraintViolation<?> violation : violations) {
+ actualConstraintTypes.add(((Annotation)
violation.getConstraintDescriptor().getAnnotation()).annotationType().getName());
+ }
+
+ assertEquals(expectedConsraintTypes.length,
actualConstraintTypes.size(),
+ "Wrong number of constraint types.");
+
+ for (Class<?> expectedConstraintType : expectedConsraintTypes) {
+ assertTrue(
+ actualConstraintTypes.contains(expectedConstraintType.getName()),
+ "The constraint type " + expectedConstraintType.getName()
+ + " is not in the list of actual violated constraint types: "
+ + actualConstraintTypes);
+ }
+ }
+
+ public static <T> void assertCorrectPropertyPaths(
+ Set<ConstraintViolation<T>> violations, String... propertyPaths) {
+ List<Path> propertyPathsOfViolations = new ArrayList<Path>();
+ for (ConstraintViolation<?> violation : violations) {
+ propertyPathsOfViolations.add(violation.getPropertyPath());
+ }
+
+ assertEquals(propertyPaths.length, propertyPathsOfViolations.size(),
+ "Wrong number of property paths. Expected: " + propertyPaths.length
+ + " Actual: " + propertyPathsOfViolations.size());
+
+ for (String propertyPath : propertyPaths) {
+ Path expectedPath = PathImpl.createPathFromString(propertyPath);
+ boolean containsPath = false;
+ for (Path actualPath : propertyPathsOfViolations) {
+ if (assertEqualPaths(expectedPath, actualPath)) {
+ containsPath = true;
+ break;
+ }
+ }
+ if (!containsPath) {
+ fail(expectedPath
+ + " is not in the list of path instances contained in the
actual constraint violations: "
+ + propertyPathsOfViolations);
+ }
+ }
+ }
+
+ public static <T> void assertConstraintViolation(
+ ConstraintViolation<T> violation, Class<?> rootBean, Object
invalidValue,
+ String propertyPath) {
+ Path expectedPath = PathImpl.createPathFromString(propertyPath);
+ if (!assertEqualPaths(violation.getPropertyPath(), expectedPath)) {
+ fail("Property paths differ. Actual: " + violation.getPropertyPath()
+ + " Expected: " + expectedPath);
+ }
+
+ assertEquals(violation.getRootBeanClass(), rootBean, "Wrong root
bean.");
+ assertEquals(violation.getInvalidValue(), invalidValue,
+ "Wrong invalid value.");
+ }
+
+ public static boolean assertEqualPaths(Path p1, Path p2) {
+ Iterator<Path.Node> p1Iterator = p1.iterator();
+ Iterator<Path.Node> p2Iterator = p2.iterator();
+ while (p1Iterator.hasNext()) {
+ Path.Node p1Node = p1Iterator.next();
+ if (!p2Iterator.hasNext()) {
+ return false;
+ }
+ Path.Node p2Node = p2Iterator.next();
+
+ // do the comparison on the node values
+ if (p2Node.getName() == null) {
+ if (p1Node.getName() != null) {
+ return false;
+ }
+ } else if (!p2Node.getName().equals(p1Node.getName())) {
+ return false;
+ }
+
+ if (p2Node.isInIterable() != p1Node.isInIterable()) {
+ return false;
+ }
+
+ if (p2Node.getIndex() == null) {
+ if (p1Node.getIndex() != null) {
+ return false;
+ }
+ } else if (!p2Node.getIndex().equals(p1Node.getIndex())) {
+ return false;
+ }
+
+ if (p2Node.getKey() == null) {
+ if (p1Node.getKey() != null) {
+ return false;
+ }
+ } else if (!p2Node.getKey().equals(p1Node.getKey())) {
+ return false;
+ }
+ }
+
+ return !p2Iterator.hasNext();
+ }
+
+ public static PropertyDescriptor getPropertyDescriptor(Class<?> clazz,
+ String property) {
+ Validator validator = getValidatorUnderTest();
+ return
validator.getConstraintsForClass(clazz).getConstraintsForProperty(
+ property);
+ }
+
+ public static Set<ConstraintDescriptor<?>> getConstraintDescriptorsFor(
+ Class<?> clazz, String property) {
+ ElementDescriptor elementDescriptor = getPropertyDescriptor(clazz,
property);
+ return elementDescriptor.getConstraintDescriptors();
+ }
+
+ public static Object getInputStreamForPath(String path) {
+
+ return null;
+ }
+
+ private static <U extends ValidationProvider<?>> void
instantiateValidationProviderUnderTest() {
+
+ }
+
+ public static class PathImpl implements Path {
+
+ /**
+ * Regular expression used to split a string path into its elements.
+ *
+ * @see <a href="http://www.regexplanet.com/simple/index.jsp">Regular
+ * expression tester</a>
+ */
+ private static final RegExp pathPattern =
RegExp.compile("(\\w+)(\\[(\\w*)\\])?(\\.(.*))*");
+
+ private static final String PROPERTY_PATH_SEPARATOR = ".";
+
+ private final List<Node> nodeList;
+
+ public static PathImpl createPathFromString(String propertyPath) {
+ if (propertyPath == null) {
+ throw new IllegalArgumentException(
+ "null is not allowed as property path.");
+ }
+
+ if (propertyPath.length() == 0) {
+ return createNewPath(null);
+ }
+
+ return parseProperty(propertyPath);
+ }
+
+ public static PathImpl createNewPath(String name) {
+ PathImpl path = new PathImpl();
+ NodeImpl node = new NodeImpl(name);
+ path.addNode(node);
+ return path;
+ }
+
+ private PathImpl() {
+ nodeList = new ArrayList<Node>();
+ }
+
+ public void addNode(Node node) {
+ nodeList.add(node);
+ }
+
+ public Iterator<Path.Node> iterator() {
+ return nodeList.iterator();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ Iterator<Path.Node> iter = iterator();
+ while (iter.hasNext()) {
+ Node node = iter.next();
+ builder.append(node.toString());
+ if (iter.hasNext()) {
+ builder.append(PROPERTY_PATH_SEPARATOR);
+ }
+ }
+ return builder.toString();
+ }
+
+ private static PathImpl parseProperty(String property) {
+ PathImpl path = new PathImpl();
+ String tmp = property;
+ do {
+ MatchResult matcher = pathPattern.exec(tmp);
+ if (matcher != null) {
+ String value = matcher.getGroup(1);
+ String indexed = matcher.getGroup(2);
+ String index = matcher.getGroup(3);
+ NodeImpl node = new NodeImpl(value);
+ if (indexed != null) {
+ node.setInIterable(true);
+ }
+ if (index != null && index.length() > 0) {
+ try {
+ Integer i = Integer.parseInt(index);
+ node.setIndex(i);
+ } catch (NumberFormatException e) {
+ node.setKey(index);
+ }
+ }
+ path.addNode(node);
+ tmp = matcher.getGroup(5);
+ } else {
+ throw new IllegalArgumentException("Unable to parse property
path "
+ + property);
+ }
+ } while (tmp != null);
+ return path;
+ }
+ }
+
+ public static class NodeImpl implements Path.Node {
+
+ private static final String INDEX_OPEN = "[";
+ private static final String INDEX_CLOSE = "]";
+
+ private final String name;
+ private boolean isInIterable;
+ private Integer index;
+ private Object key;
+
+ public NodeImpl(String name) {
+ this.name = name;
+ }
+
+ NodeImpl(Path.Node node) {
+ this.name = node.getName();
+ this.isInIterable = node.isInIterable();
+ this.index = node.getIndex();
+ this.key = node.getKey();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public boolean isInIterable() {
+ return isInIterable;
+ }
+
+ public void setInIterable(boolean inIterable) {
+ isInIterable = inIterable;
+ }
+
+ public Integer getIndex() {
+ return index;
+ }
+
+ public void setIndex(Integer index) {
+ isInIterable = true;
+ this.index = index;
+ }
+
+ public Object getKey() {
+ return key;
+ }
+
+ public void setKey(Object key) {
+ isInIterable = true;
+ this.key = key;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder(name == null ? "" : name);
+ if (isInIterable) {
+ builder.append(INDEX_OPEN);
+ if (getIndex() != null) {
+ builder.append(getIndex());
+ } else if (getKey() != null) {
+ builder.append(getKey());
+ }
+ builder.append(INDEX_CLOSE);
+ }
+ return builder.toString();
+ }
+ }
+}
=======================================
--- /dev/null
+++
/trunk/samples/validationtck/src/org/jboss/test/audit/JbossTestAudit.gwt.xml
Mon Nov 15 10:52:58 2010
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+This is a HACK, is not a general solution for using JBoss Test Audit.
+It is only enough to run the tests in the GWT Validation TCK.
+-->
+<module>
+ <inherits name="com.google.gwt.user.User" />
+ <source path="">
+ <exclude name="super/" />
+ </source>
+ <super-source path="super" />
+</module>
=======================================
--- /dev/null
+++
/trunk/samples/validationtck/src/org/jboss/testharness/JbossTestHarness.gwt.xml
Mon Nov 15 10:52:58 2010
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+This is a HACK, is not a general solution for using JBoss Test Harness.
+It is only enough to run the tests in the GWT Validation TCK.
+-->
+<module>
+ <inherits name="org.testng.TestNg" />
+ <source path="">
+ <exclude name="super/" />
+ <include name="api/DeploymentException.java"/>
+ </source>
+ <super-source path="super" />
+</module>
=======================================
--- /dev/null
+++
/trunk/samples/validationtck/src/org/jboss/testharness/super/org/jboss/testharness/AbstractTest.java
Mon Nov 15 10:52:58 2010
@@ -0,0 +1,200 @@
+//Modified by Google.
+package org.jboss.testharness;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import java.util.logging.Logger;
+import org.jboss.testharness.api.Configuration;
+import org.jboss.testharness.api.DeploymentException;
+//import org.jboss.testharness.api.TestResult;
+//import org.jboss.testharness.api.TestResult.Status;
+//import org.jboss.testharness.impl.ConfigurationImpl;
+//import org.jboss.testharness.impl.packaging.ArtifactGenerator;
+import org.jboss.testharness.impl.packaging.TCKArtifact;
+import org.testng.IHookCallBack;
+import org.testng.IHookable;
+//import org.testng.ITestContext;
+import org.testng.ITestResult;
+//import org.testng.annotations.AfterClass;
+//import org.testng.annotations.AfterSuite;
+//import org.testng.annotations.BeforeClass;
+//import org.testng.annotations.BeforeSuite;
+
+/**
+ * Abstract Test
+ * <p>
+ * Modified by Google to only include the minimum needed to run the
JSR-303 tck.
+ */
+public abstract class AbstractTest implements IHookable
+{
+
+ private static Logger log =
Logger.getLogger(AbstractTest.class.getName());
+
+ private static boolean inContainer = false;
+
+ public static boolean isInContainer()
+ {
+ return inContainer;
+ }
+
+ public static void setInContainer(boolean inContainer)
+ {
+ AbstractTest.inContainer = inContainer;
+ }
+
+ private TCKArtifact artifact;
+ private DeploymentException deploymentException;
+ private boolean skipTest = false;
+
+ private boolean isSuiteDeployingTestsToContainer()
+ {
+ return !isInContainer() &&
(!getCurrentConfiguration().isStandalone() ||
getCurrentConfiguration().isRunIntegrationTests());
+ }
+
+ private void generateArtifact()
+ {
+
+ }
+
+ protected TCKArtifact postCreate(TCKArtifact artifact)
+ {
+ return artifact;
+ }
+
+ private boolean isDeployToContainerNeeded()
+ {
+ /*
+ * If this isn't running inside the container AND there is an
artifact to
+ * deploy AND EITHER we are in standalone mode and it isn't a unit
test OR
+ * we aren't in standalone mode THEN we need to deploy
+ */
+ return !isInContainer() && artifact != null &&
((getCurrentConfiguration().isStandalone() && !artifact.isUnit() &&
getCurrentConfiguration().isRunIntegrationTests()) |
| !getCurrentConfiguration().isStandalone());
+ }
+
+ private void deployArtifact()
+ {
+
+ }
+
+ protected DeploymentException
handleDeploymentFailure(DeploymentException deploymentException)
+ {
+ return deploymentException;
+ }
+
+
+ private void undeployArtifact() throws Exception
+ {
+ if (isDeployToContainerNeeded())
+ {
+
getCurrentConfiguration().getContainers().undeploy(artifact.getDefaultName());
+ }
+ if (getCurrentConfiguration().isStandalone() && artifact != null &&
artifact.isUnit())
+ {
+ getCurrentConfiguration().getStandaloneContainers().undeploy();
+ }
+ }
+
+ private void checkAssertionsEnabled()
+ {
+ boolean assertionsEnabled = false;
+ try
+ {
+ assert false;
+ }
+ catch (AssertionError error)
+ {
+ assertionsEnabled = true;
+ }
+ if (!assertionsEnabled)
+ {
+ throw new IllegalStateException("Assertions must be enabled!");
+ }
+ }
+
+ //@BeforeSuite(alwaysRun = true, groups = "scaffold")
+// public void beforeSuite(ITestContext context) throws Exception
+// {
+// if (isSuiteDeployingTestsToContainer())
+// {
+// getCurrentConfiguration().getContainers().setup();
+// }
+// if (getCurrentConfiguration().isStandalone())
+// {
+// getCurrentConfiguration().getStandaloneContainers().setup();
+// }
+// checkAssertionsEnabled();
+// }
+
+ //@AfterSuite(alwaysRun = true, groups = "scaffold")
+ public void afterSuite() throws Exception
+ {
+ if (isSuiteDeployingTestsToContainer())
+ {
+ getCurrentConfiguration().getContainers().cleanup();
+ }
+ if (getCurrentConfiguration().isStandalone())
+ {
+ getCurrentConfiguration().getStandaloneContainers().cleanup();
+ }
+ }
+
+ //@BeforeClass(alwaysRun = true, groups = "scaffold")
+ public void beforeClass() throws Throwable
+ {
+ generateArtifact();
+ deployArtifact();
+
+ }
+
+ //@AfterClass(alwaysRun = true, groups = "scaffold")
+ public void afterClass() throws Exception
+ {
+ undeployArtifact();
+ this.artifact = null;
+ this.deploymentException = null;
+ skipTest = false;
+ }
+
+ public void beforeMethod()
+ {
+
+ }
+
+ public void afterMethod()
+ {
+
+ }
+
+ public final void run(IHookCallBack callback, ITestResult testResult)
+ {
+ }
+
+ protected Configuration getCurrentConfiguration()
+ {
+ return null; //ConfigurationImpl.get();
+ }
+
+ protected String getContextPath()
+ {
+ return "http://" + getCurrentConfiguration().getHost() + "/" +
this.getClass().getName() + "/";
+ }
+
+ protected boolean isThrowablePresent(Class<? extends Throwable>
throwableType, Throwable throwable)
+ {
+ if (throwable == null)
+ {
+ return false;
+ }
+// else if (throwableType.isAssignableFrom(throwable.getClass()))
+// {
+// return true;
+// }
+// else
+// {
+// return isThrowablePresent(throwableType, throwable.getCause());
+// }
+ return true;
+ }
+}
=======================================
--- /dev/null
+++
/trunk/samples/validationtck/src/org/jboss/testharness/super/org/jboss/testharness/api/Configuration.java
Mon Nov 15 10:52:58 2010
@@ -0,0 +1,138 @@
+package org.jboss.testharness.api;
+
+import java.util.List;
+
+import org.jboss.testharness.spi.Containers;
+import org.jboss.testharness.spi.StandaloneContainers;
+
+/**
+ * The configuration of the TCK.
+ *
+ * The TCK may be configured using system properties or placed in a
properties
+ * file called META-INF/web-beans-tck.properties.
+ *
+ * Porting package property names are the FQCN of the SPI class. Other
property
+ * names (one for each non-porting package SPI configuration option) are
+ * specified here. The defaults are also listed here.
+ *
+ * The TCK may also be configured programatically through this interface
+ *
+ * <p>
+ * Modified by Google.
+ * <ul>
+ * <li>Removed references to TestLauncher</li>
+ * <li>Removed revernces to the output dir.</li>
+ * <ul>
+ *
+ * @author Pete Muir
+ *
+ */
+public interface Configuration
+{
+
+ public static final String OUTPUT_DIRECTORY_PROPERTY_NAME
= "org.jboss.testharness.outputDirectory";
+ public static final String STANDALONE_PROPERTY_NAME
= "org.jboss.testharness.standalone";
+ public static final String RUN_INTEGRATION_TESTS_PROPERTY_NAME
= "org.jboss.testharness.runIntegrationTests";
+ public static final String CONNECT_TIMEOUT_PROPERTY_NAME
= "org.jboss.testharness.connectTimeout";
+ public static final String LIBRARY_DIRECTORY_PROPERTY_NAME
= "org.jboss.testharness.libraryDirectory";
+ public static final String HOST_PROPERTY_NAME
= "org.jboss.testharness.host";
+ public static final String TEST_PACKAGE_PROPERTY_NAME
= "org.jboss.testharness.testPackage";
+
+ public static final boolean DEFAULT_STANDALONE = true;
+ public static final boolean DEFAULT_RUN_INTEGRATION_TESTS = false;
+ public static final int DEFAULT_CONNECT_DELAY = 5000;
+ public static final boolean DEFAULT_WRITE_DEPLOYED_ARCHIVES_TO_DISK =
false;
+ public static final String DEFAULT_LIBRARY_DIRECTORY = null;
+ public static final String DEFAULT_HOST = "localhost:8080";
+
+ /**
+ * The output directory to put TCK specific output. The TestNG output
+ * directory is configured via TestNG.
+ *
+ * By default set to ${tmp}/jsr-299-tck
+ */
+ public String getOutputDirectory();
+
+ /**
+ * Whether the TCK is in standalone mode or not.
+ *
+ * By default true
+ */
+ public boolean isStandalone();
+
+ /**
+ * When the TCK is running in container tests it will attempt to
connect to
+ * the server every 200ms until the timeout is reached.
+ *
+ * By default 5000ms
+ */
+ public int getConnectTimeout();
+
+ /**
+ * The TCK allows additional libraries to be put in the deployed test
+ * artifacts (for example the porting package for the implementation).
Any
+ * jars in this directory will be added to the deployed artifact.
+ *
+ * By default no directory is used.
+ */
+ public String getLibraryDirectory();
+
+ /**
+ * The TCK test launcher
+ *
+ * @see TestLauncher
+ *
+ */
+ public Object getInContainerTestLauncher();
+
+ /**
+ * The implementation of {...@link Containers} in use.
+ */
+ public Containers getContainers();
+
+ /**
+ * Whether to run integration tests, by default false.
+ */
+ public boolean isRunIntegrationTests();
+
+ public void setOutputDirectory(String outputDirectory);
+
+ public void setStandalone(boolean standalone);
+
+ public void setConnectTimeout(int connectTimeout);
+
+ public void setLibraryDirectory(String libraryDir);
+
+ public void setInContainerTestLauncher(Object testLauncher);
+
+ public void setContainers(Containers containers);
+
+ /**
+ * The implementation of {...@link StandaloneContainers} in use.
+ */
+ public StandaloneContainers getStandaloneContainers();
+
+ public void setStandaloneContainers(StandaloneContainers
standaloneContainers);
+
+ public void setRunIntegrationTests(boolean runIntegrationTests);
+
+ /**
+ * The TCK will use this as the remote host to connect to run in
container
+ * tests. By default localhost:8080
+ *
+ */
+ public String getHost();
+
+ public void setHost(String host);
+
+ public List<String> getExtraPackages();
+
+ public List<ResourceDescriptor> getExtraResources();
+
+ public List<String> getExtraDeploymentProperties();
+
+ public String getTestPackage();
+
+ public void setTestPackage(String packageName);
+
+}
=======================================
--- /dev/null
+++
/trunk/samples/validationtck/src/org/jboss/testharness/super/org/jboss/testharness/api/ResourceDescriptor.java
Mon Nov 15 10:52:58 2010
@@ -0,0 +1,14 @@
+//Modified by Google:
+//Removed URL
+package org.jboss.testharness.api;
+
+
+public interface ResourceDescriptor
+{
+
+ public String getName();
+
+ //public URL getSource();
+ public Object getSource();
+
+}
=======================================
--- /dev/null
+++
/trunk/samples/validationtck/src/org/jboss/testharness/super/org/jboss/testharness/impl/packaging/TCKArtifact.java
Mon Nov 15 10:52:58 2010
@@ -0,0 +1,77 @@
+package org.jboss.testharness.impl.packaging;
+
+import java.util.Set;
+
+import org.jboss.testharness.api.ResourceDescriptor;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public interface TCKArtifact {
+ TCKArtifact initialize();
+
+ Object getJarAsStream();
+
+ Object getJar();
+
+ Object getExplodedJar();
+
+ void create();
+
+ void writeArtifactToDisk(String outputDirectory);
+
+ void writeArtifactToDisk(String outputDirectory, String ObjectName);
+
+ String getDefaultName();
+
+ Set<Class<?>> getClasses();
+
+ Set<ResourceDescriptor> getResources();
+
+ void addPackage(Object pkg);
+
+ void addPackage(String packageName, boolean addRecursively);
+
+ Object getClassesRoot(Object archiveRoot);
+
+ String getClassesRoot();
+
+ void setClassesRoot(String classesRoot);
+
+ Class<?> getDeclaringClass();
+
+ String getExtension();
+
+ void setExtension(String extension);
+
+ Set<ResourceDescriptor> getLibraries();
+
+ Object getLibraryRoot(Object archiveRoot);
+
+ void setLibrariesRoot(String libraryRoot);
+
+ boolean isLibrariesSupported();
+
+ void setLibrariesSupported(boolean librariesSupported);
+
+ boolean isUnit();
+
+ void setUnit(boolean unit);
+
+ Class<? extends Throwable> getExpectedDeploymentException();
+
+ void setExpectedDeploymentException(Class<? extends Throwable>
expectedDeploymentException);
+
+ boolean isRunLocally();
+
+ void setRunLocally(boolean runLocally);
+
+ String getXmlConfigDestination();
+
+ void setXmlConfigDestination(String xmlConfigDest);
+
+ ResourceDescriptor getXmlConfig();
+
+ void skipIncludeXmlConfig(boolean skip);
+}
+
=======================================
--- /dev/null
+++
/trunk/samples/validationtck/src/org/jboss/testharness/super/org/jboss/testharness/spi/Containers.java
Mon Nov 15 10:52:58 2010
@@ -0,0 +1,85 @@
+//Modified by Google
+package org.jboss.testharness.spi;
+
+//import java.io.IOException;
+//import java.io.InputStream;
+
+import org.jboss.testharness.api.DeploymentException;
+
+/**
+ * Incontainer mode deployment related operations
+ *
+ * The TCK porting package must provide an implementation of this interface
+ * which is suitable for the target implementation and application server
+ *
+ * <p>
+ * Modified by Google.
+ * <ul>
+ * <li>Removed refrences to java.io.</li>
+ * <ul>
+ *
+ * @author Pete Muir
+ *
+ */
+public interface Containers
+{
+
+ public static final String PROPERTY_NAME = Containers.class.getName();
+
+ /**
+ * The war/ear to deploy to the container, it should be read using a
+ * JarInputStream. Any deployment exceptions can be found through
+ * {...@link #getDeploymentException()}.
+ *
+ * For a successful deployment, a symmetric {...@link #undeploy(String)}
will be
+ * called.
+ *
+ * @see #undeploy(String)
+ *
+ * @param archive the archive
+ * @param name the name the TCK uses to refer to this archive, unique
within
+ * this tck run
+ * @return true if the deployment suceeded, otherwise false
+ * @throws IOException if any communication problems with the server
occur
+ * during deployment. These will cause the test suite to
fail.
+ */
+ public boolean deploy(Object archive, String name);
+
+ public DeploymentException getDeploymentException();
+
+ /**
+ * Undeploy the war/ear from the container.
+ *
+ * @see #deploy(InputStream, String)
+ *
+ * @param name the name the TCK uses to refer to this archive, unique
within
+ * this tck run
+ * @throws IOException if any communication problems with the server
occur
+ * during deployment. These will cause the test suite to
fail.
+ */
+ public void undeploy(String name);
+
+ /**
+ * Called before the TCK starts executing the testsuite, but after the
suite
+ * has been configured.
+ *
+ * A TCK suite lifecycle callback, useful for setting up the container.
This
+ * method may be a no-op if no setup is required.
+ *
+ * @throws IOException if any communication problems with the server
occur
+ * during setup. These will cause the test suite to fail.
+ */
+ public void setup();
+
+ /**
+ * Called after the TCK finishes executing the testsuite.
+ *
+ * A TCK suite lifecycle callback, useful for cleaning up and shutting
down
+ * the container. This method may be a no-op if no setup is required.
+ *
+ * @throws IOException if any communication problems with the server
occur
+ * during cleanup. These will cause the test suite to fail.
+ */
+ public void cleanup() ;
+
+}
=======================================
--- /dev/null
+++
/trunk/samples/validationtck/src/org/jboss/testharness/super/org/jboss/testharness/spi/StandaloneContainers.java
Mon Nov 15 10:52:58 2010
@@ -0,0 +1,102 @@
+//Modified by Google
+package org.jboss.testharness.spi;
+
+import java.util.Collection;
+
+import org.jboss.testharness.api.DeploymentException;
+
+/**
+ * Standalone mode deployment related operations. If the TCK is placed in
+ * standalone mode, unit tests will be deployed via this interface.
+ *
+ * You must implement this as part of the porting package if you intend to
run
+ * the TCK in standalone mode
+ *
+ * @author Pete Muir
+ *
+ */
+public interface StandaloneContainers
+{
+
+ public static final String PROPERTY_NAME =
StandaloneContainers.class.getName();
+
+ /**
+ * <p>Bootstrap the container by registering Beans and Observers,
raising
+ * @Initialized event, validating the deployment, and raising the
+ * @Deployed event.</p>
+ *
+ * <p>Any classes passed in should be fully deployed. This includes:</p>
+ *
+ * <ul>
+ * <li>Simple beans</li>
+ * <li>Session beans</li>
+ * <li>Producer methods and producer fields</li>
+ * <li>Observer methods</li>
+ * <li>support for Event and Instance injection points</li>
+ * </ul>
+ *
+ * The container should be in an fully initialized state when the
+ * method returns
+ *
+ * @param classes the classes to deploy
+ */
+ public void deploy(Collection<Class<?>> classes) throws
DeploymentException;
+
+ /**
+ * <p>Bootstrap the container for a test by registering Beans and
Observers,
+ * raising @Initialized event, validating the deployment, and raising
the
+ * @Deployed event.</p>
+ *
+ * <p>Any classes passed in should be fully deployed. This includes:</p>
+ *
+ * <ul>
+ * <li>Simple beans</li>
+ * <li>Session beans</li>
+ * <li>Producer methods and producer fields</li>
+ * <li>Observer methods</li>
+ * <li>support for Event and Instance injection points</li>
+ * </ul>
+ *
+ * The container should be in an fully initialized state when the
+ * method returns
+ *
+ * @param classes the classes to deploy
+ * @param beansXmls the beans.xml files to deploy
+ *
+ * @return true if the deployment suceeded, otherwise false
+ */
+ public boolean deploy(Collection<Class<?>> classes, Collection<Object>
beansXmls);
+
+ /**
+ * Any deployment exception, or null if the deployment suceeded
+ *
+ * @return
+ */
+ public DeploymentException getDeploymentException();
+
+ /**
+ * Cleanup the container after this test
+ *
+ */
+ public void undeploy();
+
+ /**
+ * Called before the TCK starts executing the testsuite, but after the
suite
+ * has been configured.
+ *
+ * A TCK suite lifecycle callback, useful for setting up the container.
This
+ * method may be a no-op if no setup is required.
+ *
+ */
+ public void setup();
+
+ /**
+ * Called after the TCK finishes executing the testsuite.
+ *
+ * A TCK suite lifecycle callback, useful for cleaning up and shutting
down
+ * the container. This method may be a no-op if no setup is required.
+ *
+ */
+ public void cleanup();
+
+}
=======================================
--- /dev/null
+++ /trunk/samples/validationtck/src/org/testng/TestNg.gwt.xml Mon Nov 15
10:52:58 2010
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+This is a HACK, is not a general solution for using TestNg.
+It is only enough to run the tests in the GWT Validation TCK.
+-->
+<module>
+ <inherits name="com.google.gwt.user.User" />
+ <source path="annotations">
+ <exclude name="ITestAnnotation.java" />
+ <exclude name="Listeners.java" />
+ <exclude name="Optional.java" />
+ </source>
+ <source path="collections" />
+ <source path="">
+ <include name="Assert.java" />
+ <include name="AssertJUnit.java" />
+ <include name="IClass.java" />
+ <include name="IHookable.java" />
+ <include name="IHookCallBack.java" />
+ <include name="ITestResult.java" />
+ <include name="ITestNGListener.java" />
+ <include name="ITestNGMethod.java" />
+ <include name="IAttributes.java" />
+ <include name="IRetryAnalyzer.java" />
+ <include name="ITestClass.java" />
+ </source>
+ <super-source path="super" />
+</module>
=======================================
***Additional files exist in this changeset.***
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors