Package org.w3c.mwi.mobileok.basic

The package contains the mobileOK Checker Java library that is a reference implementation of the W3C mobileOK Basic Tests 1.0 standard, and may be used to claim mobileOK conformance, or in a more generic way to build a moki representation of a Web resource and run a series of tests against it.

See:
          Description

Interface Summary
DecodedContentFactory Interface that must be implemented by resource factories.
HostnameVerifier Interface for checking if a hostname matches the names stored in an X.509 certificate.
ResourceExtractor Interface that must be implemented by all resource extractors.
ResourceRetriever Interface that must be implemented by Web resource retrievers.
ResourceRetrieverFactory Interface that must be implemented by resource retriever factories.
RetrievalElement Interface that represents a client/server exchange when a Web resource is being retrieved.
TestImplementation Tests that may be run by the Checker must implement the TestImplementation interface.
 

Class Summary
AbstractCSSTestImplementation Abstract implementation of AbstractTestImplementation that provides helper methods to parse the CSS styles (whether inline, embedded or external) defined in the Web resource under test.
AbstractCSSTestImplementation.TestErrorInfo  
AbstractTestImplementation Abstract implementation of the TestImplementation interface for test implementations that return the outcome of the test as a DOM tree.
AbstractXSLTTestImplementation Abstract implementation of AbstractTestImplementation for tests that apply an XSL stylesheets to the DOM moki representation of the Web resource returned by PreprocessorResults.getMokiDocument().
AutoRefreshTest Implements the AUTO_REFRESH and REDIRECTION mobileOK test.
CachingTest Implements the CACHING mobileOK test.
CharacterEncodingSupportTest Implements the CHARACTER_ENCODING_SUPPORT and CHARACTER_ENCODING_USE mobileOK test.
ClasspathURIResolver A URIResolver which is aware of resources available from the classpath, and not just from the file system or "real" URIs.
ContentFormatSupportTest Implements the CONTENT_FORMAT_SUPPORT mobileOK test.
CssContent Represents a CSS content.
CSSMediaHandler Handler for CSS stylesheets documents that checks whether all the CSS styles apply to media types other than all and handheld.
CssResourceExtractor Extracts CSS resources referenced by the given resource that apply to the handheld or all media type.
CSSUtils Static helper class that defines useful methods to parse and validate CSS resources using the W3C CSS Validator.
DecodedContent Represents the decoded content of a resource.
DefaultInputModeTest Implements the DEFAULT_INPUT_MODE mobileOK test.
DOMUtils Static helper class that defines useful constants and methods to build and parse DOM trees.
DOMUtils.XSLTURIResolver  
ExtendedCatalogResolver Catalog to entity resolver wrapper that makes it possible to use a CatalogResolver as an EntityResolver for XHTML validation purpose.
ExternalResourcesTest Implements the EXTERNAL_RESOURCES mobileOK test.
FailedRetrievalElement An instance of the class represents an exchange that failed during while trying to retrieve a resource
FragmentRetrievalElement An instance of the class represents a textual fragment of a retrieved resource.
GifImageContent Represents a image/gif image resource.
GraphicsForSpacingTest Implements the GRAPHICS_FOR_SPACING mobileOK test.
HostnameVerifier.AbstractVerifier  
HttpResourceRetriever Resource retriever that handles the HTTP scheme.
HttpRetrievalElement An instance of the class represents an HTTP client/server exchange, i.e.
ImageContent Abstract class that represents an image resource with a defined width and height.
ImageMapsTest Implements the IMAGE_MAPS mobileOK test.
ImageResourceExtractor Extracts all image resources embedded in the given XHTML resource.
ImagesSpecifySizeTest Implements the IMAGES_SPECIFY_SIZE mobileOK test.
InCssResourceExtractor Extracts resources (images and imported CSS stylesheets) defined in the given CSS stylesheets.
JpegImageContent Represents a image/jpeg image resource.
LinkedResourceExtractor Extracts all linked resources from a given XHTML resource.
LinkTargetFormatTest Implements the LINK_TARGET_FORMAT mobileOK test.
MainDocumentTest Implements side tests performed on the Web resource under test, and in particular the tests on the meta element with an http_equiv attribute as defined in Meta http-equiv Elements in the W3C mobileOK Basic Tests 1.0 standard.
MeasuresTest Implements the mobileOK MEASURES test.
MinimizeTest Implements the MINIMIZE mobileOK test.
MobileOKCatalog Modified version of Catalog that can also read catalog files from the classpath.
MobileOKConfiguration mobileOK configuration generator.
MobileOKDecodedContentFactory mobileOK decoded content factory implementation.
MobileOKNamespaceContext Defines mobileOK namespaces prefixes that can be used in XPath expressions.
MobileOKResourceRetrieverFactory mobileOK resource retriever factory implementation.
MobileOKSSLProtocolSocketFactory SSL factory to use to create and check secure sockets to a remote host against the mobileOK trust rules defined in the HTTPS section of the W3C mobileOK Basic Tests 1.0 standard.
MobileOKTrustManager Trust manager that checks the validity of an X509 server certificate against the mobileOK trust rules defined in the HTTPS section of the W3C mobileOK Basic Tests 1.0 standard.
NoFramesTest Implements the NO_FRAMES mobileOK test.
NonTextAlternativesTest Implements the NON_TEXT_ALTERNATIVES mobileOK test.
NotSupportedContent Class that represents a resource whose content-type is not supported, or whose content-type is not supported within the context of the resource.
NotSupportedImageContent Represents a image/jpeg image resource.
ObjectResourceExtractor Extracts resources defined within object elements in the given XHTML resource, and resources defined in img elements that appear as the fallback content of an object element that would not be rendered by browsers.
ObjectsOrScriptTest Implements the OBJECTS_OR_SCRIPT mobileOK test.
PageSizeLimitTest Implements the PAGE_SIZE_LIMIT mobileOK test.
PageTitleTest Implements the PAGE_TITLE mobileOK test.
PopUpsTest Implements the POP_UPS mobileOK test.
Preprocessor Creates the intermediate moki representation of an HTTP(S) resource from its URI.
PreprocessorResults Encapsulates the moki representation of a primary Web resource and of all the Web resources it might import, embed, or link to.
ProvideDefaultsTest Implements the PROVIDE_DEFAULTS mobileOK test.
PseudoAttributes Helper class to parse the pseudo-attributes of an XML processing instruction as real attributes.
Resource Encapsulates information and basic functionality to represent Web resources.
ResourceComparator Compares Resources based on their context and their URI.
ResourceContext The ResourceType class is an extensible enumeration of the types of resources that may be handled by the Checker.
RetrievalFailedContent Class that represents a resource that could not be retrieved because some of some network error.
StyleSheetsSupportTest Implements the STYLE_SHEETS_SUPPORT mobileOK test.
StyleSheetsUseTest Implements the STYLE_SHEETS_USE mobileOK test.
TablesAlternativesTest Implements the TABLES_ALTERNATIVES mobileOK test.
TablesLayoutTest Implements the TABLES_LAYOUT mobileOK test.
TablesNestedTest Implements the TABLES_NESTED mobileOK test.
Tester Runs tests on an HTTP(S) resource identified by its URI.
TesterConfiguration Encapsulates configuration options that determine how the Checker behaves in terms of resource preprocessing and tests checking.
TestResult Encapsulates the outcome of a single test.
TestResults Encapsulates tests outcomes.
TestSubResult Encapsulates the outcome of a single subtest.
TestSubResultBytePosition Represents a position as a byte offset in a binary representation of a Web resource.
TestSubResultGeneralPosition Represents a position that merely consists of the URI of the Web resource.
TestSubResultHeaderPosition Represents a position that is an HTTP header field of a Web resource.
TestSubResultLineColumnPosition Represents a line/column position in a textual representation of a Web resource.
TestSubResultPosition Abstract class that defines the position or the resource that made a TestSubResult subtest WARN or FAIL.
TextContent Base class that represents an UTF-8 encoded text content.
ThirdPartiesMessageUtils Static helper class that provides methods to convert error messages returned by third partiy tools to ValidationByteMessage messages.
ValidationByteMessage Represents a validation error in a stream, including message and location.
ValidationLineAndColumnMessage Represents a validation error in a text, including message and location in a line/column form.
XhtmlContent Represents an XHTML resource.
XhtmlContent.CommonCatalogResolver  
XhtmlContent.MinimizeHandler  
XhtmlContent.XHTMLCatalogResolver  
XHTMLValidationErrorHandler Handler for XML validation errors.
 

