W3C home > Mailing lists > Public > public-mobileok-checker@w3.org > March 2007

Another draft of test framework

From: Sean Owen <srowen@google.com>
Date: Thu, 1 Mar 2007 14:12:41 -0500
Message-ID: <e920a71c0703011112g6aa5475fhe513978102408b8e@mail.gmail.com>
To: public-mobileok-checker@w3.org
Here's another cut at a test framework. It exposes intermediate test
states in the HTTP-in-RDF vocab, and results in the EARL vocab, per my
ACTION. Also per my ACTION I'm offering this overview of the code for
discussion as we need to decide whether this is roughly OK as a
starting point or not.

Attached is source, a sample of the intermediate output XML at the
moment, and a sample of the EARL results.


All code is in package org.w3c.mwi.mobileok.basic. Depends on Java 5,
Commons Codec, Commons HttpClient, Commons Logging.


THE PUBLIC API

Tester
This is the top-level abstraction which runs the test. It can be
constructed to operate on a file, a URI, or can be given the HTTP
response body and headers directly. It exposes a runTests() method
that runs everything, or, runTest() which runs just one test.

TestType
Just an enum of all test types.

TestResults
TestResult
Returned by runTests() and runTest() respectively, and encapsulate the
results of many tests and one test, respectively. TestResults includes
many TestResult instances. These objects include test outcome,
warnings, and information.

TestOutcome
Just an enum of PASS and FAIL, the two test outcomes

TestException
Throw if something goes wrong in the tester -- that is, not just that
there was an error accessing the document but that something is wrong
with the tester.


NON-PUBLIC INTERNALS

TestImplementation
AbstractTestImplementation
There's an implementation of TestImplementation for each mobileOK
basic test, and AbstractTestImplementation fills the usual role of
holding bits of logic common to implementations.

TestContext
Packages all the details of the preprocessing done by Tester, like the
results of retrieving the resource, for all implementations to use.

HTTPResource
HTTPTextResource
Encapsulates an HTTP request, its execution, and the response.
HTTPTextResource just extends this to try to treat the body as text
and make it available as a String

CachingTest, etc.
Implementations for particular mobileOK basic tests.


SAMPLE USAGE IN JAVA
... which just prints results to System.out

		final Tester tester = new Tester(new URI("http://foobar.com"));
		final TestResults results = tester.runTests();

		final TransformerFactory tFactory = TransformerFactory.newInstance();
		final StreamResult result = new StreamResult(System.out);
		tFactory.newTransformer().transform(new
DOMSource(results.getIntermediateResultsDOM()), result);
		tFactory.newTransformer().transform(new
DOMSource(results.getTestResultsDOM()), result);


Received on Thursday, 1 March 2007 19:13:19 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 8 January 2008 14:13:02 GMT