This document describes the design and usage of the mobileOK Basic Tests 1.0 reference implementation. It is intended to be useful to developers who wish to integrate the reference implementation into an existing application or infrastructure.
mobileOK Basic Tests 1.0 specifies the essential behavior required of all implementations, but leaves many other decisions up to particular implementations. It allows for implementations to provide additional functionality beyond what is required. So, this document also discusses implementation-specific decisions taken during development. These are intended to be useful to developers who are porting this implementation to another platform, or, developing a new implementation from scratch.
This reference implementation is written in Java and requires Java SE 5.0. It is a pure Java library, rather than an application. It is intended to be embedded in another application, possibly one that provides a GUI or web-based interface to its functionality.
In essence, the library accepts as input a URI, and outputs two sets of information. In the end, the test results are produced, of course. But much more information is also produced, concerning what occurred during testing -- specifically, detailed information about the document under test, its retrieval and parsing, some derived counts and statistics, and information on linked resources.
The test results output satisfies the requirements of mobileOK Basic Tests 1.0. It is simply the results of each of test, plus warning and informational messages. It is available via a native Java API (see TestResults
below), and also as an XML document which uses the Evaluation and Report Language (EARL) schema.
The additional output, named the "preprocessor" output, exists to aid extensibility. The reference implementation does a great deal of preprocessing before it begins test execution, so, it makes sense to expose the details of this preprocessing for other applications to use as well, even though it is not directly related to the test results.
The key API classes are:
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.
Just an enum of all test types.
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.
Just an enum of PASS
and FAIL
, the two test outcomes
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.
Tester tester = new Tester("http://example.org"); TestResults results = tester.runTests(); TestOutcome outcome = results.getOverallOutcome(); TestResult = results.getResultForTest(TestType.AUTO_REFRESH); ... TestResult oneResult = tester.runTest(TestType.AUTO_REFRESH);
While provided as a library, it is also possible to get quick results on the command line:
java -cp mobileOKBasic-RI.jar org.w3c.mwi.mobileok.basic.Tester http://example.org
This section discusses implementation decisions taken in design and development that were not dictated by the mobileOK Basic Tests specification.
The most noticeable feature of this implementation is that it exposes a large amount of information about the results of accessing and preprocessing the URI under test. It is exposed as a DOM from TestResults.getPreprocessorDocument()
which may be serialized and used by any external tool. The Appendices describe the format of this DOM in detail. This data structure contains the following information:
TODO
Test results are available from the method Tester.runTests()
, which returns a TestResults
object. The same information is available as a DOM from TestResults.getTestResultsDocument()
, in a format described in the Appendices. The format uses the EARL RDF vocabulary to describe the outcome. Test results are provided in this form as well to ease integration with external tools. The test results data structures include the following information:
PASS
or FAIL
)PASS
or FAIL
)This section contains notes that may be useful to developers who wish to build on this implementation to construct additional tests of mobile content beyond what is defined in mobileOK Basic.
TODO
It is expected that the most common cause of test failures is malformed markup. This will cause the VALID_MARKUP test to fail of course, and thus the entire test suite.
However, many tests must have a valid DOM to run and produce any useful information. It is of course desirable to provide as much information as possible to the person running the tests rather than completely fail on the common case of malformed markup.
So, in the event that the input document cannot be parsed into a DOM, this implementation will attempt to "tidy" the document and then re-run all tests. This does not change the fact that the overall test suite result is FAIL; however, this does potentially allow some tests to run and provide some useful feedback to the developer.
Like any good software library, this reference implementation includes automated tests. All tests are implemented using the standard JUnit framework. In addition to some unit tests of common code, this also includes a series of tests consisting of documents and associated HTTP headers plus expected output documents. This makes it easy to run the implementation on many example resources and verify that the implementation outputs expected test results.
Test cases may be found in subdirectories of test/testcases
. Each subdirectory contains:
index.html
The test harness starts an embedded Tomcat server to serve these resources, and employs a special servlet that reads the *.headers files and sets HTTP response headers appropriately. In this way, the implementation can be tested against a real HTTP server.
TODO
TODO