Package org.basex.core
Class Sandbox
java.lang.Object
org.basex.core.Sandbox
If this class is extended, tests will be run in a sandbox.
- Author:
- BaseX Team 2005-21, BSD License, Christian Gruen
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static ContextDatabase context.protected static final intDatabase port.protected static final PrintStreamDefault error stream.protected static final intHTTP port.protected static final StringRoot path.protected static final StringTest name.protected static final PrintStreamDefault output stream.protected static final StringREST identifier.protected static final StringRoot path.protected static final intHTTP stop port. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static voidChecks if a query yields the specified result.static ClientSessioncreateClient(String... login) Creates a client instance.static BaseXServercreateServer(String... args) Creates a new, sandboxed server instance.protected static voiderror(String query, QueryError... error) Checks if a query yields the specified error code.protected static voiderror(String query, QueryException ex, QueryError... errors) Checks if an exception yields one of the specified error codes.protected static StringRuns a query.protected static StringExecutes a command and returns exceptions into assertion errors.static voidRemoves test databases and closes the database context.static voidCreates the sandbox.protected static voidinline(boolean enable) Triggers function inlining.static StringNormalizes newlines in a query result.protected static StringRuns a query and returns exceptions into assertion errors.protected static voidChecks if a query yields the specified string.static IOFilesandbox()Returns the sandbox database path.protected static StringserialParams(String arg) Returns serialization parameters.protected static voidSets an option and returns exceptions into assertion errors.static voidstopServer(BaseXServer server) Stops a server instance.protected static StringCreates a transform expression from a given input and modification clause.protected static StringCreates a transform expression from a given input, modification and return clause.protected static voidunroll(boolean enable) Triggers function inlining.protected static voidWrites a test file.
-
Field Details
-
DB_PORT
protected static final int DB_PORTDatabase port.- See Also:
-
STOP_PORT
protected static final int STOP_PORTHTTP stop port.- See Also:
-
HTTP_PORT
protected static final int HTTP_PORTHTTP port.- See Also:
-
REST
REST identifier.- See Also:
-
HTTP_ROOT
Root path.- See Also:
-
REST_ROOT
Root path.- See Also:
-
OUT
Default output stream. -
ERR
Default error stream. -
NAME
Test name. -
context
Database context.
-
-
Constructor Details
-
Sandbox
public Sandbox()
-
-
Method Details
-
execute
Executes a command and returns exceptions into assertion errors.- Parameters:
cmd- command to be run- Returns:
- string result
-
set
Sets an option and returns exceptions into assertion errors.- Parameters:
option- option to be setvalue- value to be assigned
-
query
Runs a query and returns exceptions into assertion errors.- Parameters:
query- query to be evaluated- Returns:
- string result
-
query
Checks if a query yields the specified string.- Parameters:
query- query stringexpected- expected result
-
transform
Creates a transform expression from a given input, modification and return clause.- Parameters:
input- input XML fragment, target of the updating expressionmodify- updating expression, make sure to address all target nodes via the $input variable, i.e. delete node $input/artrn- return clause- Returns:
- the query formulated with a transform expression
-
transform
Creates a transform expression from a given input and modification clause.- Parameters:
input- input XML fragment, target of the updating expressionmodification- updating expression, make sure to address all target nodes via the $input variable, i.e. delete node $input/a- Returns:
- the query formulated with a transform expression
-
contains
Checks if a query yields the specified result.- Parameters:
query- query stringresult- query result
-
error
Checks if a query yields the specified error code.- Parameters:
query- query stringerror- allowed errors
-
error
Checks if an exception yields one of the specified error codes.- Parameters:
query- queryex- resulting query exceptionerrors- allowed errors
-
serialParams
Returns serialization parameters.- Parameters:
arg- serialization arguments- Returns:
- parameter string
-
eval
Runs a query.- Parameters:
query- query string- Returns:
- result
- Throws:
QueryException- query exceptionIOException- I/O exception
-
write
Writes a test file.- Parameters:
file- filedata- data to write
-
initSandbox
public static void initSandbox()Creates the sandbox. -
finishSandbox
public static void finishSandbox()Removes test databases and closes the database context. -
inline
protected static void inline(boolean enable) Triggers function inlining.- Parameters:
enable- flag
-
unroll
protected static void unroll(boolean enable) Triggers function inlining.- Parameters:
enable- flag
-
createServer
Creates a new, sandboxed server instance.- Parameters:
args- additional arguments- Returns:
- server instance
- Throws:
IOException- I/O exception
-
stopServer
Stops a server instance.- Parameters:
server- server- Throws:
IOException- I/O exception
-
createClient
Creates a client instance.- Parameters:
login- optional login data- Returns:
- client instance
- Throws:
IOException- I/O exception
-
sandbox
Returns the sandbox database path.- Returns:
- database path
-
normNL
Normalizes newlines in a query result.- Parameters:
result- input string- Returns:
- normalized string
-