Skip to content

Tags: stefanbirkner/system-rules

Tags

system-rules-1.19.0

Toggle system-rules-1.19.0's commit message

Verified

This commit was signed with the committer’s verified signature.
stefanbirkner Stefan Birkner
Raw bytes of System.out and System.err are logged

SystemErrRule and SystemOutRule have a new method "getLogAsBytes" which
returns the raw bytes that have been written to System.err/System.out.
This method can be used for testing applications that write raw binary
data.

Fixes #66.

Co-authored-by: Stefan Birkner <[email protected]>

system-rules-1.18.0

Toggle system-rules-1.18.0's commit message

Verified

This commit was signed with the committer’s verified signature.
stefanbirkner Stefan Birkner
Variables can be set after creating the rule

Some environment variables have the same value for all tests. Someone
who reads the test can easily recognize this when the set and clear
methods for these variables are directly called within the statement
that creates the EnvironmentVariables rule.

    @rule
    public final EnvironmentVariables environmentVariables
        = new EnvironmentVariables()
            .set("name", "value")
            .clear("another variable");

This also fixes a bug where the environment variables are not reset when
the set and clear methods are called from within the static initializer
of the EnvironmentVariables rule. E.g.

    @rule
    public final EnvironmentVariables environmentVariables
        = new EnvironmentVariables() {{
            set("dummy variable", "dummy value"
        }};

Fixes #49 and #61.

system-rules-1.17.2

Toggle system-rules-1.17.2's commit message

Verified

This commit was signed with the committer’s verified signature.
stefanbirkner Stefan Birkner
Make TextFromStandardInputStream Java 5 compatible

System Rules supports Java 5, but String#getBytes(Charset) is not part
of the Java 5 API.

system-rules-1.17.1

Toggle system-rules-1.17.1's commit message

Verified

This commit was signed with the committer’s verified signature.
stefanbirkner Stefan Birkner
Fix ProvideSystemProperty's static factory methods

These methods have been able to throw a checked exception. Therefore
they couldn't be used to directly initialize the rule like in the
following code.

    @rule
    public final ProvideSystemProperty provideSystemProperty
        = fromResource("some.properties");

This is now fixed by wrapping the IOException with a RuntimeException.

system-rules-1.17.0

Toggle system-rules-1.17.0's commit message

Verified

This commit was signed with the committer’s verified signature.
stefanbirkner Stefan Birkner
Add EnvironmentVariables#clear(String...)

The code

    environmentVariables.clear("some variable");

has better semantics than

    environmentVariables.set("some variable", null);

Fixes #53.

system-rules-1.16.1

Toggle system-rules-1.16.1's commit message

Verified

This commit was signed with the committer’s verified signature.
stefanbirkner Stefan Birkner
RestoreSystemProperties sets correct properties.

RestoreSystemProperties now replaces the system properties with a copy
of the original properties. This ensures that the properties behave like
the original properties. That was not the case before. E.g. the
`contains` method returned `false` for a property that has been
originally set but was not modified in the test.

Fixes #43.

system-rules-1.16.0

Toggle system-rules-1.16.0's commit message
Add rule for modifying environment variables.

By default environment variables cannot be set in Java code. You have
to modify internals in order to set them. This task is hidden by the
rule. In addition every change to environment variables is reverted
after the test.

system-rules-1.15.1

Toggle system-rules-1.15.1's commit message
Improve emulation of System.in.

`System.in.read()` blocks until it faces the EOL character(s). This
cannot be easily emulated because that behaviour is implemented in
native code.

The first attempt was sending -1 after the end of each text or line.
This is an insufficient solution because -1 indicates the end of the
stream. It seems that the blocking behaviour is mainly needed for code
that uses Scanner (which uses `System.in.read(byte[], int, int)`
internally.) Hence the -1 hack was replaced by an enhanced
implementation of `read(byte[], int, int)` that returns the whole next
line.

Fixes #35.

system-rules-1.15.0

Toggle system-rules-1.15.0's commit message
Don't use TeeOutputStream.

Implementing an own OutputStream makes the code simpler. Additionally it
avoids the dependency to commons-io. (Fixes #32.)

system-rules-1.14.0

Toggle system-rules-1.14.0's commit message
Add rules that disallow writes to console.

The rules `DisallowWriteToSystemErr` and `DisallowWriteToSystemOut` let
tests fail if they try to write to `System.err` or `System.out`. The
rules are a nice replacement for static code analysis because they cover
external libraries, too.