Enum Summary
CssContent.CssType Describes the different types of CSS content that may be handled.
FragmentBoxType Defines the different boxing types of a resource fragment.
HeaderParseMethod Enumerates the possible HTTP header fields values parsing rules and maps well-known HTTP header fields to parsing rules.
HTTPErrorsType Enumerates all the possible HTTPS and HTTP Response errors that may be returned by the Preprocessor while trying to create the internal moki representation of the Web resource under test.
Resource.LoadType Describes the different ways that a typical browser would handle a resource.
TestOutcome Represents the outcome of a test, a subtest, or a series of tests.
TestSubResultPositionType Enumerates the different types of positions that may be set in subtests that return a WARN or a FAIL.
TestType Enumerates the individual tests run by the mobileOK Checker.
XHTMLValidationStatus Enumerates the different possible XML validation status.
 

Exception Summary
SSLHostnameUnverifiedException Exception thrown when a hostname does not match the names of an X.509 certificate.
TestException An exception thrown when an internal, unexpected testing error is encountered.
 

Package org.w3c.mwi.mobileok.basic Description

The package contains the mobileOK Checker Java library that is a reference implementation of the W3C mobileOK Basic Tests 1.0 standard, and may be used to claim mobileOK conformance, or in a more generic way to build a moki representation of a Web resource and run a series of tests against it.

