Return-Path: Delivered-To: apmail-incubator-chemistry-commits-archive@minotaur.apache.org Received: (qmail 21541 invoked from network); 26 Aug 2009 14:19:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 26 Aug 2009 14:19:45 -0000 Received: (qmail 22532 invoked by uid 500); 26 Aug 2009 14:19:45 -0000 Delivered-To: apmail-incubator-chemistry-commits-archive@incubator.apache.org Received: (qmail 22499 invoked by uid 500); 26 Aug 2009 14:19:45 -0000 Mailing-List: contact chemistry-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: chemistry-dev@incubator.apache.org Delivered-To: mailing list chemistry-commits@incubator.apache.org Received: (qmail 22489 invoked by uid 99); 26 Aug 2009 14:19:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Aug 2009 14:19:44 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Aug 2009 14:19:33 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A93D12388852; Wed, 26 Aug 2009 14:19:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r808023 - in /incubator/chemistry/trunk/chemistry/chemistry-tck-atompub: ./ src/main/java/org/apache/chemistry/tck/atompub/ src/main/java/org/apache/chemistry/tck/atompub/client/ src/main/java/org/apache/chemistry/tck/atompub/test/ src/main... Date: Wed, 26 Aug 2009 14:19:12 -0000 To: chemistry-commits@incubator.apache.org From: dcaruana@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090826141913.A93D12388852@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dcaruana Date: Wed Aug 26 14:19:11 2009 New Revision: 808023 URL: http://svn.apache.org/viewvc?rev=808023&view=rev Log: CMIS-49 : Add TCKRunner to AtomPub TCK - introduce TCKRunner - provision of TCKOptions from custom inputs (not just system properties) - allow custom writers for TCK output - support for executing specific tests Moved tests into main source tree to allow packaging of full TCK into jar. Added: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/TCKMessageWriter.java - copied, changed from r807547, incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/TCKLogger.java incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/TCKSkipCapabilityException.java (with props) incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/TCKTestResult.java (with props) incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/TCKTestSuite.java (with props) incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/custom/ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/custom/CMISCustomTypeTest.java - copied unchanged from r807547, incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/custom/CMISCustomTypeTest.java incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/custom/TCKCustomTest.java - copied unchanged from r807547, incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/custom/TCKCustomTest.java incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/AllowableActionsTest.java - copied unchanged from r807547, incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/AllowableActionsTest.java incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/ContentStreamTest.java - copied, changed from r807547, incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/ContentStreamTest.java incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/CreateTest.java - copied unchanged from r807547, incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/CreateTest.java incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/DeleteTest.java - copied unchanged from r807547, incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/DeleteTest.java incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/FolderChildrenTest.java - copied unchanged from r807547, incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/FolderChildrenTest.java incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/FolderHierarchyTest.java - copied, changed from r807547, incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/FolderHierarchyTest.java incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/GetTest.java - copied unchanged from r807547, incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/GetTest.java incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/QueryPagingTest.java - copied, changed from r807547, incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/QueryPagingTest.java incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/QueryTest.java - copied, changed from r807547, incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/QueryTest.java incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/RepositoryServiceTest.java - copied unchanged from r807547, incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/RepositoryServiceTest.java incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/TypeDefinitionTest.java - copied unchanged from r807547, incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/TypeDefinitionTest.java incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/UpdateTest.java - copied unchanged from r807547, incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/UpdateTest.java incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/VersionsTest.java - copied unchanged from r807547, incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/VersionsTest.java incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/tools/TCKRunner.java (with props) incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/tools/TCKRunnerOptions.java (with props) incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/utils/LogMessageWriter.java (with props) incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/resources/org/apache/chemistry/tck/atompub/templates/custom/ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/resources/org/apache/chemistry/tck/atompub/templates/custom/createcustomdocument.atomentry.xml - copied unchanged from r807547, incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/resources/org/apache/chemistry/tck/atompub/templates/custom/createcustomdocument.atomentry.xml incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/resources/org/apache/chemistry/tck/atompub/templates/custom/createcustomfolder.atomentry.xml - copied unchanged from r807547, incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/resources/org/apache/chemistry/tck/atompub/templates/custom/createcustomfolder.atomentry.xml incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/resources/org/apache/chemistry/tck/atompub/templates/custom/updatecustomdocument.atomentry.xml - copied unchanged from r807547, incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/resources/org/apache/chemistry/tck/atompub/templates/custom/updatecustomdocument.atomentry.xml incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/TCKTestSuiteTest.java (with props) incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/resources/org/apache/chemistry/tck/atompub/examples/ - copied from r807547, incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/resources/org/apache/chemistry/tck/atompub/examples/ Removed: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/TCKLogger.java incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/tools/TCKExecutor.java incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/utils/SystemPropertyOptions.java incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/resources/org/apache/chemistry/tck/atompub/examples/ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/custom/ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/resources/org/apache/chemistry/tck/atompub/templates/custom/ Modified: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/README.txt incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/pom.xml incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/TCKOptions.java incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/TCKTest.java incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/client/CMISClient.java incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/resources/log4j.xml Modified: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/README.txt URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/README.txt?rev=808023&r1=808022&r2=808023&view=diff ============================================================================== --- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/README.txt (original) +++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/README.txt Wed Aug 26 14:19:11 2009 @@ -30,6 +30,10 @@ org.apache.chemistry.tck.atompub.test.custom (just a reflection of the current implementation) +All of the above tests are added to the following test suite: + +org.apache.chemistry.tck.test.TCKTestSuite + CMIS AtomPub Tck Basic Usage Instructions ----------------------------------------- @@ -48,19 +52,12 @@ 2) Copy example section 3) Edit the value to represent your provider 4) Edit chemistry.tck.serviceUrl for your provider -5) Edit chemistry.tck.username and chemistry.tck.password properties for your provider +5) Edit chemistry.tck.user and chemistry.tck.password properties for your provider (note: username and password may be removed if authentication is not required) +6) Edit other chemistry.tck.xxx settings as to your requirements By default, all tests are executed. -Individual tests are executed with: - -mvn test -p -Dtest= - -e.g. - -mvn test -p -Dtest=RepositoryTest - Tck Test Results ---------------- @@ -69,19 +66,47 @@ Each test outputs the following files... -org.apache.chemistry.tck.atompub.test.xxx.XXXTest.txt : summary of test results -TEST-org.apache.chemistry.tck.atompub.test.spec.CMISTest.txt : detailed report of test results and test environment -org.apache.chemistry.tck.atompub.test.xxx.XXXTest-output.txt : trace of all CMIS requests and responses +org.apache.chemistry.tck.atompub.test.TCKTestSuiteTest.txt : summary of test results +TEST-org.apache.chemistry.tck.atompub.test.TCKTestSuiteTest.txt : detailed report of test results and test environment +org.apache.chemistry.tck.atompub.test.TCKTestSuiteTest-output.txt : trace of all CMIS requests and responses -Tck Advanced Configuration --------------------------- +Executing Tck JUnit Tests +------------------------- + +Individual Tck JUnit tests may be executed in any environment (e.g. Eclipse). They must be +provided with appropriate Tck Options for successful execution. + +Each Tck Option can be set as a system property e.g. + +-Dchemistry.tck.serviceUrl=http://localhost:8080/cmis + + +Tck Runner +---------- + +The class... + +org.apache.chemistry.tck.atompub.tools.TCKRunner + +provides a programmatic front-end to the TCK tests. TCK options may be pulled from a custom +location and TCK output may be redirected to a custom destination. + +This allows for example, a HTML form front-end to the TCK tests. + + +Tck Options +----------- -The following properties may also be set in the profile: +The TCK supports the following options: +chemistry.tck.serviceUrl : url to the repository service document +chemistry.tck.user : username to authenticate with +chemistry.tck.password : password to authenticate with +chemistry.tck.tests (*=default) : test name pattern identifying which tests to execute. * is wildcard. chemistry.tck.validate (true=default|false) : true => validate responses against CMIS XSD chemistry.tck.failOnValidationError (true|false=default) : true => fail on validation error -chemistry.tck.traceRequests (true=default|false) : true => trace requests and responses +chemistry.tck.traceRequests (true|false=default) : true => trace requests and responses chemistry.tck.deleteTestFixture (true=default|false) : true => remove test data at end of test Modified: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/pom.xml URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/pom.xml?rev=808023&r1=808022&r2=808023&view=diff ============================================================================== --- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/pom.xml (original) +++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/pom.xml Wed Aug 26 14:19:11 2009 @@ -88,24 +88,11 @@ org.apache.xerces.jaxp.SAXParserFactoryImpl - chemistry.tck.validate - true - - - chemistry.tck.failOnValidationError - false - - - chemistry.tck.traceRequests - false + + chemistry.tck.tests + - true - - - - **/test/custom/**/*.java - @@ -127,9 +114,12 @@ org.apache.maven.plugins maven-surefire-plugin - false + chemistry.tck.tests + * + + chemistry.tck.serviceUrl http://localhost/cmis @@ -141,6 +131,18 @@ chemistry.tck.password cmispassword + + chemistry.tck.validate + true + + + chemistry.tck.failOnValidationError + false + + + chemistry.tck.traceRequests + false + Copied: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/TCKMessageWriter.java (from r807547, incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/TCKLogger.java) URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/TCKMessageWriter.java?p2=incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/TCKMessageWriter.java&p1=incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/TCKLogger.java&r1=807547&r2=808023&rev=808023&view=diff ============================================================================== --- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/TCKLogger.java (original) +++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/TCKMessageWriter.java Wed Aug 26 14:19:11 2009 @@ -17,13 +17,18 @@ */ package org.apache.chemistry.tck.atompub; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - /** - * TCK Logger + * TCK Message Writer + * + * Output informational messages during TCK tests */ -public class TCKLogger { - public static final Log logger = LogFactory.getLog(TCKLogger.class); +public interface TCKMessageWriter { + + public void info(String message); + + public void warn(String message); + + public void trace(String message); + } Modified: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/TCKOptions.java URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/TCKOptions.java?rev=808023&r1=808022&r2=808023&view=diff ============================================================================== --- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/TCKOptions.java (original) +++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/TCKOptions.java Wed Aug 26 14:19:11 2009 @@ -17,25 +17,88 @@ */ package org.apache.chemistry.tck.atompub; +import java.io.Serializable; +import java.util.Properties; + /** * TCK Options */ -public interface TCKOptions { - - public String getServiceUrl(); - - public String getUser(); - - public String getPassword(); - - public Boolean getValidate(); - - public Boolean getFailOnValidationError(); - - public Boolean getTraceRequests(); +public class TCKOptions implements Serializable{ - public Boolean getDeleteTestFixture(); + public final static String PROP_SERVICE_URL = "chemistry.tck.serviceUrl"; + public final static String PROP_USERNAME = "chemistry.tck.user"; + public final static String PROP_PASSWORD = "chemistry.tck.password"; + public final static String PROP_VALIDATE = "chemistry.tck.validate"; + public final static String PROP_FAIL_ON_VALIDATION_ERROR = "chemistry.tck.failOnValidationError"; + public final static String PROP_TRACE_REQUESTS = "chemistry.tck.traceRequests"; + public final static String PROP_DELETE_TEST_FIXTURE = "chemistry.tck.deleteTestFixture"; + + private static final long serialVersionUID = 5805080271712377369L; + protected Properties properties; + + public TCKOptions(Properties properties) { + this.properties = properties; + } + + /** + * @return username (default: null, if not specified, or empty string) + */ + public String getUsername() { + String val = properties.getProperty(PROP_USERNAME); + return val != null && val.length() > 0 ? val : null; + } + + /** + * @return password (default: null) + */ + public String getPassword() { + String val = properties.getProperty(PROP_PASSWORD); + return val; + } + + /** + * @return serviceUrl (default: null, if not specified, or empty string) + */ + public String getServiceUrl() { + String val = properties.getProperty(PROP_SERVICE_URL); + return val != null && val.length() > 0 ? val : null; + } + + /** + * @return validate (default: true) + */ + public boolean getValidate() { + String val = properties.getProperty(PROP_VALIDATE, "true"); + return Boolean.valueOf(val); + } + + /** + * @return fail on validation error (default: false) + */ + public boolean getFailOnValidationError() { + String val = properties.getProperty(PROP_FAIL_ON_VALIDATION_ERROR, "false"); + return Boolean.valueOf(val); + } + + /** + * @return trace requests (default: false) + */ + public boolean getTraceRequests() { + String val = properties.getProperty(PROP_TRACE_REQUESTS, "false"); + return Boolean.valueOf(val); + } + + /** + * @return delete fixture data (default: true) + */ + public boolean getDeleteTestFixture() { + String val = properties.getProperty(PROP_DELETE_TEST_FIXTURE, "true"); + return Boolean.valueOf(val); + } + + public String getConnectionFactory() { + return null; + } - public String getConnectionFactory(); } Added: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/TCKSkipCapabilityException.java URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/TCKSkipCapabilityException.java?rev=808023&view=auto ============================================================================== --- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/TCKSkipCapabilityException.java (added) +++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/TCKSkipCapabilityException.java Wed Aug 26 14:19:11 2009 @@ -0,0 +1,45 @@ +/* + * 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. + * + * Authors: + * David Caruana, Alfresco + */ +package org.apache.chemistry.tck.atompub; + +public class TCKSkipCapabilityException extends Exception { + + private static final long serialVersionUID = 3715821943383140356L; + + private String capability; + private String required; + private String actual; + + public TCKSkipCapabilityException(String capability, String required, String actual) { + super("Expected capability " + capability + " value of " + required + " but was " + actual); + this.capability = capability; + this.required = required; + this.actual = actual; + } + + public String getCapability() { + return capability; + } + + public String getRequired() { + return required; + } + + public String getActual() { + return actual; + } +} Propchange: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/TCKSkipCapabilityException.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/TCKTest.java URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/TCKTest.java?rev=808023&r1=808022&r2=808023&view=diff ============================================================================== --- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/TCKTest.java (original) +++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/TCKTest.java Wed Aug 26 14:19:11 2009 @@ -18,6 +18,7 @@ package org.apache.chemistry.tck.atompub; import junit.framework.TestCase; +import junit.framework.TestResult; import org.apache.chemistry.tck.atompub.client.CMISAppModel; import org.apache.chemistry.tck.atompub.client.CMISClient; @@ -25,50 +26,63 @@ import org.apache.chemistry.tck.atompub.http.Connection; import org.apache.chemistry.tck.atompub.http.ConnectionFactory; import org.apache.chemistry.tck.atompub.http.httpclient.HttpClientConnectionFactory; +import org.apache.chemistry.tck.atompub.utils.LogMessageWriter; import org.apache.chemistry.tck.atompub.utils.ResourceLoader; -import org.apache.chemistry.tck.atompub.utils.SystemPropertyOptions; /** * Base Test Class for TCK Tests */ public class TCKTest extends TestCase { + protected TCKMessageWriter messageWriter = null; protected TCKOptions options = null; protected CMISClient client; protected CMISAppModel model; protected CMISTestFixture fixture; protected ResourceLoader templates; - public void setOptions(TCKOptions properties) { - this.options = properties; + + public void setMessageWriter(TCKMessageWriter messageWriter) { + this.messageWriter = messageWriter; + } + + public void setOptions(TCKOptions options) { + this.options = options; } @Override public void setUp() { // construct TCK properties if (options == null) - options = new SystemPropertyOptions(); + options = new TCKOptions(System.getProperties()); + + // construct TCK message writer + if (messageWriter == null) + messageWriter = new LogMessageWriter(); // construct connection to server // TODO: allow configuration of different connection factory ConnectionFactory connFactory = new HttpClientConnectionFactory(); - String user = options.getUser(); + String user = options.getUsername(); String password = options.getPassword(); - Connection connection = (user == null) ? connFactory.createConnection() : connFactory.createConnection(user, - password); - + Connection connection; + if (user == null) { + connection = connFactory.createConnection(); + } else { + connection = connFactory.createConnection(user, password); + } + // construct CMIS test client String url = options.getServiceUrl(); if (url == null) fail("CMIS Service URL not specified"); - client = new CMISClient(connection, url); - Boolean validate = (options.getValidate() == null) ? true : options.getValidate(); + client = new CMISClient(connection, url, messageWriter); + boolean validate = options.getValidate(); client.setValidate(validate); - Boolean failOnValidationError = (options.getFailOnValidationError() == null) ? false : options - .getFailOnValidationError(); + boolean failOnValidationError = options.getFailOnValidationError(); client.setFailOnValidationError(failOnValidationError); - Boolean trace = (options.getTraceRequests() == null) ? true : options.getTraceRequests(); - client.setTrace(trace); + boolean traceRequests = options.getTraceRequests(); + client.setTrace(traceRequests); // construct model helper model = new CMISAppModel(); @@ -79,29 +93,28 @@ // construct test fixture fixture = new CMISTestFixture(client, getName()); - if (TCKLogger.logger.isInfoEnabled()) { - TCKLogger.logger.info("Start Test: " + getClass().getName() + "." + getName()); - TCKLogger.logger.info("Service URL: " + url); - TCKLogger.logger.info("User: " + user); - TCKLogger.logger.info("Password: " + password); - TCKLogger.logger.info("Validate: " + validate); - TCKLogger.logger.info("Fail on Validation Error: " + failOnValidationError); - TCKLogger.logger.info("Trace Requests: " + trace); - } + messageWriter.info("Start Test: " + getClass().getName() + "." + getName()); + messageWriter.info("Service URL: " + url); + messageWriter.info("User: " + user); + messageWriter.info("Password: " + password); + messageWriter.info("Validate: " + validate); + messageWriter.info("Fail on Validation Error: " + failOnValidationError); + messageWriter.info("Trace Requests: " + traceRequests); } @Override + public void run(TestResult result) { + super.run(new TCKTestResult(result, messageWriter)); + } + + @Override public void tearDown() throws Exception { - Boolean delete = (options.getDeleteTestFixture() == null) ? true : options.getDeleteTestFixture(); - if (delete) + if (options.getDeleteTestFixture()) { fixture.delete(); + } else { + messageWriter.warn("Kept Test Data: " + getClass().getName() + "." + getName()); + } - if (TCKLogger.logger.isInfoEnabled()) - TCKLogger.logger.info("End Test: " + getClass().getName() + "." + getName()); - } - - public void skipTest(String reason) { - if (TCKLogger.logger.isInfoEnabled()) - TCKLogger.logger.info("Skiped Test: " + getClass().getName() + "." + getName() + ": " + reason); + messageWriter.info("End Test: " + getClass().getName() + "." + getName()); } } Added: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/TCKTestResult.java URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/TCKTestResult.java?rev=808023&view=auto ============================================================================== --- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/TCKTestResult.java (added) +++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/TCKTestResult.java Wed Aug 26 14:19:11 2009 @@ -0,0 +1,129 @@ +/* + * 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. + * + * Authors: + * David Caruana, Alfresco + */ +package org.apache.chemistry.tck.atompub; + +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; + +import junit.framework.AssertionFailedError; +import junit.framework.Test; +import junit.framework.TestFailure; +import junit.framework.TestListener; +import junit.framework.TestResult; + + +public class TCKTestResult extends TestResult { + + private final TestResult orig; + private List skips; + private final TCKMessageWriter messageWriter; + + + public TCKTestResult(TestResult orig, TCKMessageWriter messageWriter) { + this.orig = orig; + this.messageWriter = messageWriter; + this.skips = new ArrayList(); + } + + @Override + public synchronized void addError(Test test, Throwable throwable) { + if (throwable instanceof TCKSkipCapabilityException) { + if (messageWriter != null) { + messageWriter.warn("Skipped Test: " + throwable.getMessage()); + } + if (orig instanceof TCKTestResult) { + ((TCKTestResult)orig).addSkip(test, (TCKSkipCapabilityException)throwable); + } + } else { + orig.addError(test, throwable); + } + } + + public synchronized void addSkip(Test test, TCKSkipCapabilityException skipException) { + skips.add(new TestFailure(test, skipException)); + } + + @Override + public synchronized void addFailure(Test test, AssertionFailedError assertionFailedError) { + orig.addFailure(test, assertionFailedError); + } + + @Override + public synchronized void addListener(TestListener testListener) { + orig.addListener(testListener); + } + + @Override + public synchronized void removeListener(TestListener testListener) { + orig.removeListener(testListener); + } + + @Override + public void endTest(Test test) { + orig.endTest(test); + } + + @Override + public synchronized int errorCount() { + return orig.errorCount(); + } + + @Override + public synchronized Enumeration errors() { + return orig.errors(); + } + + @Override + public synchronized int failureCount() { + return orig.failureCount(); + } + + public synchronized int skipCount() { + return skips.size(); + } + + @Override + public synchronized Enumeration failures() { + return orig.failures(); + } + + @Override + public synchronized int runCount() { + return orig.runCount(); + } + + @Override + public synchronized boolean shouldStop() { + return orig.shouldStop(); + } + + @Override + public void startTest(Test test) { + orig.startTest(test); + } + + @Override + public synchronized void stop() { + orig.stop(); + } + + @Override + public synchronized boolean wasSuccessful() { + return orig.wasSuccessful(); + } +} Propchange: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/TCKTestResult.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/client/CMISClient.java URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/client/CMISClient.java?rev=808023&r1=808022&r2=808023&view=diff ============================================================================== --- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/client/CMISClient.java (original) +++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/client/CMISClient.java Wed Aug 26 14:19:11 2009 @@ -39,7 +39,7 @@ import org.apache.chemistry.abdera.ext.CMISConstants; import org.apache.chemistry.abdera.ext.CMISObject; import org.apache.chemistry.abdera.ext.CMISRepositoryInfo; -import org.apache.chemistry.tck.atompub.TCKLogger; +import org.apache.chemistry.tck.atompub.TCKMessageWriter; import org.apache.chemistry.tck.atompub.http.Connection; import org.apache.chemistry.tck.atompub.http.GetRequest; import org.apache.chemistry.tck.atompub.http.PostRequest; @@ -58,6 +58,8 @@ */ public class CMISClient { + private TCKMessageWriter messageWriter; + private Connection connection; private boolean traceConnection; @@ -75,9 +77,10 @@ private CMISCapabilities cmisCapabilities = null; - public CMISClient(Connection connection, String serviceUrl) { + public CMISClient(Connection connection, String serviceUrl, TCKMessageWriter messageWriter) { this.connection = connection; this.serviceUrl = serviceUrl; + this.messageWriter = messageWriter; } public void setValidate(boolean validate) { @@ -345,16 +348,16 @@ * @throws IOException */ public Response executeRequest(Request req, int expectedStatus, Validator validator) throws IOException { - if (traceConnection && TCKLogger.logger.isInfoEnabled()) { - TCKLogger.logger.info("Request: " + req.getMethod() + " " + req.getFullUri() + if (traceConnection) { + messageWriter.trace("Request: " + req.getMethod() + " " + req.getFullUri() + (req.getBody() == null ? "" : "\n" + new String(req.getBody(), req.getEncoding()))); } Response res = connection.executeRequest(req); - if (traceConnection && TCKLogger.logger.isInfoEnabled()) { - TCKLogger.logger.info("Response: " + res.getStatus() + " " + req.getMethod() + " " + req.getFullUri() - + (res.getContentAsString() == null ? "" : "\n" + res.getContentAsString())); + if (traceConnection) { + messageWriter.trace("Response: " + res.getStatus() + " " + req.getMethod() + " " + + req.getFullUri() + (res.getContentAsString() == null ? "" : "\n" + res.getContentAsString())); } if (expectedStatus > -1) @@ -396,9 +399,7 @@ Document document = cmisValidator.getDocumentBuilder().parse(new InputSource(new StringReader(xml))); validator.validate(new DOMSource(document)); } catch (SAXException e) { - if (TCKLogger.logger.isInfoEnabled()) { - TCKLogger.logger.info("Failed Validation: " + cmisValidator.toString(e, null)); - } + messageWriter.info("Failed Validation: " + cmisValidator.toString(e, null)); if (failOnValidationError) { Assert.fail(cmisValidator.toString(e, xml)); } Added: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/TCKTestSuite.java URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/TCKTestSuite.java?rev=808023&view=auto ============================================================================== --- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/TCKTestSuite.java (added) +++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/TCKTestSuite.java Wed Aug 26 14:19:11 2009 @@ -0,0 +1,67 @@ +/* + * 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. + * + * Authors: + * David Caruana, Alfresco + */ +package org.apache.chemistry.tck.atompub.test; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +import org.apache.chemistry.tck.atompub.test.spec.AllowableActionsTest; +import org.apache.chemistry.tck.atompub.test.spec.ContentStreamTest; +import org.apache.chemistry.tck.atompub.test.spec.CreateTest; +import org.apache.chemistry.tck.atompub.test.spec.DeleteTest; +import org.apache.chemistry.tck.atompub.test.spec.FolderChildrenTest; +import org.apache.chemistry.tck.atompub.test.spec.FolderHierarchyTest; +import org.apache.chemistry.tck.atompub.test.spec.GetTest; +import org.apache.chemistry.tck.atompub.test.spec.QueryPagingTest; +import org.apache.chemistry.tck.atompub.test.spec.QueryTest; +import org.apache.chemistry.tck.atompub.test.spec.RepositoryServiceTest; +import org.apache.chemistry.tck.atompub.test.spec.TypeDefinitionTest; +import org.apache.chemistry.tck.atompub.test.spec.UpdateTest; +import org.apache.chemistry.tck.atompub.test.spec.VersionsTest; + +/** + * Suite of all TCK Tests + */ +public class TCKTestSuite extends TestCase { + + public static Test suite() + { + TestSuite suite = new TestSuite(); + + // spec tests + suite.addTestSuite(RepositoryServiceTest.class); + suite.addTestSuite(TypeDefinitionTest.class); + suite.addTestSuite(CreateTest.class); + suite.addTestSuite(GetTest.class); + suite.addTestSuite(DeleteTest.class); + suite.addTestSuite(FolderChildrenTest.class); + suite.addTestSuite(FolderHierarchyTest.class); + suite.addTestSuite(ContentStreamTest.class); + suite.addTestSuite(UpdateTest.class); + suite.addTestSuite(QueryTest.class); + suite.addTestSuite(QueryPagingTest.class); + suite.addTestSuite(AllowableActionsTest.class); + suite.addTestSuite(VersionsTest.class); + + // custom type tests + // TODO: when mechanism for registering custom types is done + + return suite; + } + +} Propchange: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/TCKTestSuite.java ------------------------------------------------------------------------------ svn:eol-style = native Copied: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/ContentStreamTest.java (from r807547, incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/ContentStreamTest.java) URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/ContentStreamTest.java?p2=incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/ContentStreamTest.java&p1=incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/ContentStreamTest.java&r1=807547&r2=808023&rev=808023&view=diff ============================================================================== --- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/ContentStreamTest.java (original) +++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/ContentStreamTest.java Wed Aug 26 14:19:11 2009 @@ -35,7 +35,7 @@ public void testContentStreamEmpty() throws Exception { // create document for setting / getting content - Entry document = fixture.createTestDocument("testContent", "createDocumentNoContent.atomentry.xml"); + Entry document = fixture.createTestDocument("testContent", "createdocumentNoContent.atomentry.xml"); // retrieve content client.executeRequest(new GetRequest(document.getContentSrc().toString()), 404); Copied: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/FolderHierarchyTest.java (from r807547, incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/FolderHierarchyTest.java) URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/FolderHierarchyTest.java?p2=incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/FolderHierarchyTest.java&p1=incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/FolderHierarchyTest.java&r1=807547&r2=808023&rev=808023&view=diff ============================================================================== --- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/FolderHierarchyTest.java (original) +++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/FolderHierarchyTest.java Wed Aug 26 14:19:11 2009 @@ -23,6 +23,7 @@ import org.apache.abdera.model.Feed; import org.apache.abdera.model.Link; import org.apache.chemistry.abdera.ext.CMISCapabilities; +import org.apache.chemistry.tck.atompub.TCKSkipCapabilityException; import org.apache.chemistry.tck.atompub.TCKTest; import org.apache.chemistry.tck.atompub.fixture.AssertValidObjectParentsVisitor; import org.apache.chemistry.tck.atompub.fixture.CMISTree; @@ -35,22 +36,6 @@ */ public class FolderHierarchyTest extends TCKTest { - public void testGetFolderTreeMinusOne() throws Exception { - getFolderTreeDepthN(3, -1); - } - - public void testGetFolderTreeOne() throws Exception { - getFolderTreeDepthN(3, 1); - } - - public void testGetFolderTreeExactDepth() throws Exception { - getFolderTreeDepthN(3, 3); - } - - public void testGetFolderTreeOverDepth() throws Exception { - getFolderTreeDepthN(3, 4); - } - private void getFolderTreeDepthN(int depth, int getDepth) throws Exception { // construct hierarchy of folders and docs EntryTree folderTree = fixture.createTestTree("foldertree", depth, 2, null, null); @@ -69,40 +54,20 @@ Assert.assertFalse(folderTree.equalsTree(retrievedFoldersOnly)); } - public void testGetDescendantsMinusOne() throws Exception { - CMISCapabilities capabilities = client.getCapabilities(); - if (!capabilities.getDescendants()) { - skipTest("Capabilities Get Descendants: false"); - return; - } - getDescendantsDepthN(3, -1); + public void testGetFolderTreeMinusOne() throws Exception { + getFolderTreeDepthN(3, -1); } - public void testGetDescendantsOne() throws Exception { - CMISCapabilities capabilities = client.getCapabilities(); - if (!capabilities.getDescendants()) { - skipTest("Capabilities Get Descendants: false"); - return; - } - getDescendantsDepthN(3, 1); + public void testGetFolderTreeOne() throws Exception { + getFolderTreeDepthN(3, 1); } - public void testGetDescendantsExactDepth() throws Exception { - CMISCapabilities capabilities = client.getCapabilities(); - if (!capabilities.getDescendants()) { - skipTest("Capabilities Get Descendants: false"); - return; - } - getDescendantsDepthN(3, 3); + public void testGetFolderTreeExactDepth() throws Exception { + getFolderTreeDepthN(3, 3); } - public void testGetDescendantsOverDepth() throws Exception { - CMISCapabilities capabilities = client.getCapabilities(); - if (!capabilities.getDescendants()) { - skipTest("Capabilities Get Descendants: false"); - return; - } - getDescendantsDepthN(3, 4); + public void testGetFolderTreeOverDepth() throws Exception { + getFolderTreeDepthN(3, 4); } private void getDescendantsDepthN(int depth, int getDepth) throws Exception { @@ -121,6 +86,33 @@ EntryTree retrievedDescendantsOnly = new CMISTree(descendantsTree, descendants); Assert.assertTrue(constructedDescendantsOnly.equalsTree(retrievedDescendantsOnly)); } + + private void checkGetDescendantsCapability() throws TCKSkipCapabilityException, Exception { + CMISCapabilities capabilities = client.getCapabilities(); + if (!capabilities.getDescendants()) { + throw new TCKSkipCapabilityException("getDescendants", "true", "false"); + } + } + + public void testGetDescendantsMinusOne() throws Exception { + checkGetDescendantsCapability(); + getDescendantsDepthN(3, -1); + } + + public void testGetDescendantsOne() throws Exception { + checkGetDescendantsCapability(); + getDescendantsDepthN(3, 1); + } + + public void testGetDescendantsExactDepth() throws Exception { + checkGetDescendantsCapability(); + getDescendantsDepthN(3, 3); + } + + public void testGetDescendantsOverDepth() throws Exception { + checkGetDescendantsCapability(); + getDescendantsDepthN(3, 4); + } public void testGetObjectParents() throws Exception { EntryTree folder = fixture.createTestTree("children", 3, 2, null, null); Copied: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/QueryPagingTest.java (from r807547, incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/QueryPagingTest.java) URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/QueryPagingTest.java?p2=incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/QueryPagingTest.java&p1=incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/QueryPagingTest.java&r1=807547&r2=808023&rev=808023&view=diff ============================================================================== --- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/QueryPagingTest.java (original) +++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/QueryPagingTest.java Wed Aug 26 14:19:11 2009 @@ -28,6 +28,7 @@ import org.apache.chemistry.abdera.ext.CMISCapabilities; import org.apache.chemistry.abdera.ext.CMISConstants; import org.apache.chemistry.abdera.ext.CMISObject; +import org.apache.chemistry.tck.atompub.TCKSkipCapabilityException; import org.apache.chemistry.tck.atompub.TCKTest; import org.apache.chemistry.tck.atompub.fixture.EntryTree; import org.apache.chemistry.tck.atompub.http.PostRequest; @@ -57,8 +58,7 @@ CMISCapabilities capabilities = client.getCapabilities(); String capability = capabilities.getQuery(); if (capability.equals("none")) { - skipTest("Query capability: " + capability); - return; + throw new TCKSkipCapabilityException("query", "anything other than none", capability); } // create folder and children to page through Copied: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/QueryTest.java (from r807547, incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/QueryTest.java) URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/QueryTest.java?p2=incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/QueryTest.java&p1=incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/QueryTest.java&r1=807547&r2=808023&rev=808023&view=diff ============================================================================== --- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/spec/QueryTest.java (original) +++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/QueryTest.java Wed Aug 26 14:19:11 2009 @@ -28,6 +28,7 @@ import org.apache.chemistry.abdera.ext.CMISCapabilities; import org.apache.chemistry.abdera.ext.CMISConstants; import org.apache.chemistry.abdera.ext.CMISObject; +import org.apache.chemistry.tck.atompub.TCKSkipCapabilityException; import org.apache.chemistry.tck.atompub.TCKTest; import org.apache.chemistry.tck.atompub.http.PostRequest; import org.apache.chemistry.tck.atompub.http.Request; @@ -73,9 +74,8 @@ public void testQueryFolderMetaData() throws Exception { CMISCapabilities capabilities = client.getCapabilities(); String capability = capabilities.getQuery(); - if (!(capability.equals("metadataonly") && capability.equals("bothseperate") && capability.equals("bothcombined"))) { - skipTest("Query capability: " + capability); - return; + if (!(capability.equals("metadataonly") || capability.equals("bothseperate") || capability.equals("bothcombined"))) { + throw new TCKSkipCapabilityException("query", "metadataonly or bothseparate or bothcombined", capability); } IRI queryHREF = client.getQueryCollection(client.getWorkspace()); @@ -106,10 +106,8 @@ public void testQueryDocumentMetaData() throws Exception { CMISCapabilities capabilities = client.getCapabilities(); String capability = capabilities.getQuery(); - if (!(capability.equals("metadataonly") && capability.equals("bothseperate") && capability - .equals("bothcombined"))) { - skipTest("Query capability: " + capability); - return; + if (!(capability.equals("metadataonly") || capability.equals("bothseperate") || capability.equals("bothcombined"))) { + throw new TCKSkipCapabilityException("query", "metadataonly or bothseparate or bothcombined", capability); } IRI queryHREF = client.getQueryCollection(client.getWorkspace()); @@ -141,9 +139,8 @@ public void testQueryDocumentFullText() throws Exception { CMISCapabilities capabilities = client.getCapabilities(); String capability = capabilities.getQuery(); - if (!(capability.equals("fulltextonly") && capability.equals("bothseperate") && capability.equals("bothcombined"))) { - skipTest("Query capability: " + capability); - return; + if (!(capability.equals("fulltextonly") || capability.equals("bothseperate") || capability.equals("bothcombined"))) { + throw new TCKSkipCapabilityException("query", "fulltextonly or bothseparate or bothcombined", capability); } IRI queryHREF = client.getQueryCollection(client.getWorkspace()); @@ -176,8 +173,7 @@ CMISCapabilities capabilities = client.getCapabilities(); String capability = capabilities.getQuery(); if (!capability.equals("bothcombined")) { - skipTest("Query capability: " + capability); - return; + throw new TCKSkipCapabilityException("query", "bothcombined", capability); } IRI queryHREF = client.getQueryCollection(client.getWorkspace()); @@ -211,8 +207,7 @@ CMISCapabilities capabilities = client.getCapabilities(); String capability = capabilities.getQuery(); if (capability.equals("none")) { - skipTest("Query capability: " + capability); - return; + throw new TCKSkipCapabilityException("query", "anything other than none", capability); } // retrieve query collection Added: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/tools/TCKRunner.java URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/tools/TCKRunner.java?rev=808023&view=auto ============================================================================== --- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/tools/TCKRunner.java (added) +++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/tools/TCKRunner.java Wed Aug 26 14:19:11 2009 @@ -0,0 +1,307 @@ +/* + * 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. + * + * Authors: + * David Caruana, Alfresco + */ +package org.apache.chemistry.tck.atompub.tools; + +import java.util.Enumeration; +import java.util.Properties; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestFailure; +import junit.framework.TestResult; +import junit.framework.TestSuite; +import junit.runner.BaseTestRunner; + +import org.apache.chemistry.tck.atompub.TCKMessageWriter; +import org.apache.chemistry.tck.atompub.TCKTest; +import org.apache.chemistry.tck.atompub.TCKTestResult; +import org.apache.chemistry.tck.atompub.utils.LogMessageWriter; + + +/** + * Test Runner for AtomPub TCK + */ +public class TCKRunner extends BaseTestRunner { + + private TCKRunnerOptions options; + private TCKMessageWriter messageWriter; + private TestSuite testSuite; + + /** + * Construct + */ + public TCKRunner() { + this(new LogMessageWriter()); + } + + /** + * Construct + * + * @param messageWriter message writer for all output + */ + public TCKRunner(TCKMessageWriter messageWriter) { + this(new TCKRunnerOptions(System.getProperties()), messageWriter); + } + + /** + * Construct + * + * @param options TCK runner options + */ + public TCKRunner(TCKRunnerOptions options) { + this(options, new LogMessageWriter()); + } + + /** + * Construct + * + * @param options TCK runner options + * @param messageWriter message writer for all output + */ + public TCKRunner(TCKRunnerOptions options, TCKMessageWriter messageWriter) { + String testSuiteName = options.getTestSuiteName(); + Test test = getTest(testSuiteName); + if (test == null) { + throw new IllegalArgumentException("Failed to create Test Suite " + testSuiteName); + } + if (!(test instanceof TestSuite)) { + throw new IllegalArgumentException("Test suite " + testSuiteName + " is not a TestSuite"); + } + this.options = options; + this.testSuite = (TestSuite) test; + this.messageWriter = messageWriter; + } + + /** + * @return options + */ + public TCKRunnerOptions getOptions() { + return options; + } + /** + * @return array of all available test names + */ + public String[] getTestNames() { + return getFilteredTestNames(options.getTestFilter()); + } + + /** + * @param filter + * @return array of test names filtered by filter + */ + public String[] getFilteredTestNames(String filter) { + TestSuite all = flattenTestSuite(testSuite, filter); + String[] names = new String[all.testCount()]; + for (int i = 0; i < all.testCount(); i++) { + Test test = all.testAt(i); + names[i] = getTestName(test); + } + return names; + } + + /** + * @return test suite containing flatten list of all tests + */ + public TestSuite getTests() { + TestSuite all = flattenTestSuite(testSuite, options.getTestFilter()); + return all; + } + + /** + * Execute TCK tests + * @param properties configuration of TCK tests (see TCKOptions) + */ + public void execute(Properties properties) { + // flatten tests and filter according to tests mask + String filter = options.getTestFilter(); + TestSuite suite = flattenTestSuite((TestSuite) testSuite, filter); + for (int i = 0; i < suite.testCount(); i++) { + Test test = suite.testAt(i); + if (test instanceof TCKTest) { + ((TCKTest) test).setMessageWriter(messageWriter); + ((TCKTest) test).setOptions(options); + } + } + + // execute the suite + messageWriter.info("Executing tests: " + filter); + TCKTestResult testResult = new TCKTestResult(new TestResult(), null); + testResult.addListener(this); + suite.run(testResult); + + // print summary + printErrors(testResult); + printFailures(testResult); + printFooter(testResult); + } + + @Override + protected void runFailed(String message) { + messageWriter.info(message); + } + + @Override + public void testEnded(String testName) { + } + + @Override + public void testFailed(int status, Test test, Throwable t) { + messageWriter.info("Failed: " + test.toString() + " , Error: " + t.getMessage()); + } + + @Override + public void testStarted(String testName) { + } + + /** + * Flatten a hierarchy of test suites into a list of tests + * + * @param suite test suite to flatten + * @param filter mask (name) to filter out tests + * @return test suite of flatten tests + */ + private TestSuite flattenTestSuite(TestSuite suite, String filter) { + FilterVisitor visitor = new FilterVisitor(filter); + visitTests(suite, visitor); + return visitor.getSuite(); + + } + + /** + * @param test + * @return test name + */ + private String getTestName(Test test) { + return test.getClass().getSimpleName() + "." + ((TestCase) test).getName(); + } + + /** + * Visit each test in test suite hierarchy + * + * @param test test suite or test case + * @param visitor callback + */ + private void visitTests(Test test, TestVisitor visitor) { + if (test instanceof TestCase) { + visitor.visitTest(test); + } else if (test instanceof TestSuite) { + TestSuite suite = (TestSuite) test; + for (int i = 0; i < suite.testCount(); i++) { + visitTests(suite.testAt(i), visitor); + } + } + } + + /** + * Test visitor callback + */ + private interface TestVisitor { + public void visitTest(Test test); + } + + /** + * Visitor that flattens and filters test suite + */ + private class FilterVisitor implements TestVisitor { + private String filter; + private TestSuite suite; + + public FilterVisitor(String filter) { + this.filter = filter; + this.suite = new TestSuite(); + } + + public void visitTest(Test test) { + if (filter == null || filter.equals(TCKRunnerOptions.FILTER_WILDCARD) + || getTestName(test).matches(filter.replace(TCKRunnerOptions.FILTER_WILDCARD, "[A-Za-z0-9]*"))) { + suite.addTest(test); + } + } + + public TestSuite getSuite() { + return suite; + } + } + + protected void printErrors(TCKTestResult result) { + printDefects(result.errors(), result.errorCount(), "error"); + } + + protected void printFailures(TCKTestResult result) { + printDefects(result.failures(), result.failureCount(), "failure"); + } + + protected void printDefects(Enumeration booBoos, int count, String type) { + if (count == 0) + return; + messageWriter.info(""); + if (count == 1) + messageWriter.info("There was " + count + " " + type + ":"); + else + messageWriter.info("There were " + count + " " + type + "s:"); + for (int i = 1; booBoos.hasMoreElements(); i++) { + printDefect(booBoos.nextElement(), i); + } + } + + public void printDefect(TestFailure booBoo, int count) { + printDefectHeader(booBoo, count); + printDefectTrace(booBoo); + } + + protected void printDefectHeader(TestFailure booBoo, int count) { + messageWriter.info(count + ") " + booBoo.failedTest()); + } + + protected void printDefectTrace(TestFailure booBoo) { + messageWriter.info(BaseTestRunner.getFilteredTrace(booBoo.trace())); + } + + protected void printFooter(TCKTestResult result) { + if (result.wasSuccessful()) { + messageWriter.info(""); + messageWriter.info("OK"); + messageWriter.info(result.runCount() + " successful test" + (result.runCount() == 1 ? "" : "s")); + messageWriter.info(result.skipCount() + " skipped test" + (result.skipCount() == 1 ? "" : "s")); + } else { + messageWriter.info(""); + messageWriter.info("FAILURES!!!"); + messageWriter.info("Tests run: " + result.runCount()); + messageWriter.info("Failures: " + result.failureCount()); + messageWriter.info("Errors: " + result.errorCount()); + } + } + + /** + * Main entry point + * + * @param args (see TCKOptions) + */ + public static void main(String args[]) { + // build properties from arguments + Properties properties = new Properties(); + for (String arg : args) { + String[] argComponents = arg.split("="); + properties.setProperty(argComponents[0], argComponents[1]); + } + + // construct and start runner + TCKRunner runner = new TCKRunner(new TCKRunnerOptions(properties), new LogMessageWriter()); + runner.execute(properties); + } + +} \ No newline at end of file Propchange: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/tools/TCKRunner.java ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/tools/TCKRunnerOptions.java URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/tools/TCKRunnerOptions.java?rev=808023&view=auto ============================================================================== --- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/tools/TCKRunnerOptions.java (added) +++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/tools/TCKRunnerOptions.java Wed Aug 26 14:19:11 2009 @@ -0,0 +1,54 @@ +/* + * 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. + * + * Authors: + * David Caruana, Alfresco + */ +package org.apache.chemistry.tck.atompub.tools; + +import java.util.Properties; + +import org.apache.chemistry.tck.atompub.TCKOptions; +import org.apache.chemistry.tck.atompub.test.TCKTestSuite; + +public class TCKRunnerOptions extends TCKOptions { + + public static final String FILTER_WILDCARD = "*"; + public static final String TCK_TEST_SUITE = TCKTestSuite.class.getName(); + + private static final long serialVersionUID = 4441003106227678366L; + private final static String PROP_TEST_SUITE = "chemistry.tck.testSuite"; + private final static String PROP_TESTS = "chemistry.tck.tests"; + + + public TCKRunnerOptions(Properties properties) { + super(properties); + } + + /** + * @return test suite name (default: TCK test suite) + */ + public String getTestSuiteName() { + String val = properties.getProperty(PROP_TEST_SUITE); + return (val == null || val.length() == 0) ? TCK_TEST_SUITE : val; + } + + /** + * @return test names to execute (default: *, empty string = no tests) + */ + public String getTestFilter() { + String val = properties.getProperty(PROP_TESTS); + return val != null ? val : FILTER_WILDCARD; + } + +} Propchange: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/tools/TCKRunnerOptions.java ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/utils/LogMessageWriter.java URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/utils/LogMessageWriter.java?rev=808023&view=auto ============================================================================== --- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/utils/LogMessageWriter.java (added) +++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/utils/LogMessageWriter.java Wed Aug 26 14:19:11 2009 @@ -0,0 +1,39 @@ +/* + * 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.apache.chemistry.tck.atompub.utils; + +import org.apache.chemistry.tck.atompub.TCKMessageWriter; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class LogMessageWriter implements TCKMessageWriter { + + public static final Log logger = LogFactory.getLog(TCKMessageWriter.class); + + public void info(String message) { + if (logger.isInfoEnabled()) + logger.info(message); + } + + public void warn(String message) { + if (logger.isWarnEnabled()) + logger.warn(message); + } + + public void trace(String message) { + if (logger.isTraceEnabled()) + logger.trace(message); + } + +} Propchange: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/utils/LogMessageWriter.java ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/TCKTestSuiteTest.java URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/TCKTestSuiteTest.java?rev=808023&view=auto ============================================================================== --- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/TCKTestSuiteTest.java (added) +++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/TCKTestSuiteTest.java Wed Aug 26 14:19:11 2009 @@ -0,0 +1,18 @@ +package org.apache.chemistry.tck.atompub.test; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.apache.chemistry.tck.atompub.tools.TCKRunner; + +/** + * TCK Test + */ +public class TCKTestSuiteTest extends TestSuite { + + public static Test suite() + { + TCKRunner runner = new TCKRunner(); + return runner.getTests(); + } +} Propchange: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/java/org/apache/chemistry/tck/atompub/test/TCKTestSuiteTest.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/resources/log4j.xml URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/resources/log4j.xml?rev=808023&r1=808022&r2=808023&view=diff ============================================================================== --- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/resources/log4j.xml (original) +++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/test/resources/log4j.xml Wed Aug 26 14:19:11 2009 @@ -13,8 +13,8 @@ - - + +