Package org.apache.batik.test.svg
Class SVGOnLoadExceptionTest
java.lang.Object
org.apache.batik.test.AbstractTest
org.apache.batik.test.svg.SVGOnLoadExceptionTest
- All Implemented Interfaces:
Test
This test takes an SVG file as an input. It processes the input SVG
(meaning it turns it into a GVT tree) and then dispatches the 'onload'
event.
In that process, the test checks for the occurence of a specific
exception type and, for BridgeExceptions, for a given error code.
If an exception of the given type (and, optionally, code) happens,
then the test passes. If an exception of an unexpected type
(or code, for BridgeExceptions) happens, or if no exception happens,
the test fails.
The following properties control the test's operation:
- Scripts: list of allowed script types (e.g., "application/java-archive")
- ScriptOrigin: "ANY", "DOCUMENT", "EMBEDED", "NONE"
- ResourceOrigin: "ANY", "DOCUMENT", "EMBEDED", "NONE"
- ExpectedExceptionClass (e.g., "java.lang.SecurityException")
- ExpectedErrorCode (e.g., "err.uri.unsecure")
- Validate (e.g., "true")
- Version:
- $Id: SVGOnLoadExceptionTest.java 1831626 2018-05-15 11:10:36Z ssteiner $
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Entry describign the expected error codestatic final String
Entry describing the expected exceptionstatic final String
Entry describing the unexpected error codestatic final String
Entry describing the unexpected exceptionstatic final String
Entry describing the unexpected exceptionstatic final String
Value used to disable error code check on BridgeExceptionsstatic final String
Error when the expected exception did not occurstatic final String
Error when the script does not run as expected.static final String
Error when a BridgeException occured, as expected, but with an unexpected error codestatic final String
Error when an exception occured, but not of the expected classprotected String
Expected error code (for BridgeExceptions)protected String
Name of the expected exception classprotected String
The name of the test filestatic final String
Value for the script having successfully run.protected String
The allowed external resource originprotected boolean
Controls whether on not the document should be processed from a 'restricted' context, one with no createClassLoader permission.protected String
The allowed script originprotected String
The allowed script typesprotected boolean
True if the scripts are run securely (i.e., with a security manager)protected String
The URL for the input SVG document to be testedstatic final String
Test Namespaceprotected Boolean
Controls whether or not the input SVG document should be validatedFields inherited from class org.apache.batik.test.AbstractTest
id, name, parent
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected SVGOnLoadExceptionTest.TestUserAgent
Give subclasses a chance to build their own UserAgentboolean
boolean
protected TestReport
Compares the input exception with the expected exception If they match, then the test passes.protected boolean
Check if the input class' name (or one of its base classes) matches the input name.protected String
resolveURL
(String url) Resolves the input string as follows.runImpl()
Run this test and produce a report.void
setExpectedErrorCode
(String expectedErrorCode) void
setExpectedExceptionClass
(String expectedExceptionClass) void
Set thisTest
's id.void
setResourceOrigin
(String resourceOrigin) void
setRestricted
(boolean restricted) void
setScriptOrigin
(String scriptOrigin) void
setScripts
(String scripts) void
setSecure
(boolean secure) void
setValidate
(Boolean validate) protected TestReport
testImpl()
Implementation helperMethods inherited from class org.apache.batik.test.AbstractTest
assertEquals, assertEquals, assertNull, assertTrue, error, getId, getName, getParent, getQualifiedId, reportError, reportException, reportSuccess, run, runImplBasic, setName, setParent
-
Field Details
-
RAN
Value for the script having successfully run.- See Also:
-
ERROR_EXCEPTION_DID_NOT_OCCUR
Error when the expected exception did not occur- See Also:
-
ERROR_UNEXPECTED_EXCEPTION
Error when an exception occured, but not of the expected class- See Also:
-
ERROR_UNEXPECTED_ERROR_CODE
Error when a BridgeException occured, as expected, but with an unexpected error code- See Also:
-
ERROR_SCRIPT_DID_NOT_RUN
Error when the script does not run as expected.- See Also:
-
ENTRY_KEY_UNEXPECTED_EXCEPTION
Entry describing the unexpected exception- See Also:
-
ENTRY_KEY_UNEXPECTED_ERROR_CODE
Entry describing the unexpected error code- See Also:
-
ENTRY_KEY_EXPECTED_ERROR_CODE
Entry describign the expected error code- See Also:
-
ENTRY_KEY_EXPECTED_EXCEPTION
Entry describing the expected exception- See Also:
-
ENTRY_KEY_UNEXPECTED_RESULT
Entry describing the unexpected exception- See Also:
-
ERROR_CODE_NO_CHECK
Value used to disable error code check on BridgeExceptions- See Also:
-
testNS
Test Namespace- See Also:
-
svgURL
The URL for the input SVG document to be tested -
scripts
The allowed script types -
expectedExceptionClass
Name of the expected exception class -
expectedErrorCode
Expected error code (for BridgeExceptions) -
scriptOrigin
The allowed script origin -
resourceOrigin
The allowed external resource origin -
secure
protected boolean secureTrue if the scripts are run securely (i.e., with a security manager) -
validate
Controls whether or not the input SVG document should be validated -
fileName
The name of the test file -
restricted
protected boolean restrictedControls whether on not the document should be processed from a 'restricted' context, one with no createClassLoader permission.
-
-
Constructor Details
-
SVGOnLoadExceptionTest
public SVGOnLoadExceptionTest()Default constructor
-
-
Method Details
-
getRestricted
public boolean getRestricted() -
setRestricted
public void setRestricted(boolean restricted) -
setScripts
-
getScripts
-
setScriptOrigin
-
getScriptOrigin
-
setResourceOrigin
-
getResourceOrigin
-
setSecure
public void setSecure(boolean secure) -
getSecure
public boolean getSecure() -
setExpectedExceptionClass
-
getExpectedExceptionClass
-
setExpectedErrorCode
-
getExpectedErrorCode
-
getValidate
-
setValidate
-
setId
Description copied from class:AbstractTest
Set thisTest
's id. Null is not allowed.- Specified by:
setId
in interfaceTest
- Overrides:
setId
in classAbstractTest
-
resolveURL
Resolves the input string as follows. + First, the string is interpreted as a file description. If the file exists, then the file name is turned into a URL. + Otherwise, the string is supposed to be a URL. If it is an invalid URL, an IllegalArgumentException is thrown. -
runImpl
Run this test and produce a report. The test goes through the following steps:- load the input SVG into a Document
- build the GVT tree corresponding to the Document and dispatch the 'onload' event
- Overrides:
runImpl
in classAbstractTest
- Throws:
Exception
-
testImpl
Implementation helper -
handleException
Compares the input exception with the expected exception If they match, then the test passes. Otherwise, the test fails -
isMatch
Check if the input class' name (or one of its base classes) matches the input name. -
buildUserAgent
Give subclasses a chance to build their own UserAgent
-