The Javadoc contains details about the classes of the mobileOK Checker. Methods and fields are not entirely documented.

The library was developped with extensibility in mind. The library in itself only contains tests and material required to check whether a Web resource is mobileOK, but can be easily completed without having to change the code of the library itself to support more URI schemes, different processing rules, different tests, ...

The library may either be used as a real library and hooked up in another application, or as a standalone command-line application.

Overview

The main entry-point of the library is the Tester class. Processing is splitted in 2 steps:

  1. the pre-processing step where the resource to test is retrieved and the moki representation of the resource is created.
  2. the testing step where tests are run on the moki representation of the resource.

Pre-processing step

The Preprocessor class handles the pre-processing. Its goal is to generate the moki representation of the resource under test. The moki representation of a given resource contains more information than just the resource in itself. It also contains information about the stylesheets that may be referenced by the resource, the images and objects that may be embedded in the content, and links that may appear in the resource under test.

The moki representation is thus created from a list of retrieved Resources. A Resource is defined as:

Each created Resource is:

  1. retrieved
  2. decoded
  3. parsed to extract additional resources

The processing goes on until all the resources needed to build the final moki representation of the initial resource have been retrieved and decoded.

Resource retrieval

Resource retrieval is done by a ResourceRetriever, based on the scheme of the URI to retrieve. mobileOK only applies to HTTP/HTTPS URIs, and so the only implementation in the library is the HttpResourceRetriever class.

Resource retrieval generates a list of RetrievalElements that represent the client/server exchanges needed to retrieve the resource. The last RetrievalElement of the list should be the actual retrieved representation of the resource (or a FailedRetrievalElement if some network error occurred).

Decoded content

Once retrieved, a Resource is decoded and validated against its supposed content-type. Decoded content is created by a DecodedContentFactory. Decoded content extends the DecodedContent class.

The mobileOK-specific decoded content factory is implemented in the MobileOKDecodedContentFactory class. It creates various types of decoded content depending on the context that gave birth to the resource and on the content-type of the retrieval representation:

These classes can be serialized to their moki representation through a call to the DecodedContent.toMokiNode(Document, Node) function.

Extraction of additional resources

Once decoded, a Resource is parsed by one or more ResourceExtractor(s) to extract additional resources that need to be retrieved to build the final moki representation of the initial resource. Each ResourceExtractor should handle one type of resources to extract.

mobileOK defines the following resource extractors:

The list of extractors that are applied to resources may be overridden prior to running the pre-processing.

Note extractors create new resources that are in turn retrieved, decoded and parsed.

Tests running step

The Checker simply applies a list of TestImplementations to the moki representation created during the pre-processing step.

A TestImplementation must return a TestResult that will be used to generate the final report returned by the Checker.

The list of tests to apply may be overridden prior to running the Checker.

Extensibility

Although the mobileOK Checker library was developped as a reference implementation of the mobileOK standard, the library was written so that it can be used as a more generic resource checking framework. Many common needs that extend the purpose of the mobileOK standard can be implemented without having to change code in the library. If you think your specific need cannot be addressed without tweaking the code of the library itself, feel free to discuss it on the public-mobileok-checker@w3.org mailing-list. We would be happy to make the library more generic.

The flexibility comes from the fact that the configuration of the checker allows anyone to override mobileOK-specific settings. The configuration parameters are defined in the TesterConfiguration class.

The following sub-sections describe potential needs you may have, along with possible implementation solutions that do not require changes in the code of the library. The overall flexibility is somewhat slightly reduced by the schema of the moki representation. The schema may have to be updated in a future release to describe resources in a more generic way.

Changing the HTTP headers sent in HTTP requests

The mobileOK Checker uses specific values for the User-Agent, Accept, and Accept-Charset HTTP headers, as defined in the HTTP Request section of the mobileOK standard. To override these default values, simply define the new values when creating the instance of the TesterConfiguration class that will be used by the Checker, using the keys defined in HttpResourceRetriever:

Changing the list of tests

Tests must implement the TestImplementation interface. The list of tests that need to be applied needs to be defined when the configuration of the Checker is set anyway, so you simply need to define your own list of tests to have them run on the moki representation of the resource under test.

MobileOKConfiguration.getMobileOKTests() returns the mobileOK-specific list of tests.

Support for new URI schemes

Let's say you want to add support for the file scheme. You need to:

Support for new Content-Types

Let's say you want to add support for image/png images. You need to:

Support for new text encodings

XhtmlContent and CssContent derive from TextContent that only truly supports UTF-8. There is no easy way to add support for additional encodings for the time being. You would need to implement a new class that extends TextContent, and thus re-implement XhtmlContent and CssContent.

Support for an explicit list of encodings will probably be added to the TextContent class in some future release of the library.

Changing extraction rules

Parsing of decoded resources to extract additional resources rely on a list of ResourceExtractors. Again, all you have to do if you need to change or complete the extraction rules defined in mobileOK is to set your own list of ResourceExtractors that the Checker will use.

Related links