|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.w3c.mwi.mobileok.basic.Tester
public final class Tester
Runs tests on an HTTP(S) resource identified by its URI.
An instance of the Tester
class is bound to a Web resource
when it is first instanciated. The runTests()
method can then
be used to run the tests, and retrieve the final mobileOK report as an
instance of the TestResults
class.
The internal moki representation of the Web resource under test can
also be retrieved through the getPreprocessorResults()
method.
The class also defines the static main(String[])
entry-point method,
triggered when the mobileOK Checker library is used as a stand-alone program
and run from the command-line.
NB: the mobileOK Checker only supports the
HTTP
and HTTPS
URI schemes. The mobileOK Checker
will return an HTTPErrorsType.HTTP_RESPONSE_1
error message when run
on a URI with a different scheme.
Sample usage as a library:
import org.w3c.mwi.mobileok.basic;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
javax.xml.transform.dom.DOMSource;
Tester tester = new Tester(new URI("http://example.org"));
TestResults results = tester.runTests();
TransformerFactory tFactory = TransformerFactory.newInstance();
StreamResult result = new StreamResult(System.out);
tFactory.newTransformer().transform(new DOMSource(results.getIntermediateResultsDOM()), result);
tFactory.newTransformer().transform(new DOMSource(results.getTestResultsDOM()), result);
Command-line usage when standalone:
Tester [options] URI
-m <arg> moki filename
-p <arg> proxyHost:proxyPort
-pass <arg> user password
-r <arg> result filename
-user <arg> user name
The version of the mobileOK Checker Java Library maintained by the W3C mobileOK Checker Task Force is a reference implementation of the W3C mobileOK Basic Tests 1.0 W3C standard, which means that it implements all the mobileOK tests formally defined in the document and only them. It may be used to claim that a Web resource is mobileOK.
TestResults
,
PreprocessorResults
Field Summary | |
---|---|
private Preprocessor |
preprocessor
Preprocessor used to build the intermediary moki
representation of the resource under test. |
Constructor Summary | |
---|---|
private |
Tester(java.io.File file)
Creates a class instance bound to a file. |
|
Tester(java.net.URI uri)
Creates a class instance bound to a URI. |
Method Summary | |
---|---|
private static java.net.URI |
fileToURI(java.io.File file)
Returns the file URI of the given file. |
PreprocessorResults |
getPreprocessorResults()
Returns the intermediate moki representation of the
resource bound to this instance. |
static void |
main(java.lang.String... args)
Main entry-point of the mobileOK Checker library when the library is used as a stand-alone application. |
TestResults |
runTests()
Runs all defined tests on the URI bound to this instance. |
TestResults |
runTests(java.util.List<TestImplementation> tests)
Runs a precise list of tests on the URI bound to this instance. |
private static void |
usage(org.apache.commons.cli.Options options)
Helper static method that prints the list of options that may be set to run the mobileOK Checker from the command-line. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final Preprocessor preprocessor
moki
representation of the resource under test.
Constructor Detail |
---|
public Tester(java.net.URI uri)
The mobileOK Checker only supports the HTTP
and
HTTPS
URI schemes. Instanciation won't fail if the
URI uses another scheme, but the Checker won't be able to
retrieve the resource and will return an HTTPErrorsType.HTTP_RESPONSE_1
error message.
uri
- URI of the HTTP(S) that needs to be checked.private Tester(java.io.File file)
There is actually no support for the file
scheme
within the mobileOK Checker. This constructor is thus more of a
placeholder for a potential future feature of the mobileOK Checker.
The constructor is flagged as private
in the meantime
not to create confusion of false expectations.
file
- file resource that needs to be checked.Method Detail |
---|
private static java.net.URI fileToURI(java.io.File file)
file
URI of the given file.
file
- file whose URI needs to be extracted.Tester(File)
public PreprocessorResults getPreprocessorResults() throws TestException
moki
representation of the
resource bound to this instance.
If not already done, the moki
representation is created,
which means that the first call to this method may take a lot of time,
and/or fail.
The TesterConfiguration
that needs to be used to build the moki
representation of the resource must be set prior to calling this method.
moki
representation of the resource.
TestException
- an unexpected error occurred while creating the
intermediate moki
representation of the resource,
or the TesterConfiguration instance has not been set through
a call to TesterConfiguration.setConfiguration(TesterConfiguration)
.public TestResults runTests() throws TestException
Creates the intermediate moki
representation of the
resource if not already done through a call to getPreprocessorResults()
.
The TesterConfiguration
that needs to be used to build the moki
representation of the resource must be set prior to calling this method.
TestException
- an unexpected error occurred while creating the
intermediate moki
representation of the resource,
or the TesterConfiguration instance has not been set through
a call to TesterConfiguration.setConfiguration(TesterConfiguration)
.public TestResults runTests(java.util.List<TestImplementation> tests) throws TestException
The intermediate moki
representation of the resource
is available through a call to getPreprocessorResults()
.
tests
- the list of tests to run
TestException
- an unexpected error occurred or the tester
configuration is missing.public static void main(java.lang.String... args) throws java.lang.Exception
The method extracts the arguments from the command-line, runs the
Checker on the given URI and returns the intermediary moki
representation of the URI and the final report as XML streams
(either to the standard output or to some given file).
Command-line usage:
Tester [options] URI
-m <arg> moki filename
-p <arg> proxyHost:proxyPort
-pass <arg> user password
-r <arg> result filename
-user <arg> user name
java.lang.Exception
- an unexpected error occurred.private static void usage(org.apache.commons.cli.Options options)
options
- the list of command-line options to print.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |