sandbox


License

License

Categories

Categories

Net
GroupId

GroupId

net.avh4.util
ArtifactId

ArtifactId

sandbox
Last Version

Last Version

0.0.6
Release Date

Release Date

Type

Type

jar
Description

Description

sandbox
Project URL

Project URL

https://github.com/avh4/sandbox
Source Code Management

Source Code Management

https://github.com/avh4/sandbox

Download sandbox

How to add to project

<!-- https://jarcasting.com/artifacts/net.avh4.util/sandbox/ -->
<dependency>
    <groupId>net.avh4.util</groupId>
    <artifactId>sandbox</artifactId>
    <version>0.0.6</version>
</dependency>
// https://jarcasting.com/artifacts/net.avh4.util/sandbox/
implementation 'net.avh4.util:sandbox:0.0.6'
// https://jarcasting.com/artifacts/net.avh4.util/sandbox/
implementation ("net.avh4.util:sandbox:0.0.6")
'net.avh4.util:sandbox:jar:0.0.6'
<dependency org="net.avh4.util" name="sandbox" rev="0.0.6">
  <artifact name="sandbox" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.avh4.util', module='sandbox', version='0.0.6')
)
libraryDependencies += "net.avh4.util" % "sandbox" % "0.0.6"
[net.avh4.util/sandbox "0.0.6"]

Dependencies

compile (1)

Group / Artifact Type Version
commons-io : commons-io jar 2.0.1

test (4)

Group / Artifact Type Version
junit : junit-dep jar 4.8.2
org.mockito : mockito-core jar 1.8.5
org.hamcrest : hamcrest-integration jar 1.2.1
org.jbehave : jbehave-core jar 3.5

Project Modules

There are no modules declared in this project.

Build Status

Sandbox

Create and manage temporary folders to simplify integration testing

Usage

Add sandbox as a dependency (you probably only want it for tests). Maven dependency info:

    <dependency>
        <groupId>net.avh4.util</groupId>
        <artifactId>sandbox</artifactId>
        <version>0.0.6</version>
        <scope>test</scope>
    </dependency>

Any code that wants to play in the sandbox should have a root path that can be injected:

    public class MyService {
        private final File root;
        
        public MyService(File root) {
            this.root = root;
        }
        
        public void doSomething() {
            File configFile = new File(root, "config.xml");
            File fileToWrite = new File(root, "output.txt");
            ...
        }
    }

Create a sandbox and populate it with some files. This example copies test-config.xml from the classpath into config.xml in the sandbox.

    Sandbox sandbox = new Sandbox();
    sandbox.useResource("test-config.xml", "config.xml");

Test your code in the sandbox.

    MyService service = new MyService(sandbox.getRoot());
    assert(sandbox.newFile("output.txt").exists() == true);

Versions

Version
0.0.6
0.0.5
0.0.4
0.0.3
0.0.2
0.0.1